Skip to content

Commit 9a236b5

Browse files
luizlucadavem330
authored andcommitted
net: dsa: realtek: realtek-smi: clean-up reset
When reset GPIO was missing, the driver was still printing an info message and still trying to assert the reset. Although gpiod_set_value() will silently ignore calls with NULL gpio_desc, it is better to make it clear the driver might allow gpio_desc to be NULL. The initial value for the reset pin was changed to GPIOD_OUT_LOW, followed by a gpiod_set_value() asserting the reset. This way, it will be easier to spot if and where the reset really happens. A new "asserted RESET" message was added just after the reset is asserted, similar to the existing "deasserted RESET" message. Both messages were demoted to dbg. The code comment is not needed anymore. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Acked-by: Arınç ÜNAL <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dd263a8 commit 9a236b5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/net/dsa/realtek/realtek-smi.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,19 @@ static int realtek_smi_probe(struct platform_device *pdev)
420420

421421
/* TODO: if power is software controlled, set up any regulators here */
422422

423-
/* Assert then deassert RESET */
424-
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
423+
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
425424
if (IS_ERR(priv->reset)) {
426425
dev_err(dev, "failed to get RESET GPIO\n");
427426
return PTR_ERR(priv->reset);
428427
}
429-
msleep(REALTEK_SMI_HW_STOP_DELAY);
430-
gpiod_set_value(priv->reset, 0);
431-
msleep(REALTEK_SMI_HW_START_DELAY);
432-
dev_info(dev, "deasserted RESET\n");
428+
if (priv->reset) {
429+
gpiod_set_value(priv->reset, 1);
430+
dev_dbg(dev, "asserted RESET\n");
431+
msleep(REALTEK_SMI_HW_STOP_DELAY);
432+
gpiod_set_value(priv->reset, 0);
433+
msleep(REALTEK_SMI_HW_START_DELAY);
434+
dev_dbg(dev, "deasserted RESET\n");
435+
}
433436

434437
/* Fetch MDIO pins */
435438
priv->mdc = devm_gpiod_get_optional(dev, "mdc", GPIOD_OUT_LOW);
@@ -474,7 +477,10 @@ static int realtek_smi_remove(struct platform_device *pdev)
474477
dsa_unregister_switch(priv->ds);
475478
if (priv->slave_mii_bus)
476479
of_node_put(priv->slave_mii_bus->dev.of_node);
477-
gpiod_set_value(priv->reset, 1);
480+
481+
/* leave the device reset asserted */
482+
if (priv->reset)
483+
gpiod_set_value(priv->reset, 1);
478484

479485
platform_set_drvdata(pdev, NULL);
480486

0 commit comments

Comments
 (0)