[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1263a26d-a622-45d7-8043-262f2b92ed3b@gmail.com>
Date: Fri, 9 Jan 2026 12:00:41 +0100
From: Heiner Kallweit <hkallweit1@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, Andrew Lunn <andrew+netdev@...n.ch>,
Russell King - ARM Linux <linux@...linux.org.uk>,
Paolo Abeni <pabeni@...hat.com>, Eric Dumazet <edumazet@...gle.com>,
David Miller <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] net: phy: fixed_phy: replace list of fixed PHYs
with static array
On 1/9/2026 3:11 AM, Jakub Kicinski wrote:
> On Tue, 6 Jan 2026 17:56:26 +0100 Heiner Kallweit wrote:
>> +/* The DSA loop driver may allocate 4 fixed PHY's, and 4 additional
>> + * fixed PHY's for a system should be sufficient.
>> + */
>> +#define NUM_FP 8
>> +
>> struct fixed_phy {
>> - int addr;
>> struct phy_device *phydev;
>> struct fixed_phy_status status;
>> int (*link_update)(struct net_device *, struct fixed_phy_status *);
>> - struct list_head node;
>> };
>>
>> +static struct fixed_phy fmb_fixed_phys[NUM_FP];
>> static struct mii_bus *fmb_mii_bus;
>> -static LIST_HEAD(fmb_phys);
>> +static DEFINE_IDA(phy_fixed_ida);
>
> Isn't IDA an overkill for a range this tiny?
> IDA is useful if the ID range is large and may be sparse.
> Here a bitmap would suffice.
>
Thanks for the suggestion! The IDA has been there forever, just the definition
has been moved now. I think switching to a bitmap is a good option.
Can we handle this as a follow-up?
> DECLARE_BITMAP(phy_fixed_ids, NUM_FP);
>
> id = find_first_zero_bit(phy_fixed_ids, NUM_FP);
> if (id >= NUM_FP)
> return -ENOSPC;
>
> set_bit(id, phy_fixed_ids);
> ...
Powered by blists - more mailing lists