From 887c2560b6ceb5fe7ac24704e85af507c6d960e5 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Sun, 8 Jan 2006 12:33:45 +0100 Subject: [PATCH] USB: kzalloc for storage another one for kzalloc. This covers the storage subdirectory. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/datafab.c | 3 +-- drivers/usb/storage/isd200.c | 8 +++----- drivers/usb/storage/jumpshot.c | 3 +-- drivers/usb/storage/sddr55.c | 3 +-- drivers/usb/storage/shuttle_usbat.c | 3 +-- 5 files changed, 7 insertions(+), 13 deletions(-) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 54e3e6c7ecd..01d8971ad7d 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c @@ -512,13 +512,12 @@ int datafab_transport(struct scsi_cmnd * srb, struct us_data *us) }; if (!us->extra) { - us->extra = kmalloc(sizeof(struct datafab_info), GFP_NOIO); + us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO); if (!us->extra) { US_DEBUGP("datafab_transport: Gah! " "Can't allocate storage for Datafab info struct!\n"); return USB_STOR_TRANSPORT_ERROR; } - memset(us->extra, 0, sizeof(struct datafab_info)); us->extra_destructor = datafab_info_destructor; ((struct datafab_info *)us->extra)->lun = -1; } diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index ecb328aa9ea..7308e8cbe8f 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -1361,21 +1361,19 @@ static int isd200_init_info(struct us_data *us) struct isd200_info *info; info = (struct isd200_info *) - kmalloc(sizeof(struct isd200_info), GFP_KERNEL); + kzalloc(sizeof(struct isd200_info), GFP_KERNEL); if (!info) retStatus = ISD200_ERROR; else { - memset(info, 0, sizeof(struct isd200_info)); info->id = (struct hd_driveid *) - kmalloc(sizeof(struct hd_driveid), GFP_KERNEL); + kzalloc(sizeof(struct hd_driveid), GFP_KERNEL); info->RegsBuf = (unsigned char *) kmalloc(sizeof(info->ATARegs), GFP_KERNEL); if (!info->id || !info->RegsBuf) { isd200_free_info_ptrs(info); kfree(info); retStatus = ISD200_ERROR; - } else - memset(info->id, 0, sizeof(struct hd_driveid)); + } } if (retStatus == ISD200_GOOD) { diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index aff9d51c327..5031aa98f6a 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c @@ -441,12 +441,11 @@ int jumpshot_transport(struct scsi_cmnd * srb, struct us_data *us) }; if (!us->extra) { - us->extra = kmalloc(sizeof(struct jumpshot_info), GFP_NOIO); + us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO); if (!us->extra) { US_DEBUGP("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n"); return USB_STOR_TRANSPORT_ERROR; } - memset(us->extra, 0, sizeof(struct jumpshot_info)); us->extra_destructor = jumpshot_info_destructor; } diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 8451779f426..0b1b5b59ca7 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -751,11 +751,10 @@ int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) struct sddr55_card_info *info; if (!us->extra) { - us->extra = kmalloc( + us->extra = kzalloc( sizeof(struct sddr55_card_info), GFP_NOIO); if (!us->extra) return USB_STOR_TRANSPORT_ERROR; - memset(us->extra, 0, sizeof(struct sddr55_card_info)); us->extra_destructor = sddr55_card_info_destructor; } diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index fea176d7e79..f2bc5c9e23d 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -1318,12 +1318,11 @@ int init_usbat(struct us_data *us) unsigned char subcountL = USBAT_ATA_LBA_ME; unsigned char *status = us->iobuf; - us->extra = kmalloc(sizeof(struct usbat_info), GFP_NOIO); + us->extra = kzalloc(sizeof(struct usbat_info), GFP_NOIO); if (!us->extra) { US_DEBUGP("init_usbat: Gah! Can't allocate storage for usbat info struct!\n"); return 1; } - memset(us->extra, 0, sizeof(struct usbat_info)); info = (struct usbat_info *) (us->extra); /* Enable peripheral control signals */ -- cgit v1.2.3-70-g09d2 From 4186ecf8ad16dd05759a09594de6a87e48759ba6 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Wed, 11 Jan 2006 15:55:29 +0100 Subject: [PATCH] USB: convert a bunch of USB semaphores to mutexes the patch below converts a bunch of semaphores-used-as-mutex in the USB code to mutexes Signed-off-by: Arjan van de Ven Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.c | 23 +++--- drivers/usb/class/usblp.c | 15 ++-- drivers/usb/core/devices.c | 7 +- drivers/usb/core/hcd.c | 25 ++++--- drivers/usb/core/hcd.h | 2 +- drivers/usb/core/hub.c | 7 +- drivers/usb/core/notify.c | 15 ++-- drivers/usb/core/usb.c | 5 +- drivers/usb/image/mdc800.c | 63 ++++++++-------- drivers/usb/input/ati_remote.c | 2 - drivers/usb/media/dabusb.c | 31 ++++---- drivers/usb/media/dabusb.h | 2 +- drivers/usb/media/ov511.c | 91 +++++++++++------------ drivers/usb/media/ov511.h | 11 ++- drivers/usb/media/se401.c | 12 +-- drivers/usb/media/se401.h | 3 +- drivers/usb/media/sn9c102.h | 5 +- drivers/usb/media/sn9c102_core.c | 156 +++++++++++++++++++-------------------- drivers/usb/media/stv680.c | 13 ++-- drivers/usb/media/stv680.h | 2 +- drivers/usb/media/usbvideo.c | 28 +++---- drivers/usb/media/usbvideo.h | 5 +- drivers/usb/media/vicam.c | 21 +++--- drivers/usb/media/w9968cf.c | 75 ++++++++++--------- drivers/usb/media/w9968cf.h | 14 +--- drivers/usb/misc/idmouse.c | 25 ++++--- drivers/usb/misc/ldusb.c | 11 +-- drivers/usb/misc/legousbtower.c | 11 +-- drivers/usb/mon/mon_main.c | 19 ++--- drivers/usb/mon/mon_text.c | 21 +++--- drivers/usb/mon/usb_mon.h | 2 +- drivers/usb/storage/scsiglue.c | 9 ++- drivers/usb/storage/usb.c | 25 ++++--- drivers/usb/storage/usb.h | 5 +- 34 files changed, 389 insertions(+), 372 deletions(-) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 97bdeb1c218..6dd339f4c0f 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,7 @@ static struct usb_driver acm_driver; static struct tty_driver *acm_tty_driver; static struct acm *acm_table[ACM_TTY_MINORS]; -static DECLARE_MUTEX(open_sem); +static DEFINE_MUTEX(open_mutex); #define ACM_READY(acm) (acm && acm->dev && acm->used) @@ -431,8 +432,8 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) int rv = -EINVAL; int i; dbg("Entering acm_tty_open.\n"); - - down(&open_sem); + + mutex_lock(&open_mutex); acm = acm_table[tty->index]; if (!acm || !acm->dev) @@ -474,14 +475,14 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) done: err_out: - up(&open_sem); + mutex_unlock(&open_mutex); return rv; full_bailout: usb_kill_urb(acm->ctrlurb); bail_out: acm->used--; - up(&open_sem); + mutex_unlock(&open_mutex); return -EIO; } @@ -507,7 +508,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) if (!acm || !acm->used) return; - down(&open_sem); + mutex_lock(&open_mutex); if (!--acm->used) { if (acm->dev) { acm_set_control(acm, acm->ctrlout = 0); @@ -518,7 +519,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) } else acm_tty_unregister(acm); } - up(&open_sem); + mutex_unlock(&open_mutex); } static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) @@ -1013,9 +1014,9 @@ static void acm_disconnect(struct usb_interface *intf) return; } - down(&open_sem); + mutex_lock(&open_mutex); if (!usb_get_intfdata(intf)) { - up(&open_sem); + mutex_unlock(&open_mutex); return; } acm->dev = NULL; @@ -1045,11 +1046,11 @@ static void acm_disconnect(struct usb_interface *intf) if (!acm->used) { acm_tty_unregister(acm); - up(&open_sem); + mutex_unlock(&open_mutex); return; } - up(&open_sem); + mutex_unlock(&open_mutex); if (acm->tty) tty_hangup(acm->tty); diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index d34848ac30b..48dee4b8d8e 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -55,6 +55,7 @@ #include #include #include +#include #undef DEBUG #include @@ -223,7 +224,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp); /* forward reference to make our lives easier */ static struct usb_driver usblp_driver; -static DECLARE_MUTEX(usblp_sem); /* locks the existence of usblp's */ +static DEFINE_MUTEX(usblp_mutex); /* locks the existence of usblp's */ /* * Functions for usblp control messages. @@ -351,7 +352,7 @@ static int usblp_open(struct inode *inode, struct file *file) if (minor < 0) return -ENODEV; - down (&usblp_sem); + mutex_lock (&usblp_mutex); retval = -ENODEV; intf = usb_find_interface(&usblp_driver, minor); @@ -399,7 +400,7 @@ static int usblp_open(struct inode *inode, struct file *file) } } out: - up (&usblp_sem); + mutex_unlock (&usblp_mutex); return retval; } @@ -425,13 +426,13 @@ static int usblp_release(struct inode *inode, struct file *file) { struct usblp *usblp = file->private_data; - down (&usblp_sem); + mutex_lock (&usblp_mutex); usblp->used = 0; if (usblp->present) { usblp_unlink_urbs(usblp); } else /* finish cleanup from disconnect */ usblp_cleanup (usblp); - up (&usblp_sem); + mutex_unlock (&usblp_mutex); return 0; } @@ -1152,7 +1153,7 @@ static void usblp_disconnect(struct usb_interface *intf) device_remove_file(&intf->dev, &dev_attr_ieee1284_id); - down (&usblp_sem); + mutex_lock (&usblp_mutex); down (&usblp->sem); usblp->present = 0; usb_set_intfdata (intf, NULL); @@ -1166,7 +1167,7 @@ static void usblp_disconnect(struct usb_interface *intf) if (!usblp->used) usblp_cleanup (usblp); - up (&usblp_sem); + mutex_unlock (&usblp_mutex); } static struct usb_device_id usblp_ids [] = { diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 2684e15b813..c0f37343a27 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include "usb.h" @@ -570,7 +571,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte if (!access_ok(VERIFY_WRITE, buf, nbytes)) return -EFAULT; - down (&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); /* print devices for all busses */ list_for_each_entry(bus, &usb_bus_list, bus_list) { /* recurse through all children of the root hub */ @@ -580,12 +581,12 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); usb_unlock_device(bus->root_hub); if (ret < 0) { - up(&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); return ret; } total_written += ret; } - up (&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); return total_written; } diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 0018bbc4de3..9223f286967 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -93,7 +94,7 @@ struct usb_busmap { static struct usb_busmap busmap; /* used when updating list of hcds */ -DECLARE_MUTEX (usb_bus_list_lock); /* exported only for usbfs */ +DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */ EXPORT_SYMBOL_GPL (usb_bus_list_lock); /* used for controlling access to virtual root hubs */ @@ -761,14 +762,14 @@ static int usb_register_bus(struct usb_bus *bus) { int busnum; - down (&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); if (busnum < USB_MAXBUS) { set_bit (busnum, busmap.busmap); bus->busnum = busnum; } else { printk (KERN_ERR "%s: too many buses\n", usbcore_name); - up(&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); return -E2BIG; } @@ -776,7 +777,7 @@ static int usb_register_bus(struct usb_bus *bus) bus->controller, "usb_host%d", busnum); if (IS_ERR(bus->class_dev)) { clear_bit(busnum, busmap.busmap); - up(&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); return PTR_ERR(bus->class_dev); } @@ -784,7 +785,7 @@ static int usb_register_bus(struct usb_bus *bus) /* Add it to the local list of buses */ list_add (&bus->bus_list, &usb_bus_list); - up (&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); usb_notify_add_bus(bus); @@ -809,9 +810,9 @@ static void usb_deregister_bus (struct usb_bus *bus) * controller code, as well as having it call this when cleaning * itself up */ - down (&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); list_del (&bus->bus_list); - up (&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); usb_notify_remove_bus(bus); @@ -844,14 +845,14 @@ static int register_root_hub (struct usb_device *usb_dev, set_bit (devnum, usb_dev->bus->devmap.devicemap); usb_set_device_state(usb_dev, USB_STATE_ADDRESS); - down (&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); usb_dev->bus->root_hub = usb_dev; usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); if (retval != sizeof usb_dev->descriptor) { usb_dev->bus->root_hub = NULL; - up (&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); dev_dbg (parent_dev, "can't read %s device descriptor %d\n", usb_dev->dev.bus_id, retval); return (retval < 0) ? retval : -EMSGSIZE; @@ -863,7 +864,7 @@ static int register_root_hub (struct usb_device *usb_dev, dev_err (parent_dev, "can't register root hub for %s, %d\n", usb_dev->dev.bus_id, retval); } - up (&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); if (retval == 0) { spin_lock_irq (&hcd_root_hub_lock); @@ -1891,9 +1892,9 @@ void usb_remove_hcd(struct usb_hcd *hcd) hcd->rh_registered = 0; spin_unlock_irq (&hcd_root_hub_lock); - down(&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); usb_disconnect(&hcd->self.root_hub); - up(&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); hcd->poll_rh = 0; del_timer_sync(&hcd->rh_timer); diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 591b5aad1a1..f44a2fe62a9 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -364,7 +364,7 @@ extern void usb_set_device_state(struct usb_device *udev, /* exported only within usbcore */ extern struct list_head usb_bus_list; -extern struct semaphore usb_bus_list_lock; +extern struct mutex usb_bus_list_lock; extern wait_queue_head_t usb_kill_urb_queue; extern struct usb_bus *usb_bus_get (struct usb_bus *bus); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 650d5ee5871..867fa813023 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -2162,7 +2163,7 @@ static int hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, int retry_counter) { - static DECLARE_MUTEX(usb_address0_sem); + static DEFINE_MUTEX(usb_address0_mutex); struct usb_device *hdev = hub->hdev; int i, j, retval; @@ -2183,7 +2184,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, if (oldspeed == USB_SPEED_LOW) delay = HUB_LONG_RESET_TIME; - down(&usb_address0_sem); + mutex_lock(&usb_address0_mutex); /* Reset the device; full speed may morph to high speed */ retval = hub_port_reset(hub, port1, udev, delay); @@ -2381,7 +2382,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, fail: if (retval) hub_port_disable(hub, port1, 0); - up(&usb_address0_sem); + mutex_unlock(&usb_address0_mutex); return retval; } diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c index fbbebab52fb..4b55285de9a 100644 --- a/drivers/usb/core/notify.c +++ b/drivers/usb/core/notify.c @@ -13,16 +13,17 @@ #include #include #include +#include #include "usb.h" static struct notifier_block *usb_notifier_list; -static DECLARE_MUTEX(usb_notifier_lock); +static DEFINE_MUTEX(usb_notifier_lock); static void usb_notifier_chain_register(struct notifier_block **list, struct notifier_block *n) { - down(&usb_notifier_lock); + mutex_lock(&usb_notifier_lock); while (*list) { if (n->priority > (*list)->priority) break; @@ -30,13 +31,13 @@ static void usb_notifier_chain_register(struct notifier_block **list, } n->next = *list; *list = n; - up(&usb_notifier_lock); + mutex_unlock(&usb_notifier_lock); } static void usb_notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n) { - down(&usb_notifier_lock); + mutex_lock(&usb_notifier_lock); while ((*nl)!=NULL) { if ((*nl)==n) { *nl = n->next; @@ -45,7 +46,7 @@ static void usb_notifier_chain_unregister(struct notifier_block **nl, nl=&((*nl)->next); } exit: - up(&usb_notifier_lock); + mutex_unlock(&usb_notifier_lock); } static int usb_notifier_call_chain(struct notifier_block **n, @@ -54,7 +55,7 @@ static int usb_notifier_call_chain(struct notifier_block **n, int ret=NOTIFY_DONE; struct notifier_block *nb = *n; - down(&usb_notifier_lock); + mutex_lock(&usb_notifier_lock); while (nb) { ret = nb->notifier_call(nb,val,v); if (ret&NOTIFY_STOP_MASK) { @@ -63,7 +64,7 @@ static int usb_notifier_call_chain(struct notifier_block **n, nb = nb->next; } exit: - up(&usb_notifier_lock); + mutex_unlock(&usb_notifier_lock); return ret; } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 13d1d367f7f..d7352aa73b5 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -639,7 +640,7 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id) struct usb_bus *bus; struct usb_device *dev = NULL; - down(&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); for (buslist = usb_bus_list.next; buslist != &usb_bus_list; buslist = buslist->next) { @@ -653,7 +654,7 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id) goto exit; } exit: - up(&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); return dev; } diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index 4e3e4d048c1..08daf400f98 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -96,6 +96,7 @@ #include #include #include +#include #include #include @@ -169,7 +170,7 @@ struct mdc800_data int out_count; // Bytes in the buffer int open; // Camera device open ? - struct semaphore io_lock; // IO -lock + struct mutex io_lock; // IO -lock char in [8]; // Command Input Buffer int in_count; @@ -497,7 +498,7 @@ static int mdc800_usb_probe (struct usb_interface *intf, info ("Found Mustek MDC800 on USB."); - down (&mdc800->io_lock); + mutex_lock(&mdc800->io_lock); retval = usb_register_dev(intf, &mdc800_class); if (retval) { @@ -542,7 +543,7 @@ static int mdc800_usb_probe (struct usb_interface *intf, mdc800->state=READY; - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); usb_set_intfdata(intf, mdc800); return 0; @@ -620,7 +621,7 @@ static int mdc800_device_open (struct inode* inode, struct file *file) int retval=0; int errn=0; - down (&mdc800->io_lock); + mutex_lock(&mdc800->io_lock); if (mdc800->state == NOT_CONNECTED) { @@ -656,7 +657,7 @@ static int mdc800_device_open (struct inode* inode, struct file *file) dbg ("Mustek MDC800 device opened."); error_out: - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return errn; } @@ -669,7 +670,7 @@ static int mdc800_device_release (struct inode* inode, struct file *file) int retval=0; dbg ("Mustek MDC800 device closed."); - down (&mdc800->io_lock); + mutex_lock(&mdc800->io_lock); if (mdc800->open && (mdc800->state != NOT_CONNECTED)) { usb_kill_urb(mdc800->irq_urb); @@ -682,7 +683,7 @@ static int mdc800_device_release (struct inode* inode, struct file *file) retval=-EIO; } - up(&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return retval; } @@ -695,21 +696,21 @@ 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; - down (&mdc800->io_lock); + mutex_lock(&mdc800->io_lock); if (mdc800->state == NOT_CONNECTED) { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EBUSY; } if (mdc800->state == WORKING) { warn ("Illegal State \"working\" reached during read ?!"); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EBUSY; } if (!mdc800->open) { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EBUSY; } @@ -717,7 +718,7 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l { if (signal_pending (current)) { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EINTR; } @@ -736,7 +737,7 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l if (usb_submit_urb (mdc800->download_urb, GFP_KERNEL)) { err ("Can't submit download urb (status=%i)",mdc800->download_urb->status); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return len-left; } wait_event_timeout(mdc800->download_wait, mdc800->downloaded, @@ -745,14 +746,14 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l if (mdc800->download_urb->status != 0) { err ("request download-bytes fails (status=%i)",mdc800->download_urb->status); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return len-left; } } else { /* No more bytes -> that's an error*/ - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } } @@ -761,7 +762,7 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l /* Copy Bytes */ if (copy_to_user(ptr, &mdc800->out [mdc800->out_ptr], sts)) { - up(&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EFAULT; } ptr+=sts; @@ -770,7 +771,7 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l } } - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return len-left; } @@ -785,15 +786,15 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s { size_t i=0; - down (&mdc800->io_lock); + mutex_lock(&mdc800->io_lock); if (mdc800->state != READY) { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EBUSY; } if (!mdc800->open ) { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EBUSY; } @@ -802,13 +803,13 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s unsigned char c; if (signal_pending (current)) { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EINTR; } if(get_user(c, buf+i)) { - up(&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EFAULT; } @@ -829,7 +830,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s } else { - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } @@ -841,7 +842,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) { err ("Camera didn't get ready.\n"); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } @@ -853,7 +854,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s if (usb_submit_urb (mdc800->write_urb, GFP_KERNEL)) { err ("submitting write urb fails (status=%i)", mdc800->write_urb->status); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } wait_event_timeout(mdc800->write_wait, mdc800->written, TO_WRITE_GET_READY*HZ/1000); @@ -861,7 +862,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s if (mdc800->state == WORKING) { usb_kill_urb(mdc800->write_urb); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } @@ -873,7 +874,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s { err ("call 0x07 before 0x05,0x3e"); mdc800->state=READY; - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } mdc800->pic_len=-1; @@ -892,7 +893,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ)) { err ("requesting answer from irq fails"); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } @@ -920,7 +921,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND)) { err ("Command Timeout."); - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return -EIO; } } @@ -930,7 +931,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s } i++; } - up (&mdc800->io_lock); + mutex_unlock(&mdc800->io_lock); return i; } @@ -984,7 +985,7 @@ static int __init usb_mdc800_init (void) mdc800->dev = NULL; mdc800->state=NOT_CONNECTED; - init_MUTEX (&mdc800->io_lock); + mutex_init (&mdc800->io_lock); init_waitqueue_head (&mdc800->irq_wait); init_waitqueue_head (&mdc800->write_wait); diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index f7bdc506e61..99f986cb6e9 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c @@ -159,8 +159,6 @@ static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; */ #define FILTER_TIME (HZ / 20) -static DECLARE_MUTEX(disconnect_sem); - struct ati_remote { struct input_dev *idev; struct usb_device *udev; diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c index 6f560fe9a51..1774ab7a40d 100644 --- a/drivers/usb/media/dabusb.c +++ b/drivers/usb/media/dabusb.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "dabusb.h" #include "dabfirmware.h" @@ -570,7 +571,7 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l s->readptr = 0; } } - err: //up(&s->mutex); + err: //mutex_unlock(&s->mutex); return ret; } @@ -585,10 +586,10 @@ static int dabusb_open (struct inode *inode, struct file *file) s = &dabusb[devnum - DABUSB_MINOR]; dbg("dabusb_open"); - down (&s->mutex); + mutex_lock(&s->mutex); while (!s->usbdev || s->opened) { - up (&s->mutex); + mutex_unlock(&s->mutex); if (file->f_flags & O_NONBLOCK) { return -EBUSY; @@ -598,15 +599,15 @@ static int dabusb_open (struct inode *inode, struct file *file) if (signal_pending (current)) { return -EAGAIN; } - down (&s->mutex); + mutex_lock(&s->mutex); } if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { - up(&s->mutex); + mutex_unlock(&s->mutex); err("set_interface failed"); return -EINVAL; } s->opened = 1; - up (&s->mutex); + mutex_unlock(&s->mutex); file->f_pos = 0; file->private_data = s; @@ -620,10 +621,10 @@ static int dabusb_release (struct inode *inode, struct file *file) dbg("dabusb_release"); - down (&s->mutex); + mutex_lock(&s->mutex); dabusb_stop (s); dabusb_free_buffers (s); - up (&s->mutex); + mutex_unlock(&s->mutex); if (!s->remove_pending) { if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0) @@ -648,10 +649,10 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm if (s->remove_pending) return -EIO; - down (&s->mutex); + mutex_lock(&s->mutex); if (!s->usbdev) { - up (&s->mutex); + mutex_unlock(&s->mutex); return -EIO; } @@ -691,7 +692,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm ret = -ENOIOCTLCMD; break; } - up (&s->mutex); + mutex_unlock(&s->mutex); return ret; } @@ -737,7 +738,7 @@ static int dabusb_probe (struct usb_interface *intf, s = &dabusb[intf->minor]; - down (&s->mutex); + mutex_lock(&s->mutex); s->remove_pending = 0; s->usbdev = usbdev; s->devnum = intf->minor; @@ -760,7 +761,7 @@ static int dabusb_probe (struct usb_interface *intf, } dbg("bound to interface: %d", intf->altsetting->desc.bInterfaceNumber); usb_set_intfdata (intf, s); - up (&s->mutex); + mutex_unlock(&s->mutex); retval = usb_register_dev(intf, &dabusb_class); if (retval) { @@ -771,7 +772,7 @@ static int dabusb_probe (struct usb_interface *intf, return 0; reject: - up (&s->mutex); + mutex_unlock(&s->mutex); s->usbdev = NULL; return -ENODEV; } @@ -828,7 +829,7 @@ static int __init dabusb_init (void) for (u = 0; u < NRDABUSB; u++) { pdabusb_t s = &dabusb[u]; memset (s, 0, sizeof (dabusb_t)); - init_MUTEX (&s->mutex); + mutex_init (&s->mutex); s->usbdev = NULL; s->total_buffer_size = buffers; init_waitqueue_head (&s->wait); diff --git a/drivers/usb/media/dabusb.h b/drivers/usb/media/dabusb.h index 10b666e43ab..96b03e4af8b 100644 --- a/drivers/usb/media/dabusb.h +++ b/drivers/usb/media/dabusb.h @@ -18,7 +18,7 @@ typedef enum { _stopped=0, _started } driver_state_t; typedef struct { - struct semaphore mutex; + struct mutex mutex; struct usb_device *usbdev; wait_queue_head_t wait; wait_queue_head_t remove_ok; diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 51e9cc06f7e..cfec8c61574 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -365,14 +365,14 @@ reg_w(struct usb_ov511 *ov, unsigned char reg, unsigned char value) PDEBUG(5, "0x%02X:0x%02X", reg, value); - down(&ov->cbuf_lock); + mutex_lock(&ov->cbuf_lock); ov->cbuf[0] = value; rc = usb_control_msg(ov->dev, usb_sndctrlpipe(ov->dev, 0), (ov->bclass == BCL_OV518)?1:2 /* REG_IO */, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, (__u16)reg, &ov->cbuf[0], 1, 1000); - up(&ov->cbuf_lock); + mutex_unlock(&ov->cbuf_lock); if (rc < 0) err("reg write: error %d: %s", rc, symbolic(urb_errlist, rc)); @@ -387,7 +387,7 @@ reg_r(struct usb_ov511 *ov, unsigned char reg) { int rc; - down(&ov->cbuf_lock); + mutex_lock(&ov->cbuf_lock); rc = usb_control_msg(ov->dev, usb_rcvctrlpipe(ov->dev, 0), (ov->bclass == BCL_OV518)?1:3 /* REG_IO */, @@ -401,7 +401,7 @@ reg_r(struct usb_ov511 *ov, unsigned char reg) PDEBUG(5, "0x%02X:0x%02X", reg, ov->cbuf[0]); } - up(&ov->cbuf_lock); + mutex_unlock(&ov->cbuf_lock); return rc; } @@ -444,7 +444,7 @@ ov518_reg_w32(struct usb_ov511 *ov, unsigned char reg, u32 val, int n) PDEBUG(5, "0x%02X:%7d, n=%d", reg, val, n); - down(&ov->cbuf_lock); + mutex_lock(&ov->cbuf_lock); *((__le32 *)ov->cbuf) = __cpu_to_le32(val); @@ -453,7 +453,7 @@ ov518_reg_w32(struct usb_ov511 *ov, unsigned char reg, u32 val, int n) 1 /* REG_IO */, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, (__u16)reg, ov->cbuf, n, 1000); - up(&ov->cbuf_lock); + mutex_unlock(&ov->cbuf_lock); if (rc < 0) err("reg write multiple: error %d: %s", rc, @@ -768,14 +768,14 @@ i2c_r(struct usb_ov511 *ov, unsigned char reg) { int rc; - down(&ov->i2c_lock); + mutex_lock(&ov->i2c_lock); if (ov->bclass == BCL_OV518) rc = ov518_i2c_read_internal(ov, reg); else rc = ov511_i2c_read_internal(ov, reg); - up(&ov->i2c_lock); + mutex_unlock(&ov->i2c_lock); return rc; } @@ -785,14 +785,14 @@ i2c_w(struct usb_ov511 *ov, unsigned char reg, unsigned char value) { int rc; - down(&ov->i2c_lock); + mutex_lock(&ov->i2c_lock); if (ov->bclass == BCL_OV518) rc = ov518_i2c_write_internal(ov, reg, value); else rc = ov511_i2c_write_internal(ov, reg, value); - up(&ov->i2c_lock); + mutex_unlock(&ov->i2c_lock); return rc; } @@ -842,9 +842,9 @@ i2c_w_mask(struct usb_ov511 *ov, { int rc; - down(&ov->i2c_lock); + mutex_lock(&ov->i2c_lock); rc = ov51x_i2c_write_mask_internal(ov, reg, value, mask); - up(&ov->i2c_lock); + mutex_unlock(&ov->i2c_lock); return rc; } @@ -880,7 +880,7 @@ i2c_w_slave(struct usb_ov511 *ov, { int rc = 0; - down(&ov->i2c_lock); + mutex_lock(&ov->i2c_lock); /* Set new slave IDs */ rc = i2c_set_slave_internal(ov, slave); @@ -894,7 +894,7 @@ out: if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0) err("Couldn't restore primary I2C slave"); - up(&ov->i2c_lock); + mutex_unlock(&ov->i2c_lock); return rc; } @@ -906,7 +906,7 @@ i2c_r_slave(struct usb_ov511 *ov, { int rc; - down(&ov->i2c_lock); + mutex_lock(&ov->i2c_lock); /* Set new slave IDs */ rc = i2c_set_slave_internal(ov, slave); @@ -923,7 +923,7 @@ out: if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0) err("Couldn't restore primary I2C slave"); - up(&ov->i2c_lock); + mutex_unlock(&ov->i2c_lock); return rc; } @@ -933,7 +933,7 @@ ov51x_set_slave_ids(struct usb_ov511 *ov, unsigned char sid) { int rc; - down(&ov->i2c_lock); + mutex_lock(&ov->i2c_lock); rc = i2c_set_slave_internal(ov, sid); if (rc < 0) @@ -942,7 +942,7 @@ ov51x_set_slave_ids(struct usb_ov511 *ov, unsigned char sid) // FIXME: Is this actually necessary? rc = ov51x_reset(ov, OV511_RESET_NOREGS); out: - up(&ov->i2c_lock); + mutex_unlock(&ov->i2c_lock); return rc; } @@ -3832,7 +3832,7 @@ ov51x_alloc(struct usb_ov511 *ov) const int raw_bufsize = OV511_NUMFRAMES * MAX_RAW_DATA_SIZE(w, h); PDEBUG(4, "entered"); - down(&ov->buf_lock); + mutex_lock(&ov->buf_lock); if (ov->buf_state == BUF_ALLOCATED) goto out; @@ -3879,12 +3879,12 @@ ov51x_alloc(struct usb_ov511 *ov) ov->buf_state = BUF_ALLOCATED; out: - up(&ov->buf_lock); + mutex_unlock(&ov->buf_lock); PDEBUG(4, "leaving"); return 0; error: ov51x_do_dealloc(ov); - up(&ov->buf_lock); + mutex_unlock(&ov->buf_lock); PDEBUG(4, "errored"); return -ENOMEM; } @@ -3893,9 +3893,9 @@ static void ov51x_dealloc(struct usb_ov511 *ov) { PDEBUG(4, "entered"); - down(&ov->buf_lock); + mutex_lock(&ov->buf_lock); ov51x_do_dealloc(ov); - up(&ov->buf_lock); + mutex_unlock(&ov->buf_lock); PDEBUG(4, "leaving"); } @@ -3914,7 +3914,7 @@ ov51x_v4l1_open(struct inode *inode, struct file *file) PDEBUG(4, "opening"); - down(&ov->lock); + mutex_lock(&ov->lock); err = -EBUSY; if (ov->user) @@ -3958,7 +3958,7 @@ ov51x_v4l1_open(struct inode *inode, struct file *file) ov51x_led_control(ov, 1); out: - up(&ov->lock); + mutex_unlock(&ov->lock); return err; } @@ -3970,7 +3970,7 @@ ov51x_v4l1_close(struct inode *inode, struct file *file) PDEBUG(4, "ov511_close"); - down(&ov->lock); + mutex_lock(&ov->lock); ov->user--; ov51x_stop_isoc(ov); @@ -3981,15 +3981,15 @@ ov51x_v4l1_close(struct inode *inode, struct file *file) if (ov->dev) ov51x_dealloc(ov); - up(&ov->lock); + mutex_unlock(&ov->lock); /* Device unplugged while open. Only a minimum of unregistration is done * here; the disconnect callback already did the rest. */ if (!ov->dev) { - down(&ov->cbuf_lock); + mutex_lock(&ov->cbuf_lock); kfree(ov->cbuf); ov->cbuf = NULL; - up(&ov->cbuf_lock); + mutex_unlock(&ov->cbuf_lock); ov51x_dealloc(ov); kfree(ov); @@ -4449,12 +4449,12 @@ ov51x_v4l1_ioctl(struct inode *inode, struct file *file, struct usb_ov511 *ov = video_get_drvdata(vdev); int rc; - if (down_interruptible(&ov->lock)) + if (mutex_lock_interruptible(&ov->lock)) return -EINTR; rc = video_usercopy(inode, file, cmd, arg, ov51x_v4l1_ioctl_internal); - up(&ov->lock); + mutex_unlock(&ov->lock); return rc; } @@ -4468,7 +4468,7 @@ ov51x_v4l1_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos) int i, rc = 0, frmx = -1; struct ov511_frame *frame; - if (down_interruptible(&ov->lock)) + if (mutex_lock_interruptible(&ov->lock)) return -EINTR; PDEBUG(4, "%ld bytes, noblock=%d", count, noblock); @@ -4604,11 +4604,11 @@ restart: PDEBUG(4, "read finished, returning %ld (sweet)", count); - up(&ov->lock); + mutex_unlock(&ov->lock); return count; error: - up(&ov->lock); + mutex_unlock(&ov->lock); return rc; } @@ -4631,14 +4631,14 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))) return -EINVAL; - if (down_interruptible(&ov->lock)) + if (mutex_lock_interruptible(&ov->lock)) return -EINTR; pos = (unsigned long)ov->fbuf; while (size > 0) { page = vmalloc_to_pfn((void *)pos); if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { - up(&ov->lock); + mutex_unlock(&ov->lock); return -EAGAIN; } start += PAGE_SIZE; @@ -4649,7 +4649,7 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma) size = 0; } - up(&ov->lock); + mutex_unlock(&ov->lock); return 0; } @@ -5738,11 +5738,10 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) init_waitqueue_head(&ov->wq); - init_MUTEX(&ov->lock); /* to 1 == available */ - init_MUTEX(&ov->buf_lock); - init_MUTEX(&ov->param_lock); - init_MUTEX(&ov->i2c_lock); - init_MUTEX(&ov->cbuf_lock); + mutex_init(&ov->lock); /* to 1 == available */ + mutex_init(&ov->buf_lock); + mutex_init(&ov->i2c_lock); + mutex_init(&ov->cbuf_lock); ov->buf_state = BUF_NOT_ALLOCATED; @@ -5833,10 +5832,10 @@ error: } if (ov->cbuf) { - down(&ov->cbuf_lock); + mutex_lock(&ov->cbuf_lock); kfree(ov->cbuf); ov->cbuf = NULL; - up(&ov->cbuf_lock); + mutex_unlock(&ov->cbuf_lock); } kfree(ov); @@ -5881,10 +5880,10 @@ ov51x_disconnect(struct usb_interface *intf) /* Free the memory */ if (ov && !ov->user) { - down(&ov->cbuf_lock); + mutex_lock(&ov->cbuf_lock); kfree(ov->cbuf); ov->cbuf = NULL; - up(&ov->cbuf_lock); + mutex_unlock(&ov->cbuf_lock); ov51x_dealloc(ov); kfree(ov); diff --git a/drivers/usb/media/ov511.h b/drivers/usb/media/ov511.h index 086509a137c..bce9b363388 100644 --- a/drivers/usb/media/ov511.h +++ b/drivers/usb/media/ov511.h @@ -5,6 +5,7 @@ #include #include #include +#include #define OV511_DEBUG /* Turn on debug messages */ @@ -435,7 +436,7 @@ struct usb_ov511 { int led_policy; /* LED: off|on|auto; OV511+ only */ - struct semaphore lock; /* Serializes user-accessible operations */ + struct mutex lock; /* Serializes user-accessible operations */ int user; /* user count for exclusive use */ int streaming; /* Are we streaming Isochronous? */ @@ -473,11 +474,9 @@ struct usb_ov511 { int packet_size; /* Frame size per isoc desc */ int packet_numbering; /* Is ISO frame numbering enabled? */ - struct semaphore param_lock; /* params lock for this camera */ - /* Framebuffer/sbuf management */ int buf_state; - struct semaphore buf_lock; + struct mutex buf_lock; struct ov51x_decomp_ops *decomp_ops; @@ -494,12 +493,12 @@ struct usb_ov511 { int pal; /* Device is designed for PAL resolution */ /* I2C interface */ - struct semaphore i2c_lock; /* Protect I2C controller regs */ + struct mutex i2c_lock; /* Protect I2C controller regs */ unsigned char primary_i2c_slave; /* I2C write id of sensor */ /* Control transaction stuff */ unsigned char *cbuf; /* Buffer for payload */ - struct semaphore cbuf_lock; + struct mutex cbuf_lock; }; /* Used to represent a list of values and their respective symbolic names */ diff --git a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c index 2ba562285fd..8c3b1ad8a8f 100644 --- a/drivers/usb/media/se401.c +++ b/drivers/usb/media/se401.c @@ -1157,21 +1157,21 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma) unsigned long size = vma->vm_end-vma->vm_start; unsigned long page, pos; - down(&se401->lock); + mutex_lock(&se401->lock); if (se401->dev == NULL) { - up(&se401->lock); + mutex_unlock(&se401->lock); return -EIO; } if (size > (((SE401_NUMFRAMES * se401->maxframesize) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))) { - up(&se401->lock); + mutex_unlock(&se401->lock); return -EINVAL; } pos = (unsigned long)se401->fbuf; while (size > 0) { page = vmalloc_to_pfn((void *)pos); if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { - up(&se401->lock); + mutex_unlock(&se401->lock); return -EAGAIN; } start += PAGE_SIZE; @@ -1181,7 +1181,7 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma) else size = 0; } - up(&se401->lock); + mutex_unlock(&se401->lock); return 0; } @@ -1366,7 +1366,7 @@ static int se401_probe(struct usb_interface *intf, memcpy(&se401->vdev, &se401_template, sizeof(se401_template)); memcpy(se401->vdev.name, se401->camera_name, strlen(se401->camera_name)); init_waitqueue_head(&se401->wq); - init_MUTEX(&se401->lock); + mutex_init(&se401->lock); wmb(); if (video_register_device(&se401->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { diff --git a/drivers/usb/media/se401.h b/drivers/usb/media/se401.h index 2e5846f1eb2..e88a40d4c86 100644 --- a/drivers/usb/media/se401.h +++ b/drivers/usb/media/se401.h @@ -5,6 +5,7 @@ #include #include #include +#include #define se401_DEBUG /* Turn on debug messages */ @@ -189,7 +190,7 @@ struct usb_se401 { int maxframesize; int cframesize; /* current framesize */ - struct semaphore lock; + struct mutex lock; int user; /* user count for exclusive use */ int removed; /* device disconnected */ diff --git a/drivers/usb/media/sn9c102.h b/drivers/usb/media/sn9c102.h index 17d60c1eea7..59e44be27cb 100644 --- a/drivers/usb/media/sn9c102.h +++ b/drivers/usb/media/sn9c102.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "sn9c102_sensor.h" @@ -109,7 +110,7 @@ struct sn9c102_module_param { u8 force_munmap; }; -static DECLARE_MUTEX(sn9c102_sysfs_lock); +static DEFINE_MUTEX(sn9c102_sysfs_lock); static DECLARE_RWSEM(sn9c102_disconnect); struct sn9c102_device { @@ -141,7 +142,7 @@ struct sn9c102_device { enum sn9c102_dev_state state; u8 users; - struct semaphore dev_sem, fileop_sem; + struct mutex dev_mutex, fileop_mutex; spinlock_t queue_lock; wait_queue_head_t open, wait_frame, wait_stream; }; diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c index c81397e4714..30119080871 100644 --- a/drivers/usb/media/sn9c102_core.c +++ b/drivers/usb/media/sn9c102_core.c @@ -866,18 +866,18 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf) struct sn9c102_device* cam; ssize_t count; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } count = sprintf(buf, "%u\n", cam->sysfs.reg); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -890,18 +890,18 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) u8 index; ssize_t count; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } index = sn9c102_strtou8(buf, len, &count); if (index > 0x1f || !count) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EINVAL; } @@ -910,7 +910,7 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) DBG(2, "Moved SN9C10X register index to 0x%02X", cam->sysfs.reg); DBG(3, "Written bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -922,17 +922,17 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf) ssize_t count; int val; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } if ((val = sn9c102_read_reg(cam, cam->sysfs.reg)) < 0) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EIO; } @@ -940,7 +940,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf) DBG(3, "Read bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -954,24 +954,24 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len) ssize_t count; int err; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } value = sn9c102_strtou8(buf, len, &count); if (!count) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EINVAL; } err = sn9c102_write_reg(cam, value, cam->sysfs.reg); if (err) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EIO; } @@ -979,7 +979,7 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len) cam->sysfs.reg, value); DBG(3, "Written bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -990,12 +990,12 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf) struct sn9c102_device* cam; ssize_t count; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } @@ -1003,7 +1003,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf) DBG(3, "Read bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -1016,18 +1016,18 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) u8 index; ssize_t count; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } index = sn9c102_strtou8(buf, len, &count); if (!count) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EINVAL; } @@ -1036,7 +1036,7 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg); DBG(3, "Written bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -1048,22 +1048,22 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf) ssize_t count; int val; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } if (!(cam->sensor->sysfs_ops & SN9C102_I2C_READ)) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENOSYS; } if ((val = sn9c102_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EIO; } @@ -1071,7 +1071,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf) DBG(3, "Read bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -1085,29 +1085,29 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len) ssize_t count; int err; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } if (!(cam->sensor->sysfs_ops & SN9C102_I2C_WRITE)) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENOSYS; } value = sn9c102_strtou8(buf, len, &count); if (!count) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EINVAL; } err = sn9c102_i2c_write(cam, cam->sysfs.i2c_reg, value); if (err) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -EIO; } @@ -1115,7 +1115,7 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len) cam->sysfs.i2c_reg, value); DBG(3, "Written bytes: %zd", count); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return count; } @@ -1130,18 +1130,18 @@ sn9c102_store_green(struct class_device* cd, const char* buf, size_t len) u8 value; ssize_t count; - if (down_interruptible(&sn9c102_sysfs_lock)) + if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; cam = video_get_drvdata(to_video_device(cd)); if (!cam) { - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; } bridge = cam->bridge; - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); value = sn9c102_strtou8(buf, len, &count); if (!count) @@ -1404,7 +1404,7 @@ static int sn9c102_init(struct sn9c102_device* cam) } if (!(cam->state & DEV_INITIALIZED)) { - init_MUTEX(&cam->fileop_sem); + mutex_init(&cam->fileop_mutex); spin_lock_init(&cam->queue_lock); init_waitqueue_head(&cam->wait_frame); init_waitqueue_head(&cam->wait_stream); @@ -1422,13 +1422,13 @@ static int sn9c102_init(struct sn9c102_device* cam) static void sn9c102_release_resources(struct sn9c102_device* cam) { - down(&sn9c102_sysfs_lock); + mutex_lock(&sn9c102_sysfs_lock); DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); video_set_drvdata(cam->v4ldev, NULL); video_unregister_device(cam->v4ldev); - up(&sn9c102_sysfs_lock); + mutex_unlock(&sn9c102_sysfs_lock); kfree(cam->control_buffer); } @@ -1449,7 +1449,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) cam = video_get_drvdata(video_devdata(filp)); - if (down_interruptible(&cam->dev_sem)) { + if (mutex_lock_interruptible(&cam->dev_mutex)) { up_read(&sn9c102_disconnect); return -ERESTARTSYS; } @@ -1461,7 +1461,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) err = -EWOULDBLOCK; goto out; } - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); err = wait_event_interruptible_exclusive(cam->open, cam->state & DEV_DISCONNECTED || !cam->users); @@ -1473,7 +1473,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) up_read(&sn9c102_disconnect); return -ENODEV; } - down(&cam->dev_sem); + mutex_lock(&cam->dev_mutex); } @@ -1501,7 +1501,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); out: - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); up_read(&sn9c102_disconnect); return err; } @@ -1511,7 +1511,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp) { struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); - down(&cam->dev_sem); /* prevent disconnect() to be called */ + mutex_lock(&cam->dev_mutex); /* prevent disconnect() to be called */ sn9c102_stop_transfer(cam); @@ -1519,7 +1519,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp) if (cam->state & DEV_DISCONNECTED) { sn9c102_release_resources(cam); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); kfree(cam); return 0; } @@ -1529,7 +1529,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp) DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); return 0; } @@ -1543,33 +1543,33 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) unsigned long lock_flags; int err = 0; - if (down_interruptible(&cam->fileop_sem)) + if (mutex_lock_interruptible(&cam->fileop_mutex)) return -ERESTARTSYS; if (cam->state & DEV_DISCONNECTED) { DBG(1, "Device not present"); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } if (cam->state & DEV_MISCONFIGURED) { DBG(1, "The camera is misconfigured. Close and open it " "again."); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EIO; } if (cam->io == IO_MMAP) { DBG(3, "Close and open the device again to choose " "the read method"); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EINVAL; } if (cam->io == IO_NONE) { if (!sn9c102_request_buffers(cam,cam->nreadbuffers, IO_READ)) { DBG(1, "read() failed, not enough memory"); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENOMEM; } cam->io = IO_READ; @@ -1583,13 +1583,13 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) } if (!count) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return 0; } if (list_empty(&cam->outqueue)) { if (filp->f_flags & O_NONBLOCK) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EAGAIN; } err = wait_event_interruptible @@ -1598,15 +1598,15 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) (cam->state & DEV_DISCONNECTED) || (cam->state & DEV_MISCONFIGURED) ); if (err) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return err; } if (cam->state & DEV_DISCONNECTED) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } if (cam->state & DEV_MISCONFIGURED) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EIO; } } @@ -1634,7 +1634,7 @@ exit: PDBGG("Frame #%lu, bytes read: %zu", (unsigned long)f->buf.index, count); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return count; } @@ -1647,7 +1647,7 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait) unsigned long lock_flags; unsigned int mask = 0; - if (down_interruptible(&cam->fileop_sem)) + if (mutex_lock_interruptible(&cam->fileop_mutex)) return POLLERR; if (cam->state & DEV_DISCONNECTED) { @@ -1685,12 +1685,12 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait) if (!list_empty(&cam->outqueue)) mask |= POLLIN | POLLRDNORM; - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return mask; error: - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return POLLERR; } @@ -1724,25 +1724,25 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) void *pos; u32 i; - if (down_interruptible(&cam->fileop_sem)) + if (mutex_lock_interruptible(&cam->fileop_mutex)) return -ERESTARTSYS; if (cam->state & DEV_DISCONNECTED) { DBG(1, "Device not present"); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } if (cam->state & DEV_MISCONFIGURED) { DBG(1, "The camera is misconfigured. Close and open it " "again."); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EIO; } if (cam->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || size != PAGE_ALIGN(cam->frame[0].buf.length)) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EINVAL; } @@ -1751,7 +1751,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) break; } if (i == cam->nbuffers) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EINVAL; } @@ -1761,7 +1761,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) pos = cam->frame[i].bufmem; while (size > 0) { /* size is page-aligned */ if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EAGAIN; } start += PAGE_SIZE; @@ -1774,7 +1774,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) sn9c102_vm_open(vma); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return 0; } @@ -2655,19 +2655,19 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); int err = 0; - if (down_interruptible(&cam->fileop_sem)) + if (mutex_lock_interruptible(&cam->fileop_mutex)) return -ERESTARTSYS; if (cam->state & DEV_DISCONNECTED) { DBG(1, "Device not present"); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } if (cam->state & DEV_MISCONFIGURED) { DBG(1, "The camera is misconfigured. Close and open it " "again."); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EIO; } @@ -2675,7 +2675,7 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return err; } @@ -2722,7 +2722,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) goto fail; } - init_MUTEX(&cam->dev_sem); + mutex_init(&cam->dev_mutex); r = sn9c102_read_reg(cam, 0x00); if (r < 0 || r != 0x10) { @@ -2776,7 +2776,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) cam->v4ldev->release = video_device_release; video_set_drvdata(cam->v4ldev, cam); - down(&cam->dev_sem); + mutex_lock(&cam->dev_mutex); err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, video_nr[dev_nr]); @@ -2786,7 +2786,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) DBG(1, "Free /dev/videoX node not found"); video_nr[dev_nr] = -1; dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); goto fail; } @@ -2803,7 +2803,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) usb_set_intfdata(intf, cam); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); return 0; @@ -2827,7 +2827,7 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) down_write(&sn9c102_disconnect); - down(&cam->dev_sem); + mutex_lock(&cam->dev_mutex); DBG(2, "Disconnecting %s...", cam->v4ldev->name); @@ -2847,7 +2847,7 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) sn9c102_release_resources(cam); } - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); if (!cam->users) kfree(cam); diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c index b497a6a0a20..b1a6be2958e 100644 --- a/drivers/usb/media/stv680.c +++ b/drivers/usb/media/stv680.c @@ -67,6 +67,7 @@ #include #include #include +#include #include "stv680.h" @@ -1258,22 +1259,22 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma) unsigned long size = vma->vm_end-vma->vm_start; unsigned long page, pos; - down (&stv680->lock); + mutex_lock(&stv680->lock); if (stv680->udev == NULL) { - up (&stv680->lock); + mutex_unlock(&stv680->lock); return -EIO; } if (size > (((STV680_NUMFRAMES * stv680->maxframesize) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))) { - up (&stv680->lock); + mutex_unlock(&stv680->lock); return -EINVAL; } pos = (unsigned long) stv680->fbuf; while (size > 0) { page = vmalloc_to_pfn((void *)pos); if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { - up (&stv680->lock); + mutex_unlock(&stv680->lock); return -EAGAIN; } start += PAGE_SIZE; @@ -1283,7 +1284,7 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma) else size = 0; } - up (&stv680->lock); + mutex_unlock(&stv680->lock); return 0; } @@ -1409,7 +1410,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name)); init_waitqueue_head (&stv680->wq); - init_MUTEX (&stv680->lock); + mutex_init (&stv680->lock); wmb (); if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { diff --git a/drivers/usb/media/stv680.h b/drivers/usb/media/stv680.h index b0551cdb280..ea46e0001e6 100644 --- a/drivers/usb/media/stv680.h +++ b/drivers/usb/media/stv680.h @@ -118,7 +118,7 @@ struct usb_stv { int origGain; int origMode; /* original camera mode */ - struct semaphore lock; /* to lock the structure */ + struct mutex lock; /* to lock the structure */ int user; /* user count for exclusive use */ int removed; /* device disconnected */ int streaming; /* Are we streaming video? */ diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index 63d279ec722..0b51fae720a 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -714,7 +714,7 @@ int usbvideo_register( cams->md_module = md; if (cams->md_module == NULL) warn("%s: module == NULL!", __FUNCTION__); - init_MUTEX(&cams->lock); /* to 1 == available */ + mutex_init(&cams->lock); /* to 1 == available */ for (i = 0; i < num_cams; i++) { struct uvd *up = &cams->cam[i]; @@ -862,7 +862,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) if (uvd->debug > 0) info("%s(%p.)", __FUNCTION__, intf); - down(&uvd->lock); + mutex_lock(&uvd->lock); uvd->remove_pending = 1; /* Now all ISO data will be ignored */ /* At this time we ask to cancel outstanding URBs */ @@ -882,7 +882,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) info("%s: In use, disconnect pending.", __FUNCTION__); else usbvideo_CameraRelease(uvd); - up(&uvd->lock); + mutex_unlock(&uvd->lock); info("USB camera disconnected."); usbvideo_ClientDecModCount(uvd); @@ -929,19 +929,19 @@ static int usbvideo_find_struct(struct usbvideo *cams) err("No usbvideo handle?"); return -1; } - down(&cams->lock); + mutex_lock(&cams->lock); for (u = 0; u < cams->num_cameras; u++) { struct uvd *uvd = &cams->cam[u]; if (!uvd->uvd_used) /* This one is free */ { uvd->uvd_used = 1; /* In use now */ - init_MUTEX(&uvd->lock); /* to 1 == available */ + mutex_init(&uvd->lock); /* to 1 == available */ uvd->dev = NULL; rv = u; break; } } - up(&cams->lock); + mutex_unlock(&cams->lock); return rv; } @@ -983,7 +983,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) /* Not relying upon caller we increase module counter ourselves */ usbvideo_ClientIncModCount(uvd); - down(&uvd->lock); + mutex_lock(&uvd->lock); for (i=0; i < USBVIDEO_NUMSBUF; i++) { uvd->sbuf[i].urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); if (uvd->sbuf[i].urb == NULL) { @@ -1006,7 +1006,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) * return control to the client's probe function right now. */ allocate_done: - up (&uvd->lock); + mutex_unlock(&uvd->lock); usbvideo_ClientDecModCount(uvd); return uvd; } @@ -1120,7 +1120,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) info("%s($%p)", __FUNCTION__, dev); usbvideo_ClientIncModCount(uvd); - down(&uvd->lock); + mutex_lock(&uvd->lock); if (uvd->user) { err("%s: Someone tried to open an already opened device!", __FUNCTION__); @@ -1201,7 +1201,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) } } } - up(&uvd->lock); + mutex_unlock(&uvd->lock); if (errCode != 0) usbvideo_ClientDecModCount(uvd); if (uvd->debug > 0) @@ -1230,7 +1230,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) if (uvd->debug > 1) info("%s($%p)", __FUNCTION__, dev); - down(&uvd->lock); + mutex_lock(&uvd->lock); GET_CALLBACK(uvd, stopDataPump)(uvd); usbvideo_rvfree(uvd->fbuf, uvd->fbuf_size); uvd->fbuf = NULL; @@ -1251,7 +1251,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) info("usbvideo_v4l_close: Final disconnect."); usbvideo_CameraRelease(uvd); } - up(&uvd->lock); + mutex_unlock(&uvd->lock); usbvideo_ClientDecModCount(uvd); if (uvd->debug > 1) @@ -1511,7 +1511,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, if (uvd->debug >= 1) info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock); - down(&uvd->lock); + mutex_lock(&uvd->lock); /* See if a frame is completed, then use it. */ for(i = 0; i < USBVIDEO_NUMFRAMES; i++) { @@ -1643,7 +1643,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, } } read_done: - up(&uvd->lock); + mutex_unlock(&uvd->lock); return count; } diff --git a/drivers/usb/media/usbvideo.h b/drivers/usb/media/usbvideo.h index 6c390a1f981..135433c2680 100644 --- a/drivers/usb/media/usbvideo.h +++ b/drivers/usb/media/usbvideo.h @@ -19,6 +19,7 @@ #include #include #include +#include /* Most helpful debugging aid */ #define assert(expr) ((void) ((expr) ? 0 : (err("assert failed at line %d",__LINE__)))) @@ -213,7 +214,7 @@ struct uvd { unsigned long flags; /* FLAGS_USBVIDEO_xxx */ unsigned long paletteBits; /* Which palettes we accept? */ unsigned short defaultPalette; /* What palette to use for read() */ - struct semaphore lock; + struct mutex lock; int user; /* user count for exclusive use */ videosize_t videosize; /* Current setting */ @@ -272,7 +273,7 @@ struct usbvideo { int num_cameras; /* As allocated */ struct usb_driver usbdrv; /* Interface to the USB stack */ char drvName[80]; /* Driver name */ - struct semaphore lock; /* Mutex protecting camera structures */ + struct mutex lock; /* Mutex protecting camera structures */ struct usbvideo_cb cb; /* Table of callbacks (virtual methods) */ struct video_device vdt; /* Video device template */ struct uvd *cam; /* Array of camera structures */ diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c index 5df14407387..8cfc47b831f 100644 --- a/drivers/usb/media/vicam.c +++ b/drivers/usb/media/vicam.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "usbvideo.h" // #define VICAM_DEBUG @@ -407,7 +408,7 @@ struct vicam_camera { struct usb_device *udev; // usb device /* guard against simultaneous accesses to the camera */ - struct semaphore cam_lock; + struct mutex cam_lock; int is_initialized; u8 open_count; @@ -461,12 +462,12 @@ static int send_control_msg(struct vicam_camera *cam, u16 size) { int status = -ENODEV; - down(&cam->cam_lock); + mutex_lock(&cam->cam_lock); if (cam->udev) { status = __send_control_msg(cam, request, value, index, cp, size); } - up(&cam->cam_lock); + mutex_unlock(&cam->cam_lock); return status; } static int @@ -831,13 +832,13 @@ vicam_close(struct inode *inode, struct file *file) rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); kfree(cam->cntrlbuf); - down(&cam->cam_lock); + mutex_lock(&cam->cam_lock); cam->open_count--; open_count = cam->open_count; udev = cam->udev; - up(&cam->cam_lock); + mutex_unlock(&cam->cam_lock); if (!open_count && !udev) { kfree(cam); @@ -960,7 +961,7 @@ read_frame(struct vicam_camera *cam, int framenum) request[8] = 0; // bytes 9-15 do not seem to affect exposure or image quality - down(&cam->cam_lock); + mutex_lock(&cam->cam_lock); if (!cam->udev) { goto done; @@ -985,7 +986,7 @@ read_frame(struct vicam_camera *cam, int framenum) } done: - up(&cam->cam_lock); + mutex_unlock(&cam->cam_lock); } static ssize_t @@ -1309,7 +1310,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id) cam->shutter_speed = 15; - init_MUTEX(&cam->cam_lock); + mutex_init(&cam->cam_lock); memcpy(&cam->vdev, &vicam_template, sizeof (vicam_template)); @@ -1351,7 +1352,7 @@ vicam_disconnect(struct usb_interface *intf) /* stop the camera from being used */ - down(&cam->cam_lock); + mutex_lock(&cam->cam_lock); /* mark the camera as gone */ @@ -1368,7 +1369,7 @@ vicam_disconnect(struct usb_interface *intf) open_count = cam->open_count; - up(&cam->cam_lock); + mutex_unlock(&cam->cam_lock); if (!open_count) { kfree(cam); diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 78cd1a577d2..b57dec3782e 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -47,6 +47,13 @@ #include "w9968cf.h" #include "w9968cf_decoder.h" +static struct w9968cf_vpp_t* w9968cf_vpp; +static DECLARE_WAIT_QUEUE_HEAD(w9968cf_vppmod_wait); + +static LIST_HEAD(w9968cf_dev_list); /* head of V4L registered cameras list */ +static DEFINE_MUTEX(w9968cf_devlist_mutex); /* semaphore for list traversal */ + +static DECLARE_RWSEM(w9968cf_disconnect); /* prevent races with open() */ /**************************************************************************** @@ -2418,7 +2425,7 @@ w9968cf_configure_camera(struct w9968cf_device* cam, enum w9968cf_model_id mod_id, const unsigned short dev_nr) { - init_MUTEX(&cam->fileop_sem); + mutex_init(&cam->fileop_mutex); init_waitqueue_head(&cam->open); spin_lock_init(&cam->urb_lock); spin_lock_init(&cam->flist_lock); @@ -2646,7 +2653,7 @@ static void w9968cf_adjust_configuration(struct w9968cf_device* cam) --------------------------------------------------------------------------*/ static void w9968cf_release_resources(struct w9968cf_device* cam) { - down(&w9968cf_devlist_sem); + mutex_lock(&w9968cf_devlist_mutex); DBG(2, "V4L device deregistered: /dev/video%d", cam->v4ldev->minor) @@ -2657,7 +2664,7 @@ static void w9968cf_release_resources(struct w9968cf_device* cam) kfree(cam->control_buffer); kfree(cam->data_buffer); - up(&w9968cf_devlist_sem); + mutex_unlock(&w9968cf_devlist_mutex); } @@ -2677,14 +2684,14 @@ static int w9968cf_open(struct inode* inode, struct file* filp) cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); - down(&cam->dev_sem); + mutex_lock(&cam->dev_mutex); if (cam->sensor == CC_UNKNOWN) { DBG(2, "No supported image sensor has been detected by the " "'ovcamchip' module for the %s (/dev/video%d). Make " "sure it is loaded *before* (re)connecting the camera.", symbolic(camlist, cam->id), cam->v4ldev->minor) - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); up_read(&w9968cf_disconnect); return -ENODEV; } @@ -2693,11 +2700,11 @@ static int w9968cf_open(struct inode* inode, struct file* filp) DBG(2, "%s (/dev/video%d) has been already occupied by '%s'", symbolic(camlist, cam->id),cam->v4ldev->minor,cam->command) if ((filp->f_flags & O_NONBLOCK)||(filp->f_flags & O_NDELAY)) { - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); up_read(&w9968cf_disconnect); return -EWOULDBLOCK; } - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); err = wait_event_interruptible_exclusive(cam->open, cam->disconnected || !cam->users); @@ -2709,7 +2716,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp) up_read(&w9968cf_disconnect); return -ENODEV; } - down(&cam->dev_sem); + mutex_lock(&cam->dev_mutex); } DBG(5, "Opening '%s', /dev/video%d ...", @@ -2738,7 +2745,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp) DBG(5, "Video device is open") - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); up_read(&w9968cf_disconnect); return 0; @@ -2746,7 +2753,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp) deallocate_memory: w9968cf_deallocate_memory(cam); DBG(2, "Failed to open the video device") - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); up_read(&w9968cf_disconnect); return err; } @@ -2758,13 +2765,13 @@ static int w9968cf_release(struct inode* inode, struct file* filp) cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); - down(&cam->dev_sem); /* prevent disconnect() to be called */ + mutex_lock(&cam->dev_mutex); /* prevent disconnect() to be called */ w9968cf_stop_transfer(cam); if (cam->disconnected) { w9968cf_release_resources(cam); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); kfree(cam); return 0; } @@ -2774,7 +2781,7 @@ static int w9968cf_release(struct inode* inode, struct file* filp) wake_up_interruptible_nr(&cam->open, 1); DBG(5, "Video device closed") - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); return 0; } @@ -2791,18 +2798,18 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) if (filp->f_flags & O_NONBLOCK) return -EWOULDBLOCK; - if (down_interruptible(&cam->fileop_sem)) + if (mutex_lock_interruptible(&cam->fileop_mutex)) return -ERESTARTSYS; if (cam->disconnected) { DBG(2, "Device not present") - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } if (cam->misconfigured) { DBG(2, "The camera is misconfigured. Close and open it again.") - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EIO; } @@ -2817,11 +2824,11 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) cam->frame[1].status == F_READY || cam->disconnected); if (err) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return err; } if (cam->disconnected) { - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } @@ -2835,7 +2842,7 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) if (copy_to_user(buf, fr->buffer, count)) { fr->status = F_UNUSED; - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EFAULT; } *f_pos += count; @@ -2844,7 +2851,7 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) DBG(5, "%zu bytes read", count) - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return count; } @@ -2898,24 +2905,24 @@ w9968cf_ioctl(struct inode* inode, struct file* filp, cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); - if (down_interruptible(&cam->fileop_sem)) + if (mutex_lock_interruptible(&cam->fileop_mutex)) return -ERESTARTSYS; if (cam->disconnected) { DBG(2, "Device not present") - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -ENODEV; } if (cam->misconfigured) { DBG(2, "The camera is misconfigured. Close and open it again.") - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return -EIO; } err = w9968cf_v4l_ioctl(inode, filp, cmd, (void __user *)arg); - up(&cam->fileop_sem); + mutex_unlock(&cam->fileop_mutex); return err; } @@ -3502,8 +3509,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) if (!cam) return -ENOMEM; - init_MUTEX(&cam->dev_sem); - down(&cam->dev_sem); + mutex_init(&cam->dev_mutex); + mutex_lock(&cam->dev_mutex); cam->usbdev = udev; /* NOTE: a local copy is used to avoid possible race conditions */ @@ -3515,10 +3522,10 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) simcams = W9968CF_SIMCAMS; /* How many cameras are connected ? */ - down(&w9968cf_devlist_sem); + mutex_lock(&w9968cf_devlist_mutex); list_for_each(ptr, &w9968cf_dev_list) sc++; - up(&w9968cf_devlist_sem); + mutex_unlock(&w9968cf_devlist_mutex); if (sc >= simcams) { DBG(2, "Device rejected: too many connected cameras " @@ -3578,9 +3585,9 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) w9968cf_configure_camera(cam, udev, mod_id, dev_nr); /* Add a new entry into the list of V4L registered devices */ - down(&w9968cf_devlist_sem); + mutex_lock(&w9968cf_devlist_mutex); list_add(&cam->v4llist, &w9968cf_dev_list); - up(&w9968cf_devlist_sem); + mutex_unlock(&w9968cf_devlist_mutex); dev_nr = (dev_nr < W9968CF_MAX_DEVICES-1) ? dev_nr+1 : 0; w9968cf_turn_on_led(cam); @@ -3588,7 +3595,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) w9968cf_i2c_init(cam); usb_set_intfdata(intf, cam); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); return 0; fail: /* Free unused memory */ @@ -3596,7 +3603,7 @@ fail: /* Free unused memory */ kfree(cam->data_buffer); if (cam->v4ldev) video_device_release(cam->v4ldev); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); kfree(cam); return err; } @@ -3611,7 +3618,7 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf) if (cam) { /* Prevent concurrent accesses to data */ - down(&cam->dev_sem); + mutex_lock(&cam->dev_mutex); cam->disconnected = 1; @@ -3630,7 +3637,7 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf) } else w9968cf_release_resources(cam); - up(&cam->dev_sem); + mutex_unlock(&cam->dev_mutex); if (!cam->users) kfree(cam); diff --git a/drivers/usb/media/w9968cf.h b/drivers/usb/media/w9968cf.h index 47a6ff79417..a87be719a28 100644 --- a/drivers/usb/media/w9968cf.h +++ b/drivers/usb/media/w9968cf.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include @@ -194,14 +194,6 @@ enum w9968cf_vpp_flag { VPP_UYVY_TO_RGBX = 0x08, }; -static struct w9968cf_vpp_t* w9968cf_vpp; -static DECLARE_WAIT_QUEUE_HEAD(w9968cf_vppmod_wait); - -static LIST_HEAD(w9968cf_dev_list); /* head of V4L registered cameras list */ -static DECLARE_MUTEX(w9968cf_devlist_sem); /* semaphore for list traversal */ - -static DECLARE_RWSEM(w9968cf_disconnect); /* prevent races with open() */ - /* Main device driver structure */ struct w9968cf_device { struct device dev; /* device structure */ @@ -277,8 +269,8 @@ struct w9968cf_device { struct i2c_client* sensor_client; /* Locks */ - struct semaphore dev_sem, /* for probe, disconnect,open and close */ - fileop_sem; /* for read and ioctl */ + struct mutex dev_mutex, /* for probe, disconnect,open and close */ + fileop_mutex; /* for read and ioctl */ spinlock_t urb_lock, /* for submit_urb() and unlink_urb() */ flist_lock; /* for requested frame list accesses */ wait_queue_head_t open, wait_queue; diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index b3aca512433..d0b16725669 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -121,7 +122,7 @@ static struct usb_driver idmouse_driver = { }; /* prevent races between open() and disconnect() */ -static DECLARE_MUTEX(disconnect_sem); +static DEFINE_MUTEX(disconnect_mutex); static int idmouse_create_image(struct usb_idmouse *dev) { @@ -213,18 +214,18 @@ static int idmouse_open(struct inode *inode, struct file *file) int result = 0; /* prevent disconnects */ - down(&disconnect_sem); + mutex_lock(&disconnect_mutex); /* get the interface from minor number and driver information */ interface = usb_find_interface (&idmouse_driver, iminor (inode)); if (!interface) { - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return -ENODEV; } /* get the device information block from the interface */ dev = usb_get_intfdata(interface); if (!dev) { - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return -ENODEV; } @@ -258,7 +259,7 @@ error: up(&dev->sem); /* unlock the disconnect semaphore */ - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return result; } @@ -267,12 +268,12 @@ static int idmouse_release(struct inode *inode, struct file *file) struct usb_idmouse *dev; /* prevent a race condition with open() */ - down(&disconnect_sem); + mutex_lock(&disconnect_mutex); dev = (struct usb_idmouse *) file->private_data; if (dev == NULL) { - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return -ENODEV; } @@ -282,7 +283,7 @@ static int idmouse_release(struct inode *inode, struct file *file) /* are we really open? */ if (dev->open <= 0) { up(&dev->sem); - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return -ENODEV; } @@ -292,12 +293,12 @@ static int idmouse_release(struct inode *inode, struct file *file) /* the device was unplugged before the file was released */ up(&dev->sem); idmouse_delete(dev); - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return 0; } up(&dev->sem); - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return 0; } @@ -399,7 +400,7 @@ static void idmouse_disconnect(struct usb_interface *interface) struct usb_idmouse *dev; /* prevent races with open() */ - down(&disconnect_sem); + mutex_lock(&disconnect_mutex); /* get device structure */ dev = usb_get_intfdata(interface); @@ -421,7 +422,7 @@ static void idmouse_disconnect(struct usb_interface *interface) if (!dev->open) idmouse_delete(dev); - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); info("%s disconnected", DRIVER_DESC); } diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index f6bdaf08a80..966acb474f6 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -172,7 +173,7 @@ struct ld_usb { }; /* prevent races between open() and disconnect() */ -static DECLARE_MUTEX(disconnect_sem); +static DEFINE_MUTEX(disconnect_mutex); static struct usb_driver ld_usb_driver; @@ -293,7 +294,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) nonseekable_open(inode, file); subminor = iminor(inode); - down(&disconnect_sem); + mutex_lock(&disconnect_mutex); interface = usb_find_interface(&ld_usb_driver, subminor); @@ -355,7 +356,7 @@ unlock_exit: up(&dev->sem); unlock_disconnect_exit: - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); return retval; } @@ -740,7 +741,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) struct ld_usb *dev; int minor; - down(&disconnect_sem); + mutex_lock(&disconnect_mutex); dev = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); @@ -761,7 +762,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) up(&dev->sem); } - up(&disconnect_sem); + mutex_unlock(&disconnect_mutex); dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", (minor - USB_LD_MINOR_BASE)); diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 1336745b8f5..779bcf0373a 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -256,7 +257,7 @@ static void tower_disconnect (struct usb_interface *interface); /* prevent races between open() and disconnect */ -static DECLARE_MUTEX (disconnect_sem); +static DEFINE_MUTEX (disconnect_mutex); /* file operations needed when we register this driver */ static struct file_operations tower_fops = { @@ -349,7 +350,7 @@ static int tower_open (struct inode *inode, struct file *file) nonseekable_open(inode, file); subminor = iminor(inode); - down (&disconnect_sem); + mutex_lock (&disconnect_mutex); interface = usb_find_interface (&tower_driver, subminor); @@ -427,7 +428,7 @@ unlock_exit: up (&dev->sem); unlock_disconnect_exit: - up (&disconnect_sem); + mutex_unlock (&disconnect_mutex); dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); @@ -1005,7 +1006,7 @@ static void tower_disconnect (struct usb_interface *interface) dbg(2, "%s: enter", __FUNCTION__); - down (&disconnect_sem); + mutex_lock (&disconnect_mutex); dev = usb_get_intfdata (interface); usb_set_intfdata (interface, NULL); @@ -1027,7 +1028,7 @@ static void tower_disconnect (struct usb_interface *interface) up (&dev->sem); } - up (&disconnect_sem); + mutex_unlock (&disconnect_mutex); info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index c34944c7504..b03e346e33f 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "usb_mon.h" #include "../core/hcd.h" @@ -23,7 +24,7 @@ static void mon_dissolve(struct mon_bus *mbus, struct usb_bus *ubus); static void mon_bus_drop(struct kref *r); static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus); -DECLARE_MUTEX(mon_lock); +DEFINE_MUTEX(mon_lock); static struct dentry *mon_dir; /* /dbg/usbmon */ static LIST_HEAD(mon_buses); /* All buses we know: struct mon_bus */ @@ -196,14 +197,14 @@ static void mon_bus_remove(struct usb_bus *ubus) { struct mon_bus *mbus = ubus->mon_bus; - down(&mon_lock); + mutex_lock(&mon_lock); list_del(&mbus->bus_link); debugfs_remove(mbus->dent_t); debugfs_remove(mbus->dent_s); mon_dissolve(mbus, ubus); kref_put(&mbus->ref, mon_bus_drop); - up(&mon_lock); + mutex_unlock(&mon_lock); } static int mon_notify(struct notifier_block *self, unsigned long action, @@ -307,9 +308,9 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus) goto err_create_s; mbus->dent_s = d; - down(&mon_lock); + mutex_lock(&mon_lock); list_add_tail(&mbus->bus_link, &mon_buses); - up(&mon_lock); + mutex_unlock(&mon_lock); return; err_create_s: @@ -347,11 +348,11 @@ static int __init mon_init(void) usb_register_notify(&mon_nb); - down(&usb_bus_list_lock); + mutex_lock(&usb_bus_list_lock); list_for_each_entry (ubus, &usb_bus_list, bus_list) { mon_bus_init(mondir, ubus); } - up(&usb_bus_list_lock); + mutex_unlock(&usb_bus_list_lock); return 0; } @@ -363,7 +364,7 @@ static void __exit mon_exit(void) usb_unregister_notify(&mon_nb); usb_mon_deregister(); - down(&mon_lock); + mutex_lock(&mon_lock); while (!list_empty(&mon_buses)) { p = mon_buses.next; mbus = list_entry(p, struct mon_bus, bus_link); @@ -387,7 +388,7 @@ static void __exit mon_exit(void) mon_dissolve(mbus, mbus->u_bus); kref_put(&mbus->ref, mon_bus_drop); } - up(&mon_lock); + mutex_unlock(&mon_lock); debugfs_remove(mon_dir); } diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 611612146ae..59089e8b7e5 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "usb_mon.h" @@ -54,7 +55,7 @@ struct mon_reader_text { wait_queue_head_t wait; int printf_size; char *printf_buf; - struct semaphore printf_lock; + struct mutex printf_lock; char slab_name[SLAB_NAME_SZ]; }; @@ -208,7 +209,7 @@ static int mon_text_open(struct inode *inode, struct file *file) struct mon_reader_text *rp; int rc; - down(&mon_lock); + mutex_lock(&mon_lock); mbus = inode->u.generic_ip; ubus = mbus->u_bus; @@ -220,7 +221,7 @@ static int mon_text_open(struct inode *inode, struct file *file) memset(rp, 0, sizeof(struct mon_reader_text)); INIT_LIST_HEAD(&rp->e_list); init_waitqueue_head(&rp->wait); - init_MUTEX(&rp->printf_lock); + mutex_init(&rp->printf_lock); rp->printf_size = PRINTF_DFL; rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL); @@ -247,7 +248,7 @@ static int mon_text_open(struct inode *inode, struct file *file) mon_reader_add(mbus, &rp->r); file->private_data = rp; - up(&mon_lock); + mutex_unlock(&mon_lock); return 0; // err_busy: @@ -257,7 +258,7 @@ err_slab: err_alloc_pr: kfree(rp); err_alloc: - up(&mon_lock); + mutex_unlock(&mon_lock); return rc; } @@ -301,7 +302,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf, set_current_state(TASK_RUNNING); remove_wait_queue(&rp->wait, &waita); - down(&rp->printf_lock); + mutex_lock(&rp->printf_lock); cnt = 0; pbuf = rp->printf_buf; limit = rp->printf_size; @@ -358,7 +359,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf, if (copy_to_user(buf, rp->printf_buf, cnt)) cnt = -EFAULT; - up(&rp->printf_lock); + mutex_unlock(&rp->printf_lock); kmem_cache_free(rp->e_slab, ep); return cnt; } @@ -371,12 +372,12 @@ static int mon_text_release(struct inode *inode, struct file *file) struct list_head *p; struct mon_event_text *ep; - down(&mon_lock); + mutex_lock(&mon_lock); mbus = inode->u.generic_ip; if (mbus->nreaders <= 0) { printk(KERN_ERR TAG ": consistency error on close\n"); - up(&mon_lock); + mutex_unlock(&mon_lock); return 0; } mon_reader_del(mbus, &rp->r); @@ -402,7 +403,7 @@ static int mon_text_release(struct inode *inode, struct file *file) kfree(rp->printf_buf); kfree(rp); - up(&mon_lock); + mutex_unlock(&mon_lock); return 0; } diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h index 4be0f934607..8e0613c350c 100644 --- a/drivers/usb/mon/usb_mon.h +++ b/drivers/usb/mon/usb_mon.h @@ -49,7 +49,7 @@ void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r); */ extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len); -extern struct semaphore mon_lock; +extern struct mutex mon_lock; extern struct file_operations mon_fops_text; extern struct file_operations mon_fops_stat; diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 4ef5527028c..5f11e19eaae 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -271,9 +272,9 @@ static int device_reset(struct scsi_cmnd *srb) US_DEBUGP("%s called\n", __FUNCTION__); /* lock the device pointers and do the reset */ - down(&(us->dev_semaphore)); + mutex_lock(&(us->dev_mutex)); result = us->transport_reset(us); - up(&(us->dev_semaphore)); + mutex_unlock(&us->dev_mutex); return result < 0 ? FAILED : SUCCESS; } @@ -286,9 +287,9 @@ static int bus_reset(struct scsi_cmnd *srb) US_DEBUGP("%s called\n", __FUNCTION__); - down(&(us->dev_semaphore)); + mutex_lock(&(us->dev_mutex)); result = usb_stor_port_reset(us); - up(&(us->dev_semaphore)); + mutex_unlock(&us->dev_mutex); return result < 0 ? FAILED : SUCCESS; } diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index dbcf23980ff..dd108634348 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -188,7 +189,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message) struct us_data *us = usb_get_intfdata(iface); /* Wait until no command is running */ - down(&us->dev_semaphore); + mutex_lock(&us->dev_mutex); US_DEBUGP("%s\n", __FUNCTION__); if (us->suspend_resume_hook) @@ -198,7 +199,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message) /* When runtime PM is working, we'll set a flag to indicate * whether we should autoresume when a SCSI request arrives. */ - up(&us->dev_semaphore); + mutex_unlock(&us->dev_mutex); return 0; } @@ -206,14 +207,14 @@ static int storage_resume(struct usb_interface *iface) { struct us_data *us = usb_get_intfdata(iface); - down(&us->dev_semaphore); + mutex_lock(&us->dev_mutex); US_DEBUGP("%s\n", __FUNCTION__); if (us->suspend_resume_hook) (us->suspend_resume_hook)(us, US_RESUME); iface->dev.power.power_state.event = PM_EVENT_ON; - up(&us->dev_semaphore); + mutex_unlock(&us->dev_mutex); return 0; } @@ -276,12 +277,12 @@ static int usb_stor_control_thread(void * __us) US_DEBUGP("*** thread awakened.\n"); /* lock the device pointers */ - down(&(us->dev_semaphore)); + mutex_lock(&(us->dev_mutex)); /* if the device has disconnected, we are free to exit */ if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { US_DEBUGP("-- exiting\n"); - up(&(us->dev_semaphore)); + mutex_unlock(&us->dev_mutex); break; } @@ -370,7 +371,7 @@ SkipForAbort: scsi_unlock(host); /* unlock the device pointers */ - up(&(us->dev_semaphore)); + mutex_unlock(&us->dev_mutex); } /* for (;;) */ scsi_host_put(host); @@ -815,8 +816,8 @@ static void quiesce_and_remove_host(struct us_data *us) * The thread will exit when it sees the DISCONNECTING flag. */ /* Wait for the current command to finish, then remove the host */ - down(&us->dev_semaphore); - up(&us->dev_semaphore); + mutex_lock(&us->dev_mutex); + mutex_unlock(&us->dev_mutex); /* queuecommand won't accept any new commands and the control * thread won't execute a previously-queued command. If there @@ -870,9 +871,9 @@ retry: /* For bulk-only devices, determine the max LUN value */ if (us->protocol == US_PR_BULK && !(us->flags & US_FL_SINGLE_LUN)) { - down(&us->dev_semaphore); + mutex_lock(&us->dev_mutex); us->max_lun = usb_stor_Bulk_max_lun(us); - up(&us->dev_semaphore); + mutex_unlock(&us->dev_mutex); } scsi_scan_host(us_to_host(us)); printk(KERN_DEBUG "usb-storage: device scan complete\n"); @@ -912,7 +913,7 @@ static int storage_probe(struct usb_interface *intf, us = host_to_us(host); memset(us, 0, sizeof(struct us_data)); - init_MUTEX(&(us->dev_semaphore)); + mutex_init(&(us->dev_mutex)); init_MUTEX_LOCKED(&(us->sema)); init_completion(&(us->notify)); init_waitqueue_head(&us->delay_wait); diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 7259fd1f6b0..009fb0953a5 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -49,6 +49,7 @@ #include #include #include +#include #include struct us_data; @@ -103,9 +104,9 @@ typedef void (*pm_hook)(struct us_data *, int); /* power management hook */ struct us_data { /* The device we're working with * It's important to note: - * (o) you must hold dev_semaphore to change pusb_dev + * (o) you must hold dev_mutex to change pusb_dev */ - struct semaphore dev_semaphore; /* protect pusb_dev */ + struct mutex dev_mutex; /* protect pusb_dev */ struct usb_device *pusb_dev; /* this usb_device */ struct usb_interface *pusb_intf; /* this interface */ struct us_unusual_dev *unusual_dev; /* device-filter entry */ -- cgit v1.2.3-70-g09d2 From 80b6ca48321974a6566a1c9048ba34f60420bca6 Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Mon, 27 Feb 2006 21:29:43 +0100 Subject: [PATCH] USB: kzalloc() conversion for rest of drivers/usb Signed-off-by: Eric Sesterhenn Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-mem.c | 10 +++------- drivers/usb/host/ehci-sched.c | 3 +-- drivers/usb/host/hc_crisv10.c | 12 ++++-------- drivers/usb/media/ov511.c | 4 +--- drivers/usb/media/pwc/pwc-if.c | 3 +-- drivers/usb/media/se401.c | 4 +--- drivers/usb/media/stv680.c | 7 ++----- drivers/usb/misc/auerswald.c | 6 ++---- drivers/usb/misc/usblcd.c | 3 +-- drivers/usb/misc/usbtest.c | 9 +++------ drivers/usb/mon/mon_main.c | 3 +-- drivers/usb/mon/mon_text.c | 3 +-- drivers/usb/net/zd1201.c | 9 +++------ drivers/usb/serial/cp2101.c | 4 +--- drivers/usb/serial/cypress_m8.c | 3 +-- drivers/usb/serial/ftdi_sio.c | 3 +-- drivers/usb/serial/garmin_gps.c | 3 +-- drivers/usb/serial/io_edgeport.c | 3 +-- drivers/usb/serial/io_ti.c | 6 ++---- drivers/usb/serial/ir-usb.c | 3 +-- drivers/usb/serial/keyspan.c | 6 ++---- drivers/usb/serial/kobil_sct.c | 16 +++++----------- drivers/usb/serial/mct_u232.c | 3 +-- drivers/usb/serial/option.c | 3 +-- drivers/usb/serial/pl2303.c | 6 ++---- drivers/usb/serial/ti_usb_3410_5052.c | 3 +-- drivers/usb/serial/usb-serial.c | 6 ++---- drivers/usb/serial/visor.c | 3 +-- drivers/usb/storage/isd200.c | 2 +- 29 files changed, 48 insertions(+), 101 deletions(-) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index ec7eb3f4f86..766061e0260 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c @@ -220,13 +220,9 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) ehci->periodic [i] = EHCI_LIST_END; /* software shadow of hardware table */ - ehci->pshadow = kmalloc (ehci->periodic_size * sizeof (void *), flags); - if (ehci->pshadow == NULL) { - goto fail; - } - memset (ehci->pshadow, 0, ehci->periodic_size * sizeof (void *)); - - return 0; + ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags); + if (ehci->pshadow != NULL) + return 0; fail: ehci_dbg (ehci, "couldn't init memory\n"); diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 90d6900a37f..5871944e614 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -864,9 +864,8 @@ iso_sched_alloc (unsigned packets, gfp_t mem_flags) int size = sizeof *iso_sched; size += packets * sizeof (struct ehci_iso_packet); - iso_sched = kmalloc (size, mem_flags); + iso_sched = kzalloc(size, mem_flags); if (likely (iso_sched != NULL)) { - memset(iso_sched, 0, size); INIT_LIST_HEAD (&iso_sched->td_list); } return iso_sched; diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 641268d7e6f..2fe7fd19437 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -2137,10 +2137,9 @@ static int etrax_usb_submit_bulk_urb(struct urb *urb) urb->status = -EINPROGRESS; /* Setup the hcpriv data. */ - urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG); + urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG); assert(urb_priv != NULL); /* This sets rx_offset to 0. */ - memset(urb_priv, 0, sizeof(etrax_urb_priv_t)); urb_priv->urb_state = NOT_STARTED; urb->hcpriv = urb_priv; @@ -2475,10 +2474,9 @@ static int etrax_usb_submit_ctrl_urb(struct urb *urb) urb->status = -EINPROGRESS; /* Setup the hcpriv data. */ - urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG); + urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG); assert(urb_priv != NULL); /* This sets rx_offset to 0. */ - memset(urb_priv, 0, sizeof(etrax_urb_priv_t)); urb_priv->urb_state = NOT_STARTED; urb->hcpriv = urb_priv; @@ -2767,9 +2765,8 @@ static void etrax_usb_add_to_intr_sb_list(struct urb *urb, int epid) maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); interval = urb->interval; - urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG); + urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG); assert(urb_priv != NULL); - memset(urb_priv, 0, sizeof(etrax_urb_priv_t)); urb->hcpriv = urb_priv; first_ep = &TxIntrEPList[0]; @@ -2997,9 +2994,8 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid) prev_sb_desc = next_sb_desc = temp_sb_desc = NULL; - urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC); + urb_priv = kzalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC); assert(urb_priv != NULL); - memset(urb_priv, 0, sizeof(etrax_urb_priv_t)); urb->hcpriv = urb_priv; urb_priv->epid = epid; diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 1d887ec0608..da44579d6f2 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -5686,13 +5686,11 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) if (idesc->bInterfaceSubClass != 0x00) return -ENODEV; - if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) { + if ((ov = kzalloc(sizeof(*ov), GFP_KERNEL)) == NULL) { err("couldn't kmalloc ov struct"); goto error_out; } - memset(ov, 0, sizeof(*ov)); - ov->dev = dev; ov->iface = idesc->bInterfaceNumber; ov->led_policy = led; diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c index db6753dc5ba..90eb2604281 100644 --- a/drivers/usb/media/pwc/pwc-if.c +++ b/drivers/usb/media/pwc/pwc-if.c @@ -1867,12 +1867,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id Info("Warning: more than 1 configuration available.\n"); /* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */ - pdev = kmalloc(sizeof(struct pwc_device), GFP_KERNEL); + pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL); if (pdev == NULL) { Err("Oops, could not allocate memory for pwc_device.\n"); return -ENOMEM; } - memset(pdev, 0, sizeof(struct pwc_device)); pdev->type = type_id; pdev->vsize = default_size; pdev->vframes = default_fps; diff --git a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c index 8c3b1ad8a8f..f03ea7f8959 100644 --- a/drivers/usb/media/se401.c +++ b/drivers/usb/media/se401.c @@ -1345,13 +1345,11 @@ static int se401_probe(struct usb_interface *intf, /* We found one */ info("SE401 camera found: %s", camera_name); - if ((se401 = kmalloc(sizeof(*se401), GFP_KERNEL)) == NULL) { + if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) { err("couldn't kmalloc se401 struct"); return -ENOMEM; } - memset(se401, 0, sizeof(*se401)); - se401->dev = dev; se401->iface = interface->bInterfaceNumber; se401->camera_name = camera_name; diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c index b1a6be2958e..9636da20748 100644 --- a/drivers/usb/media/stv680.c +++ b/drivers/usb/media/stv680.c @@ -318,12 +318,11 @@ static int stv_init (struct usb_stv *stv680) unsigned char *buffer; unsigned long int bufsize; - buffer = kmalloc (40, GFP_KERNEL); + buffer = kzalloc (40, GFP_KERNEL); if (buffer == NULL) { PDEBUG (0, "STV(e): Out of (small buf) memory"); return -1; } - memset (buffer, 0, 40); udelay (100); /* set config 1, interface 0, alternate 0 */ @@ -1388,14 +1387,12 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id goto error; } /* We found one */ - if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) { + if ((stv680 = kzalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) { PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct."); retval = -ENOMEM; goto error; } - memset (stv680, 0, sizeof (*stv680)); - stv680->udev = dev; stv680->camera_name = camera_name; diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index ad2f4cccd38..1fef36e71c5 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -570,10 +570,9 @@ static int auerchain_setup (pauerchain_t acp, unsigned int numElements) /* fill the list of free elements */ for (;numElements; numElements--) { - acep = (pauerchainelement_t) kmalloc (sizeof (auerchainelement_t), GFP_KERNEL); + acep = kzalloc(sizeof(auerchainelement_t), GFP_KERNEL); if (!acep) goto ac_fail; - memset (acep, 0, sizeof (auerchainelement_t)); INIT_LIST_HEAD (&acep->list); list_add_tail (&acep->list, &acp->free_list); } @@ -761,10 +760,9 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned /* fill the list of free elements */ for (;numElements; numElements--) { - bep = (pauerbuf_t) kmalloc (sizeof (auerbuf_t), GFP_KERNEL); + bep = kzalloc(sizeof(auerbuf_t), GFP_KERNEL); if (!bep) goto bl_fail; - memset (bep, 0, sizeof (auerbuf_t)); bep->list = bcp; INIT_LIST_HEAD (&bep->buff_list); bep->bufp = kmalloc (bufsize, GFP_KERNEL); diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index cc3dae3f34e..c82c402285a 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c @@ -270,12 +270,11 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id int retval = -ENOMEM; /* allocate memory for our device state and initialize it */ - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { err("Out of memory"); goto error; } - memset(dev, 0x00, sizeof(*dev)); kref_init(&dev->kref); dev->udev = usb_get_dev(interface_to_usbdev(interface)); diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 84fa1728f05..9d59b901841 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -382,12 +382,11 @@ alloc_sglist (int nents, int max, int vary) for (i = 0; i < nents; i++) { char *buf; - buf = kmalloc (size, SLAB_KERNEL); + buf = kzalloc (size, SLAB_KERNEL); if (!buf) { free_sglist (sg, i); return NULL; } - memset (buf, 0, size); /* kmalloc pages are always physically contiguous! */ sg_init_one(&sg[i], buf, size); @@ -842,10 +841,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) * as with bulk/intr sglists, sglen is the queue depth; it also * controls which subtests run (more tests than sglen) or rerun. */ - urb = kmalloc (param->sglen * sizeof (struct urb *), SLAB_KERNEL); + urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL); if (!urb) return -ENOMEM; - memset (urb, 0, param->sglen * sizeof (struct urb *)); for (i = 0; i < param->sglen; i++) { int pipe = usb_rcvctrlpipe (udev, 0); unsigned len; @@ -1865,10 +1863,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) } #endif - dev = kmalloc (sizeof *dev, SLAB_KERNEL); + dev = kzalloc(sizeof(*dev), SLAB_KERNEL); if (!dev) return -ENOMEM; - memset (dev, 0, sizeof *dev); info = (struct usbtest_info *) id->driver_info; dev->info = info; init_MUTEX (&dev->sem); diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index b03e346e33f..6ecc2730221 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c @@ -277,9 +277,8 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus) char name[NAMESZ]; int rc; - if ((mbus = kmalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL) + if ((mbus = kzalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL) goto err_alloc; - memset(mbus, 0, sizeof(struct mon_bus)); kref_init(&mbus->ref); spin_lock_init(&mbus->lock); INIT_LIST_HEAD(&mbus->r_list); diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 59089e8b7e5..ac043ec2b8d 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -213,12 +213,11 @@ static int mon_text_open(struct inode *inode, struct file *file) mbus = inode->u.generic_ip; ubus = mbus->u_bus; - rp = kmalloc(sizeof(struct mon_reader_text), GFP_KERNEL); + rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL); if (rp == NULL) { rc = -ENOMEM; goto err_alloc; } - memset(rp, 0, sizeof(struct mon_reader_text)); INIT_LIST_HEAD(&rp->e_list); init_waitqueue_head(&rp->wait); mutex_init(&rp->printf_lock); diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index f3a8e2807c3..fe9b60cd8d9 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -621,10 +621,9 @@ static int zd1201_drvr_start(struct zd1201 *zd) __le16 zdmax; unsigned char *buffer; - buffer = kmalloc(ZD1201_RXSIZE, GFP_KERNEL); + buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL); if (!buffer) return -ENOMEM; - memset(buffer, 0, ZD1201_RXSIZE); usb_fill_bulk_urb(zd->rx_urb, zd->usb, usb_rcvbulkpipe(zd->usb, zd->endp_in), buffer, ZD1201_RXSIZE, @@ -1750,11 +1749,9 @@ static int zd1201_probe(struct usb_interface *interface, usb = interface_to_usbdev(interface); - zd = kmalloc(sizeof(struct zd1201), GFP_KERNEL); - if (!zd) { + zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL); + if (!zd) return -ENOMEM; - } - memset(zd, 0, sizeof(struct zd1201)); zd->ap = ap; zd->usb = usb; zd->removed = 0; diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index dc7a069503e..9ea7b4a4a22 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -169,9 +169,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, /* Number of integers required to contain the array */ length = (((size - 1) | 3) + 1)/4; - buf = kmalloc (length * sizeof(u32), GFP_KERNEL); - memset(buf, 0, length * sizeof(u32)); - + buf = kcalloc(length, sizeof(u32), GFP_KERNEL); if (!buf) { dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); return -ENOMEM; diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 68067fe117a..71af3bf5adb 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -435,11 +435,10 @@ static int generic_startup (struct usb_serial *serial) dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); - priv = kmalloc(sizeof (struct cypress_private), GFP_KERNEL); + priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL); if (!priv) return -ENOMEM; - memset(priv, 0x00, sizeof (struct cypress_private)); spin_lock_init(&priv->lock); priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE); if (priv->buf == NULL) { diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index c145e1ed842..ece52a6328b 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1141,12 +1141,11 @@ static int ftdi_sio_attach (struct usb_serial *serial) dbg("%s",__FUNCTION__); - priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); + priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); if (!priv){ err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); return -ENOMEM; } - memset(priv, 0, sizeof(*priv)); spin_lock_init(&priv->rx_lock); init_waitqueue_head(&priv->delta_msr_wait); diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index d6f55e9dcca..5ec9bf5bac8 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -1422,12 +1422,11 @@ static int garmin_attach (struct usb_serial *serial) dbg("%s", __FUNCTION__); - garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL); + garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); if (garmin_data_p == NULL) { dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__); return -ENOMEM; } - memset (garmin_data_p, 0, sizeof(struct garmin_data)); init_timer(&garmin_data_p->timer); spin_lock_init(&garmin_data_p->lock); INIT_LIST_HEAD(&garmin_data_p->pktlist); diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 3f29e6b0fd1..b606c596810 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -2725,12 +2725,11 @@ static int edge_startup (struct usb_serial *serial) dev = serial->dev; /* create our private serial structure */ - edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL); + edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); if (edge_serial == NULL) { dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); return -ENOMEM; } - memset (edge_serial, 0, sizeof(struct edgeport_serial)); spin_lock_init(&edge_serial->es_lock); edge_serial->serial = serial; usb_set_serial_data(serial, edge_serial); diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index afc0f34b3a4..8e1e2253748 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2727,12 +2727,11 @@ static int edge_startup (struct usb_serial *serial) dev = serial->dev; /* create our private serial structure */ - edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL); + edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); if (edge_serial == NULL) { dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); return -ENOMEM; } - memset (edge_serial, 0, sizeof(struct edgeport_serial)); sema_init(&edge_serial->es_sem, 1); edge_serial->serial = serial; usb_set_serial_data(serial, edge_serial); @@ -2745,12 +2744,11 @@ static int edge_startup (struct usb_serial *serial) /* set up our port private structures */ for (i = 0; i < serial->num_ports; ++i) { - edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); + edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); if (edge_port == NULL) { dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); goto cleanup; } - memset (edge_port, 0, sizeof(struct edgeport_port)); spin_lock_init(&edge_port->ep_lock); edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE); if (edge_port->ep_out_buf == NULL) { diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index a5901042144..426182ddc42 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -184,10 +184,9 @@ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, struct irda_class_desc *desc; int ret; - desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL); + desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL); if (desc == NULL) return NULL; - memset(desc, 0, sizeof(struct irda_class_desc)); ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0), IU_REQ_GET_CLASS_DESC, diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 3b958e60f5e..052b735c4fb 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -2250,12 +2250,11 @@ static int keyspan_startup (struct usb_serial *serial) } /* Setup private data for serial driver */ - s_priv = kmalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); + s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); if (!s_priv) { dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__); return -ENOMEM; } - memset(s_priv, 0, sizeof(struct keyspan_serial_private)); s_priv->device_details = d_details; usb_set_serial_data(serial, s_priv); @@ -2263,12 +2262,11 @@ static int keyspan_startup (struct usb_serial *serial) /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; - p_priv = kmalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); + p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); if (!p_priv) { dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i); return (1); } - memset(p_priv, 0, sizeof(struct keyspan_port_private)); p_priv->device_details = d_details; usb_set_serial_port_data(port, p_priv); } diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index b8b213185d0..87dfcd89ffa 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -255,11 +255,9 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) } // allocate memory for transfer buffer - transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL); + transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); if (! transfer_buffer) { return -ENOMEM; - } else { - memset(transfer_buffer, 0, transfer_buffer_length); } // allocate write_urb @@ -383,11 +381,10 @@ static void kobil_read_int_callback( struct urb *purb, struct pt_regs *regs) // BEGIN DEBUG /* - dbg_data = (unsigned char *) kmalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); + dbg_data = kzalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); if (! dbg_data) { return; } - memset(dbg_data, 0, (3 * purb->actual_length + 10)); for (i = 0; i < purb->actual_length; i++) { sprintf(dbg_data +3*i, "%02X ", data[i]); } @@ -518,11 +515,10 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) } // allocate memory for transfer buffer - transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL); + transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); if (!transfer_buffer) { return -ENOMEM; } - memset(transfer_buffer, 0, transfer_buffer_length); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), @@ -564,11 +560,10 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, } // allocate memory for transfer buffer - transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL); + transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); if (! transfer_buffer) { return -ENOMEM; } - memset(transfer_buffer, 0, transfer_buffer_length); if (set & TIOCM_RTS) rts = 1; @@ -655,11 +650,10 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, (struct termios __user *)arg)) return -EFAULT; - settings = (unsigned char *) kmalloc(50, GFP_KERNEL); + settings = kzalloc(50, GFP_KERNEL); if (! settings) { return -ENOBUFS; } - memset(settings, 0, 50); switch (priv->internal_termios.c_cflag & CBAUD) { case B1200: diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index b6d6cab9c85..35bd29b6c40 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -348,10 +348,9 @@ static int mct_u232_startup (struct usb_serial *serial) struct mct_u232_private *priv; struct usb_serial_port *port, *rport; - priv = kmalloc(sizeof(struct mct_u232_private), GFP_KERNEL); + priv = kzalloc(sizeof(struct mct_u232_private), GFP_KERNEL); if (!priv) return -ENOMEM; - memset(priv, 0, sizeof(struct mct_u232_private)); spin_lock_init(&priv->lock); usb_set_serial_port_data(serial->port[0], priv); diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 52bdf6fe46f..a8455c9e79d 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -631,13 +631,12 @@ static int option_startup(struct usb_serial *serial) /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; - portdata = kmalloc(sizeof(*portdata), GFP_KERNEL); + portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); if (!portdata) { dbg("%s: kmalloc for option_port_private (%d) failed!.", __FUNCTION__, i); return (1); } - memset(portdata, 0, sizeof(struct option_port_private)); usb_set_serial_port_data(port, portdata); diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 37c81c08faa..cf2213bae0e 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -218,10 +218,9 @@ static int pl2303_startup (struct usb_serial *serial) dbg("device type: %d", type); for (i = 0; i < serial->num_ports; ++i) { - priv = kmalloc (sizeof (struct pl2303_private), GFP_KERNEL); + priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL); if (!priv) goto cleanup; - memset (priv, 0x00, sizeof (struct pl2303_private)); spin_lock_init(&priv->lock); priv->buf = pl2303_buf_alloc(PL2303_BUF_SIZE); if (priv->buf == NULL) { @@ -383,12 +382,11 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol } } - buf = kmalloc (7, GFP_KERNEL); + buf = kzalloc (7, GFP_KERNEL); if (!buf) { dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); return; } - memset (buf, 0x00, 0x07); i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0), GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index c18db325707..c3a2071b802 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -416,12 +416,11 @@ static int ti_startup(struct usb_serial *serial) dev->actconfig->desc.bConfigurationValue); /* create device structure */ - tdev = kmalloc(sizeof(struct ti_device), GFP_KERNEL); + tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL); if (tdev == NULL) { dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); return -ENOMEM; } - memset(tdev, 0, sizeof(struct ti_device)); sema_init(&tdev->td_open_close_sem, 1); tdev->td_serial = serial; usb_set_serial_data(serial, tdev); diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index b5c96e74a90..097f4e8488f 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -564,12 +564,11 @@ static struct usb_serial * create_serial (struct usb_device *dev, { struct usb_serial *serial; - serial = kmalloc (sizeof (*serial), GFP_KERNEL); + serial = kzalloc(sizeof(*serial), GFP_KERNEL); if (!serial) { dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); return NULL; } - memset (serial, 0, sizeof(*serial)); serial->dev = usb_get_dev(dev); serial->type = driver; serial->interface = interface; @@ -778,10 +777,9 @@ int usb_serial_probe(struct usb_interface *interface, serial->num_port_pointers = max_endpoints; dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints); for (i = 0; i < max_endpoints; ++i) { - port = kmalloc(sizeof(struct usb_serial_port), GFP_KERNEL); + port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); if (!port) goto probe_error; - memset(port, 0x00, sizeof(struct usb_serial_port)); port->number = i + serial->minor; port->serial = serial; spin_lock_init(&port->lock); diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 11a48d87475..f5c3841d484 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -763,10 +763,9 @@ static int generic_startup(struct usb_serial *serial) int i; for (i = 0; i < serial->num_ports; ++i) { - priv = kmalloc (sizeof(*priv), GFP_KERNEL); + priv = kzalloc (sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - memset (priv, 0x00, sizeof(*priv)); spin_lock_init(&priv->lock); usb_set_serial_port_data(serial->port[i], priv); } diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 7308e8cbe8f..6831dca93c1 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -1382,7 +1382,7 @@ static int isd200_init_info(struct us_data *us) } else US_DEBUGP("ERROR - kmalloc failure\n"); - return(retStatus); + return retStatus; } /************************************************************************** -- cgit v1.2.3-70-g09d2 From 1e7a5a84e407dfa20813a7f55413be8193ee5380 Mon Sep 17 00:00:00 2001 From: Phil Dibowitz Date: Sun, 5 Mar 2006 21:36:51 -0800 Subject: [PATCH] USB: storage: sandisk unusual_devices entry The following adds an unusual_devs entry for the SanDisk ImageMate CompactFlash USB drive, for the US_FL_FIX_CAPACITY flag. Additionally, it removes trailing whitespace from the previous entry. It's based on the patch sent by Roman Hodek . Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 31ca92056c2..a0d35583120 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -760,12 +760,19 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY ), -UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, +/* Submitted by Roman Hodek */ +UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, "Sandisk", "ImageMate SDDR-05a", US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN ), +UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009, + "SanDisk Corporation", + "ImageMate CompactFlash USB", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_FIX_CAPACITY ), + #ifdef CONFIG_USB_STORAGE_USBAT UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, "Sandisk", -- cgit v1.2.3-70-g09d2 From c713c973fb4bfdb22cce488cca4f9f8006ed58ce Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sun, 5 Mar 2006 21:43:40 -0800 Subject: [PATCH] USB: storage: another unusual_devs.h entry Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index a0d35583120..5d78fb42cb0 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -1080,6 +1080,16 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff, 0), #endif +/* + * Pete Zaitcev , bz#164688. + * The device blatantly ignores LUN and returns 1 in GetMaxLUN. + */ +UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100, + "Unknown", + "Unknown", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_SINGLE_LUN ), + /* Submitted by Joris Struyve */ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, "Medion", -- cgit v1.2.3-70-g09d2 From 23b7885d50c5f5fe6dca93d4b0913f6e7b878dad Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sun, 5 Mar 2006 21:45:44 -0800 Subject: [PATCH] USB: storage: unusual_devs.h entry 0420:0001 Ref https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=176584 Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 5d78fb42cb0..8310e86d745 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -120,6 +120,12 @@ UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_IGNORE_RESIDUE ), +/* Reported by Pete Zaitcev , bz#176584 */ +UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100, + "GENERIC", "MP3 PLAYER", /* MyMusix PD-205 on the outside. */ + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_IGNORE_RESIDUE ), + /* Reported by Olaf Hering from novell bug #105878 */ UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, "SMSC", -- cgit v1.2.3-70-g09d2 From 9d5847bc1a3977fbfb4057aad41458df89792309 Mon Sep 17 00:00:00 2001 From: Rodolfo Quesada Date: Mon, 6 Mar 2006 10:45:42 -0500 Subject: [PATCH] USB: storage: new unusual_devs.h entry: Mitsumi 7in1 Card Reader This patch (as661) adds an unusual_devs entry for the Mitsumi 7in1 Card Reader. From: Rodolfo Quesada Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/usb/storage') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 8310e86d745..c4a9dcff5f2 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -62,6 +62,13 @@ UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_SINGLE_LUN ), +/* Reported by Rodolfo Quesada */ +UNUSUAL_DEV( 0x03ee, 0x6906, 0x0003, 0x0003, + "VIA Technologies Inc.", + "Mitsumi multi cardreader", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_IGNORE_RESIDUE ), + UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200, "HP", "CD-Writer+", -- cgit v1.2.3-70-g09d2