UDC and oddball sysfs layout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi !

So the UDC cores creates a rather funny sysfs layout.

If "foo@bar" is my platform device which I pass as "parent" to the
gadget I pass to usb_add_gadget_udc_release(), that function creates
a funny layout underneath that node:

  - A "gadget" directory which is gadget.dev and is always named just
"gadget".

  - A "udc" directory which itself contains a bunch of directories
that represent the core internal "udc" devices, and whose names are
copies of the name of the parent (my platform device). 

This is quite odd, as we end up with siblings for what should be a
hierarchical relationship imho. IE, the gadget I think should be a
child of the UDC no ?

Also, btw, I didn't figure out by which sysfs black magic those 'udc'
devices end up below that "udc" directory... They are created using
device_add with the parent being my platform device and the name
being my platform device name, how is that "udc" intermediary subdir
gets created ? I looked into device_add and didn't see anything obvious
:-)

In my this doesn't work well, because I'm trying to create 5 of them.

The "easy fix" is for me to create 5 sub-devices under my platform
device to use as parents, though that's a bit klunky. Also because of
all them appearing as class devices under the udc class, they need to
have globally unique names.

Would it be a huge ABI breakage to re-organize things a bit in there ?
For example, of the 2 devices created by usb_add_gadget_udc_release

 - Could the udc one be the parent of the gadget one to represent
more truly the relationship ?

 - Could we specify the name of the UDC one ? (I would call them
platform_dev_name:port{0, 1, 2, ...} for example in my case).

With those 2 changes, the gadget is still called "gadget" in case that
is somewhat expected by userspace (is it ?) and we have a more sensible
representation, allowing for multiple gadgets under a platform device
without creating intermediary platform devices.

Or am I missing something key here ?

Also (but that's less of an issue), does "gadget" needs to be named
such ? What is the gadget->name field for ? I also noticed various
UDCs setup gadget->dev.init_name but that's never used afaik. Any
reason why ?

If I can just use gadget->name for the gadget device name, then I can
call these "port0", "port1", ... and then make the udc device name
be:

	ret = dev_set_name(&udc->dev, "%s:%s",
			   kobject_name(&parent->kobj), gadget->name);

Which nicely avoids the duplication.


Cheers,
Ben.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux