Re: [RFC PATCH net-next 1/7] net: phy: introduce phy numbering and phy namespaces

From
Jakub Kicinski <kuba@kernel.org>
Date
2023-09-08 15:36:13
Also in
lkml
Reply to
Maxime Chevallier, 2023-09-07
On Thu, 7 Sep 2023 14:19:04 +0200 Maxime Chevallier wrote:
quoted
I think you can simplify this code quite a bit by using idr.
idr_alloc_cyclic() looks like it will do the allocation you want,
plus the IDR subsystem will store the pointer to the object (in
this case the phy device) and allow you to look that up. That
probably gets rid of quite a bit of code.

You will need to handle the locking around IDR however.  
Oh thanks for pointing this out. I had considered idr but I didn't spot
the _cyclic() helper, and I had ruled that out thinking it would re-use
ids directly after freeing them. I'll be more than happy to use that.
Perhaps use xarray directly, I don't think we need the @base offset or
quick access to @next which AFAICT is the only reason one would prefer
IDR?
Thread (35 messages) 35 messages, 6 authors, last reply 2023-10-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help