From 61280dd4b7da8670fa816ece49fb3c60a7de17c3 Mon Sep 17 00:00:00 2001 From: salmoon Date: Thu, 31 Oct 2002 16:39:51 +0000 Subject: add usbdevfs filesystem support --- kernel/mpio.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'kernel') diff --git a/kernel/mpio.c b/kernel/mpio.c index 7ee67cb..54a336d 100644 --- a/kernel/mpio.c +++ b/kernel/mpio.c @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef CONFIG_USB_DEBUG # define DEBUG @@ -56,7 +57,7 @@ /* * Version Information */ -#define DRIVER_VERSION "0.0.1" +#define DRIVER_VERSION "0.0.2" #define DRIVER_AUTHOR "Yuji Touya " #define DRIVER_DESC "USB MPIO driver" @@ -71,6 +72,7 @@ struct mpio_usb_data { struct usb_device *mpio_dev; /* init: probe_mpio */ + devfs_handle_t devfs; /* devfs device */ unsigned int ifnum; /* Interface number of the USB device */ int isopen; /* nz if open */ int present; /* Device is present on the bus */ @@ -80,6 +82,8 @@ struct mpio_usb_data { struct semaphore lock; /* general race avoidance */ }; +extern devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */ + static struct mpio_usb_data mpio_instance; static int open_mpio(struct inode *inode, struct file *file) @@ -275,6 +279,15 @@ read_mpio(struct file *file, char *buffer, size_t count, loff_t * ppos) return read_count; } +static struct +file_operations usb_mpio_fops = { + read: read_mpio, + write: write_mpio, +/* ioctl: ioctl_mpio, */ + open: open_mpio, + release: close_mpio, +}; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) /* Hmm, .... */ static void *probe_mpio(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) @@ -313,6 +326,14 @@ static void *probe_mpio(struct usb_device *dev, unsigned int ifnum) } dbg("probe_mpio: ibuf address:%p", mpio->ibuf); + mpio->devfs = devfs_register(usb_devfs_handle, "mpio", + DEVFS_FL_DEFAULT, USB_MAJOR, + MPIO_MINOR, + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP, &usb_mpio_fops, NULL); + if (mpio->devfs == NULL) + dbg("probe_mpio: device node registration failed"); + init_MUTEX(&(mpio->lock)); return mpio; @@ -322,6 +343,8 @@ static void disconnect_mpio(struct usb_device *dev, void *ptr) { struct mpio_usb_data *mpio = (struct mpio_usb_data *) ptr; + devfs_unregister(mpio->devfs); + if (mpio->isopen) { mpio->isopen = 0; /* better let it finish - the release will do whats needed */ @@ -336,15 +359,6 @@ static void disconnect_mpio(struct usb_device *dev, void *ptr) mpio->present = 0; } -static struct -file_operations usb_mpio_fops = { - read: read_mpio, - write: write_mpio, -/* ioctl: ioctl_mpio, */ - open: open_mpio, - release: close_mpio, -}; - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) static struct usb_device_id mpio_table [] = { { USB_DEVICE(0x2735, 1) }, /* MPIO-* (all models?) */ -- cgit v1.2.3