diff mbox series

[net-next,v2,2/7] net: phy: aquantia: search for firmware-name in fwnode

Message ID trinity-ad10e630-a77b-4887-b006-2f8885745738-1726430104089@3c-app-gmx-bap07 (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: tn40xx: add support for AQR105 based cards | expand

Commit Message

Hans-Frieder Vogt Sept. 15, 2024, 7:55 p.m. UTC
Allow the firmware name of an Aquantia PHY alternatively be provided by the property
"firmware-name" of a swnode. This software node may be provided by the MAC or MDIO driver.

Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net>
---
 drivers/net/phy/aquantia/aquantia_firmware.c | 6 ++++++
 1 file changed, 6 insertions(+)

--
2.45.2

Comments

Andrew Lunn Sept. 15, 2024, 8:32 p.m. UTC | #1
On Sun, Sep 15, 2024 at 09:55:04PM +0200, Hans-Frieder Vogt wrote:
> Allow the firmware name of an Aquantia PHY alternatively be provided by the property
> "firmware-name" of a swnode. This software node may be provided by the MAC or MDIO driver.
> 
> Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net>
> ---
>  drivers/net/phy/aquantia/aquantia_firmware.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c
> index 524627a36c6f..f0e0f04aa2f0 100644
> --- a/drivers/net/phy/aquantia/aquantia_firmware.c
> +++ b/drivers/net/phy/aquantia/aquantia_firmware.c
> @@ -330,8 +330,14 @@ static int aqr_firmware_load_fs(struct phy_device *phydev)
> 
>  	ret = of_property_read_string(dev->of_node, "firmware-name",
>  				      &fw_name);
> +	/* try next, whether firmware-name has been provided in a swnode */
>  	if (ret)
> +		ret = device_property_read_string(dev, "firmware-name",
> +						  &fw_name);

I could be getting this wrong, but my understanding is that
device_property_read_string() will look at dev and see if there is an
OF node available. If so, it will get the property from OF. If there
is not, it looks to see if there is a swnode, and if there is, it uses
that. And if there is an ACPI node, it tries there. So i _think_ you
can replace the of_property_read_string() with
device_property_read_string().

	Andrew
Hans-Frieder Vogt Sept. 15, 2024, 8:46 p.m. UTC | #2
On 15.09.2024 22.32, Andrew Lunn wrote:
> On Sun, Sep 15, 2024 at 09:55:04PM +0200, Hans-Frieder Vogt wrote:
>> Allow the firmware name of an Aquantia PHY alternatively be provided by the property
>> "firmware-name" of a swnode. This software node may be provided by the MAC or MDIO driver.
>>
>> Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net>
>> ---
>>   drivers/net/phy/aquantia/aquantia_firmware.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c
>> index 524627a36c6f..f0e0f04aa2f0 100644
>> --- a/drivers/net/phy/aquantia/aquantia_firmware.c
>> +++ b/drivers/net/phy/aquantia/aquantia_firmware.c
>> @@ -330,8 +330,14 @@ static int aqr_firmware_load_fs(struct phy_device *phydev)
>>
>>   	ret = of_property_read_string(dev->of_node, "firmware-name",
>>   				      &fw_name);
>> +	/* try next, whether firmware-name has been provided in a swnode */
>>   	if (ret)
>> +		ret = device_property_read_string(dev, "firmware-name",
>> +						  &fw_name);
> I could be getting this wrong, but my understanding is that
> device_property_read_string() will look at dev and see if there is an
> OF node available. If so, it will get the property from OF. If there
> is not, it looks to see if there is a swnode, and if there is, it uses
> that. And if there is an ACPI node, it tries there. So i _think_ you
> can replace the of_property_read_string() with
> device_property_read_string().
When I checked it first, it didn't look like that. However, I think I
found now, where
it diverts into the two directions: of_node or fwnode.
Thanks!

     Hans
diff mbox series

Patch

diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c
index 524627a36c6f..f0e0f04aa2f0 100644
--- a/drivers/net/phy/aquantia/aquantia_firmware.c
+++ b/drivers/net/phy/aquantia/aquantia_firmware.c
@@ -330,8 +330,14 @@  static int aqr_firmware_load_fs(struct phy_device *phydev)

 	ret = of_property_read_string(dev->of_node, "firmware-name",
 				      &fw_name);
+	/* try next, whether firmware-name has been provided in a swnode */
 	if (ret)
+		ret = device_property_read_string(dev, "firmware-name",
+						  &fw_name);
+	if (ret) {
+		phydev_err(phydev, "failed to read firmware name: %d\n", ret);
 		return ret;
+	}

 	ret = request_firmware(&fw, fw_name, dev);
 	if (ret) {