aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorsalmoon <salmoon>2002-10-31 16:39:51 +0000
committersalmoon <salmoon>2002-10-31 16:39:51 +0000
commit61280dd4b7da8670fa816ece49fb3c60a7de17c3 (patch)
treec9e4f1f63ad73a88c4442802e4297e6590c309c0 /kernel
parentc7351455575348d9d9847604069ee15132f2d8e0 (diff)
downloadmpiosh-61280dd4b7da8670fa816ece49fb3c60a7de17c3.tar.gz
mpiosh-61280dd4b7da8670fa816ece49fb3c60a7de17c3.tar.bz2
mpiosh-61280dd4b7da8670fa816ece49fb3c60a7de17c3.zip
add usbdevfs filesystem support
Diffstat (limited to 'kernel')
-rw-r--r--kernel/mpio.c34
1 files changed, 24 insertions, 10 deletions
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 <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
#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 <salmoon@users.sourceforge.net>"
#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?) */