[net-next: PATCH v7 4/7] dsa: lan9303: write reg only if necessary

From: Jerry Ray
Date: Tue Jan 17 2023 - 18:32:28 EST


As the regmap_write() is over a slow bus that will sleep, we can speed up
the boot-up time a bit by not bothering to clear a bit that is already
clear.

Signed-off-by: Jerry Ray <jerry.ray@xxxxxxxxxxxxx>
---
drivers/net/dsa/lan9303-core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 66466d50d015..a4decf42a002 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -915,8 +915,11 @@ static int lan9303_setup(struct dsa_switch *ds)
if (ret)
return (ret);

- reg &= ~LAN9303_VIRT_SPECIAL_TURBO;
- regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
+ /* Clear the TURBO Mode bit if it was set. */
+ if (reg & LAN9303_VIRT_SPECIAL_TURBO) {
+ reg &= ~LAN9303_VIRT_SPECIAL_TURBO;
+ regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
+ }

ret = lan9303_setup_tagging(chip);
if (ret)
--
2.17.1