All of lore.kernel.org
 help / color / mirror / Atom feed
* Writing a rule specific to a USB connector
@ 2011-08-23  8:03 Diego Iastrubni
  2011-08-23  8:15 ` Tom Gundersen
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Diego Iastrubni @ 2011-08-23  8:03 UTC (permalink / raw)
  To: linux-hotplug

Hi all,

Sorry if this offtopic is this list, in such case please point me to
correct location.
I am tring to write a rule that will create a specific char device for
every different USB connector (this is an embeeded application, and
the use case is: "please connect the device to the upper connector").
I am using 173 on 2.6.32/arm.

I have two different USB controllers which can be identified by
ATTRS{serial}="musb_hdrc" and ATTRS{serial}="ehci-omap.0"


First try:

KERNEL="hidraw[0-9]*", ATTRS{serial}="musb_hdrc", SYMLINK+="aaaaaaaaaa"
KERNEL="hidraw[0-9]*", ATTRS{idVendor}="c1ca", SYMLINK+="bbbbbbbbbbb"


OK, works. I see both links generated. Now I need to combine them:

KERNEL="hidraw[0-9]*", ATTRS{idVendor}="c1ca",
ATTRS{serial}="musb_hdrc", SYMLINK+="cccccccccc"
KERNEL="hidraw[0-9]*", ATTRS{serial}="musb_hdrc",
ATTRS{idVendor}="c1ca", SYMLINK+="dddddddddd"


None working. What I think in happening is that the idVendor of the
USB hub is matched and not of the device. I need to match:

ATTR{idVendor}="c1ca" and some parent has ATTRS{serial}="musb_hdrc"


What is the golden rule I am missing?

- diego

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing a rule specific to a USB connector
  2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
@ 2011-08-23  8:15 ` Tom Gundersen
  2011-08-23  8:59 ` Diego Iastrubni
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Gundersen @ 2011-08-23  8:15 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2011 at 10:03 AM, Diego Iastrubni <diegoiast@gmail.com> wrote:
> KERNEL="hidraw[0-9]*", ATTRS{serial}="musb_hdrc", SYMLINK+="aaaaaaaaaa"
> KERNEL="hidraw[0-9]*", ATTRS{idVendor}="c1ca", SYMLINK+="bbbbbbbbbbb"
>
>
> OK, works. I see both links generated. Now I need to combine them:
>
> KERNEL="hidraw[0-9]*", ATTRS{idVendor}="c1ca",
> ATTRS{serial}="musb_hdrc", SYMLINK+="cccccccccc"
> KERNEL="hidraw[0-9]*", ATTRS{serial}="musb_hdrc",
> ATTRS{idVendor}="c1ca", SYMLINK+="dddddddddd"

ATTRS matches on a parent device, two instances of ATTRS matches on
_the same_ parent device. In your case I guess idVendor and serial
match on different parent devices, which would explain why they work
separately but no together.

Finally you say:

> None working. What I think in happening is that the idVendor of the
> USB hub is matched and not of the device. I need to match:
>
> ATTR{idVendor}="c1ca" and some parent has ATTRS{serial}="musb_hdrc"
>
>
> What is the golden rule I am missing?

Sounds to me like you should have used:

KERNEL="hidraw[0-9]*", ATTR{idVendor}="c1ca",
ATTRS{serial}="musb_hdrc", SYMLINK+="eeeeeeeee"

Cheers,

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing a rule specific to a USB connector
  2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
  2011-08-23  8:15 ` Tom Gundersen
@ 2011-08-23  8:59 ` Diego Iastrubni
  2011-08-23  9:51 ` Tom Gundersen
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Diego Iastrubni @ 2011-08-23  8:59 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2011 at 11:15 AM, Tom Gundersen <teg@jklm.no> wrote:
> ATTRS matches on a parent device, two instances of ATTRS matches on
> _the same_ parent device. In your case I guess idVendor and serial
> match on different parent devices, which would explain why they work
> separately but no together.

