aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--kernel/mpio.c34
2 files changed, 28 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b0f7f08..cbded18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-11-01 Yuji Touya <salmoon@users.sourceforge.net>
+
+ * kernel/mpio.c: Add usbdevfs filesystem support
+
2002-10-29 Andreas Buesching <crunchy@tzi.de>
* mpiosh/mpiosh.c (mpiosh_init): uses the new configuration file
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?) */