linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Trouble getting udev rule to fire, works in udevtest
@ 2009-07-18  1:31 Ben Beuchler
  2009-07-18  8:34 ` Alan Jenkins
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ben Beuchler @ 2009-07-18  1:31 UTC (permalink / raw)
  To: linux-hotplug

I'm trying to write a rule that detects the unplugging of a particular
USB device and unloads the kernel module when that happens.  The
reason is that the module appears to be buggy in that if the device is
reconnected without first unloading the module, the module hangs and
the device is not activated.  At this point even forcibly unloading
the module makes no difference.

The device is a MultiTech GSM modem.   The udevinfo used to build the
rule is pasted below.  Here is the rule I've created (and installed in
/etc/udev/rules.d/85-mts_gsm_3410_remove.rules):

SUBSYSTEMS="usb", ACTION="remove", ATTRS{idVendor}="06e0",
ATTRS{idProduct}="f111", RUN+="modprobe -r ti_usb_3410_5052"

For testing purposes, I changed the modprobe to "echo hello from
ti_usb_remove >> /tmp/udev.works"

udevtest seems to indicate that the rule works:

# udevtest --action=remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0 | grep -v
^parse_file
[:snipped udevtest explanation:]
import_uevent_var: import into environment: 'DRIVER=ti_usb_3410_5052_1'
udevtest: looking at device
'/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0' from
subsystem 'usb-serial'
udevtest: run: '/bin/sh -c 'echo 2 >
/sys/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0/device/bConfigurationValue''
udevtest: run: 'echo hello from ti_usb_remove >> /tmp/udev.works'
udevtest: run: 'socket:/org/kernel/udev/monitor'

However if I actually unplug the device, /tmp/udev.works doesn't show
up.   On the off chance that my kernel doesn't support inotify, I also
tried running "udevcontrol reload_rules".  Still failed.  The output
of udevmonitor, captured while unplugging the device, is pasted below.
 For giggles, I also tried running a "logger hello" command instead of
the echo.  Does not appear to run.

Any idea what I'm doing wrong?

Thanks!

-Ben

kernel version: 2.6.24-24
udev version: 117-8


#################
### udevmonitor
#################
UEVENT[1247880336.509326] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/usb_endpoint/usbdev4.31_ep81
(usb_endpoint)
UEVENT[1247880336.509376] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/usb_endpoint/usbdev4.31_ep01
(usb_endpoint)
UEVENT[1247880336.509387] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/usb_endpoint/usbdev4.31_ep83
(usb_endpoint)
UEVENT[1247880336.509397] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0/tty/ttyUSB0
(tty)
UEVENT[1247880336.509405] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0 (usb-serial)
UEVENT[1247880336.509413] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0 (usb)
UEVENT[1247880336.509420] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/usb_endpoint/usbdev4.31_ep00
(usb_endpoint)
UEVENT[1247880336.509427] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1 (usb)
UDEV  [1247880336.513110] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/usb_endpoint/usbdev4.31_ep81
(usb_endpoint)
UDEV  [1247880336.517862] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/usb_endpoint/usbdev4.31_ep01
(usb_endpoint)
UDEV  [1247880336.520061] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/usb_endpoint/usbdev4.31_ep83
(usb_endpoint)
UDEV  [1247880336.521405] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0/tty/ttyUSB0
(tty)
UDEV  [1247880336.527260] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0 (usb-serial)
UDEV  [1247880336.531013] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/usb_endpoint/usbdev4.31_ep00
(usb_endpoint)
UDEV  [1247880336.532150] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0 (usb)
UDEV  [1247880336.535154] remove
/devices/pci0000:00/0000:00:1d.3/usb4/4-1 (usb)

#################
# udevinfo
#################
# udevinfo -a -p /devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0

Udevinfo 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/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0/ttyUSB0':
    KERNEL="ttyUSB0"
    SUBSYSTEM="usb-serial"
    DRIVER="ti_usb_3410_5052_1"
    ATTR{port_number}="0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:2.0':
    KERNELS="4-1:2.0"
    SUBSYSTEMS="usb"
    DRIVERS="ti_usb_3410_5052"
    ATTRS{bInterfaceNumber}="00"
    ATTRS{bAlternateSetting}=" 0"
    ATTRS{bNumEndpoints}="03"
    ATTRS{bInterfaceClass}="ff"
    ATTRS{bInterfaceSubClass}="00"
    ATTRS{bInterfaceProtocol}="00"
    ATTRS{modalias}="usb:v06E0pF111d0101dcFFdsc00dp00icFFisc00ip00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb4/4-1':
    KERNELS="4-1"
    SUBSYSTEMS="usb"
    DRIVERS="usb"
    ATTRS{dev}="189:414"
    ATTRS{configuration}=""
    ATTRS{bNumInterfaces}=" 1"
    ATTRS{bConfigurationValue}="2"
    ATTRS{bmAttributes}="a0"
    ATTRS{bMaxPower}="500mA"
    ATTRS{urbnum}="13"
    ATTRS{idVendor}="06e0"
    ATTRS{idProduct}="f111"
    ATTRS{bcdDevice}="0101"
    ATTRS{bDeviceClass}="ff"
    ATTRS{bDeviceSubClass}="00"
    ATTRS{bDeviceProtocol}="00"
    ATTRS{bNumConfigurations}="2"
    ATTRS{bMaxPacketSize0}="8"
    ATTRS{speed}="12"
    ATTRS{busnum}="4"
    ATTRS{devnum}="31"
    ATTRS{version}=" 1.10"
    ATTRS{maxchild}="0"
    ATTRS{quirks}="0x0"
    ATTRS{authorized}="1"
    ATTRS{manufacturer}="Texas Instruments"
    ATTRS{product}="TUSB3410 Serial Port"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb4':
    KERNELS="usb4"
    SUBSYSTEMS="usb"
    DRIVERS="usb"
    ATTRS{dev}="189:384"
    ATTRS{configuration}=""
    ATTRS{bNumInterfaces}=" 1"
    ATTRS{bConfigurationValue}="1"
    ATTRS{bmAttributes}="e0"
    ATTRS{bMaxPower}="  0mA"
    ATTRS{urbnum}="668"
    ATTRS{idVendor}="0000"
    ATTRS{idProduct}="0000"
    ATTRS{bcdDevice}="0206"
    ATTRS{bDeviceClass}="09"
    ATTRS{bDeviceSubClass}="00"
    ATTRS{bDeviceProtocol}="00"
    ATTRS{bNumConfigurations}="1"
    ATTRS{bMaxPacketSize0}="64"
    ATTRS{speed}="12"
    ATTRS{busnum}="4"
    ATTRS{devnum}="1"
    ATTRS{version}=" 1.10"
    ATTRS{maxchild}="2"
    ATTRS{quirks}="0x0"
    ATTRS{authorized}="1"
    ATTRS{manufacturer}="Linux 2.6.24-24-server uhci_hcd"
    ATTRS{product}="UHCI Host Controller"
    ATTRS{serial}="0000:00:1d.3"
    ATTRS{authorized_default}="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3':
    KERNELS="0000:00:1d.3"
    SUBSYSTEMS="pci"
    DRIVERS="uhci_hcd"
    ATTRS{vendor}="0x8086"
    ATTRS{device}="0x27cb"
    ATTRS{subsystem_vendor}="0x103c"
    ATTRS{subsystem_device}="0x31fe"
    ATTRS{class}="0x0c0300"
    ATTRS{irq}="21"
    ATTRS{local_cpus}="00000000,00000000"
    ATTRS{modalias}="pci:v00008086d000027CBsv0000103Csd000031FEbc0Csc03i00"
    ATTRS{numa_node}="-1"
    ATTRS{enable}="1"
    ATTRS{broken_parity_status}="0"
    ATTRS{msi_bus}=""

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

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

end of thread, other threads:[~2009-08-01  4:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-18  1:31 Trouble getting udev rule to fire, works in udevtest Ben Beuchler
2009-07-18  8:34 ` Alan Jenkins
2009-07-30  0:00 ` Ben Beuchler
2009-07-31 19:06 ` Alan Jenkins
2009-08-01  4:57 ` Ben Beuchler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).