Eventually I found a documentation that mentions this, but in was not
easy. A very stable difference, hard to understand (now documented in
this archive!). Thanks!

> Sounds to me like you should have used:
>
> KERNEL="hidraw[0-9]*", ATTR{idVendor}="c1ca",
> ATTRS{serial}="musb_hdrc", SYMLINK+="eeeeeeeee"

KERNEL="hidraw[0-9]*", ATTR{idVendor}="c1ca",     SYMLINK+="1111111"
KERNEL="hidraw[0-9]*", ATTRS{idVendor}="c1ca",    SYMLINK+="2222222"
KERNEL="hidraw[0-9]*", ATTRS{serial}="musb_hdrc", SYMLINK+="3333333"
KERNEL="hidraw[0-9]*", ATTR{idVendor}="c1ca",
ATTRS{serial}="musb_hdrc", SYMLINK+="4444444"

[/root 10.10.10.44] $ udevadm test /sys/class/hidraw/hidraw0 2>&1 |  grep DEV
UDEV_LOG=6
DEVPATH=/devices/platform/musb_hdrc/usb1/1-1/1-1.1/1-1.1:1.0/0003:C1CA:0003.0008/hidraw/hidraw0
DEVNAME=/dev/hidraw0
DEVLINKS=/dev/2222222 /dev/3333333

[/root 10.10.10.44] $ udevadm info --query=all --name=/dev/hidraw0
--attribute-walk 2>&1 | egrep 'serial|idVendor'
    ATTRS{idVendor}="c1ca"
    ATTRS{idVendor}="05e3"
    ATTRS{idVendor}="1d6b"
    ATTRS{serial}="musb_hdrc"

I was expecting to see "11111", and I don't. This explains why
"444444" is not working. Still - something is not working here.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing a rule specific to a USB connector
  2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
  2011-08-23  8:15 ` Tom Gundersen
  2011-08-23  8:59 ` Diego Iastrubni
@ 2011-08-23  9:51 ` Tom Gundersen
  2011-08-23 10:45 ` Diego Iastrubni
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Gundersen @ 2011-08-23  9:51 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2011 at 10:59 AM, Diego Iastrubni <diegoiast@gmail.com> wrote:
> KERNEL="hidraw[0-9]*", ATTR{idVendor}="c1ca",     SYMLINK+="1111111"

[...]

> [/root 10.10.10.44] $ udevadm info --query=all --name=/dev/hidraw0
> --attribute-walk 2>&1 | egrep 'serial|idVendor'
>    ATTRS{idVendor}="c1ca"
>    ATTRS{idVendor}="05e3"
>    ATTRS{idVendor}="1d6b"
>    ATTRS{serial}="musb_hdrc"
>
> I was expecting to see "11111", and I don't. This explains why
> "444444" is not working. Still - something is not working here.

I guess c1ca is not the idVendor of your hidraw device, but of one of
it its parents. Could you post the output of "udevadm info --query=all
--name=/dev/hidraw0 --attribute-walk" (without the egrep)?

-t

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing a rule specific to a USB connector
  2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
                   ` (2 preceding siblings ...)
  2011-08-23  9:51 ` Tom Gundersen
