On 2015-12-07 12:42, Martin Pieuchot wrote:
On 07/12/15(Mon) 00:36, Mickael Torres wrote:
On 2015-12-06 20:10, Ian Darwin wrote:
>On 2015-12-06 12:23 PM, Stuart Henderson wrote:
>>On 2015/12/06 06:02, Mickael Torres wrote:
>>>Hello,
>>>
>>>This is a kernel patch plus a utility called ugenctl I use to allow
>>>selected USB devices to attach as ugen(4) instead of their more
>>>specific
>>>driver. My use case is a Microchip "PICkit 2 Microcontroller
>>>Programmer"
>>>that attaches as uhid(4), but the command line utility pk2cmd wants a
>>>udev(4) device. There maybe are some other use cases.
>>If a device is generally pointless with uhid, we can just knock it
>>out completely in the kernel, see the UQ_BAD_HID mechanism. I think this
>>applies to your device.
>>
>>The bigger problem is "dual use" devices; e.g. some want UPS to attach
>>to upd(4), others want ugen(4) for use with NUT/apcupsd. Your code is
>>partially useful for these, but because it just changes things at
>>attach,
>>won't survive a reboot - if it could instead force a device to detach
>>and reattach to ugen it would help a lot more cases.
>>
>One fairly common (I believe) use is with USB printers that attach as ulpt
>but CUPS wants as ugen - for these, this is useful as it stands - just run
>it
>from rc. Do people want their UPS to sometimes be upd and other times be
>a ugen? I can see there might be "I want to change this now" cases, but I
>suspect the majority could be done once at each boot and be quite useful.

Hello,

Hello Mickael,

an updated version that detach/reattach if a device is already connected,
when
adding and when removing from the ugen list.
Seems to work well, but I don't have a lot of hardware to test it.
What do you think ?

I'd really prefer a solution that doesn't need any button.  In other
words to always be able to use your device from userland if the kernel
is not using it.

One way would be to always attach a ugen(4) driver to every USB device,
I think that's what FreeBSD does.  The other way would be to use the
usb(4) bus interface to talk to your device.  In both cases some work
is needed to guarantee that an endpoint is only driven by one driver at
a time.  Right now this is done by attaching only one driver.

To which driver your device currently attaches?  What kind of transfers
to you want to submit from userland?  The libusb already allow your to
submit(some) control transfers.  It would be nice if you could improve
this rather than adding a hack like this one.

Cheers,
Martin

Hello Martin,

Actually the device attaches as uhid. I don't know which kind of transfer
is used, I'll have to look into this, but the soft (pk2cmd) uses libusb
and only works when the device is attached as ugen.
And another soft (pic32prog) which also uses libusb seems to only detect
the device when it is attached as uhid.
I'll try to take a look into libusb.

Cheers,
Mike.

Reply via email to