Re: [RFC PATCH] net: devlink: devlink_nl_info_fill: populate default information

From
Vincent MAILHOL <hidden>
Date
2022-11-24 16:20:35
Also in
lkml
Reply to
Jiri Pirko, 2022-11-23
On Wed. 23 Nov. 2022 at 21:10, Jiri Pirko [off-list ref] wrote:
Wed, Nov 23, 2022 at 12:00:44PM CET, mailhol.vincent@wanadoo.fr wrote:
quoted
On Wed. 23 nov. 2022 à 18:46, Jiri Pirko [off-list ref] wrote:
quoted
Tue, Nov 22, 2022 at 04:49:34PM CET, mailhol.vincent@wanadoo.fr wrote:
(...)
quoted
quoted
quoted
+      if (!strcmp(dev->parent->type->name, "usb_device")) {
Comparing to string does not seem correct here.
There is a is_usb_device() which does the check:
 https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/usb/core/usb.h#L152

but this macro is not exposed outside of the usb core. The string
comparison was the only solution I found.
Find a different one. String check here is wrong.
After looking again, I found no alternative and so I asked the USB
mailing list and got an answer from Greg. There is no ways to do so
and the class code is not supposed to do this:
https://lore.kernel.org/linux-usb/Y3+VfNdt%2FK7UtRcw@kroah.com/ (local)

So I guess that there will be no code factorization for device specific values.

@Jakub, with this in mind, does it still make sense to add the bitmap?
Aside from the driver name, it seems that there will be no code
factorization for other types dependent values. If we only set the
driver name at the core level, I would rather just clean up the
existing. (Side comment, I finished implementing the bitmap just
before receiving Greg's answer; I guess my code will go to the trash
can...)
Thread (37 messages) 37 messages, 5 authors, last reply 2022-11-28
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