Mercurial > code > home > repos > light9
comparison dmx_usb_module/dmx_usb.c @ 634:7d59926031ba
attempted fixes to dmx_usb kernel module for 2.6.38. untested; may crash you
Ignore-this: 7d3167e0c028a60f152114a8addcb18
author | drewp@bigasterisk.com |
---|---|
date | Wed, 15 Jun 2011 07:54:58 +0000 |
parents | 3648a427e9a0 |
children | 01d330152a18 |
comparison
equal
deleted
inserted
replaced
633:3648a427e9a0 | 634:7d59926031ba |
---|---|
36 /* Use our own dbg macro */ | 36 /* Use our own dbg macro */ |
37 #undef dbg | 37 #undef dbg |
38 #define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) | 38 #define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) |
39 | 39 |
40 | 40 |
41 // from http://www.linuxinsight.com/vmware-workstation-7.1.3-runs-great-on-linux-kernel-2.6.37.html | |
42 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) | |
43 #define DECLARE_MUTEX(_m) DEFINE_SEMAPHORE(_m) | |
44 #define init_MUTEX(_m) sema_init(_m, 1) | |
45 #endif | |
46 | |
41 /* Version Information */ | 47 /* Version Information */ |
42 #define DRIVER_VERSION "v0.1.20060816" | 48 #define DRIVER_VERSION "v0.1.20060816" |
43 #define DRIVER_AUTHOR "Erwin Rol, erwin@erwinrol.com" | 49 #define DRIVER_AUTHOR "Erwin Rol, erwin@erwinrol.com" |
44 #define DRIVER_DESC "DMX USB Driver" | 50 #define DRIVER_DESC "DMX USB Driver" |
45 | 51 |
94 static DECLARE_MUTEX (disconnect_sem); | 100 static DECLARE_MUTEX (disconnect_sem); |
95 | 101 |
96 /* local function prototypes */ | 102 /* local function prototypes */ |
97 //static ssize_t dmx_usb_read (struct file *file, char *buffer, size_t count, loff_t *ppos); | 103 //static ssize_t dmx_usb_read (struct file *file, char *buffer, size_t count, loff_t *ppos); |
98 static ssize_t dmx_usb_write (struct file *file, const char *buffer, size_t count, loff_t *ppos); | 104 static ssize_t dmx_usb_write (struct file *file, const char *buffer, size_t count, loff_t *ppos); |
99 static int dmx_usb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); | 105 static int dmx_usb_ioctl (struct file *file, unsigned int cmd, unsigned long arg); |
100 static int dmx_usb_open (struct inode *inode, struct file *file); | 106 static int dmx_usb_open (struct inode *inode, struct file *file); |
101 static int dmx_usb_release (struct inode *inode, struct file *file); | 107 static int dmx_usb_release (struct inode *inode, struct file *file); |
102 | 108 |
103 static int dmx_usb_probe (struct usb_interface *interface, const struct usb_device_id *id); | 109 static int dmx_usb_probe (struct usb_interface *interface, const struct usb_device_id *id); |
104 static void dmx_usb_disconnect (struct usb_interface *interface); | 110 static void dmx_usb_disconnect (struct usb_interface *interface); |
117 */ | 123 */ |
118 .owner = THIS_MODULE, | 124 .owner = THIS_MODULE, |
119 | 125 |
120 /* .read = dmx_usb_read, */ | 126 /* .read = dmx_usb_read, */ |
121 .write = dmx_usb_write, | 127 .write = dmx_usb_write, |
122 .ioctl = dmx_usb_ioctl, | 128 .unlocked_ioctl = dmx_usb_ioctl, |
123 .open = dmx_usb_open, | 129 .open = dmx_usb_open, |
124 .release = dmx_usb_release, | 130 .release = dmx_usb_release, |
125 }; | 131 }; |
126 | 132 |
127 /* | 133 /* |
524 } | 530 } |
525 | 531 |
526 | 532 |
527 /** | 533 /** |
528 */ | 534 */ |
529 static int dmx_usb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 535 static int dmx_usb_ioctl (struct file *file, unsigned int cmd, unsigned long arg) |
530 { | 536 { |
531 struct dmx_usb_device *dev; | 537 struct dmx_usb_device *dev; |
538 | |
539 lock_kernel(); // this was originally getting the Big Kernel | |
540 // Lock. I don't know if that was needed, but I don't want to | |
541 // destabilize anything as I move to unlocked_ioctl | |
532 | 542 |
533 dev = (struct dmx_usb_device *)file->private_data; | 543 dev = (struct dmx_usb_device *)file->private_data; |
534 | 544 |
535 /* lock this object */ | 545 /* lock this object */ |
536 down (&dev->sem); | 546 down (&dev->sem); |
537 | 547 |
538 /* verify that the device wasn't unplugged */ | 548 /* verify that the device wasn't unplugged */ |
539 if (!dev->present) { | 549 if (!dev->present) { |
540 up (&dev->sem); | 550 up (&dev->sem); |
551 unlock_kernel(); | |
541 return -ENODEV; | 552 return -ENODEV; |
542 } | 553 } |
543 | 554 |
544 dbg("%s - minor %d, cmd 0x%.4x, arg %ld", __FUNCTION__, | 555 dbg("%s - minor %d, cmd 0x%.4x, arg %ld", __FUNCTION__, |
545 dev->minor, cmd, arg); | 556 dev->minor, cmd, arg); |
547 /* fill in your device specific stuff here */ | 558 /* fill in your device specific stuff here */ |
548 | 559 |
549 /* unlock the device */ | 560 /* unlock the device */ |
550 up (&dev->sem); | 561 up (&dev->sem); |
551 | 562 |
563 unlock_kernel(); | |
552 /* return that we did not understand this ioctl call */ | 564 /* return that we did not understand this ioctl call */ |
553 return -ENOTTY; | 565 return -ENOTTY; |
554 } | 566 } |
555 | 567 |
556 | 568 |