Re: udev rule and libusb

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

 



On Sat, May 31, 2008 at 5:23 AM, Roland Roberts <roland@xxxxxxxxxxxxx> wrote:
> I'm working on a userspace driver for the Meade DSI Pro camera.  It uses the
> EZ-USB FX2 chip which requires a firmware upload.  I've successfully
> extracted the firmware into an Intel hex format file and now have a udev
> rule to load the firmware after which the device renumerates.  Here's the
> udev rule I have:
>
> # 1. Pre-renumeration IDs
> # Meade DSI Pro II
> BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c",
> SYSFS{idProduct}=="0100", ENV{DEVICE}!="", \
> RUN+="/sbin/fxload -t fx2 -D $ENV{DEVICE} -I

$DEVICE is the deprecated /proc usb devfs. Use DEVNAME if you want the
udev maintained node.

> /lib/firmware/meade-dsiproII.hex"
>
> # 2. Post-renumeration IDs
> # Meade DSI Pro II
> BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c",
> SYSFS{idProduct}=="0101", ENV{DEVICE}!="", \
> SYMLINK+="dsiproII.%n" MODE="0666"
>
> The symlink is good, it points to /dev/bus/usb/<bus>/<device>, and all it
> well.  I can find and access the device using libusb to iterate over all
> devices.  But the device node in /dev/bus/usb does not have the correct
> permissions; it has 0644 owner root.  This doesn't quite cut it for me.
>
> But...
>
> If I change the second rule to
>
> BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c",
> SYSFS{idProduct}=="0101", ENV{DEVICE}!="", \
> NAME="dsiproII" SYMLINK+="dsiproII.%n" MODE="0666"

Never supply NAME= here, libusb needs the udev created names, in the
defined foemat, not your own names.

> then I get the node /dev/dsiproII with the correct permissions, but the
> device node in /dev/bus/usb/<bus>/<dev> is gone and libusb can no longer
> find the device.
>
> I've asked about this over on the linux-usb list and they suggested I ask
> here.  So I am :-)
>
> What I *really* want is to us the pam console rules to change the owner like
> what happens when I plug in a webcam with the v4l stuff; I can get that to
> work if I use the NAME= directive (although I have an issue with SELinux I'm
> still working on there), but I really need the libusb part working.
>
> So...
>
> 1. Can I get my "preferred" name and still have libusb find the device?

Add a SYMLINK+="myname".

> 2. If not, can I get the permission change applied to the underlying device
> node?

Match the device, and set the permissions with a rule:
  SUBSYSTEM=="usb", ATTR{idVendor}=="156c", ATTR{idProduct}=="0101",
MODE:="0666"

> 3. If yes, do I have to use the RUN directive with a helper to get this to
> work?

No, but if your system runs anything like pam_console, be aware that
this may alter the permissions after udev set it to to the specified
value.

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