Changeset - 7d59926031ba
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 14 years ago 2011-06-15 07:54:58
drewp@bigasterisk.com
attempted fixes to dmx_usb kernel module for 2.6.38. untested; may crash you
Ignore-this: 7d3167e0c028a60f152114a8addcb18
1 file changed with 15 insertions and 3 deletions:
0 comments (0 inline, 0 general)
dmx_usb_module/dmx_usb.c
Show inline comments
 
@@ -35,12 +35,18 @@
 

	
 
/* Use our own dbg macro */
 
#undef dbg
 
#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0)
 

	
 

	
 
// from http://www.linuxinsight.com/vmware-workstation-7.1.3-runs-great-on-linux-kernel-2.6.37.html
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
 
   #define DECLARE_MUTEX(_m) DEFINE_SEMAPHORE(_m)
 
   #define init_MUTEX(_m) sema_init(_m, 1)
 
#endif
 

	
 
/* Version Information */
 
#define DRIVER_VERSION "v0.1.20060816"
 
#define DRIVER_AUTHOR "Erwin Rol, erwin@erwinrol.com"
 
#define DRIVER_DESC "DMX USB Driver"
 

	
 
/* Module parameters */
 
@@ -93,13 +99,13 @@ struct dmx_usb_device {
 
/* prevent races between open() and disconnect() */
 
static DECLARE_MUTEX (disconnect_sem);
 

	
 
/* local function prototypes */
 
//static ssize_t dmx_usb_read	(struct file *file, char *buffer, size_t count, loff_t *ppos);
 
static ssize_t dmx_usb_write	(struct file *file, const char *buffer, size_t count, loff_t *ppos);
 
static int dmx_usb_ioctl	(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
 
static int dmx_usb_ioctl	(struct file *file, unsigned int cmd, unsigned long arg);
 
static int dmx_usb_open		(struct inode *inode, struct file *file);
 
static int dmx_usb_release	(struct inode *inode, struct file *file);
 

	
 
static int dmx_usb_probe	(struct usb_interface *interface, const struct usb_device_id *id);
 
static void dmx_usb_disconnect	(struct usb_interface *interface);
 

	
 
@@ -116,13 +122,13 @@ static struct file_operations dmx_usb_fo
 
	 * or should the open() function fail.
 
	 */
 
	.owner =	THIS_MODULE,
 

	
 
	/* .read =		dmx_usb_read, */ 
 
	.write =	dmx_usb_write,
 
	.ioctl =	dmx_usb_ioctl,
 
	.unlocked_ioctl = dmx_usb_ioctl,
 
	.open =		dmx_usb_open,
 
	.release =	dmx_usb_release,
 
};
 

	
 
/* 
 
 * usb class driver info in order to get a minor number from the usb core,
 
@@ -523,35 +529,41 @@ exit:
 
	return retval;
 
}
 

	
 

	
 
/**
 
 */
 
static int dmx_usb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
 
static int dmx_usb_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
 
{
 
	struct dmx_usb_device *dev;
 

	
 
	lock_kernel(); // this was originally getting the Big Kernel
 
	// Lock. I don't know if that was needed, but I don't want to
 
	// destabilize anything as I move to unlocked_ioctl
 

	
 
	dev = (struct dmx_usb_device *)file->private_data;
 

	
 
	/* lock this object */
 
	down (&dev->sem);
 

	
 
	/* verify that the device wasn't unplugged */
 
	if (!dev->present) {
 
		up (&dev->sem);
 
		unlock_kernel();
 
		return -ENODEV;
 
	}
 

	
 
	dbg("%s - minor %d, cmd 0x%.4x, arg %ld", __FUNCTION__,
 
	    dev->minor, cmd, arg);
 

	
 
	/* fill in your device specific stuff here */
 

	
 
	/* unlock the device */
 
	up (&dev->sem);
 

	
 
	unlock_kernel();
 
	/* return that we did not understand this ioctl call */
 
	return -ENOTTY;
 
}
 

	
 

	
 
/**
0 comments (0 inline, 0 general)