[PATCH net-next] net: stmmac: mdio: use phy_find_first to simplify stmmac_mdio_register

Heiner Kallweit hkallweit1 at gmail.com
Fri Oct 17 13:56:34 PDT 2025


On 10/17/2025 10:39 PM, Andrew Lunn wrote:
>> -	int addr, found, max_addr;
>> +	struct phy_device *phydev;
>> +	int addr, max_addr;
>>  
>>  	if (!mdio_bus_data)
>>  		return 0;
>> @@ -668,41 +669,31 @@ int stmmac_mdio_register(struct net_device *ndev)
>>  	if (priv->plat->phy_node || mdio_node)
>>  		goto bus_register_done;
>>  
>> -	found = 0;
>> -	for (addr = 0; addr < max_addr; addr++) {
> 
> With this loop gone...
> 
>> +	phydev = phy_find_first(new_bus);
>> +	if (!phydev || phydev->mdio.addr >= max_addr) {
>>  		dev_warn(dev, "No PHY found\n");
>>  		err = -ENODEV;
>>  		goto no_phy_found;
>>  	}
>>  
>> +	/*
>> +	 * If an IRQ was provided to be assigned after
>> +	 * the bus probe, do it here.
>> +	 */
>> +	if (!mdio_bus_data->irqs && mdio_bus_data->probed_phy_irq > 0) {
>> +		new_bus->irq[addr] = mdio_bus_data->probed_phy_irq;
> 
> ... what is setting addr to a value?
> 
Thanks. Indeed, addr can be removed and here phydev->mdio.addr has to be used.

> 	Andrew

--
pw-bot: cr



More information about the linux-arm-kernel mailing list