From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: Re: Trouble getting udev rule to fire, works in udevtest
Date: Sat, 18 Jul 2009 08:34:30 +0000 [thread overview]
Message-ID: <4A618916.7080302@tuffmail.co.uk> (raw)
In-Reply-To: <479b70ed0907171831m45700092j111920d71e4a2da9@mail.gmail.com>
On 7/18/09, Ben Beuchler <insyte@gmail.com> wrote:
> 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?
ATTR won't work on a real remove, because the sysfs files are removed
before udev processes the event.
Apparently you can change the match to ACTION="add" and set
ENV{REMOVE_CMD}="modprobe -r ti_usb_3410_5052" instead. This feature
was recently mentioned here
<http://article.gmane.org/gmane.linux.hotplug.devel/14221>.
I don't know when REMOVE_CMD was added to the rules. If your rules are
too old, you should be able implement it yourself. It is a really
simple idea, you just need another rule to run the command on remove.
ACTION="remove", ENV{REMOVE_CMD}="?*", RUN+="$env{REMOVE_CMD}"
Oh, and this is a pretty major bug in the module, please make sure it
has been reported to the appropriate people :-).
Alan
next prev parent reply other threads:[~2009-07-18 8:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-18 1:31 Trouble getting udev rule to fire, works in udevtest Ben Beuchler
2009-07-18 8:34 ` Alan Jenkins [this message]
2009-07-30 0:00 ` Ben Beuchler
2009-07-31 19:06 ` Alan Jenkins
2009-08-01 4:57 ` Ben Beuchler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A618916.7080302@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).