[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b97bcd67-82a4-b8fc-40c2-a3c230a4a14e@gmail.com>
Date: Wed, 16 Jan 2019 07:06:14 +0100
From: Heiner Kallweit <hkallweit1@...il.com>
To: Florian Fainelli <f.fainelli@...il.com>,
Andrew Lunn <andrew@...n.ch>,
David Miller <davem@...emloft.net>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] net: phy: check return code when requesting PHY
driver module
On 15.01.2019 23:32, Florian Fainelli wrote:
> On 1/15/19 12:33 PM, Heiner Kallweit wrote:
>> When requesting the PHY driver module fails we'll bind the genphy
>> driver later. This isn't obvious to the user and may cause, depending
>> on the PHY, different types of issues. Therefore check the return code
>> of request_module() and inform the user in case of failure.
>
> Would you see any value in checking but not propagating the
> request_module() return value back to the caller? Surely, something will
> fail later on which may, or may not be properly handled.
>
Right, if we have a hard fail in request_module() and load the genphy
driver later then the PHY may work properly or it may not. So indeed
it may be better to return an error from phy_device_create().
Based on the discussion with Andrew I'll also add a comment explaining
what is checked (and what not).
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
>> ---
>> drivers/net/phy/phy_device.c | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index a2423cbb2..1527ed0f2 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -548,6 +548,17 @@ static const struct device_type mdio_bus_phy_type = {
>> .pm = MDIO_BUS_PHY_PM_OPS,
>> };
>>
>> +static void phy_request_driver_module(struct phy_device *dev, int phy_id)
>> +{
>> + int ret;
>> +
>> + ret = request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
>> + MDIO_ID_ARGS(phy_id));
>> + if (IS_ENABLED(CONFIG_MODULES) && ret < 0)
>> + phydev_err(dev, "error %d loading PHY driver module for ID 0x%08x\n",
>> + ret, phy_id);
>> +}
>> +
>> struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
>> bool is_c45,
>> struct phy_c45_device_ids *c45_ids)
>> @@ -610,12 +621,10 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
>> if (!(c45_ids->devices_in_package & (1 << i)))
>> continue;
>>
>> - request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
>> - MDIO_ID_ARGS(c45_ids->device_ids[i]));
>> + phy_request_driver_module(dev, c45_ids->device_ids[i]);
>> }
>> } else {
>> - request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
>> - MDIO_ID_ARGS(phy_id));
>> + phy_request_driver_module(dev, phy_id);
>> }
>>
>> device_initialize(&mdiodev->dev);
>>
>
>
Powered by blists - more mailing lists