X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fimage%2Fmdc800.c;h=a330a4b50e1672402743685102a3f1f38618f37e;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=f401557f035693bbe4292440822a55affdf9b35c;hpb=9bf4aaab3e101692164d49b7ca357651eb691cb6;p=linux-2.6.git diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index f401557f0..a330a4b50 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -23,7 +23,7 @@ * * * The driver brings the USB functions of the MDC800 to Linux. - * To use the Camera you must support the USB Protocoll of the camera + * To use the Camera you must support the USB Protocol of the camera * to the Kernel Node. * The Driver uses a misc device Node. Create it with : * mknod /dev/mustek c 180 32 @@ -95,6 +95,7 @@ #include #include #include +#include #include #include @@ -182,13 +183,48 @@ struct mdc800_data /* Specification of the Endpoints */ static struct usb_endpoint_descriptor mdc800_ed [4] = { - { 0,0, 0x01, 0x02, 8, 0,0,0 }, - { 0,0, 0x82, 0x03, 8, 0,0,0 }, - { 0,0, 0x03, 0x02, 64, 0,0,0 }, - { 0,0, 0x84, 0x02, 64, 0,0,0 } + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x01, + .bmAttributes = 0x02, + .wMaxPacketSize = __constant_cpu_to_le16(8), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x82, + .bmAttributes = 0x03, + .wMaxPacketSize = __constant_cpu_to_le16(8), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x03, + .bmAttributes = 0x02, + .wMaxPacketSize = __constant_cpu_to_le16(64), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x84, + .bmAttributes = 0x02, + .wMaxPacketSize = __constant_cpu_to_le16(64), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, }; - /* The Variable used by the driver */ static struct mdc800_data* mdc800; @@ -295,7 +331,7 @@ static void mdc800_usb_irq (struct urb *urb, struct pt_regs *res) { mdc800->camera_request_ready=0; mdc800->irq_woken=1; - wake_up_interruptible (&mdc800->irq_wait); + wake_up (&mdc800->irq_wait); } } @@ -311,21 +347,9 @@ static void mdc800_usb_irq (struct urb *urb, struct pt_regs *res) */ static int mdc800_usb_waitForIRQ (int mode, int msec) { - DECLARE_WAITQUEUE(wait, current); - long timeout; - mdc800->camera_request_ready=1+mode; - add_wait_queue(&mdc800->irq_wait, &wait); - set_current_state(TASK_INTERRUPTIBLE); - timeout = msec*HZ/1000; - while (!mdc800->irq_woken && timeout) - { - set_current_state(TASK_UNINTERRUPTIBLE); - timeout = schedule_timeout (timeout); - } - remove_wait_queue(&mdc800->irq_wait, &wait); - set_current_state(TASK_RUNNING); + wait_event_timeout(mdc800->irq_wait, mdc800->irq_woken, msec*HZ/1000); mdc800->irq_woken = 0; if (mdc800->camera_request_ready>0) @@ -362,7 +386,7 @@ static void mdc800_usb_write_notify (struct urb *urb, struct pt_regs *res) mdc800->state=READY; } mdc800->written = 1; - wake_up_interruptible (&mdc800->write_wait); + wake_up (&mdc800->write_wait); } @@ -390,7 +414,7 @@ static void mdc800_usb_download_notify (struct urb *urb, struct pt_regs *res) err ("request bytes fails (status:%i)", urb->status); } mdc800->downloaded = 1; - wake_up_interruptible (&mdc800->download_wait); + wake_up (&mdc800->download_wait); } @@ -423,7 +447,7 @@ static int mdc800_usb_probe (struct usb_interface *intf, dbg ("(mdc800_usb_probe) called."); - if (mdc800->dev != 0) + if (mdc800->dev != NULL) { warn ("only one Mustek MDC800 is supported."); return -ENODEV; @@ -543,9 +567,9 @@ static void mdc800_usb_disconnect (struct usb_interface *intf) mdc800->state=NOT_CONNECTED; - usb_unlink_urb (mdc800->irq_urb); - usb_unlink_urb (mdc800->write_urb); - usb_unlink_urb (mdc800->download_urb); + usb_kill_urb(mdc800->irq_urb); + usb_kill_urb(mdc800->write_urb); + usb_kill_urb(mdc800->download_urb); mdc800->dev = NULL; usb_set_intfdata(intf, NULL); @@ -649,9 +673,9 @@ static int mdc800_device_release (struct inode* inode, struct file *file) down (&mdc800->io_lock); if (mdc800->open && (mdc800->state != NOT_CONNECTED)) { - usb_unlink_urb (mdc800->irq_urb); - usb_unlink_urb (mdc800->write_urb); - usb_unlink_urb (mdc800->download_urb); + usb_kill_urb(mdc800->irq_urb); + usb_kill_urb(mdc800->write_urb); + usb_kill_urb(mdc800->download_urb); mdc800->open=0; } else @@ -671,8 +695,6 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l { size_t left=len, sts=len; /* single transfer size */ char __user *ptr = buf; - long timeout; - DECLARE_WAITQUEUE(wait, current); down (&mdc800->io_lock); if (mdc800->state == NOT_CONNECTED) @@ -718,15 +740,8 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l up (&mdc800->io_lock); return len-left; } - add_wait_queue(&mdc800->download_wait, &wait); - timeout = TO_DOWNLOAD_GET_READY*HZ/1000; - while (!mdc800->downloaded && timeout) - { - set_current_state(TASK_UNINTERRUPTIBLE); - timeout = schedule_timeout (timeout); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&mdc800->download_wait, &wait); + wait_event_timeout(mdc800->download_wait, mdc800->downloaded, + TO_DOWNLOAD_GET_READY*HZ/1000); mdc800->downloaded = 0; if (mdc800->download_urb->status != 0) { @@ -770,7 +785,6 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l static ssize_t mdc800_device_write (struct file *file, const char __user *buf, size_t len, loff_t *pos) { size_t i=0; - DECLARE_WAITQUEUE(wait, current); down (&mdc800->io_lock); if (mdc800->state != READY) @@ -824,7 +838,6 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s if (mdc800->in_count == 8) { int answersize; - long timeout; if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) { @@ -844,19 +857,11 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s up (&mdc800->io_lock); return -EIO; } - add_wait_queue(&mdc800->write_wait, &wait); - timeout = TO_WRITE_GET_READY*HZ/1000; - while (!mdc800->written && timeout) - { - set_current_state(TASK_UNINTERRUPTIBLE); - timeout = schedule_timeout (timeout); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&mdc800->write_wait, &wait); + wait_event_timeout(mdc800->write_wait, mdc800->written, TO_WRITE_GET_READY*HZ/1000); mdc800->written = 0; if (mdc800->state == WORKING) { - usb_unlink_urb (mdc800->write_urb); + usb_kill_urb(mdc800->write_urb); up (&mdc800->io_lock); return -EIO; } @@ -1014,7 +1019,7 @@ static int __init usb_mdc800_init (void) cleanup_on_fail: - if (mdc800 != 0) + if (mdc800 != NULL) { err ("can't alloc memory!");