@ 2011-08-23 10:45 ` Diego Iastrubni
  2011-08-23 11:01 ` Tom Gundersen
  2011-08-23 11:34 ` Diego Iastrubni
  5 siblings, 0 replies; 7+ messages in thread
From: Diego Iastrubni @ 2011-08-23 10:45 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2011 at 12:51 PM, Tom Gundersen <teg@jklm.no> wrote:
> I guess c1ca is not the idVendor of your hidraw device, but of one of
> it its parents. Could you post the output of "udevadm info --query=all
> --name=/dev/hidraw0 --attribute-walk" (without the egrep)?

[/root 10.10.10.44] $ udevadm info --query=all --name=/dev/hidraw0
--attribute-walk

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device
'/devices/platform/musb_hdrc/usb1/1-1/1-1.1/1-1.1:1.0/0003:C1CA:0003.0001/hidraw/hidraw0':
    KERNEL="hidraw0"
    SUBSYSTEM="hidraw"
    DRIVER=""

  looking at parent device
'/devices/platform/musb_hdrc/usb1/1-1/1-1.1/1-1.1:1.0/0003:C1CA:0003.0001':
    KERNELS="0003:C1CA:0003.0001"
    SUBSYSTEMS="hid"
    DRIVERS="generic-usb"

  looking at parent device
'/devices/platform/musb_hdrc/usb1/1-1/1-1.1/1-1.1:1.0':
    KERNELS="1-1.1:1.0"
    SUBSYSTEMS="usb"
    DRIVERS="usbhid"
    ATTRS{bInterfaceNumber}="00"
    ATTRS{bAlternateSetting}=" 0"
    ATTRS{bNumEndpoints}="01"
    ATTRS{bInterfaceClass}="03"
    ATTRS{bInterfaceSubClass}="00"
    ATTRS{bInterfaceProtocol}="00"
    ATTRS{supports_autosuspend}="1"
    ATTRS{interface}="BIOGOARD"

  looking at parent device '/devices/platform/musb_hdrc/usb1/1-1/1-1.1':
    KERNELS="1-1.1"
    SUBSYSTEMS="usb"
    DRIVERS="usb"
    ATTRS{configuration}="Default configuration"
    ATTRS{bNumInterfaces}=" 1"
    ATTRS{bConfigurationValue}="1"
    ATTRS{bmAttributes}="40"
    ATTRS{bMaxPower}="  0mA"
    ATTRS{urbnum}="41"
    ATTRS{idVendor}="c1ca"
    ATTRS{idProduct}="0003"
    ATTRS{bcdDevice}="0000"
    ATTRS{bDeviceClass}="00"
    ATTRS{bDeviceSubClass}="00"
    ATTRS{bDeviceProtocol}="00"
    ATTRS{bNumConfigurations}="1"
    ATTRS{bMaxPacketSize0}="8"
    ATTRS{speed}="12"
    ATTRS{busnum}="1"
    ATTRS{devnum}="3"
    ATTRS{devpath}="1.1"
    ATTRS{version}=" 1.01"
    ATTRS{maxchild}="0"
    ATTRS{quirks}="0x0"
    ATTRS{authorized}="1"
    ATTRS{manufacturer}="Sysmop tech."
    ATTRS{product}="USB PALM"

  looking at parent device '/devices/platform/musb_hdrc/usb1/1-1':
    KERNELS="1-1"
    SUBSYSTEMS="usb"
    DRIVERS="usb"
    ATTRS{configuration}=""
    ATTRS{bNumInterfaces}=" 1"
    ATTRS{bConfigurationValue}="1"
    ATTRS{bmAttributes}="e0"
    ATTRS{bMaxPower}="100mA"
    ATTRS{urbnum}="50"
    ATTRS{idVendor}="05e3"
    ATTRS{idProduct}="0608"
    ATTRS{bcdDevice}="0702"
    ATTRS{bDeviceClass}="09"
    ATTRS{bDeviceSubClass}="00"
    ATTRS{bDeviceProtocol}="01"
    ATTRS{bNumConfigurations}="1"
    ATTRS{bMaxPacketSize0}="64"
    ATTRS{speed}="480"
    ATTRS{busnum}="1"
    ATTRS{devnum}="2"
    ATTRS{devpath}="1"
    ATTRS{version}=" 2.00"
    ATTRS{maxchild}="4"
    ATTRS{quirks}="0x0"
    ATTRS{authorized}="1"
    ATTRS{product}="USB2.0 Hub"

  looking at parent device '/devices/platform/musb_hdrc/usb1':
    KERNELS="usb1"
    SUBSYSTEMS="usb"
    DRIVERS="usb"
    ATTRS{configuration}=""
    ATTRS{bNumInterfaces}=" 1"
    ATTRS{bConfigurationValue}="1"
    ATTRS{bmAttributes}="e0"
    ATTRS{bMaxPower}="  0mA"
    ATTRS{urbnum}="26"
    ATTRS{idVendor}="1d6b"
    ATTRS{idProduct}="0002"
    ATTRS{bcdDevice}="0206"
    ATTRS{bDeviceClass}="09"
    ATTRS{bDeviceSubClass}="00"
    ATTRS{bDeviceProtocol}="00"
    ATTRS{bNumConfigurations}="1"
    ATTRS{bMaxPacketSize0}="64"
    ATTRS{speed}="480"
    ATTRS{busnum}="1"
    ATTRS{devnum}="1"
    ATTRS{devpath}="0"
    ATTRS{version}=" 2.00"
    ATTRS{maxchild}="1"
    ATTRS{quirks}="0x0"
    ATTRS{authorized}="1"
    ATTRS{manufacturer}="Linux 2.6.32 musb-hcd"
    ATTRS{product}="MUSB HDRC host driver"
    ATTRS{serial}="musb_hdrc"
    ATTRS{authorized_default}="1"

  looking at parent device '/devices/platform/musb_hdrc':
    KERNELS="musb_hdrc"
    SUBSYSTEMS="platform"
    DRIVERS="musb_hdrc"
    ATTRS{mode}="a_host"
    ATTRS{vbus}="Vbus off, timeout 1100"

  looking at parent device '/devices/platform':
    KERNELS="platform"
    SUBSYSTEMS=""
    DRIVERS=""

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing a rule specific to a USB connector
  2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
                   ` (3 preceding siblings ...)
  2011-08-23 10:45 ` Diego Iastrubni
@ 2011-08-23 11:01 ` Tom Gundersen
  2011-08-23 11:34 ` Diego Iastrubni
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Gundersen @ 2011-08-23 11:01 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2011 at 12:45 PM, Diego Iastrubni <diegoiast@gmail.com> wrote:
> On Tue, Aug 23, 2011 at 12:51 PM, Tom Gundersen <teg@jklm.no> wrote:
>> I guess c1ca is not the idVendor of your hidraw device, but of one of
>> it its parents. Could you post the output of "udevadm info --query=all
>> --name=/dev/hidraw0 --attribute-walk" (without the egrep)?
>
> [/root 10.10.10.44] $ udevadm info --query=all --name=/dev/hidraw0
> --attribute-walk

[...]

>  looking at device
> '/devices/platform/musb_hdrc/usb1/1-1/1-1.1/1-1.1:1.0/0003:C1CA:0003.0001/hidraw/hidraw0':
>    KERNEL="hidraw0"
>    SUBSYSTEM="hidraw"
>    DRIVER=""

[...]

>  looking at parent device '/devices/platform/musb_hdrc/usb1/1-1/1-1.1':
>    KERNELS="1-1.1"
>    SUBSYSTEMS="usb"
>    DRIVERS="usb"
>    ATTRS{configuration}="Default configuration"
>    ATTRS{bNumInterfaces}=" 1"
>    ATTRS{bConfigurationValue}="1"
>    ATTRS{bmAttributes}="40"
>    ATTRS{bMaxPower}="  0mA"
>    ATTRS{urbnum}="41"
>    ATTRS{idVendor}="c1ca"
>    ATTRS{idProduct}="0003"
>    ATTRS{bcdDevice}="0000"
>    ATTRS{bDeviceClass}="00"
>    ATTRS{bDeviceSubClass}="00"
>    ATTRS{bDeviceProtocol}="00"
>    ATTRS{bNumConfigurations}="1"
>    ATTRS{bMaxPacketSize0}="8"
>    ATTRS{speed}="12"
>    ATTRS{busnum}="1"
>    ATTRS{devnum}="3"
>    ATTRS{devpath}="1.1"
>    ATTRS{version}=" 1.01"
>    ATTRS{maxchild}="0"
>    ATTRS{quirks}="0x0"
>    ATTRS{authorized}="1"
>    ATTRS{manufacturer}="Sysmop tech."
>    ATTRS{product}="USB PALM"

[...]

>  looking at parent device '/devices/platform/musb_hdrc/usb1':
>    KERNELS="usb1"
>    SUBSYSTEMS="usb"
>    DRIVERS="usb"
>    ATTRS{configuration}=""
>    ATTRS{bNumInterfaces}=" 1"
>    ATTRS{bConfigurationValue}="1"
>    ATTRS{bmAttributes}="e0"
>    ATTRS{bMaxPower}="  0mA"
>    ATTRS{urbnum}="26"
>    ATTRS{idVendor}="1d6b"
>    ATTRS{idProduct}="0002"
>    ATTRS{bcdDevice}="0206"
>    ATTRS{bDeviceClass}="09"
>    ATTRS{bDeviceSubClass}="00"
>    ATTRS{bDeviceProtocol}="00"
>    ATTRS{bNumConfigurations}="1"
>    ATTRS{bMaxPacketSize0}="64"
>    ATTRS{speed}="480"
>    ATTRS{busnum}="1"
>    ATTRS{devnum}="1"
>    ATTRS{devpath}="0"
>    ATTRS{version}=" 2.00"
>    ATTRS{maxchild}="1"
>    ATTRS{quirks}="0x0"
>    ATTRS{authorized}="1"
>    ATTRS{manufacturer}="Linux 2.6.32 musb-hcd"
>    ATTRS{product}="MUSB HDRC host driver"
>    ATTRS{serial}="musb_hdrc"
>    ATTRS{authorized_default}="1"

Ok, so that explains why you don't get your 11111 symlink, the
idVendor you are matching against is not on the device you want, but
on a parent.

I honestly don't know the best way to match against two different
parents, which is apparently what you need. I guess something like
this should work though:

SUBSYSTEM!="hidraw", GOTO="hidraw_end"
ATTRS{idVendor}!="c1ca", GOTO="hidraw_end"
ATTRS{serial}="musb_hdrc", SYMLINK+="444444"
LABEL="hidraw_end"

Maybe someone else knows a better solution?

Cheers,

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing a rule specific to a USB connector
  2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
                   ` (4 preceding siblings ...)
  2011-08-23 11:01 ` Tom Gundersen
@ 2011-08-23 11:34 ` Diego Iastrubni
  5 siblings, 0 replies; 7+ messages in thread
