Which interface: sysfs, proc, devfs?
Hi!
I am writing a driver for an usb microcontroller (ezusb), which will be used for measuring and controlling. I am confused on which interface to use though. The driver is for kernel 2.6.x.
I want to send small (human readable) commends as well as data (e.g. firmware) to the device. Which filesystem is appropriate?
regards
Jonas
PS: Please CC me in replies, I am not subscribed to the list.
Quoted 7 lines · Jonas Diemer
Hi!
I am writing a driver for an usb microcontroller (ezusb), which will be used for measuring and controlling. I am confused on which interface to use though. The driver is for kernel 2.6.x.
I want to send small (human readable) commends as well as data (e.g. firmware) to the device. Which filesystem is appropriate?
What about not writing a kernel driver at all and just using libusb/usbfs? Any reason you have to have a kernel driver for your device?
thanks,
greg k-h
Quoted 3 lines · On Thu, 29 Jan 2004 15:02:50 -0800 Greg KH <[email protected]> wrote:
What about not writing a kernel driver at all and just using libusb/usbfs? Any reason you have to have a kernel driver for your device?
Well, didn't think about that, but it indeed seems more logical. Thanks for the hint.
regards
Jonas
PS: CC me in replies, please
Quoted 3 lines · On Thu, 29 Jan 2004 15:02:50 -0800 Greg KH <[email protected]> wrote:
What about not writing a kernel driver at all and just using libusb/usbfs? Any reason you have to have a kernel driver for your device?
Well, I have just looked into libusb 0.1.x... I would like to have asynchronous (non-blocking) access to my device, which libusb doesn't currently support. Also I don't like the way libusb finds devices - manually scanning all busses doesn't seem very handy.
Thus I will probably go for a kernel module, using sysfs to interface with the user. Thanks for all the help anyways-
regards
Jonas
Quoted 11 lines · Jonas Diemer
Quoted 3 lines · On Thu, 29 Jan 2004 15:02:50 -0800 Greg KH <[email protected]> wrote:
What about not writing a kernel driver at all and just using libusb/usbfs? Any reason you have to have a kernel driver for your device?
Well, I have just looked into libusb 0.1.x... I would like to have asynchronous (non-blocking) access to my device, which libusb doesn't currently support.
You mean "submit a urb and be notified when it was completed?" I thought libusb supported that with signals.
Quoted 2 lines
Also I don't like the way libusb finds devices - manually scanning all busses doesn't seem very handy.
What other way can a userspace library do this? It doesn't take very long at all, what is the problem with this?
Quoted 2 lines
Thus I will probably go for a kernel module, using sysfs to interface with the user. Thanks for all the help anyways-
Remember that sysfs is "1 value per file". If that works for your device, then I suggest you look at the usbled driver, as that is a tiny usb driver that only uses sysfs. Nothing like a 4kb kernel driver :)
Good luck,
greg k-h
Quoted 2 lines · On Sun, 1 Feb 2004 13:28:03 -0800 Greg KH <[email protected]> wrote:
You mean "submit a urb and be notified when it was completed?" I thought libusb supported that with signals.
Yeah, thats what I meant. In the html doc shipped with version 0.1.7, it says "all functions in libusb v0.1 are synchronous, meaning the functions block and wait for the operation to finish or timeout before returning execution to the calling application. Asynchronous operation will be supported in v1.0, but not v0.1."...
Quoted 2 lines
What other way can a userspace library do this? It doesn't take very long at all, what is the problem with this?
Well, I would have liked a lib-function likefind_device(int vend_id,int prod_id);
but thats really not a big deal.
Quoted 4 lines
Remember that sysfs is "1 value per file". If that works for your device, then I suggest you look at the usbled driver, as that is a tiny usb driver that only uses sysfs. Nothing like a 4kb kernel driver :)
Thanks for that hint, I'll have a look at it. I only need 1 val per file, i.e. a "firmware" file, which I learned is best done with the firmware_class.
Quoted 1 line
Good luck
Thanks
regards
Jonas
PS: CC me in replies, please.
Quoted 11 lines · Jonas Diemer
Quoted 2 lines · On Sun, 1 Feb 2004 13:28:03 -0800 Greg KH <[email protected]> wrote:
You mean "submit a urb and be notified when it was completed?" I thought libusb supported that with signals.
Yeah, thats what I meant. In the html doc shipped with version 0.1.7, it says "all functions in libusb v0.1 are synchronous, meaning the functions block and wait for the operation to finish or timeout before returning execution to the calling application. Asynchronous operation will be supported in v1.0, but not v0.1."...
Yet you want to do asynchronous support with sysfs? How would that work?
What kind of device are you writing a driver for?
Quoted 3 lines
Thanks for that hint, I'll have a look at it. I only need 1 val per file, i.e. a "firmware" file, which I learned is best done with the
firmware_class.
For firmware only download type devices, I'd really recommend sticking with libusb, unless you have to. It's much easier that way.
thanks,
greg k-h
Quoted 3 lines · On Sun, 1 Feb 2004 19:25:14 -0800 Greg KH <[email protected]> wrote:
Yet you want to do asynchronous support with sysfs? How would that work?
What kind of device are you writing a driver for?
It is not firmware uploading only. Once the firmware is uploaded, I will communicate with that device. It is a ezusb microcontroller controlling several relais, adc and dac.
Quoted 2 lines
For firmware only download type devices, I'd really recommend sticking with libusb, unless you have to. It's much easier that way.
Yepp, there's already a tool using libusb (fx2 programmer) for my chip which I indeed would use if I only wanted to download the firmware...
regards
Jonas
PS: CC me.
Quoted 8 lines
Quoted 3 lines · Greg KH
Yet you want to do asynchronous support with sysfs? How would that work?
What kind of device are you writing a driver for?It is not firmware uploading only. Once the firmware is uploaded, I will communicate with that device. It is a ezusb microcontroller controlling several relais, adc and dac.
usbfs certainly supports asynchronous communication (sending an urb and picking up the result at some convenient later time). I don't know if libusb supports it, but in any case it is easy to use usbfs directly.
Duncan.