Re: [PATCH net-next v2 2/3] net: phy: broadcom: Add support for Wake-on-LAN

From: Florian Fainelli
Date: Thu May 11 2023 - 12:17:28 EST


On 5/11/23 03:26, Paolo Abeni wrote:
Hi,

On Tue, 2023-05-09 at 15:34 -0700, Florian Fainelli wrote:
@@ -821,7 +917,28 @@ static int bcm54xx_phy_probe(struct phy_device *phydev)
if (IS_ERR(priv->ptp))
return PTR_ERR(priv->ptp);
- return 0;
+ /* We cannot utilize the _optional variant here since we want to know
+ * whether the GPIO descriptor exists or not to advertise Wake-on-LAN
+ * support or not.
+ */
+ wakeup_gpio = devm_gpiod_get(&phydev->mdio.dev, "wakeup", GPIOD_IN);
+ if (PTR_ERR(wakeup_gpio) == -EPROBE_DEFER)
+ return PTR_ERR(wakeup_gpio);
+
+ if (!IS_ERR(wakeup_gpio)) {
+ priv->wake_irq = gpiod_to_irq(wakeup_gpio);
+ ret = irq_set_irq_type(priv->wake_irq, IRQ_TYPE_LEVEL_LOW);
+ if (ret)
+ return ret;
+ }
+
+ /* If we do not have a main interrupt or a side-band wake-up interrupt,
+ * then the device cannot be marked as wake-up capable.
+ */
+ if (!bcm54xx_phy_can_wakeup(phydev))
+ return ret;

AFAICS, as this point 'ret' is 0, so the above is confusing. Do you
intend the probe to complete successfully? If so, would not be
better/more clear:

return 0;

Yes probe needs to be successful if bcm54xx_phy_can_wakeup() returns false, will change to return 0 to make that clearer. Thanks!
--
Florian