From: Diego Iastrubni @ 2011-08-23 11:34 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2011 at 2:01 PM, Tom Gundersen <teg@jklm.no> wrote:
> Ok, so that explains why you don't get your 11111 symlink, the
> idVendor you are matching against is not on the device you want, but
> on a parent.
>
> I honestly don't know the best way to match against two different
> parents, which is apparently what you need. I guess something like
> this should work though:
>
> SUBSYSTEM!="hidraw", GOTO="hidraw_end"
> ATTRS{idVendor}!="c1ca", GOTO="hidraw_end"
> ATTRS{serial}="musb_hdrc", SYMLINK+="444444"
> LABEL="hidraw_end"

... and for some reason the code above did not work. However, this
ugly piece of code does. No idea what in wrong.


SUBSYSTEMS      = "hidraw"    , GOTO     = "blabla_1"
GOTO             = "blabla_end"

LABEL            = "blabla_1"
ATTRS{idVendor} = "c1ca"      , GOTO     = "blabla_2"
GOTO             =  "blabla_end"

LABEL            = "blabla_2"
ATTRS{serial}   = "musb_hdrc"   , SYMLINK += "blabla-upper"
ATTRS{serial}   = "ehci-omap.0" , SYMLINK += "blabla-lower"

LABEL            = "blabla_end"

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-23 11:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-23  8:03 Writing a rule specific to a USB connector Diego Iastrubni
2011-08-23  8:15 ` Tom Gundersen
2011-08-23  8:59 ` Diego Iastrubni
2011-08-23  9:51 ` Tom Gundersen
2011-08-23 10:45 ` Diego Iastrubni
2011-08-23 11:01 ` Tom Gundersen
2011-08-23 11:34 ` Diego Iastrubni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.