Re: libudev, a question about the enumerate API.

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

 



On Wed, Feb 23, 2011 at 23:50, Antonio Ospite <ospite@xxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> in my attempts to handle leds setting and usb pairing for the Sixaxis
> controller I had to fight with libudev a little bit, eventually I
> succeeded in what I wanted to achieve but I still have some questions
> about the libudev API, so here I am.
>
> This is basically the layout for the device:
>
> 4-1:1.0/
> |-- 0003:054C:0268.000C Â(hid device)
> | Â |-- hidraw
> | Â | Â `-- hidraw1
> | Â `-- uevent Â(which tells me HID_PHYS)
> |
> `-- input
> Â Â`-- input17
> Â Â Â Â|-- js0
> Â Â Â Â`-- phys
>
> I needed to get the hidraw device node, and the js device number, the
> two sibling devices (from hid and input subsystem) can be matched using
> the 'phys' property.
>
> This is what I do now:
> Â0. Monitor with a filter matching the "hidraw" subsystem.
> Â1. When a matching device is connected we get the "hidraw" device.
> Â2. Go up to its "hid" parent device and check it is actually a
> Â ÂSixaxis (using HID_NAME), if not GOTO 1.
> Â3. Store the hidraw device node for later use
> Â4. Store the HID_PHYS value in order to look for the matching joystick.
> Â5. Enumerate the joystick devices with the sysname filter "js*"
> Â6. For each joystick:
> Â Âa. Go up to its input parent device
> Â Âb. Check that the phys attribute matches HID_PHYS,
> Â Â Â if so, store the joystick device number.
> Â7. Set leds
> Â8. If the Sixaxis is connected via USB do the cable pairing.
>
> My doubt is about 5. and 6a.: I have go deep in the hierarchy down to
> the js0 leaf device and then I have to go up one level to get the
> input device, naively I would have done the contrary:
> Â5'. Enumerate the input devices such that phys == HID_PHYS
> Â6'. Enumerate the devices _below_ the input device from 5'. looking
> Â Â for the jsX device.
>
> But this is not possible because the enumerate API is designed to start
> always from the root of /sys.
>
> Finally the question: why the enumerate API in libudev does not allow
> enumerating only from a _subtree_? Has that been designed this way to
> keep the API simple, or because it is not considered useful?

The usual enumeration in udev never uses the device tree in
/sys/devices/, only the subsystem lists /sys/{class,bus}/. We could
have something to enumerate all child devices of a given device. It's
not simple, but could be made working.

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


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux