diff options
Diffstat (limited to 'drivers')
160 files changed, 7787 insertions, 6375 deletions
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 52ddb04644a..4b07bdadb81 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -405,9 +405,11 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha static void xpad_irq_in(struct urb *urb) { struct usb_xpad *xpad = urb->context; - int retval; + int retval, status; - switch (urb->status) { + status = urb->status; + + switch (status) { case 0: /* success */ break; @@ -416,11 +418,11 @@ static void xpad_irq_in(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, urb->status); + __FUNCTION__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, urb->status); + __FUNCTION__, status); goto exit; } @@ -445,9 +447,11 @@ exit: #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS) static void xpad_irq_out(struct urb *urb) { - int retval; + int retval, status; - switch (urb->status) { + status = urb->status; + + switch (status) { case 0: /* success */ break; @@ -456,11 +460,11 @@ static void xpad_irq_out(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, urb->status); + __FUNCTION__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, urb->status); + __FUNCTION__, status); goto exit; } diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index a51eeedc18d..d470c72b737 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -444,7 +444,7 @@ CXACRU_ALL_FILES(INIT); /* the following three functions are stolen from drivers/usb/core/message.c */ static void cxacru_blocking_completion(struct urb *urb) { - complete((struct completion *)urb->context); + complete(urb->context); } static void cxacru_timeout_kill(unsigned long data) diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index c5ec1a55eee..abb7d7410e6 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -83,7 +83,7 @@ if (debug >= 1) \ dev_dbg(&(usb_dev)->dev, \ "[ueagle-atm dbg] %s: " format, \ - __FUNCTION__, ##args); \ + __func__, ##args); \ } while (0) #define uea_vdbg(usb_dev, format, args...) \ @@ -94,10 +94,10 @@ } while (0) #define uea_enters(usb_dev) \ - uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) + uea_vdbg(usb_dev, "entering %s\n", __func__) #define uea_leaves(usb_dev) \ - uea_vdbg(usb_dev, "leaving %s\n", __FUNCTION__) + uea_vdbg(usb_dev, "leaving %s\n", __func__) #define uea_err(usb_dev, format,args...) \ dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args) diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index e717f5b1cae..07228721caf 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c @@ -80,6 +80,7 @@ #include <linux/stat.h> #include <linux/timer.h> #include <linux/wait.h> +#include <linux/kthread.h> #ifdef VERBOSE_DEBUG static int usbatm_print_packet(const unsigned char *data, int len); @@ -1014,10 +1015,7 @@ static int usbatm_do_heavy_init(void *arg) struct usbatm_data *instance = arg; int ret; - daemonize(instance->driver->driver_name); allow_signal(SIGTERM); - instance->thread_pid = current->pid; - complete(&instance->thread_started); ret = instance->driver->heavy_init(instance, instance->usb_intf); @@ -1026,7 +1024,7 @@ static int usbatm_do_heavy_init(void *arg) ret = usbatm_atm_init(instance); mutex_lock(&instance->serialize); - instance->thread_pid = -1; + instance->thread = NULL; mutex_unlock(&instance->serialize); complete_and_exit(&instance->thread_exited, ret); @@ -1034,13 +1032,18 @@ static int usbatm_do_heavy_init(void *arg) static int usbatm_heavy_init(struct usbatm_data *instance) { - int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_FS | CLONE_FILES); - - if (ret < 0) { - usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); - return ret; + struct task_struct *t; + + t = kthread_create(usbatm_do_heavy_init, instance, + instance->driver->driver_name); + if (IS_ERR(t)) { + usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n", + __func__, PTR_ERR(t)); + return PTR_ERR(t); } + instance->thread = t; + wake_up_process(t); wait_for_completion(&instance->thread_started); return 0; @@ -1124,7 +1127,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ mutex_init(&instance->serialize); - instance->thread_pid = -1; + instance->thread = NULL; init_completion(&instance->thread_started); init_completion(&instance->thread_exited); @@ -1287,8 +1290,8 @@ void usbatm_usb_disconnect(struct usb_interface *intf) mutex_lock(&instance->serialize); instance->disconnected = 1; - if (instance->thread_pid >= 0) - kill_proc(instance->thread_pid, SIGTERM, 1); + if (instance->thread != NULL) + send_sig(SIGTERM, instance->thread, 1); mutex_unlock(&instance->serialize); wait_for_completion(&instance->thread_exited); diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index fc6c2be5999..e6887c6cf3c 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h @@ -175,7 +175,7 @@ struct usbatm_data { int disconnected; /* heavy init */ - int thread_pid; + struct task_struct *thread; struct completion thread_started; struct completion thread_exited; diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 0147ea39340..7b572e75e73 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -31,6 +31,7 @@ * v0.23 - use softirq for rx processing, as needed by tty layer * v0.24 - change probe method to evaluate CDC union descriptor * v0.25 - downstream tasks paralelized to maximize throughput + * v0.26 - multiple write urbs, writesize increased */ /* @@ -72,7 +73,7 @@ /* * Version Information */ -#define DRIVER_VERSION "v0.25" +#define DRIVER_VERSION "v0.26" #define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek" #define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters" @@ -118,7 +119,7 @@ static int acm_wb_alloc(struct acm *acm) int i, wbn; struct acm_wb *wb; - wbn = acm->write_current; + wbn = 0; i = 0; for (;;) { wb = &acm->wb[wbn]; @@ -132,11 +133,6 @@ static int acm_wb_alloc(struct acm *acm) } } -static void acm_wb_free(struct acm *acm, int wbn) -{ - acm->wb[wbn].use = 0; -} - static int acm_wb_is_avail(struct acm *acm) { int i, n; @@ -156,26 +152,22 @@ static inline int acm_wb_is_used(struct acm *acm, int wbn) /* * Finish write. */ -static void acm_write_done(struct acm *acm) +static void acm_write_done(struct acm *acm, struct acm_wb *wb) { unsigned long flags; - int wbn; spin_lock_irqsave(&acm->write_lock, flags); acm->write_ready = 1; - wbn = acm->write_current; - acm_wb_free(acm, wbn); - acm->write_current = (wbn + 1) % ACM_NW; + wb->use = 0; spin_unlock_irqrestore(&acm->write_lock, flags); } /* * Poke write. */ -static int acm_write_start(struct acm *acm) +static int acm_write_start(struct acm *acm, int wbn) { unsigned long flags; - int wbn; struct acm_wb *wb; int rc; @@ -190,24 +182,24 @@ static int acm_write_start(struct acm *acm) return 0; /* A white lie */ } - wbn = acm->write_current; if (!acm_wb_is_used(acm, wbn)) { spin_unlock_irqrestore(&acm->write_lock, flags); return 0; } wb = &acm->wb[wbn]; - acm->write_ready = 0; + if(acm_wb_is_avail(acm) <= 1) + acm->write_ready = 0; spin_unlock_irqrestore(&acm->write_lock, flags); - acm->writeurb->transfer_buffer = wb->buf; - acm->writeurb->transfer_dma = wb->dmah; - acm->writeurb->transfer_buffer_length = wb->len; - acm->writeurb->dev = acm->dev; + wb->urb->transfer_buffer = wb->buf; + wb->urb->transfer_dma = wb->dmah; + wb->urb->transfer_buffer_length = wb->len; + wb->urb->dev = acm->dev; - if ((rc = usb_submit_urb(acm->writeurb, GFP_ATOMIC)) < 0) { + if ((rc = usb_submit_urb(wb->urb, GFP_ATOMIC)) < 0) { dbg("usb_submit_urb(write bulk) failed: %d", rc); - acm_write_done(acm); + acm_write_done(acm, wb); } return rc; } @@ -268,10 +260,10 @@ static void acm_ctrl_irq(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, status); + dbg("%s - urb shutting down with status: %d", __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", __FUNCTION__, status); + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } @@ -315,7 +307,7 @@ exit: retval = usb_submit_urb (urb, GFP_ATOMIC); if (retval) err ("%s - usb_submit_urb failed with result %d", - __FUNCTION__, retval); + __func__, retval); } /* data interface returns incoming bytes, or we got unthrottled */ @@ -450,12 +442,13 @@ urbs: /* data interface wrote those outgoing bytes */ static void acm_write_bulk(struct urb *urb) { - struct acm *acm = (struct acm *)urb->context; + struct acm *acm; + struct acm_wb *wb = urb->context; dbg("Entering acm_write_bulk with status %d", urb->status); - acm_write_done(acm); - acm_write_start(acm); + acm = wb->instance; + acm_write_done(acm, wb); if (ACM_READY(acm)) schedule_work(&acm->work); } @@ -489,6 +482,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) else rv = 0; + set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); tty->driver_data = acm; acm->tty = tty; @@ -556,7 +550,8 @@ static void acm_tty_unregister(struct acm *acm) usb_put_intf(acm->control); acm_table[acm->minor] = NULL; usb_free_urb(acm->ctrlurb); - usb_free_urb(acm->writeurb); + for (i = 0; i < ACM_NW; i++) + usb_free_urb(acm->wb[i].urb); for (i = 0; i < nr; i++) usb_free_urb(acm->ru[i].urb); kfree(acm->country_codes); @@ -577,7 +572,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) if (acm->dev) { acm_set_control(acm, acm->ctrlout = 0); usb_kill_urb(acm->ctrlurb); - usb_kill_urb(acm->writeurb); + for (i = 0; i < ACM_NW; i++) + usb_kill_urb(acm->wb[i].urb); for (i = 0; i < nr; i++) usb_kill_urb(acm->ru[i].urb); usb_autopm_put_interface(acm->control); @@ -605,7 +601,6 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c spin_lock_irqsave(&acm->write_lock, flags); if ((wbn = acm_wb_alloc(acm)) < 0) { spin_unlock_irqrestore(&acm->write_lock, flags); - acm_write_start(acm); return 0; } wb = &acm->wb[wbn]; @@ -616,7 +611,7 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c wb->len = count; spin_unlock_irqrestore(&acm->write_lock, flags); - if ((stat = acm_write_start(acm)) < 0) + if ((stat = acm_write_start(acm, wbn)) < 0) return stat; return count; } @@ -809,7 +804,7 @@ static int acm_probe (struct usb_interface *intf, { struct usb_cdc_union_desc *union_header = NULL; struct usb_cdc_country_functional_desc *cfd = NULL; - char *buffer = intf->altsetting->extra; + unsigned char *buffer = intf->altsetting->extra; int buflen = intf->altsetting->extralen; struct usb_interface *control_interface; struct usb_interface *data_interface; @@ -886,9 +881,13 @@ static int acm_probe (struct usb_interface *intf, if ((call_management_function & 3) != 3) err("This device cannot do calls on its own. It is no modem."); break; - default: - err("Ignoring extra header, type %d, length %d", buffer[2], buffer[0]); + /* there are LOTS more CDC descriptors that + * could legitimately be found here. + */ + dev_dbg(&intf->dev, "Ignoring descriptor: " + "type %02x, length %d\n", + buffer[2], buffer[0]); break; } next_desc: @@ -976,7 +975,7 @@ skip_normal_probe: ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); readsize = le16_to_cpu(epread->wMaxPacketSize)* ( quirks == SINGLE_RX_URB ? 1 : 2); - acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize); + acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20; acm->control = control_interface; acm->data = data_interface; acm->minor = minor; @@ -1031,10 +1030,19 @@ skip_normal_probe: goto alloc_fail7; } } - acm->writeurb = usb_alloc_urb(0, GFP_KERNEL); - if (!acm->writeurb) { - dev_dbg(&intf->dev, "out of memory (writeurb kmalloc)\n"); - goto alloc_fail7; + for(i = 0; i < ACM_NW; i++) + { + struct acm_wb *snd = &(acm->wb[i]); + + if (!(snd->urb = usb_alloc_urb(0, GFP_KERNEL))) { + dev_dbg(&intf->dev, "out of memory (write urbs usb_alloc_urb)"); + goto alloc_fail7; + } + + usb_fill_bulk_urb(snd->urb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), + NULL, acm->writesize, acm_write_bulk, snd); + snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + snd->instance = acm; } usb_set_intfdata (intf, acm); @@ -1070,10 +1078,6 @@ skip_countries: acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; acm->ctrlurb->transfer_dma = acm->ctrl_dma; - usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), - NULL, acm->writesize, acm_write_bulk, acm); - acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP; - dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor); acm_set_control(acm, acm->ctrlout); @@ -1091,7 +1095,8 @@ skip_countries: return 0; alloc_fail8: - usb_free_urb(acm->writeurb); + for (i = 0; i < ACM_NW; i++) + usb_free_urb(acm->wb[i].urb); alloc_fail7: for (i = 0; i < num_rx_buf; i++) usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma); @@ -1115,7 +1120,8 @@ static void stop_data_traffic(struct acm *acm) tasklet_disable(&acm->urb_task); usb_kill_urb(acm->ctrlurb); - usb_kill_urb(acm->writeurb); + for(i = 0; i < ACM_NW; i++) + usb_kill_urb(acm->wb[i].urb); for (i = 0; i < acm->rx_buflimit; i++) usb_kill_urb(acm->ru[i].urb); diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index 8df6a57dcf9..046e064b033 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -59,7 +59,7 @@ * when processing onlcr, so we only need 2 buffers. These values must be * powers of 2. */ -#define ACM_NW 2 +#define ACM_NW 16 #define ACM_NR 16 struct acm_wb { @@ -67,6 +67,8 @@ struct acm_wb { dma_addr_t dmah; int len; int use; + struct urb *urb; + struct acm *instance; }; struct acm_rb { @@ -88,7 +90,7 @@ struct acm { struct usb_interface *control; /* control interface */ struct usb_interface *data; /* data interface */ struct tty_struct *tty; /* the corresponding tty */ - struct urb *ctrlurb, *writeurb; /* urbs */ + struct urb *ctrlurb; /* urbs */ u8 *ctrl_buffer; /* buffers of urbs */ dma_addr_t ctrl_dma; /* dma handles of buffers */ u8 *country_codes; /* country codes from device */ @@ -103,7 +105,6 @@ struct acm { struct list_head spare_read_urbs; struct list_head spare_read_bufs; struct list_head filled_read_bufs; - int write_current; /* current write buffer */ int write_used; /* number of non-empty write buffers */ int write_ready; /* write urb is not running */ spinlock_t write_lock; diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index a2b0aa48b8e..cc9f397e839 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig @@ -76,8 +76,8 @@ config USB_DEVICE_CLASS NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644" config USB_DYNAMIC_MINORS - bool "Dynamic USB minor allocation (EXPERIMENTAL)" - depends on USB && EXPERIMENTAL + bool "Dynamic USB minor allocation" + depends on USB help If you say Y here, the USB subsystem will use dynamic minor allocation for any device that uses the USB major number. @@ -102,31 +102,6 @@ config USB_SUSPEND If you are unsure about this, say N here. -config USB_PERSIST - bool "USB device persistence during system suspend (DANGEROUS)" - depends on USB && PM && EXPERIMENTAL - default n - help - - If you say Y here and enable the "power/persist" attribute - for a USB device, the device's data structures will remain - persistent across system suspend, even if the USB bus loses - power. (This includes hibernation, also known as swsusp or - suspend-to-disk.) The devices will reappear as if by magic - when the system wakes up, with no need to unmount USB - filesystems, rmmod host-controller drivers, or do anything - else. - - WARNING: This option can be dangerous! - - If a USB device is replaced by another of the same type while - the system is asleep, there's a good chance the kernel won't - detect the change. Likewise if the media in a USB storage - device is replaced. When this happens it's almost certain to - cause data corruption and maybe even crash your system. - - If you are unsure, say N here. - config USB_OTG bool depends on USB && EXPERIMENTAL @@ -136,14 +111,16 @@ config USB_OTG config USB_OTG_WHITELIST bool "Rely on OTG Targeted Peripherals List" - depends on USB_OTG - default y + depends on USB_OTG || EMBEDDED + default y if USB_OTG + default n if EMBEDDED help If you say Y here, the "otg_whitelist.h" file will be used as a product whitelist, so USB peripherals not listed there will be rejected during enumeration. This behavior is required by the USB OTG specification for all devices not on your product's - "Targeted Peripherals List". + "Targeted Peripherals List". "Embedded Hosts" are likewise + allowed to support only a limited number of peripherals. Otherwise, peripherals not listed there will only generate a warning and enumeration will continue. That's more like what @@ -152,9 +129,10 @@ config USB_OTG_WHITELIST config USB_OTG_BLACKLIST_HUB bool "Disable external hubs" - depends on USB_OTG + depends on USB_OTG || EMBEDDED help If you say Y here, then Linux will refuse to enumerate external hubs. OTG hosts are allowed to reduce hardware - and software costs by not supporting external hubs. + and software costs by not supporting external hubs. So + are "Emedded Hosts" that don't offer OTG support. diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index a92122a216b..568244c99bd 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -145,6 +145,23 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, endpoint->desc.wMaxPacketSize = cpu_to_le16(8); } + /* + * Some buggy high speed devices have bulk endpoints using + * maxpacket sizes other than 512. High speed HCDs may not + * be able to handle that particular bug, so let's warn... + */ + if (to_usb_device(ddev)->speed == USB_SPEED_HIGH + && usb_endpoint_xfer_bulk(d)) { + unsigned maxp; + + maxp = le16_to_cpu(endpoint->desc.wMaxPacketSize) & 0x07ff; + if (maxp != 512) + dev_warn(ddev, "config %d interface %d altsetting %d " + "bulk endpoint 0x%X has invalid maxpacket %d\n", + cfgno, inum, asnum, d->bEndpointAddress, + maxp); + } + /* Skip over any Class Specific or Vendor Specific descriptors; * find the next endpoint or interface descriptor */ endpoint->extra = buffer; diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index ae94176c64e..de17738f3ac 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -647,6 +647,7 @@ static int proc_control(struct dev_state *ps, void __user *arg) struct usbdevfs_ctrltransfer ctrl; unsigned int tmo; unsigned char *tbuf; + unsigned wLength; int i, j, ret; if (copy_from_user(&ctrl, arg, sizeof(ctrl))) @@ -654,7 +655,8 @@ static int proc_control(struct dev_state *ps, void __user *arg) ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex); if (ret) return ret; - if (ctrl.wLength > PAGE_SIZE) + wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ + if (wLength > PAGE_SIZE) return -EINVAL; tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); if (!tbuf) @@ -946,8 +948,11 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, int ret, ifnum = -1; int is_in; - if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP|USBDEVFS_URB_SHORT_NOT_OK| - URB_NO_FSBR|URB_ZERO_PACKET)) + if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP | + USBDEVFS_URB_SHORT_NOT_OK | + USBDEVFS_URB_NO_FSBR | + USBDEVFS_URB_ZERO_PACKET | + USBDEVFS_URB_NO_INTERRUPT)) return -EINVAL; if (!uurb->buffer) return -EINVAL; @@ -1102,8 +1107,24 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, as->urb->pipe = (uurb->type << 30) | __create_pipe(ps->dev, uurb->endpoint & 0xf) | (uurb->endpoint & USB_DIR_IN); - as->urb->transfer_flags = uurb->flags | - (is_in ? URB_DIR_IN : URB_DIR_OUT); + + /* This tedious sequence is necessary because the URB_* flags + * are internal to the kernel and subject to change, whereas + * the USBDEVFS_URB_* flags are a user API and must not be changed. + */ + u = (is_in ? URB_DIR_IN : URB_DIR_OUT); + if (uurb->flags & USBDEVFS_URB_ISO_ASAP) + u |= URB_ISO_ASAP; + if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK) + u |= URB_SHORT_NOT_OK; + if (uurb->flags & USBDEVFS_URB_NO_FSBR) + u |= URB_NO_FSBR; + if (uurb->flags & USBDEVFS_URB_ZERO_PACKET) + u |= URB_ZERO_PACKET; + if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT) + u |= URB_NO_INTERRUPT; + as->urb->transfer_flags = u; + as->urb->transfer_buffer_length = uurb->buffer_length; as->urb->setup_packet = (unsigned char *)dr; as->urb->start_frame = uurb->start_frame; @@ -1509,60 +1530,60 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, switch (cmd) { case USBDEVFS_CONTROL: - snoop(&dev->dev, "%s: CONTROL\n", __FUNCTION__); + snoop(&dev->dev, "%s: CONTROL\n", __func__); ret = proc_control(ps, p); if (ret >= 0) inode->i_mtime = CURRENT_TIME; break; case USBDEVFS_BULK: - snoop(&dev->dev, "%s: BULK\n", __FUNCTION__); + snoop(&dev->dev, "%s: BULK\n", __func__); ret = proc_bulk(ps, p); if (ret >= 0) inode->i_mtime = CURRENT_TIME; break; case USBDEVFS_RESETEP: - snoop(&dev->dev, "%s: RESETEP\n", __FUNCTION__); + snoop(&dev->dev, "%s: RESETEP\n", __func__); ret = proc_resetep(ps, p); if (ret >= 0) inode->i_mtime = CURRENT_TIME; break; case USBDEVFS_RESET: - snoop(&dev->dev, "%s: RESET\n", __FUNCTION__); + snoop(&dev->dev, "%s: RESET\n", __func__); ret = proc_resetdevice(ps); break; case USBDEVFS_CLEAR_HALT: - snoop(&dev->dev, "%s: CLEAR_HALT\n", __FUNCTION__); + snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__); ret = proc_clearhalt(ps, p); if (ret >= 0) inode->i_mtime = CURRENT_TIME; break; case USBDEVFS_GETDRIVER: - snoop(&dev->dev, "%s: GETDRIVER\n", __FUNCTION__); + snoop(&dev->dev, "%s: GETDRIVER\n", __func__); ret = proc_getdriver(ps, p); break; case USBDEVFS_CONNECTINFO: - snoop(&dev->dev, "%s: CONNECTINFO\n", __FUNCTION__); + snoop(&dev->dev, "%s: CONNECTINFO\n", __func__); ret = proc_connectinfo(ps, p); break; case USBDEVFS_SETINTERFACE: - snoop(&dev->dev, "%s: SETINTERFACE\n", __FUNCTION__); + snoop(&dev->dev, "%s: SETINTERFACE\n", __func__); ret = proc_setintf(ps, p); break; case USBDEVFS_SETCONFIGURATION: - snoop(&dev->dev, "%s: SETCONFIGURATION\n", __FUNCTION__); + snoop(&dev->dev, "%s: SETCONFIGURATION\n", __func__); ret = proc_setconfig(ps, p); break; case USBDEVFS_SUBMITURB: - snoop(&dev->dev, "%s: SUBMITURB\n", __FUNCTION__); + snoop(&dev->dev, "%s: SUBMITURB\n", __func__); ret = proc_submiturb(ps, p); if (ret >= 0) inode->i_mtime = CURRENT_TIME; @@ -1571,60 +1592,60 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, #ifdef CONFIG_COMPAT case USBDEVFS_SUBMITURB32: - snoop(&dev->dev, "%s: SUBMITURB32\n", __FUNCTION__); + snoop(&dev->dev, "%s: SUBMITURB32\n", __func__); ret = proc_submiturb_compat(ps, p); if (ret >= 0) inode->i_mtime = CURRENT_TIME; break; case USBDEVFS_REAPURB32: - snoop(&dev->dev, "%s: REAPURB32\n", __FUNCTION__); + snoop(&dev->dev, "%s: REAPURB32\n", __func__); ret = proc_reapurb_compat(ps, p); break; case USBDEVFS_REAPURBNDELAY32: - snoop(&dev->dev, "%s: REAPURBDELAY32\n", __FUNCTION__); + snoop(&dev->dev, "%s: REAPURBDELAY32\n", __func__); ret = proc_reapurbnonblock_compat(ps, p); break; case USBDEVFS_IOCTL32: - snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); + snoop(&dev->dev, "%s: IOCTL\n", __func__); ret = proc_ioctl_compat(ps, ptr_to_compat(p)); break; #endif case USBDEVFS_DISCARDURB: - snoop(&dev->dev, "%s: DISCARDURB\n", __FUNCTION__); + snoop(&dev->dev, "%s: DISCARDURB\n", __func__); ret = proc_unlinkurb(ps, p); break; case USBDEVFS_REAPURB: - snoop(&dev->dev, "%s: REAPURB\n", __FUNCTION__); + snoop(&dev->dev, "%s: REAPURB\n", __func__); ret = proc_reapurb(ps, p); break; case USBDEVFS_REAPURBNDELAY: - snoop(&dev->dev, "%s: REAPURBDELAY\n", __FUNCTION__); + snoop(&dev->dev, "%s: REAPURBDELAY\n", __func__); ret = proc_reapurbnonblock(ps, p); break; case USBDEVFS_DISCSIGNAL: - snoop(&dev->dev, "%s: DISCSIGNAL\n", __FUNCTION__); + snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__); ret = proc_disconnectsignal(ps, p); break; case USBDEVFS_CLAIMINTERFACE: - snoop(&dev->dev, "%s: CLAIMINTERFACE\n", __FUNCTION__); + snoop(&dev->dev, "%s: CLAIMINTERFACE\n", __func__); ret = proc_claiminterface(ps, p); break; case USBDEVFS_RELEASEINTERFACE: - snoop(&dev->dev, "%s: RELEASEINTERFACE\n", __FUNCTION__); + snoop(&dev->dev, "%s: RELEASEINTERFACE\n", __func__); ret = proc_releaseinterface(ps, p); break; case USBDEVFS_IOCTL: - snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); + snoop(&dev->dev, "%s: IOCTL\n", __func__); ret = proc_ioctl_default(ps, p); break; } diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 801b6f142fa..1e56f1cfa6d 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -157,7 +157,7 @@ static int usb_probe_device(struct device *dev) struct usb_device *udev; int error = -ENODEV; - dev_dbg(dev, "%s\n", __FUNCTION__); + dev_dbg(dev, "%s\n", __func__); if (!is_usb_device(dev)) /* Sanity check */ return error; @@ -194,7 +194,7 @@ static int usb_probe_interface(struct device *dev) const struct usb_device_id *id; int error = -ENODEV; - dev_dbg(dev, "%s\n", __FUNCTION__); + dev_dbg(dev, "%s\n", __func__); if (is_usb_device(dev)) /* Sanity check */ return error; @@ -211,7 +211,7 @@ static int usb_probe_interface(struct device *dev) if (!id) id = usb_match_dynamic_id(intf, driver); if (id) { - dev_dbg(dev, "%s - got id\n", __FUNCTION__); + dev_dbg(dev, "%s - got id\n", __func__); error = usb_autoresume_device(udev); if (error) @@ -793,9 +793,7 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) status = udriver->suspend(udev, msg); done: - dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); - if (status == 0) - udev->dev.power.power_state.event = msg.event; + dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); return status; } @@ -823,11 +821,9 @@ static int usb_resume_device(struct usb_device *udev) status = udriver->resume(udev); done: - dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); - if (status == 0) { + dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); + if (status == 0) udev->autoresume_disabled = 0; - udev->dev.power.power_state.event = PM_EVENT_ON; - } return status; } @@ -864,7 +860,7 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) } done: - dev_vdbg(&intf->dev, "%s: status %d\n", __FUNCTION__, status); + dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); return status; } @@ -914,7 +910,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume) } done: - dev_vdbg(&intf->dev, "%s: status %d\n", __FUNCTION__, status); + dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); if (status == 0) mark_active(intf); @@ -936,7 +932,6 @@ static int autosuspend_check(struct usb_device *udev, int reschedule) * is disabled. Also fail if any interfaces require remote wakeup * but it isn't available. */ - udev->do_remote_wakeup = device_may_wakeup(&udev->dev); if (udev->pm_usage_cnt > 0) return -EBUSY; if (udev->autosuspend_delay < 0 || udev->autosuspend_disabled) @@ -1098,7 +1093,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) } done: - dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); + dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); return status; } @@ -1180,8 +1175,7 @@ static int usb_resume_both(struct usb_device *udev) } } else { - /* Needed for setting udev->dev.power.power_state.event, - * for possible debugging message, and for reset_resume. */ + /* Needed for reset-resume */ status = usb_resume_device(udev); } @@ -1193,8 +1187,9 @@ static int usb_resume_both(struct usb_device *udev) } done: - dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); - udev->reset_resume = 0; + dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); + if (!status) + udev->reset_resume = 0; return status; } @@ -1262,7 +1257,7 @@ void usb_autosuspend_device(struct usb_device *udev) status = usb_autopm_do_device(udev, -1); dev_vdbg(&udev->dev, "%s: cnt %d\n", - __FUNCTION__, udev->pm_usage_cnt); + __func__, udev->pm_usage_cnt); } /** @@ -1282,7 +1277,7 @@ void usb_try_autosuspend_device(struct usb_device *udev) { usb_autopm_do_device(udev, 0); dev_vdbg(&udev->dev, "%s: cnt %d\n", - __FUNCTION__, udev->pm_usage_cnt); + __func__, udev->pm_usage_cnt); } /** @@ -1310,7 +1305,7 @@ int usb_autoresume_device(struct usb_device *udev) status = usb_autopm_do_device(udev, 1); dev_vdbg(&udev->dev, "%s: status %d cnt %d\n", - __FUNCTION__, status, udev->pm_usage_cnt); + __func__, status, udev->pm_usage_cnt); return status; } @@ -1382,7 +1377,7 @@ void usb_autopm_put_interface(struct usb_interface *intf) status = usb_autopm_do_interface(intf, -1); dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", - __FUNCTION__, status, intf->pm_usage_cnt); + __func__, status, intf->pm_usage_cnt); } EXPORT_SYMBOL_GPL(usb_autopm_put_interface); @@ -1426,7 +1421,7 @@ int usb_autopm_get_interface(struct usb_interface *intf) status = usb_autopm_do_interface(intf, 1); dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", - __FUNCTION__, status, intf->pm_usage_cnt); + __func__, status, intf->pm_usage_cnt); return status; } EXPORT_SYMBOL_GPL(usb_autopm_get_interface); @@ -1448,7 +1443,7 @@ int usb_autopm_set_interface(struct usb_interface *intf) status = usb_autopm_do_interface(intf, 0); dev_vdbg(&intf->dev, "%s: status %d cnt %d\n", - __FUNCTION__, status, intf->pm_usage_cnt); + __func__, status, intf->pm_usage_cnt); return status; } EXPORT_SYMBOL_GPL(usb_autopm_set_interface); @@ -1523,9 +1518,14 @@ static int usb_suspend(struct device *dev, pm_message_t message) udev = to_usb_device(dev); /* If udev is already suspended, we can skip this suspend and - * we should also skip the upcoming system resume. */ + * we should also skip the upcoming system resume. High-speed + * root hubs are an exception; they need to resume whenever the + * system wakes up in order for USB-PERSIST port handover to work + * properly. + */ if (udev->state == USB_STATE_SUSPENDED) { - udev->skip_sys_resume = 1; + if (udev->parent || udev->speed != USB_SPEED_HIGH) + udev->skip_sys_resume = 1; return 0; } diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 84760ddbc33..5b87ae7f0a6 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -73,7 +73,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) if (pci_enable_device(dev) < 0) return -ENODEV; dev->current_state = PCI_D0; - dev->dev.power.power_state = PMSG_ON; if (!dev->irq) { dev_err(&dev->dev, @@ -216,9 +215,9 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message) hcd->state == HC_STATE_HALT)) return -EBUSY; - if (hcd->driver->suspend) { - retval = hcd->driver->suspend(hcd, message); - suspend_report_result(hcd->driver->suspend, retval); + if (hcd->driver->pci_suspend) { + retval = hcd->driver->pci_suspend(hcd, message); + suspend_report_result(hcd->driver->pci_suspend, retval); if (retval) goto done; } @@ -302,8 +301,6 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message) done: if (retval == 0) { - dev->dev.power.power_state = PMSG_SUSPEND; - #ifdef CONFIG_PPC_PMAC /* Disable ASIC clocks for USB */ if (machine_is(powermac)) { @@ -406,12 +403,10 @@ int usb_hcd_pci_resume(struct pci_dev *dev) pci_set_master(dev); pci_restore_state(dev); - dev->dev.power.power_state = PMSG_ON; - clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); - if (hcd->driver->resume) { - retval = hcd->driver->resume(hcd); + if (hcd->driver->pci_resume) { + retval = hcd->driver->pci_resume(hcd); if (retval) { dev_err(hcd->self.controller, "PCI post-resume error %d!\n", retval); diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index e52ed1663b3..bf10e9c4195 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -129,7 +129,7 @@ static const u8 usb2_rh_dev_descriptor [18] = { 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ - 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ + 0x00, /* __u8 bDeviceProtocol; [ usb 2.0 no TT ] */ 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ @@ -291,7 +291,6 @@ static int ascii2utf (char *s, u8 *utf, int utfmax) * rh_string - provides manufacturer, product and serial strings for root hub * @id: the string ID number (1: serial number, 2: product, 3: vendor) * @hcd: the host controller for this root hub - * @type: string describing our driver * @data: return packet in UTF-16 LE * @len: length of the return packet * @@ -355,9 +354,10 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) __attribute__((aligned(4))); const u8 *bufp = tbuf; int len = 0; - int patch_wakeup = 0; int status; int n; + u8 patch_wakeup = 0; + u8 patch_protocol = 0; might_sleep(); @@ -434,6 +434,8 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) else goto error; len = 18; + if (hcd->has_tt) + patch_protocol = 1; break; case USB_DT_CONFIG << 8: if (hcd->driver->flags & HCD_USB2) { @@ -528,6 +530,13 @@ error: bmAttributes)) ((struct usb_config_descriptor *)ubuf)->bmAttributes |= USB_CONFIG_ATT_WAKEUP; + + /* report whether RH hardware has an integrated TT */ + if (patch_protocol && + len > offsetof(struct usb_device_descriptor, + bDeviceProtocol)) + ((struct usb_device_descriptor *) ubuf)-> + bDeviceProtocol = 1; } /* any errors get returned through the urb completion */ @@ -915,15 +924,6 @@ static int register_root_hub(struct usb_hcd *hcd) return retval; } -void usb_enable_root_hub_irq (struct usb_bus *bus) -{ - struct usb_hcd *hcd; - - hcd = container_of (bus, struct usb_hcd, self); - if (hcd->driver->hub_irq_enable && hcd->state != HC_STATE_HALT) - hcd->driver->hub_irq_enable (hcd); -} - /*-------------------------------------------------------------------------*/ @@ -1677,7 +1677,6 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum); * usb_hcd_irq - hook IRQs to HCD framework (bus glue) * @irq: the IRQ being raised * @__hcd: pointer to the HCD whose IRQ is being signaled - * @r: saved hardware registers * * If the controller isn't HALTed, calls the driver's irq handler. * Checks whether the controller is now dead. diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 2d1c3d5e47b..1e4b81e9eb5 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -28,7 +28,7 @@ /* * USB Packet IDs (PIDs) */ -#define USB_PID_UNDEF_0 0xf0 +#define USB_PID_EXT 0xf0 /* USB 2.0 LPM ECN */ #define USB_PID_OUT 0xe1 #define USB_PID_ACK 0xd2 #define USB_PID_DATA0 0xc3 @@ -99,6 +99,7 @@ struct usb_hcd { unsigned poll_pending:1; /* status has changed? */ unsigned wireless:1; /* Wireless USB HCD */ unsigned authorized_default:1; + unsigned has_tt:1; /* Integrated TT in root hub */ int irq; /* irq allocated */ void __iomem *regs; /* device memory/io */ @@ -177,10 +178,10 @@ struct hc_driver { * a whole, not just the root hub; they're for PCI bus glue. */ /* called after suspending the hub, before entering D3 etc */ - int (*suspend) (struct usb_hcd *hcd, pm_message_t message); + int (*pci_suspend) (struct usb_hcd *hcd, pm_message_t message); /* called after entering D0 (etc), before resuming the hub */ - int (*resume) (struct usb_hcd *hcd); + int (*pci_resume) (struct usb_hcd *hcd); /* cleanly make HCD stop writing memory and doing I/O */ void (*stop) (struct usb_hcd *hcd); @@ -209,8 +210,6 @@ struct hc_driver { int (*bus_suspend)(struct usb_hcd *); int (*bus_resume)(struct usb_hcd *); int (*start_port_reset)(struct usb_hcd *, unsigned port_num); - void (*hub_irq_enable)(struct usb_hcd *); - /* Needed only if port-change IRQs are level-triggered */ /* force handover of high-speed port to full-speed companion */ void (*relinquish_port)(struct usb_hcd *, int); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 57aeca160f3..eb57fcc701d 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -30,12 +30,6 @@ #include "hcd.h" #include "hub.h" -#ifdef CONFIG_USB_PERSIST -#define USB_PERSIST 1 -#else -#define USB_PERSIST 0 -#endif - /* if we are in debug mode, always announce new devices */ #ifdef DEBUG #ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES @@ -333,6 +327,27 @@ static int get_port_status(struct usb_device *hdev, int port1, return status; } +static int hub_port_status(struct usb_hub *hub, int port1, + u16 *status, u16 *change) +{ + int ret; + + mutex_lock(&hub->status_mutex); + ret = get_port_status(hub->hdev, port1, &hub->status->port); + if (ret < 4) { + dev_err(hub->intfdev, + "%s failed (err = %d)\n", __func__, ret); + if (ret >= 0) + ret = -EIO; + } else { + *status = le16_to_cpu(hub->status->port.wPortStatus); + *change = le16_to_cpu(hub->status->port.wPortChange); + ret = 0; + } + mutex_unlock(&hub->status_mutex); + return ret; +} + static void kick_khubd(struct usb_hub *hub) { unsigned long flags; @@ -560,7 +575,7 @@ static int hub_hub_status(struct usb_hub *hub, ret = get_hub_status(hub->hdev, &hub->status->hub); if (ret < 0) dev_err (hub->intfdev, - "%s failed (err = %d)\n", __FUNCTION__, ret); + "%s failed (err = %d)\n", __func__, ret); else { *status = le16_to_cpu(hub->status->hub.wHubStatus); *change = le16_to_cpu(hub->status->hub.wHubChange); @@ -610,9 +625,8 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) } /* caller has locked the hub device */ -static int hub_pre_reset(struct usb_interface *intf) +static void hub_stop(struct usb_hub *hub) { - struct usb_hub *hub = usb_get_intfdata(intf); struct usb_device *hdev = hub->hdev; int i; @@ -622,6 +636,89 @@ static int hub_pre_reset(struct usb_interface *intf) usb_disconnect(&hdev->children[i]); } hub_quiesce(hub); +} + +#define HUB_RESET 1 +#define HUB_RESUME 2 +#define HUB_RESET_RESUME 3 + +#ifdef CONFIG_PM + +static void hub_restart(struct usb_hub *hub, int type) +{ + struct usb_device *hdev = hub->hdev; + int port1; + + /* Check each of the children to see if they require + * USB-PERSIST handling or disconnection. Also check + * each unoccupied port to make sure it is still disabled. + */ + for (port1 = 1; port1 <= hdev->maxchild; ++port1) { + struct usb_device *udev = hdev->children[port1-1]; + int status = 0; + u16 portstatus, portchange; + + if (!udev || udev->state == USB_STATE_NOTATTACHED) { + if (type != HUB_RESET) { + status = hub_port_status(hub, port1, + &portstatus, &portchange); + if (status == 0 && (portstatus & + USB_PORT_STAT_ENABLE)) + clear_port_feature(hdev, port1, + USB_PORT_FEAT_ENABLE); + } + continue; + } + + /* Was the power session lost while we were suspended? */ + switch (type) { + case HUB_RESET_RESUME: + portstatus = 0; + portchange = USB_PORT_STAT_C_CONNECTION; + break; + + case HUB_RESET: + case HUB_RESUME: + status = hub_port_status(hub, port1, + &portstatus, &portchange); + break; + } + + /* For "USB_PERSIST"-enabled children we must + * mark the child device for reset-resume and + * turn off the various status changes to prevent + * khubd from disconnecting it later. + */ + if (udev->persist_enabled && status == 0 && + !(portstatus & USB_PORT_STAT_ENABLE)) { + if (portchange & USB_PORT_STAT_C_ENABLE) + clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_ENABLE); + if (portchange & USB_PORT_STAT_C_CONNECTION) + clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_CONNECTION); + udev->reset_resume = 1; + } + + /* Otherwise for a reset_resume we must disconnect the child, + * but as we may not lock the child device here + * we have to do a "logical" disconnect. + */ + else if (type == HUB_RESET_RESUME) + hub_port_logical_disconnect(hub, port1); + } + + hub_activate(hub); +} + +#endif /* CONFIG_PM */ + +/* caller has locked the hub device */ +static int hub_pre_reset(struct usb_interface *intf) +{ + struct usb_hub *hub = usb_get_intfdata(intf); + + hub_stop(hub); return 0; } @@ -910,7 +1007,7 @@ static void hub_disconnect(struct usb_interface *intf) /* Disconnect all children and quiesce the hub */ hub->error = 0; - hub_pre_reset(intf); + hub_stop(hub); usb_set_intfdata (intf, NULL); @@ -1098,21 +1195,42 @@ void usb_set_device_state(struct usb_device *udev, spin_unlock_irqrestore(&device_state_lock, flags); } +/* + * WUSB devices are simple: they have no hubs behind, so the mapping + * device <-> virtual port number becomes 1:1. Why? to simplify the + * life of the device connection logic in + * drivers/usb/wusbcore/devconnect.c. When we do the initial secret + * handshake we need to assign a temporary address in the unauthorized + * space. For simplicity we use the first virtual port number found to + * be free [drivers/usb/wusbcore/devconnect.c:wusbhc_devconnect_ack()] + * and that becomes it's address [X < 128] or its unauthorized address + * [X | 0x80]. + * + * We add 1 as an offset to the one-based USB-stack port number + * (zero-based wusb virtual port index) for two reasons: (a) dev addr + * 0 is reserved by USB for default address; (b) Linux's USB stack + * uses always #1 for the root hub of the controller. So USB stack's + * port #1, which is wusb virtual-port #0 has address #2. + */ static void choose_address(struct usb_device *udev) { int devnum; struct usb_bus *bus = udev->bus; /* If khubd ever becomes multithreaded, this will need a lock */ - - /* Try to allocate the next devnum beginning at bus->devnum_next. */ - devnum = find_next_zero_bit(bus->devmap.devicemap, 128, - bus->devnum_next); - if (devnum >= 128) - devnum = find_next_zero_bit(bus->devmap.devicemap, 128, 1); - - bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1); - + if (udev->wusb) { + devnum = udev->portnum + 1; + BUG_ON(test_bit(devnum, bus->devmap.devicemap)); + } else { + /* Try to allocate the next devnum beginning at + * bus->devnum_next. */ + devnum = find_next_zero_bit(bus->devmap.devicemap, 128, + bus->devnum_next); + if (devnum >= 128) + devnum = find_next_zero_bit(bus->devmap.devicemap, + 128, 1); + bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1); + } if (devnum < 128) { set_bit(devnum, bus->devmap.devicemap); udev->devnum = devnum; @@ -1127,6 +1245,13 @@ static void release_address(struct usb_device *udev) } } +static void update_address(struct usb_device *udev, int devnum) +{ + /* The address for a WUSB device is managed by wusbcore. */ + if (!udev->wusb) + udev->devnum = devnum; +} + #ifdef CONFIG_USB_SUSPEND static void usb_stop_pm(struct usb_device *udev) @@ -1173,7 +1298,7 @@ void usb_disconnect(struct usb_device **pdev) int i; if (!udev) { - pr_debug ("%s nodev\n", __FUNCTION__); + pr_debug ("%s nodev\n", __func__); return; } @@ -1510,28 +1635,6 @@ out_authorized: } -static int hub_port_status(struct usb_hub *hub, int port1, - u16 *status, u16 *change) -{ - int ret; - - mutex_lock(&hub->status_mutex); - ret = get_port_status(hub->hdev, port1, &hub->status->port); - if (ret < 4) { - dev_err (hub->intfdev, - "%s failed (err = %d)\n", __FUNCTION__, ret); - if (ret >= 0) - ret = -EIO; - } else { - *status = le16_to_cpu(hub->status->port.wPortStatus); - *change = le16_to_cpu(hub->status->port.wPortChange); - ret = 0; - } - mutex_unlock(&hub->status_mutex); - return ret; -} - - /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ static unsigned hub_is_wusb(struct usb_hub *hub) { @@ -1637,7 +1740,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1, case 0: /* TRSTRCY = 10 ms; plus some extra */ msleep(10 + 40); - udev->devnum = 0; /* Device now at address 0 */ + update_address(udev, 0); /* FALL THROUGH */ case -ENOTCONN: case -ENODEV: @@ -1842,9 +1945,8 @@ static int finish_port_resume(struct usb_device *udev) * the host and the device is the same as it was when the device * suspended. * - * If CONFIG_USB_PERSIST and @udev->reset_resume are both set then this - * routine won't check that the port is still enabled. Furthermore, - * if @udev->reset_resume is set then finish_port_resume() above will + * If @udev->reset_resume is set then this routine won't check that the + * port is still enabled. Furthermore, finish_port_resume() above will * reset @udev. The end result is that a broken power session can be * recovered and @udev will appear to persist across a loss of VBUS power. * @@ -1856,8 +1958,8 @@ static int finish_port_resume(struct usb_device *udev) * to it will be lost. Using the USB_PERSIST facility, the device can be * made to appear as if it had not disconnected. * - * This facility is inherently dangerous. Although usb_reset_device() - * makes every effort to insure that the same device is present after the + * This facility can be dangerous. Although usb_reset_device() makes + * every effort to insure that the same device is present after the * reset as before, it cannot provide a 100% guarantee. Furthermore it's * quite possible for a device to remain unaltered but its media to be * changed. If the user replaces a flash memory card while the system is @@ -1902,7 +2004,7 @@ int usb_port_resume(struct usb_device *udev) status = hub_port_status(hub, port1, &portstatus, &portchange); SuspendCleared: - if (USB_PERSIST && udev->reset_resume) + if (udev->reset_resume) want_flags = USB_PORT_STAT_POWER | USB_PORT_STAT_CONNECTION; else @@ -1927,8 +2029,6 @@ int usb_port_resume(struct usb_device *udev) } clear_bit(port1, hub->busy_bits); - if (!hub->hdev->parent && !hub->busy_bits[0]) - usb_enable_root_hub_irq(hub->hdev->bus); if (status == 0) status = finish_port_resume(udev); @@ -2000,7 +2100,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) } } - dev_dbg(&intf->dev, "%s\n", __FUNCTION__); + dev_dbg(&intf->dev, "%s\n", __func__); /* stop khubd and related activity */ hub_quiesce(hub); @@ -2009,49 +2109,20 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) static int hub_resume(struct usb_interface *intf) { - struct usb_hub *hub = usb_get_intfdata (intf); - - dev_dbg(&intf->dev, "%s\n", __FUNCTION__); + struct usb_hub *hub = usb_get_intfdata(intf); - /* tell khubd to look for changes on this hub */ - hub_activate(hub); + dev_dbg(&intf->dev, "%s\n", __func__); + hub_restart(hub, HUB_RESUME); return 0; } static int hub_reset_resume(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); - struct usb_device *hdev = hub->hdev; - int port1; + dev_dbg(&intf->dev, "%s\n", __func__); hub_power_on(hub); - - for (port1 = 1; port1 <= hdev->maxchild; ++port1) { - struct usb_device *child = hdev->children[port1-1]; - - if (child) { - - /* For "USB_PERSIST"-enabled children we must - * mark the child device for reset-resume and - * turn off the connect-change status to prevent - * khubd from disconnecting it later. - */ - if (USB_PERSIST && child->persist_enabled) { - child->reset_resume = 1; - clear_port_feature(hdev, port1, - USB_PORT_FEAT_C_CONNECTION); - - /* Otherwise we must disconnect the child, - * but as we may not lock the child device here - * we have to do a "logical" disconnect. - */ - } else { - hub_port_logical_disconnect(hub, port1); - } - } - } - - hub_activate(hub); + hub_restart(hub, HUB_RESET_RESUME); return 0; } @@ -2061,10 +2132,10 @@ static int hub_reset_resume(struct usb_interface *intf) * * The USB host controller driver calls this function when its root hub * is resumed and Vbus power has been interrupted or the controller - * has been reset. The routine marks @rhdev as having lost power. When - * the hub driver is resumed it will take notice; if CONFIG_USB_PERSIST - * is enabled then it will carry out power-session recovery, otherwise - * it will disconnect all the child devices. + * has been reset. The routine marks @rhdev as having lost power. + * When the hub driver is resumed it will take notice and carry out + * power-session recovery for all the "USB-PERSIST"-enabled child devices; + * the others will be disconnected. */ void usb_root_hub_lost_power(struct usb_device *rhdev) { @@ -2147,12 +2218,13 @@ static int hub_port_debounce(struct usb_hub *hub, int port1) return portstatus; } -static void ep0_reinit(struct usb_device *udev) +void usb_ep0_reinit(struct usb_device *udev) { usb_disable_endpoint(udev, 0 + USB_DIR_IN); usb_disable_endpoint(udev, 0 + USB_DIR_OUT); usb_enable_endpoint(udev, &udev->ep0); } +EXPORT_SYMBOL_GPL(usb_ep0_reinit); #define usb_sndaddr0pipe() (PIPE_CONTROL << 30) #define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN) @@ -2171,9 +2243,10 @@ static int hub_set_address(struct usb_device *udev, int devnum) USB_REQ_SET_ADDRESS, 0, devnum, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); if (retval == 0) { - udev->devnum = devnum; /* Device now using proper address */ + /* Device now using proper address. */ + update_address(udev, devnum); usb_set_device_state(udev, USB_STATE_ADDRESS); - ep0_reinit(udev); + usb_ep0_reinit(udev); } return retval; } @@ -2355,26 +2428,33 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, #undef GET_DESCRIPTOR_BUFSIZE } - for (j = 0; j < SET_ADDRESS_TRIES; ++j) { - retval = hub_set_address(udev, devnum); - if (retval >= 0) + /* + * If device is WUSB, we already assigned an + * unauthorized address in the Connect Ack sequence; + * authorization will assign the final address. + */ + if (udev->wusb == 0) { + for (j = 0; j < SET_ADDRESS_TRIES; ++j) { + retval = hub_set_address(udev, devnum); + if (retval >= 0) + break; + msleep(200); + } + if (retval < 0) { + dev_err(&udev->dev, + "device not accepting address %d, error %d\n", + devnum, retval); + goto fail; + } + + /* cope with hardware quirkiness: + * - let SET_ADDRESS settle, some device hardware wants it + * - read ep0 maxpacket even for high and low speed, + */ + msleep(10); + if (USE_NEW_SCHEME(retry_counter)) break; - msleep(200); - } - if (retval < 0) { - dev_err(&udev->dev, - "device not accepting address %d, error %d\n", - devnum, retval); - goto fail; - } - - /* cope with hardware quirkiness: - * - let SET_ADDRESS settle, some device hardware wants it - * - read ep0 maxpacket even for high and low speed, - */ - msleep(10); - if (USE_NEW_SCHEME(retry_counter)) - break; + } retval = usb_get_device_descriptor(udev, 8); if (retval < 8) { @@ -2391,7 +2471,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, if (retval) goto fail; - i = udev->descriptor.bMaxPacketSize0 == 0xff? + i = udev->descriptor.bMaxPacketSize0 == 0xff? /* wusb device? */ 512 : udev->descriptor.bMaxPacketSize0; if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) { if (udev->speed != USB_SPEED_FULL || @@ -2402,7 +2482,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, } dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); - ep0_reinit(udev); + usb_ep0_reinit(udev); } retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); @@ -2419,7 +2499,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, fail: if (retval) { hub_port_disable(hub, port1, 0); - udev->devnum = devnum; /* for disconnect processing */ + update_address(udev, devnum); /* for disconnect processing */ } mutex_unlock(&usb_address0_mutex); return retval; @@ -2568,6 +2648,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, udev->speed = USB_SPEED_UNKNOWN; udev->bus_mA = hub->mA_per_port; udev->level = hdev->level + 1; + udev->wusb = hub_is_wusb(hub); /* set the address */ choose_address(udev); @@ -2657,12 +2738,13 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, loop_disable: hub_port_disable(hub, port1, 1); loop: - ep0_reinit(udev); + usb_ep0_reinit(udev); release_address(udev); usb_put_dev(udev); if ((status == -ENOTCONN) || (status == -ENOTSUPP)) break; } + dev_err(hub_dev, "unable to enumerate USB device on port %d\n", port1); done: hub_port_disable(hub, port1, 1); @@ -2726,7 +2808,7 @@ static void hub_events(void) /* If the hub has died, clean up after it */ if (hdev->state == USB_STATE_NOTATTACHED) { hub->error = -ENODEV; - hub_pre_reset(intf); + hub_stop(hub); goto loop; } @@ -2872,11 +2954,6 @@ static void hub_events(void) hub->activating = 0; - /* If this is a root hub, tell the HCD it's okay to - * re-enable port-change interrupts now. */ - if (!hdev->parent && !hub->busy_bits[0]) - usb_enable_root_hub_irq(hdev->bus); - loop_autopm: /* Allow autosuspend if we're not going to run again */ if (list_empty(&hub->event_list)) @@ -2890,7 +2967,13 @@ loop: static int hub_thread(void *__unused) { + /* khubd needs to be freezable to avoid intefering with USB-PERSIST + * port handover. Otherwise it might see that a full-speed device + * was gone before the EHCI controller had handed its port over to + * the companion full-speed controller. + */ set_freezable(); + do { hub_events(); wait_event_freezable(khubd_wait, @@ -2959,16 +3042,36 @@ void usb_hub_cleanup(void) usb_deregister(&hub_driver); } /* usb_hub_cleanup() */ -static int config_descriptors_changed(struct usb_device *udev) +static int descriptors_changed(struct usb_device *udev, + struct usb_device_descriptor *old_device_descriptor) { - unsigned index; - unsigned len = 0; - struct usb_config_descriptor *buf; + int changed = 0; + unsigned index; + unsigned serial_len = 0; + unsigned len; + unsigned old_length; + int length; + char *buf; + + if (memcmp(&udev->descriptor, old_device_descriptor, + sizeof(*old_device_descriptor)) != 0) + return 1; + /* Since the idVendor, idProduct, and bcdDevice values in the + * device descriptor haven't changed, we will assume the + * Manufacturer and Product strings haven't changed either. + * But the SerialNumber string could be different (e.g., a + * different flash card of the same brand). + */ + if (udev->serial) + serial_len = strlen(udev->serial) + 1; + + len = serial_len; for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { - if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) - len = le16_to_cpu(udev->config[index].desc.wTotalLength); + old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); + len = max(len, old_length); } + buf = kmalloc(len, GFP_NOIO); if (buf == NULL) { dev_err(&udev->dev, "no mem to re-read configs after reset\n"); @@ -2976,25 +3079,41 @@ static int config_descriptors_changed(struct usb_device *udev) return 1; } for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { - int length; - int old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); - + old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf, old_length); - if (length < old_length) { + if (length != old_length) { dev_dbg(&udev->dev, "config index %d, error %d\n", index, length); + changed = 1; break; } if (memcmp (buf, udev->rawdescriptors[index], old_length) != 0) { dev_dbg(&udev->dev, "config index %d changed (#%d)\n", - index, buf->bConfigurationValue); + index, + ((struct usb_config_descriptor *) buf)-> + bConfigurationValue); + changed = 1; break; } } + + if (!changed && serial_len) { + length = usb_string(udev, udev->descriptor.iSerialNumber, + buf, serial_len); + if (length + 1 != serial_len) { + dev_dbg(&udev->dev, "serial string error %d\n", + length); + changed = 1; + } else if (memcmp(buf, udev->serial, length) != 0) { + dev_dbg(&udev->dev, "serial string changed\n"); + changed = 1; + } + } + kfree(buf); - return index != udev->descriptor.bNumConfigurations; + return changed; } /** @@ -3044,7 +3163,7 @@ int usb_reset_device(struct usb_device *udev) if (!parent_hdev) { /* this requires hcd-specific logic; see OHCI hc_restart() */ - dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__); + dev_dbg(&udev->dev, "%s for root hub!\n", __func__); return -EISDIR; } parent_hub = hdev_to_hub(parent_hdev); @@ -3054,21 +3173,18 @@ int usb_reset_device(struct usb_device *udev) /* ep0 maxpacket size may change; let the HCD know about it. * Other endpoints will be handled by re-enumeration. */ - ep0_reinit(udev); + usb_ep0_reinit(udev); ret = hub_port_init(parent_hub, udev, port1, i); if (ret >= 0 || ret == -ENOTCONN || ret == -ENODEV) break; } clear_bit(port1, parent_hub->busy_bits); - if (!parent_hdev->parent && !parent_hub->busy_bits[0]) - usb_enable_root_hub_irq(parent_hdev->bus); if (ret < 0) goto re_enumerate; /* Device might have changed firmware (DFU or similar) */ - if (memcmp(&udev->descriptor, &descriptor, sizeof descriptor) - || config_descriptors_changed (udev)) { + if (descriptors_changed(udev, &descriptor)) { dev_info(&udev->dev, "device firmware changed\n"); udev->descriptor = descriptor; /* for disconnect() calls */ goto re_enumerate; diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 1551aed65e0..2a116ce53c9 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -41,9 +41,10 @@ */ #define USB_PORT_FEAT_CONNECTION 0 #define USB_PORT_FEAT_ENABLE 1 -#define USB_PORT_FEAT_SUSPEND 2 +#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ #define USB_PORT_FEAT_OVER_CURRENT 3 #define USB_PORT_FEAT_RESET 4 +#define USB_PORT_FEAT_L1 5 /* L1 suspend */ #define USB_PORT_FEAT_POWER 8 #define USB_PORT_FEAT_LOWSPEED 9 #define USB_PORT_FEAT_HIGHSPEED 10 @@ -54,6 +55,7 @@ #define USB_PORT_FEAT_C_RESET 20 #define USB_PORT_FEAT_TEST 21 #define USB_PORT_FEAT_INDICATOR 22 +#define USB_PORT_FEAT_C_PORT_L1 23 /* * Hub Status and Hub Change results @@ -73,7 +75,8 @@ struct usb_port_status { #define USB_PORT_STAT_SUSPEND 0x0004 #define USB_PORT_STAT_OVERCURRENT 0x0008 #define USB_PORT_STAT_RESET 0x0010 -/* bits 5 to 7 are reserved */ +#define USB_PORT_STAT_L1 0x0020 +/* bits 6 to 7 are reserved */ #define USB_PORT_STAT_POWER 0x0100 #define USB_PORT_STAT_LOW_SPEED 0x0200 #define USB_PORT_STAT_HIGH_SPEED 0x0400 @@ -91,6 +94,7 @@ struct usb_port_status { #define USB_PORT_STAT_C_SUSPEND 0x0004 #define USB_PORT_STAT_C_OVERCURRENT 0x0008 #define USB_PORT_STAT_C_RESET 0x0010 +#define USB_PORT_STAT_C_L1 0x0020 /* * wHubCharacteristics (masks) @@ -191,5 +195,6 @@ struct usb_tt_clear { }; extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe); +extern void usb_ep0_reinit(struct usb_device *); #endif /* __LINUX_HUB_H */ diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 83a373e9cc3..8607846e3c3 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -463,13 +463,13 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent) inode = usbfs_get_inode(sb, S_IFDIR | 0755, 0); if (!inode) { - dbg("%s: could not get inode!",__FUNCTION__); + dbg("%s: could not get inode!",__func__); return -ENOMEM; } root = d_alloc_root(inode); if (!root) { - dbg("%s: could not get root dentry!",__FUNCTION__); + dbg("%s: could not get root dentry!",__func__); iput(inode); return -ENOMEM; } diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index c311f67b7f0..e819e5359d5 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -312,7 +312,7 @@ static void sg_complete(struct urb *urb) retval != -EBUSY) dev_err(&io->dev->dev, "%s, unlink --> %d\n", - __FUNCTION__, retval); + __func__, retval); } else if (urb == io->urbs [i]) found = 1; } @@ -550,7 +550,7 @@ void usb_sg_wait(struct usb_sg_request *io) io->urbs[i]->dev = NULL; io->urbs[i]->status = retval; dev_dbg(&io->dev->dev, "%s, submit --> %d\n", - __FUNCTION__, retval); + __func__, retval); usb_sg_cancel(io); } spin_lock_irq(&io->lock); @@ -600,7 +600,7 @@ void usb_sg_cancel(struct usb_sg_request *io) retval = usb_unlink_urb(io->urbs [i]); if (retval != -EINPROGRESS && retval != -EBUSY) dev_warn(&io->dev->dev, "%s, unlink --> %d\n", - __FUNCTION__, retval); + __func__, retval); } spin_lock(&io->lock); } @@ -784,7 +784,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) if (size <= 0 || !buf || !index) return -EINVAL; buf[0] = 0; - tbuf = kmalloc(256, GFP_KERNEL); + tbuf = kmalloc(256, GFP_NOIO); if (!tbuf) return -ENOMEM; @@ -1068,7 +1068,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) { int i; - dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, + dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__, skip_ep0 ? "non-ep0" : "all"); for (i = skip_ep0; i < 16; ++i) { usb_disable_endpoint(dev, i); @@ -1089,8 +1089,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) continue; dev_dbg(&dev->dev, "unregistering interface %s\n", interface->dev.bus_id); - usb_remove_sysfs_intf_files(interface); device_del(&interface->dev); + usb_remove_sysfs_intf_files(interface); } /* Now that the interfaces are unbound, nobody should @@ -1231,7 +1231,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) */ /* prevent submissions using previous endpoint settings */ - if (iface->cur_altsetting != alt && device_is_registered(&iface->dev)) + if (iface->cur_altsetting != alt) usb_remove_sysfs_intf_files(iface); usb_disable_interface(dev, iface); @@ -1330,8 +1330,7 @@ int usb_reset_configuration(struct usb_device *dev) struct usb_interface *intf = config->interface[i]; struct usb_host_interface *alt; - if (device_is_registered(&intf->dev)) - usb_remove_sysfs_intf_files(intf); + usb_remove_sysfs_intf_files(intf); alt = usb_altnum_to_altsetting(intf, 0); /* No altsetting 0? We'll assume the first altsetting. diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index dfc5418ea10..2e201939029 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -97,4 +97,18 @@ void usb_detect_quirks(struct usb_device *udev) if (udev->descriptor.bDeviceClass != USB_CLASS_HUB) udev->autosuspend_disabled = 1; #endif + + /* For the present, all devices default to USB-PERSIST enabled */ +#if 0 /* was: #ifdef CONFIG_PM */ + /* Hubs are automatically enabled for USB-PERSIST */ + if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) + udev->persist_enabled = 1; + +#else + /* In the absence of PM, we can safely enable USB-PERSIST + * for all devices. It will affect things like hub resets + * and EMF-related port disables. + */ + udev->persist_enabled = 1; +#endif /* CONFIG_PM */ } diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index a37ccbd1e00..5b20a60de8b 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -180,11 +180,9 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf) static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL); -#if defined(CONFIG_USB_PERSIST) || defined(CONFIG_USB_SUSPEND) -static const char power_group[] = "power"; -#endif +#ifdef CONFIG_PM -#ifdef CONFIG_USB_PERSIST +static const char power_group[] = "power"; static ssize_t show_persist(struct device *dev, struct device_attribute *attr, char *buf) @@ -222,12 +220,13 @@ static int add_persist_attributes(struct device *dev) if (is_usb_device(dev)) { struct usb_device *udev = to_usb_device(dev); - /* Hubs are automatically enabled for USB_PERSIST */ - if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) - udev->persist_enabled = 1; - rc = sysfs_add_file_to_group(&dev->kobj, - &dev_attr_persist.attr, - power_group); + /* Hubs are automatically enabled for USB_PERSIST, + * no point in creating the attribute file. + */ + if (udev->descriptor.bDeviceClass != USB_CLASS_HUB) + rc = sysfs_add_file_to_group(&dev->kobj, + &dev_attr_persist.attr, + power_group); } return rc; } @@ -238,13 +237,12 @@ static void remove_persist_attributes(struct device *dev) &dev_attr_persist.attr, power_group); } - #else #define add_persist_attributes(dev) 0 #define remove_persist_attributes(dev) do {} while (0) -#endif /* CONFIG_USB_PERSIST */ +#endif /* CONFIG_PM */ #ifdef CONFIG_USB_SUSPEND diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 9d7e63292c0..c0b1ae25ae2 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -334,7 +334,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) dev_dbg(&dev->dev, "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n", usb_endpoint_num(&ep->desc), is_out ? "out" : "in", - __FUNCTION__, max); + __func__, max); return -EMSGSIZE; } @@ -590,6 +590,30 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor) EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); /** + * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse + * @anchor: anchor the requests are bound to + * + * this allows all outstanding URBs to be unlinked starting + * from the back of the queue. This function is asynchronous. + * The unlinking is just tiggered. It may happen after this + * function has returned. + */ +void usb_unlink_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + + spin_lock_irq(&anchor->lock); + while (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); + /* this will unanchor the URB */ + usb_unlink_urb(victim); + } + spin_unlock_irq(&anchor->lock); +} +EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); + +/** * usb_wait_anchor_empty_timeout - wait for an anchor to be unused * @anchor: the anchor you want to become unused * @timeout: how long you are willing to wait in milliseconds diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 2375194a9d4..1bf8ccb9c58 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -114,13 +114,11 @@ static inline int is_usb_device_driver(struct device_driver *drv) static inline void mark_active(struct usb_interface *f) { f->is_active = 1; - f->dev.power.power_state.event = PM_EVENT_ON; } static inline void mark_quiesced(struct usb_interface *f) { f->is_active = 0; - f->dev.power.power_state.event = PM_EVENT_SUSPEND; } static inline int is_active(const struct usb_interface *f) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index d681bb27fa5..f7b54651dd4 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -44,8 +44,8 @@ menuconfig USB_GADGET if USB_GADGET config USB_GADGET_DEBUG - boolean "Debugging messages" - depends on USB_GADGET && DEBUG_KERNEL && EXPERIMENTAL + boolean "Debugging messages (DEVELOPMENT)" + depends on USB_GADGET && DEBUG_KERNEL help Many controller and gadget drivers will print some debugging messages if you use this option to ask for those messages. @@ -58,7 +58,7 @@ config USB_GADGET_DEBUG production build. config USB_GADGET_DEBUG_FILES - boolean "Debugging information files" + boolean "Debugging information files (DEVELOPMENT)" depends on USB_GADGET && PROC_FS help Some of the drivers in the "gadget" framework can expose @@ -69,7 +69,7 @@ config USB_GADGET_DEBUG_FILES here. If in doubt, or to conserve kernel memory, say "N". config USB_GADGET_DEBUG_FS - boolean "Debugging information files in debugfs" + boolean "Debugging information files in debugfs (DEVELOPMENT)" depends on USB_GADGET && DEBUG_FS help Some of the drivers in the "gadget" framework can expose @@ -337,7 +337,7 @@ config USB_AT91 config USB_GADGET_DUMMY_HCD boolean "Dummy HCD (DEVELOPMENT)" - depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL + depends on USB=y || (USB=m && USB_GADGET=m) select USB_GADGET_DUALSPEED help This host controller driver emulates USB, looping all data transfer @@ -404,7 +404,6 @@ choice config USB_ZERO tristate "Gadget Zero (DEVELOPMENT)" - depends on EXPERIMENTAL help Gadget Zero is a two-configuration device. It either sinks and sources bulk data; or it loops back a configurable number of @@ -468,8 +467,8 @@ config USB_ETH dynamically linked module called "g_ether". config USB_ETH_RNDIS - bool "RNDIS support (EXPERIMENTAL)" - depends on USB_ETH && EXPERIMENTAL + bool "RNDIS support" + depends on USB_ETH default y help Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, @@ -495,6 +494,9 @@ config USB_GADGETFS All endpoints, transfer speeds, and transfer types supported by the hardware are available, through read() and write() calls. + Currently, this option is still labelled as EXPERIMENTAL because + of existing race conditions in the underlying in-kernel AIO core. + Say "y" to link the driver statically, or "m" to build a dynamically linked module called "gadgetfs". diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index b663f23f264..fc6f3483be4 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c @@ -3248,6 +3248,8 @@ static int udc_pci_probe( /* pci setup */ if (pci_enable_device(pdev) < 0) { + kfree(dev); + dev = 0; retval = -ENODEV; goto finished; } @@ -3259,6 +3261,8 @@ static int udc_pci_probe( if (!request_mem_region(resource, len, name)) { dev_dbg(&pdev->dev, "pci device used already\n"); + kfree(dev); + dev = 0; retval = -EBUSY; goto finished; } @@ -3267,18 +3271,24 @@ static int udc_pci_probe( dev->virt_addr = ioremap_nocache(resource, len); if (dev->virt_addr == NULL) { dev_dbg(&pdev->dev, "start address cannot be mapped\n"); + kfree(dev); + dev = 0; retval = -EFAULT; goto finished; } if (!pdev->irq) { dev_err(&dev->pdev->dev, "irq not set\n"); + kfree(dev); + dev = 0; retval = -ENODEV; goto finished; } if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); + kfree(dev); + dev = 0; retval = -EBUSY; goto finished; } diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index fd15ced899d..9b913afb2e6 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -389,6 +389,7 @@ static int write_fifo(struct at91_ep *ep, struct at91_request *req) u32 csr = __raw_readl(creg); u8 __iomem *dreg = ep->creg + (AT91_UDP_FDR(0) - AT91_UDP_CSR(0)); unsigned total, count, is_last; + u8 *buf; /* * TODO: allow for writing two packets to the fifo ... that'll @@ -413,6 +414,8 @@ static int write_fifo(struct at91_ep *ep, struct at91_request *req) return 0; } + buf = req->req.buf + req->req.actual; + prefetch(buf); total = req->req.length - req->req.actual; if (ep->ep.maxpacket < total) { count = ep->ep.maxpacket; @@ -435,7 +438,7 @@ static int write_fifo(struct at91_ep *ep, struct at91_request *req) * recover when the actual bytecount matters (e.g. for USB Test * and Measurement Class devices). */ - __raw_writesb(dreg, req->req.buf + req->req.actual, count); + __raw_writesb(dreg, buf, count); csr &= ~SET_FX; csr |= CLR_FX | AT91_UDP_TXPKTRDY; __raw_writel(csr, creg); @@ -457,7 +460,7 @@ static void nuke(struct at91_ep *ep, int status) if (list_empty(&ep->queue)) return; - VDBG("%s %s\n", __FUNCTION__, ep->ep.name); + VDBG("%s %s\n", __func__, ep->ep.name); while (!list_empty(&ep->queue)) { req = list_entry(ep->queue.next, struct at91_request, queue); done(ep, req, status); @@ -792,7 +795,7 @@ static int at91_wakeup(struct usb_gadget *gadget) int status = -EINVAL; unsigned long flags; - DBG("%s\n", __FUNCTION__ ); + DBG("%s\n", __func__ ); local_irq_save(flags); if (!udc->clocked || !udc->suspended) diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index cbe44535c0f..66293105d13 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -365,16 +365,14 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) case USB_SPEED_HIGH: if (max == 512) break; - /* conserve return statements */ - default: - switch (max) { - case 8: case 16: case 32: case 64: + goto done; + case USB_SPEED_FULL: + if (max == 8 || max == 16 || max == 32 || max == 64) /* we'll fake any legal size */ break; - default: - case USB_SPEED_LOW: - goto done; - } + /* save a return statement */ + default: + goto done; } break; case USB_ENDPOINT_XFER_INT: @@ -894,13 +892,12 @@ static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state) { struct dummy *dum = platform_get_drvdata(pdev); - dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); + dev_dbg (&pdev->dev, "%s\n", __func__); spin_lock_irq (&dum->lock); dum->udc_suspended = 1; set_link_state (dum); spin_unlock_irq (&dum->lock); - pdev->dev.power.power_state = state; usb_hcd_poll_rh_status (dummy_to_hcd (dum)); return 0; } @@ -909,13 +906,12 @@ static int dummy_udc_resume (struct platform_device *pdev) { struct dummy *dum = platform_get_drvdata(pdev); - dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); + dev_dbg (&pdev->dev, "%s\n", __func__); spin_lock_irq (&dum->lock); dum->udc_suspended = 0; set_link_state (dum); spin_unlock_irq (&dum->lock); - pdev->dev.power.power_state = PMSG_ON; usb_hcd_poll_rh_status (dummy_to_hcd (dum)); return 0; } @@ -1711,7 +1707,7 @@ static int dummy_bus_suspend (struct usb_hcd *hcd) { struct dummy *dum = hcd_to_dummy (hcd); - dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); + dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); spin_lock_irq (&dum->lock); dum->rh_state = DUMMY_RH_SUSPENDED; @@ -1726,7 +1722,7 @@ static int dummy_bus_resume (struct usb_hcd *hcd) struct dummy *dum = hcd_to_dummy (hcd); int rc = 0; - dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); + dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); spin_lock_irq (&dum->lock); if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { @@ -1900,7 +1896,7 @@ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) struct dummy *dum; int rc = 0; - dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); + dev_dbg (&pdev->dev, "%s\n", __func__); hcd = platform_get_drvdata (pdev); dum = hcd_to_dummy (hcd); @@ -1916,7 +1912,7 @@ static int dummy_hcd_resume (struct platform_device *pdev) { struct usb_hcd *hcd; - dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); + dev_dbg (&pdev->dev, "%s\n", __func__); hcd = platform_get_drvdata (pdev); set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); @@ -1937,69 +1933,57 @@ static struct platform_driver dummy_hcd_driver = { /*-------------------------------------------------------------------------*/ -/* These don't need to do anything because the pdev structures are - * statically allocated. */ -static void -dummy_udc_release (struct device *dev) {} - -static void -dummy_hcd_release (struct device *dev) {} - -static struct platform_device the_udc_pdev = { - .name = (char *) gadget_name, - .id = -1, - .dev = { - .release = dummy_udc_release, - }, -}; - -static struct platform_device the_hcd_pdev = { - .name = (char *) driver_name, - .id = -1, - .dev = { - .release = dummy_hcd_release, - }, -}; +static struct platform_device *the_udc_pdev; +static struct platform_device *the_hcd_pdev; static int __init init (void) { - int retval; + int retval = -ENOMEM; if (usb_disabled ()) return -ENODEV; - retval = platform_driver_register (&dummy_hcd_driver); - if (retval < 0) + the_hcd_pdev = platform_device_alloc(driver_name, -1); + if (!the_hcd_pdev) return retval; + the_udc_pdev = platform_device_alloc(gadget_name, -1); + if (!the_udc_pdev) + goto err_alloc_udc; - retval = platform_driver_register (&dummy_udc_driver); + retval = platform_driver_register(&dummy_hcd_driver); + if (retval < 0) + goto err_register_hcd_driver; + retval = platform_driver_register(&dummy_udc_driver); if (retval < 0) goto err_register_udc_driver; - retval = platform_device_register (&the_hcd_pdev); + retval = platform_device_add(the_hcd_pdev); if (retval < 0) - goto err_register_hcd; - - retval = platform_device_register (&the_udc_pdev); + goto err_add_hcd; + retval = platform_device_add(the_udc_pdev); if (retval < 0) - goto err_register_udc; + goto err_add_udc; return retval; -err_register_udc: - platform_device_unregister (&the_hcd_pdev); -err_register_hcd: - platform_driver_unregister (&dummy_udc_driver); +err_add_udc: + platform_device_del(the_hcd_pdev); +err_add_hcd: + platform_driver_unregister(&dummy_udc_driver); err_register_udc_driver: - platform_driver_unregister (&dummy_hcd_driver); + platform_driver_unregister(&dummy_hcd_driver); +err_register_hcd_driver: + platform_device_put(the_udc_pdev); +err_alloc_udc: + platform_device_put(the_hcd_pdev); return retval; } module_init (init); static void __exit cleanup (void) { - platform_device_unregister (&the_udc_pdev); - platform_device_unregister (&the_hcd_pdev); - platform_driver_unregister (&dummy_udc_driver); - platform_driver_unregister (&dummy_hcd_driver); + platform_device_unregister(the_udc_pdev); + platform_device_unregister(the_hcd_pdev); + platform_driver_unregister(&dummy_udc_driver); + platform_driver_unregister(&dummy_hcd_driver); } module_exit (cleanup); diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index f9d07108bc3..8bdad221fa9 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -34,12 +34,12 @@ /* we must assign addresses for configurable endpoints (like net2280) */ -static __devinitdata unsigned epnum; +static __initdata unsigned epnum; // #define MANY_ENDPOINTS #ifdef MANY_ENDPOINTS /* more than 15 configurable endpoints */ -static __devinitdata unsigned in_epnum; +static __initdata unsigned in_epnum; #endif @@ -59,7 +59,7 @@ static __devinitdata unsigned in_epnum; * NOTE: each endpoint is unidirectional, as specified by its USB * descriptor; and isn't specific to a configuration or altsetting. */ -static int __devinit +static int __init ep_matches ( struct usb_gadget *gadget, struct usb_ep *ep, @@ -186,7 +186,7 @@ ep_matches ( return 1; } -static struct usb_ep * __devinit +static struct usb_ep * __init find_ep (struct usb_gadget *gadget, const char *name) { struct usb_ep *ep; @@ -228,7 +228,7 @@ find_ep (struct usb_gadget *gadget, const char *name) * * On failure, this returns a null endpoint descriptor. */ -struct usb_ep * __devinit usb_ep_autoconfig ( +struct usb_ep * __init usb_ep_autoconfig ( struct usb_gadget *gadget, struct usb_endpoint_descriptor *desc ) @@ -295,7 +295,7 @@ struct usb_ep * __devinit usb_ep_autoconfig ( * state such as ep->driver_data and the record of assigned endpoints * used by usb_ep_autoconfig(). */ -void __devinit usb_ep_autoconfig_reset (struct usb_gadget *gadget) +void __init usb_ep_autoconfig_reset (struct usb_gadget *gadget) { struct usb_ep *ep; diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index e9987230814..bb93bdd7659 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -1102,7 +1102,7 @@ static void eth_reset_config (struct eth_dev *dev) if (dev->config == 0) return; - DEBUG (dev, "%s\n", __FUNCTION__); + DEBUG (dev, "%s\n", __func__); netif_stop_queue (dev->net); netif_carrier_off (dev->net); @@ -1263,7 +1263,7 @@ static void issue_start_status (struct eth_dev *dev) struct usb_cdc_notification *event; int value; - DEBUG (dev, "%s, flush old status first\n", __FUNCTION__); + DEBUG (dev, "%s, flush old status first\n", __func__); /* flush old status * @@ -1329,7 +1329,7 @@ static void rndis_command_complete (struct usb_ep *ep, struct usb_request *req) spin_lock(&dev->lock); status = rndis_msg_parser (dev->rndis_config, (u8 *) req->buf); if (status < 0) - ERROR(dev, "%s: rndis parse error %d\n", __FUNCTION__, status); + ERROR(dev, "%s: rndis parse error %d\n", __func__, status); spin_unlock(&dev->lock); } @@ -2113,7 +2113,7 @@ static int rndis_control_ack (struct net_device *net) static void eth_start (struct eth_dev *dev, gfp_t gfp_flags) { - DEBUG (dev, "%s\n", __FUNCTION__); + DEBUG (dev, "%s\n", __func__); /* fill the rx queue */ rx_fill (dev, gfp_flags); @@ -2133,7 +2133,7 @@ static int eth_open (struct net_device *net) { struct eth_dev *dev = netdev_priv(net); - DEBUG (dev, "%s\n", __FUNCTION__); + DEBUG (dev, "%s\n", __func__); if (netif_carrier_ok (dev->net)) eth_start (dev, GFP_KERNEL); return 0; @@ -2143,7 +2143,7 @@ static int eth_stop (struct net_device *net) { struct eth_dev *dev = netdev_priv(net); - VDEBUG (dev, "%s\n", __FUNCTION__); + VDEBUG (dev, "%s\n", __func__); netif_stop_queue (net); DEBUG (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n", @@ -2229,7 +2229,7 @@ eth_unbind (struct usb_gadget *gadget) set_gadget_data (gadget, NULL); } -static u8 __devinit nibble (unsigned char c) +static u8 __init nibble (unsigned char c) { if (likely (isdigit (c))) return c - '0'; @@ -2239,7 +2239,7 @@ static u8 __devinit nibble (unsigned char c) return 0; } -static int __devinit get_ether_addr(const char *str, u8 *dev_addr) +static int __init get_ether_addr(const char *str, u8 *dev_addr) { if (str) { unsigned i; @@ -2260,7 +2260,7 @@ static int __devinit get_ether_addr(const char *str, u8 *dev_addr) return 1; } -static int __devinit +static int __init eth_bind (struct usb_gadget *gadget) { struct eth_dev *dev; diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 017a196d041..bf3f946fd45 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -644,7 +644,7 @@ struct fsg_dev { unsigned long atomic_bitflags; #define REGISTERED 0 -#define CLEAR_BULK_HALTS 1 +#define IGNORE_BULK_OUT 1 #define SUSPENDED 2 struct usb_ep *bulk_in; @@ -1104,7 +1104,7 @@ static void ep0_complete(struct usb_ep *ep, struct usb_request *req) if (req->actual > 0) dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual); if (req->status || req->actual != req->length) - DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, + DBG(fsg, "%s --> %d, %u/%u\n", __func__, req->status, req->actual, req->length); if (req->status == -ECONNRESET) // Request was cancelled usb_ep_fifo_flush(ep); @@ -1125,7 +1125,7 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) struct fsg_buffhd *bh = req->context; if (req->status || req->actual != req->length) - DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, + DBG(fsg, "%s --> %d, %u/%u\n", __func__, req->status, req->actual, req->length); if (req->status == -ECONNRESET) // Request was cancelled usb_ep_fifo_flush(ep); @@ -1146,7 +1146,7 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) dump_msg(fsg, "bulk-out", req->buf, req->actual); if (req->status || req->actual != bh->bulk_out_intended_length) - DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, + DBG(fsg, "%s --> %d, %u/%u\n", __func__, req->status, req->actual, bh->bulk_out_intended_length); if (req->status == -ECONNRESET) // Request was cancelled @@ -1169,7 +1169,7 @@ static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) struct fsg_buffhd *bh = req->context; if (req->status || req->actual != req->length) - DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, + DBG(fsg, "%s --> %d, %u/%u\n", __func__, req->status, req->actual, req->length); if (req->status == -ECONNRESET) // Request was cancelled usb_ep_fifo_flush(ep); @@ -2936,8 +2936,8 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) struct usb_request *req = bh->outreq; struct bulk_cb_wrap *cbw = req->buf; - /* Was this a real packet? */ - if (req->status) + /* Was this a real packet? Should it be ignored? */ + if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) return -EINVAL; /* Is the CBW valid? */ @@ -2948,13 +2948,17 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) req->actual, le32_to_cpu(cbw->Signature)); - /* The Bulk-only spec says we MUST stall the bulk pipes! - * If we want to avoid stalls, set a flag so that we will - * clear the endpoint halts at the next reset. */ - if (!mod_data.can_stall) - set_bit(CLEAR_BULK_HALTS, &fsg->atomic_bitflags); - fsg_set_halt(fsg, fsg->bulk_out); + /* The Bulk-only spec says we MUST stall the IN endpoint + * (6.6.1), so it's unavoidable. It also says we must + * retain this state until the next reset, but there's + * no way to tell the controller driver it should ignore + * Clear-Feature(HALT) requests. + * + * We aren't required to halt the OUT endpoint; instead + * we can simply accept and discard any data received + * until the next reset. */ halt_bulk_in_endpoint(fsg); + set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); return -EINVAL; } @@ -3140,6 +3144,7 @@ reset: goto reset; fsg->bulk_out_enabled = 1; fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); + clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); if (transport_is_cbi()) { d = ep_desc(fsg->gadget, &fs_intr_in_desc, &hs_intr_in_desc); @@ -3321,11 +3326,8 @@ static void handle_exception(struct fsg_dev *fsg) /* In case we were forced against our will to halt a * bulk endpoint, clear the halt now. (The SuperH UDC * requires this.) */ - if (test_and_clear_bit(CLEAR_BULK_HALTS, - &fsg->atomic_bitflags)) { + if (test_and_clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) usb_ep_clear_halt(fsg->bulk_in); - usb_ep_clear_halt(fsg->bulk_out); - } if (transport_is_bbb()) { if (fsg->ep0_req_tag == exception_req_tag) diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 254012ad2b9..651b8270139 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c @@ -773,11 +773,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) /* catch various bogus parameters */ if (!_req || !req->req.complete || !req->req.buf || !list_empty(&req->queue)) { - VDBG("%s, bad params\n", __FUNCTION__); + VDBG("%s, bad params\n", __func__); return -EINVAL; } if (unlikely(!_ep || !ep->desc)) { - VDBG("%s, bad ep\n", __FUNCTION__); + VDBG("%s, bad ep\n", __func__); return -EINVAL; } if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index 9fb0b1ec852..98b1483ef6a 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h @@ -512,7 +512,7 @@ struct fsl_udc { #ifdef DEBUG #define DBG(fmt, args...) printk(KERN_DEBUG "[%s] " fmt "\n", \ - __FUNCTION__, ## args) + __func__, ## args) #else #define DBG(fmt, args...) do{}while(0) #endif diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 5b42ccd0035..ff3a8513e64 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -1149,7 +1149,7 @@ fail: /* * Creates an output endpoint, and initializes output ports. */ -static int __devinit gmidi_bind(struct usb_gadget *gadget) +static int __init gmidi_bind(struct usb_gadget *gadget) { struct gmidi_device *dev; struct usb_ep *in_ep, *out_ep; diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index d3e702576de..64a592cbbe7 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c @@ -692,7 +692,7 @@ static void abort_dma(struct goku_ep *ep, int status) req->req.actual = (curr - req->req.dma) + 1; req->req.status = status; - VDBG(ep->dev, "%s %s %s %d/%d\n", __FUNCTION__, ep->ep.name, + VDBG(ep->dev, "%s %s %s %d/%d\n", __func__, ep->ep.name, ep->is_in ? "IN" : "OUT", req->req.actual, req->req.length); @@ -826,7 +826,7 @@ static int goku_dequeue(struct usb_ep *_ep, struct usb_request *_req) if (dev->ep0state == EP0_SUSPEND) return -EBUSY; - VDBG(dev, "%s %s %s %s %p\n", __FUNCTION__, _ep->name, + VDBG(dev, "%s %s %s %s %p\n", __func__, _ep->name, ep->is_in ? "IN" : "OUT", ep->dma ? "dma" : "pio", _req); @@ -898,7 +898,7 @@ static int goku_set_halt(struct usb_ep *_ep, int value) /* don't change EPxSTATUS_EP_INVALID to READY */ } else if (!ep->desc) { - DBG(ep->dev, "%s %s inactive?\n", __FUNCTION__, ep->ep.name); + DBG(ep->dev, "%s %s inactive?\n", __func__, ep->ep.name); return -EINVAL; } @@ -940,7 +940,7 @@ static int goku_fifo_status(struct usb_ep *_ep) regs = ep->dev->regs; size = readl(®s->EPxSizeLA[ep->num]) & DATASIZE; size += readl(®s->EPxSizeLB[ep->num]) & DATASIZE; - VDBG(ep->dev, "%s %s %u\n", __FUNCTION__, ep->ep.name, size); + VDBG(ep->dev, "%s %s %u\n", __func__, ep->ep.name, size); return size; } @@ -953,11 +953,11 @@ static void goku_fifo_flush(struct usb_ep *_ep) if (!_ep) return; ep = container_of(_ep, struct goku_ep, ep); - VDBG(ep->dev, "%s %s\n", __FUNCTION__, ep->ep.name); + VDBG(ep->dev, "%s %s\n", __func__, ep->ep.name); /* don't change EPxSTATUS_EP_INVALID to READY */ if (!ep->desc && ep->num != 0) { - DBG(ep->dev, "%s %s inactive?\n", __FUNCTION__, ep->ep.name); + DBG(ep->dev, "%s %s inactive?\n", __func__, ep->ep.name); return; } @@ -1286,7 +1286,7 @@ static void ep0_start(struct goku_udc *dev) struct goku_udc_regs __iomem *regs = dev->regs; unsigned i; - VDBG(dev, "%s\n", __FUNCTION__); + VDBG(dev, "%s\n", __func__); udc_reset(dev); udc_reinit (dev); @@ -1322,7 +1322,7 @@ static void udc_enable(struct goku_udc *dev) if (readl(&dev->regs->power_detect) & PW_DETECT) ep0_start(dev); else { - DBG(dev, "%s\n", __FUNCTION__); + DBG(dev, "%s\n", __func__); dev->int_enable = INT_PWRDETECT; writel(dev->int_enable, &dev->regs->int_enable); } @@ -1387,7 +1387,7 @@ stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver) { unsigned i; - DBG (dev, "%s\n", __FUNCTION__); + DBG (dev, "%s\n", __func__); if (dev->gadget.speed == USB_SPEED_UNKNOWN) driver = NULL; @@ -1726,7 +1726,7 @@ static void goku_remove(struct pci_dev *pdev) { struct goku_udc *dev = pci_get_drvdata(pdev); - DBG(dev, "%s\n", __FUNCTION__); + DBG(dev, "%s\n", __func__); BUG_ON(dev->driver); diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 0a6feafc8d2..69b0a2754f2 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1107,13 +1107,13 @@ scan: switch (state) { default: - DBG (dev, "fail %s, state %d\n", __FUNCTION__, state); + DBG (dev, "fail %s, state %d\n", __func__, state); retval = -ESRCH; break; case STATE_DEV_UNCONNECTED: case STATE_DEV_CONNECTED: spin_unlock_irq (&dev->lock); - DBG (dev, "%s wait\n", __FUNCTION__); + DBG (dev, "%s wait\n", __func__); /* wait for events */ retval = wait_event_interruptible (dev->wait, @@ -1222,7 +1222,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) DBG(dev, "bogus ep0out stall!\n"); } } else - DBG (dev, "fail %s, state %d\n", __FUNCTION__, dev->state); + DBG (dev, "fail %s, state %d\n", __func__, dev->state); spin_unlock_irq (&dev->lock); return retval; @@ -1233,7 +1233,7 @@ ep0_fasync (int f, struct file *fd, int on) { struct dev_data *dev = fd->private_data; // caller must F_SETOWN before signal delivery happens - VDEBUG (dev, "%s %s\n", __FUNCTION__, on ? "on" : "off"); + VDEBUG (dev, "%s %s\n", __func__, on ? "on" : "off"); return fasync_helper (f, fd, on, &dev->fasync); } @@ -1575,7 +1575,7 @@ static void destroy_ep_files (struct dev_data *dev) { struct list_head *entry, *tmp; - DBG (dev, "%s %d\n", __FUNCTION__, dev->state); + DBG (dev, "%s %d\n", __func__, dev->state); /* dev->state must prevent interference */ restart: @@ -1662,7 +1662,7 @@ enomem1: put_dev (dev); kfree (data); enomem0: - DBG (dev, "%s enomem\n", __FUNCTION__); + DBG (dev, "%s enomem\n", __func__); destroy_ep_files (dev); return -ENOMEM; } @@ -1672,7 +1672,7 @@ gadgetfs_unbind (struct usb_gadget *gadget) { struct dev_data *dev = get_gadget_data (gadget); - DBG (dev, "%s\n", __FUNCTION__); + DBG (dev, "%s\n", __func__); spin_lock_irq (&dev->lock); dev->state = STATE_DEV_UNBOUND; @@ -1685,7 +1685,7 @@ gadgetfs_unbind (struct usb_gadget *gadget) /* we've already been disconnected ... no i/o is active */ if (dev->req) usb_ep_free_request (gadget->ep0, dev->req); - DBG (dev, "%s done\n", __FUNCTION__); + DBG (dev, "%s done\n", __func__); put_dev (dev); } @@ -1933,7 +1933,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) fail: spin_unlock_irq (&dev->lock); - pr_debug ("%s: %s fail %Zd, %p\n", shortname, __FUNCTION__, value, dev); + pr_debug ("%s: %s fail %Zd, %p\n", shortname, __func__, value, dev); kfree (dev->buf); dev->buf = NULL; return value; diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 078f7246767..825abd2621b 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c @@ -253,7 +253,7 @@ udc_proc_read(char *page, char **start, off_t off, int count, */ static void udc_disable(struct lh7a40x_udc *dev) { - DEBUG("%s, %p\n", __FUNCTION__, dev); + DEBUG("%s, %p\n", __func__, dev); udc_set_address(dev, 0); @@ -285,7 +285,7 @@ static void udc_reinit(struct lh7a40x_udc *dev) { u32 i; - DEBUG("%s, %p\n", __FUNCTION__, dev); + DEBUG("%s, %p\n", __func__, dev); /* device/ep0 records init */ INIT_LIST_HEAD(&dev->gadget.ep_list); @@ -318,7 +318,7 @@ static void udc_enable(struct lh7a40x_udc *dev) { int ep; - DEBUG("%s, %p\n", __FUNCTION__, dev); + DEBUG("%s, %p\n", __func__, dev); dev->gadget.speed = USB_SPEED_UNKNOWN; @@ -412,7 +412,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) struct lh7a40x_udc *dev = the_controller; int retval; - DEBUG("%s: %s\n", __FUNCTION__, driver->driver.name); + DEBUG("%s: %s\n", __func__, driver->driver.name); if (!driver || driver->speed != USB_SPEED_FULL @@ -521,7 +521,7 @@ static int write_fifo(struct lh7a40x_ep *ep, struct lh7a40x_request *req) is_short = unlikely(max < ep_maxpacket(ep)); } - DEBUG("%s: wrote %s %d bytes%s%s %d left %p\n", __FUNCTION__, + DEBUG("%s: wrote %s %d bytes%s%s %d left %p\n", __func__, ep->ep.name, count, is_last ? "/L" : "", is_short ? "/S" : "", req->req.length - req->req.actual, req); @@ -555,7 +555,7 @@ static int read_fifo(struct lh7a40x_ep *ep, struct lh7a40x_request *req) /* make sure there's a packet in the FIFO. */ csr = usb_read(ep->csr1); if (!(csr & USB_OUT_CSR1_OUT_PKT_RDY)) { - DEBUG("%s: Packet NOT ready!\n", __FUNCTION__); + DEBUG("%s: Packet NOT ready!\n", __func__); return -EINVAL; } @@ -614,7 +614,7 @@ static void done(struct lh7a40x_ep *ep, struct lh7a40x_request *req, int status) unsigned int stopped = ep->stopped; u32 index; - DEBUG("%s, %p\n", __FUNCTION__, ep); + DEBUG("%s, %p\n", __func__, ep); list_del_init(&req->queue); if (likely(req->req.status == -EINPROGRESS)) @@ -644,7 +644,7 @@ static void done(struct lh7a40x_ep *ep, struct lh7a40x_request *req, int status) /** Enable EP interrupt */ static void pio_irq_enable(int ep) { - DEBUG("%s: %d\n", __FUNCTION__, ep); + DEBUG("%s: %d\n", __func__, ep); switch (ep) { case 1: @@ -665,7 +665,7 @@ static void pio_irq_enable(int ep) /** Disable EP interrupt */ static void pio_irq_disable(int ep) { - DEBUG("%s: %d\n", __FUNCTION__, ep); + DEBUG("%s: %d\n", __func__, ep); switch (ep) { case 1: @@ -690,7 +690,7 @@ void nuke(struct lh7a40x_ep *ep, int status) { struct lh7a40x_request *req; - DEBUG("%s, %p\n", __FUNCTION__, ep); + DEBUG("%s, %p\n", __func__, ep); /* Flush FIFO */ flush(ep); @@ -734,7 +734,7 @@ static void flush_all(struct lh7a40x_udc *dev) */ static void flush(struct lh7a40x_ep *ep) { - DEBUG("%s, %p\n", __FUNCTION__, ep); + DEBUG("%s, %p\n", __func__, ep); switch (ep->ep_type) { case ep_control: @@ -766,7 +766,7 @@ static void lh7a40x_in_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) usb_set_index(ep_idx); csr = usb_read(ep->csr1); - DEBUG("%s: %d, csr %x\n", __FUNCTION__, ep_idx, csr); + DEBUG("%s: %d, csr %x\n", __func__, ep_idx, csr); if (csr & USB_IN_CSR1_SENT_STALL) { DEBUG("USB_IN_CSR1_SENT_STALL\n"); @@ -776,7 +776,7 @@ static void lh7a40x_in_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) } if (!ep->desc) { - DEBUG("%s: NO EP DESC\n", __FUNCTION__); + DEBUG("%s: NO EP DESC\n", __func__); return; } @@ -802,7 +802,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) struct lh7a40x_ep *ep = &dev->ep[ep_idx]; struct lh7a40x_request *req; - DEBUG("%s: %d\n", __FUNCTION__, ep_idx); + DEBUG("%s: %d\n", __func__, ep_idx); usb_set_index(ep_idx); @@ -814,11 +814,11 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) usb_read(ep-> csr1)) & (USB_OUT_CSR1_OUT_PKT_RDY | USB_OUT_CSR1_SENT_STALL)) { - DEBUG("%s: %x\n", __FUNCTION__, csr); + DEBUG("%s: %x\n", __func__, csr); if (csr & USB_OUT_CSR1_SENT_STALL) { DEBUG("%s: stall sent, flush fifo\n", - __FUNCTION__); + __func__); /* usb_set(USB_OUT_CSR1_FIFO_FLUSH, ep->csr1); */ flush(ep); } else if (csr & USB_OUT_CSR1_OUT_PKT_RDY) { @@ -832,7 +832,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) if (!req) { printk("%s: NULL REQ %d\n", - __FUNCTION__, ep_idx); + __func__, ep_idx); flush(ep); break; } else { @@ -844,7 +844,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) } else { /* Throw packet away.. */ - printk("%s: No descriptor?!?\n", __FUNCTION__); + printk("%s: No descriptor?!?\n", __func__); flush(ep); } } @@ -886,7 +886,7 @@ static void lh7a40x_reset_intr(struct lh7a40x_udc *dev) #if 0 /* def CONFIG_ARCH_LH7A404 */ /* Does not work always... */ - DEBUG("%s: %d\n", __FUNCTION__, dev->usb_address); + DEBUG("%s: %d\n", __func__, dev->usb_address); if (!dev->usb_address) { /*usb_set(USB_RESET_IO, USB_RESET); @@ -936,7 +936,7 @@ static irqreturn_t lh7a40x_udc_irq(int irq, void *_dev) if (!intr_out && !intr_in && !intr_int) break; - DEBUG("%s (on state %s)\n", __FUNCTION__, + DEBUG("%s (on state %s)\n", __func__, state_names[dev->ep0state]); DEBUG("intr_out = %x\n", intr_out); DEBUG("intr_in = %x\n", intr_in); @@ -1016,14 +1016,14 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep, struct lh7a40x_udc *dev; unsigned long flags; - DEBUG("%s, %p\n", __FUNCTION__, _ep); + DEBUG("%s, %p\n", __func__, _ep); ep = container_of(_ep, struct lh7a40x_ep, ep); if (!_ep || !desc || ep->desc || _ep->name == ep0name || desc->bDescriptorType != USB_DT_ENDPOINT || ep->bEndpointAddress != desc->bEndpointAddress || ep_maxpacket(ep) < le16_to_cpu(desc->wMaxPacketSize)) { - DEBUG("%s, bad ep or descriptor\n", __FUNCTION__); + DEBUG("%s, bad ep or descriptor\n", __func__); return -EINVAL; } @@ -1031,7 +1031,7 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep, if (ep->bmAttributes != desc->bmAttributes && ep->bmAttributes != USB_ENDPOINT_XFER_BULK && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { - DEBUG("%s, %s type mismatch\n", __FUNCTION__, _ep->name); + DEBUG("%s, %s type mismatch\n", __func__, _ep->name); return -EINVAL; } @@ -1039,13 +1039,13 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep, if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK && le16_to_cpu(desc->wMaxPacketSize) != ep_maxpacket(ep)) || !desc->wMaxPacketSize) { - DEBUG("%s, bad %s maxpacket\n", __FUNCTION__, _ep->name); + DEBUG("%s, bad %s maxpacket\n", __func__, _ep->name); return -ERANGE; } dev = ep->dev; if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { - DEBUG("%s, bogus device state\n", __FUNCTION__); + DEBUG("%s, bogus device state\n", __func__); return -ESHUTDOWN; } @@ -1061,7 +1061,7 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep, /* Reset halt state (does flush) */ lh7a40x_set_halt(_ep, 0); - DEBUG("%s: enabled %s\n", __FUNCTION__, _ep->name); + DEBUG("%s: enabled %s\n", __func__, _ep->name); return 0; } @@ -1073,11 +1073,11 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep) struct lh7a40x_ep *ep; unsigned long flags; - DEBUG("%s, %p\n", __FUNCTION__, _ep); + DEBUG("%s, %p\n", __func__, _ep); ep = container_of(_ep, struct lh7a40x_ep, ep); if (!_ep || !ep->desc) { - DEBUG("%s, %s not enabled\n", __FUNCTION__, + DEBUG("%s, %s not enabled\n", __func__, _ep ? ep->ep.name : NULL); return -EINVAL; } @@ -1097,7 +1097,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep) spin_unlock_irqrestore(&ep->dev->lock, flags); - DEBUG("%s: disabled %s\n", __FUNCTION__, _ep->name); + DEBUG("%s: disabled %s\n", __func__, _ep->name); return 0; } @@ -1106,7 +1106,7 @@ static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, { struct lh7a40x_request *req; - DEBUG("%s, %p\n", __FUNCTION__, ep); + DEBUG("%s, %p\n", __func__, ep); req = kzalloc(sizeof(*req), gfp_flags); if (!req) @@ -1121,7 +1121,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req) { struct lh7a40x_request *req; - DEBUG("%s, %p\n", __FUNCTION__, ep); + DEBUG("%s, %p\n", __func__, ep); req = container_of(_req, struct lh7a40x_request, req); WARN_ON(!list_empty(&req->queue)); @@ -1140,25 +1140,25 @@ static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, struct lh7a40x_udc *dev; unsigned long flags; - DEBUG("\n\n\n%s, %p\n", __FUNCTION__, _ep); + DEBUG("\n\n\n%s, %p\n", __func__, _ep); req = container_of(_req, struct lh7a40x_request, req); if (unlikely (!_req || !_req->complete || !_req->buf || !list_empty(&req->queue))) { - DEBUG("%s, bad params\n", __FUNCTION__); + DEBUG("%s, bad params\n", __func__); return -EINVAL; } ep = container_of(_ep, struct lh7a40x_ep, ep); if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) { - DEBUG("%s, bad ep\n", __FUNCTION__); + DEBUG("%s, bad ep\n", __func__); return -EINVAL; } dev = ep->dev; if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) { - DEBUG("%s, bogus device state %p\n", __FUNCTION__, dev->driver); + DEBUG("%s, bogus device state %p\n", __func__, dev->driver); return -ESHUTDOWN; } @@ -1218,7 +1218,7 @@ static int lh7a40x_dequeue(struct usb_ep *_ep, struct usb_request *_req) struct lh7a40x_request *req; unsigned long flags; - DEBUG("%s, %p\n", __FUNCTION__, _ep); + DEBUG("%s, %p\n", __func__, _ep); ep = container_of(_ep, struct lh7a40x_ep, ep); if (!_ep || ep->ep.name == ep0name) @@ -1253,13 +1253,13 @@ static int lh7a40x_set_halt(struct usb_ep *_ep, int value) ep = container_of(_ep, struct lh7a40x_ep, ep); if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) { - DEBUG("%s, bad ep\n", __FUNCTION__); + DEBUG("%s, bad ep\n", __func__); return -EINVAL; } usb_set_index(ep_index(ep)); - DEBUG("%s, ep %d, val %d\n", __FUNCTION__, ep_index(ep), value); + DEBUG("%s, ep %d, val %d\n", __func__, ep_index(ep), value); spin_lock_irqsave(&ep->dev->lock, flags); @@ -1325,11 +1325,11 @@ static int lh7a40x_fifo_status(struct usb_ep *_ep) ep = container_of(_ep, struct lh7a40x_ep, ep); if (!_ep) { - DEBUG("%s, bad ep\n", __FUNCTION__); + DEBUG("%s, bad ep\n", __func__); return -ENODEV; } - DEBUG("%s, %d\n", __FUNCTION__, ep_index(ep)); + DEBUG("%s, %d\n", __func__, ep_index(ep)); /* LPD can't report unclaimed bytes from IN fifos */ if (ep_is_in(ep)) @@ -1355,7 +1355,7 @@ static void lh7a40x_fifo_flush(struct usb_ep *_ep) ep = container_of(_ep, struct lh7a40x_ep, ep); if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) { - DEBUG("%s, bad ep\n", __FUNCTION__); + DEBUG("%s, bad ep\n", __func__); return; } @@ -1376,7 +1376,7 @@ static int write_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req) max = ep_maxpacket(ep); - DEBUG_EP0("%s\n", __FUNCTION__); + DEBUG_EP0("%s\n", __func__); count = write_packet(ep, req, max); @@ -1390,7 +1390,7 @@ static int write_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req) is_last = 1; } - DEBUG_EP0("%s: wrote %s %d bytes%s %d left %p\n", __FUNCTION__, + DEBUG_EP0("%s: wrote %s %d bytes%s %d left %p\n", __func__, ep->ep.name, count, is_last ? "/L" : "", req->req.length - req->req.actual, req); @@ -1434,7 +1434,7 @@ static int read_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req) unsigned bufferspace, count, is_short; volatile u32 *fifo = (volatile u32 *)ep->fifo; - DEBUG_EP0("%s\n", __FUNCTION__); + DEBUG_EP0("%s\n", __func__); csr = usb_read(USB_EP0_CSR); if (!(csr & USB_OUT_CSR1_OUT_PKT_RDY)) @@ -1492,7 +1492,7 @@ static int read_fifo_ep0(struct lh7a40x_ep *ep, struct lh7a40x_request *req) */ static void udc_set_address(struct lh7a40x_udc *dev, unsigned char address) { - DEBUG_EP0("%s: %d\n", __FUNCTION__, address); + DEBUG_EP0("%s: %d\n", __func__, address); /* c.f. 15.1.2.2 Table 15-4 address will be used after DATA_END is set */ dev->usb_address = address; usb_set((address & USB_FA_FUNCTION_ADDR), USB_FA); @@ -1514,7 +1514,7 @@ static void lh7a40x_ep0_out(struct lh7a40x_udc *dev, u32 csr) struct lh7a40x_ep *ep = &dev->ep[0]; int ret; - DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: %x\n", __func__, csr); if (list_empty(&ep->queue)) req = 0; @@ -1533,13 +1533,13 @@ static void lh7a40x_ep0_out(struct lh7a40x_udc *dev, u32 csr) if (ret) { /* Done! */ DEBUG_EP0("%s: finished, waiting for status\n", - __FUNCTION__); + __func__); usb_set((EP0_CLR_OUT | EP0_DATA_END), USB_EP0_CSR); dev->ep0state = WAIT_FOR_SETUP; } else { /* Not done yet.. */ - DEBUG_EP0("%s: not finished\n", __FUNCTION__); + DEBUG_EP0("%s: not finished\n", __func__); usb_set(EP0_CLR_OUT, USB_EP0_CSR); } } else { @@ -1556,7 +1556,7 @@ static int lh7a40x_ep0_in(struct lh7a40x_udc *dev, u32 csr) struct lh7a40x_ep *ep = &dev->ep[0]; int ret, need_zlp = 0; - DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: %x\n", __func__, csr); if (list_empty(&ep->queue)) req = 0; @@ -1564,7 +1564,7 @@ static int lh7a40x_ep0_in(struct lh7a40x_udc *dev, u32 csr) req = list_entry(ep->queue.next, struct lh7a40x_request, queue); if (!req) { - DEBUG_EP0("%s: NULL REQ\n", __FUNCTION__); + DEBUG_EP0("%s: NULL REQ\n", __func__); return 0; } @@ -1585,17 +1585,17 @@ static int lh7a40x_ep0_in(struct lh7a40x_udc *dev, u32 csr) if (ret == 1 && !need_zlp) { /* Last packet */ - DEBUG_EP0("%s: finished, waiting for status\n", __FUNCTION__); + DEBUG_EP0("%s: finished, waiting for status\n", __func__); usb_set((EP0_IN_PKT_RDY | EP0_DATA_END), USB_EP0_CSR); dev->ep0state = WAIT_FOR_SETUP; } else { - DEBUG_EP0("%s: not finished\n", __FUNCTION__); + DEBUG_EP0("%s: not finished\n", __func__); usb_set(EP0_IN_PKT_RDY, USB_EP0_CSR); } if (need_zlp) { - DEBUG_EP0("%s: Need ZLP!\n", __FUNCTION__); + DEBUG_EP0("%s: Need ZLP!\n", __func__); usb_set(EP0_IN_PKT_RDY, USB_EP0_CSR); dev->ep0state = DATA_STATE_NEED_ZLP; } @@ -1694,7 +1694,7 @@ static void lh7a40x_ep0_setup(struct lh7a40x_udc *dev, u32 csr) struct usb_ctrlrequest ctrl; int i, bytes, is_in; - DEBUG_SETUP("%s: %x\n", __FUNCTION__, csr); + DEBUG_SETUP("%s: %x\n", __func__, csr); /* Nuke all previous transfers */ nuke(ep, -EPROTO); @@ -1799,7 +1799,7 @@ static void lh7a40x_ep0_setup(struct lh7a40x_udc *dev, u32 csr) */ static void lh7a40x_ep0_in_zlp(struct lh7a40x_udc *dev, u32 csr) { - DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: %x\n", __func__, csr); /* c.f. Table 15-14 */ usb_set((EP0_IN_PKT_RDY | EP0_DATA_END), USB_EP0_CSR); @@ -1818,7 +1818,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr) usb_set_index(0); csr = usb_read(USB_EP0_CSR); - DEBUG_EP0("%s: csr = %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: csr = %x\n", __func__, csr); /* * For overview of what we should be doing see c.f. Chapter 18.1.2.4 @@ -1832,7 +1832,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr) * - clear the SENT_STALL bit */ if (csr & EP0_SENT_STALL) { - DEBUG_EP0("%s: EP0_SENT_STALL is set: %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: EP0_SENT_STALL is set: %x\n", __func__, csr); usb_clear((EP0_SENT_STALL | EP0_SEND_STALL), USB_EP0_CSR); nuke(ep, -ECONNABORTED); dev->ep0state = WAIT_FOR_SETUP; @@ -1849,7 +1849,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr) */ if (!(csr & (EP0_IN_PKT_RDY | EP0_OUT_PKT_RDY))) { DEBUG_EP0("%s: IN_PKT_RDY and OUT_PKT_RDY are clear\n", - __FUNCTION__); + __func__); switch (dev->ep0state) { case DATA_STATE_XMIT: @@ -1877,7 +1877,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr) * - set SERVICED_SETUP_END_BIT */ if (csr & EP0_SETUP_END) { - DEBUG_EP0("%s: EP0_SETUP_END is set: %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: EP0_SETUP_END is set: %x\n", __func__, csr); usb_set(EP0_CLR_SETUP_END, USB_EP0_CSR); @@ -1896,7 +1896,7 @@ static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr) */ if (csr & EP0_OUT_PKT_RDY) { - DEBUG_EP0("%s: EP0_OUT_PKT_RDY is set: %x\n", __FUNCTION__, + DEBUG_EP0("%s: EP0_OUT_PKT_RDY is set: %x\n", __func__, csr); switch (dev->ep0state) { @@ -1926,7 +1926,7 @@ static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep) usb_set_index(0); csr = usb_read(USB_EP0_CSR); - DEBUG_EP0("%s: %x\n", __FUNCTION__, csr); + DEBUG_EP0("%s: %x\n", __func__, csr); /* Clear "out packet ready" */ usb_set(EP0_CLR_OUT, USB_EP0_CSR); @@ -1949,7 +1949,7 @@ static int lh7a40x_udc_get_frame(struct usb_gadget *_gadget) { u32 frame1 = usb_read(USB_FRM_NUM1); /* Least significant 8 bits */ u32 frame2 = usb_read(USB_FRM_NUM2); /* Most significant 3 bits */ - DEBUG("%s, %p\n", __FUNCTION__, _gadget); + DEBUG("%s, %p\n", __func__, _gadget); return ((frame2 & 0x07) << 8) | (frame1 & 0xff); } @@ -1970,7 +1970,7 @@ static const struct usb_gadget_ops lh7a40x_udc_ops = { static void nop_release(struct device *dev) { - DEBUG("%s %s\n", __FUNCTION__, dev->bus_id); + DEBUG("%s %s\n", __func__, dev->bus_id); } static struct lh7a40x_udc memory = { @@ -2065,7 +2065,7 @@ static int lh7a40x_udc_probe(struct platform_device *pdev) struct lh7a40x_udc *dev = &memory; int retval; - DEBUG("%s: %p\n", __FUNCTION__, pdev); + DEBUG("%s: %p\n", __func__, pdev); spin_lock_init(&dev->lock); dev->dev = &pdev->dev; @@ -2098,7 +2098,7 @@ static int lh7a40x_udc_remove(struct platform_device *pdev) { struct lh7a40x_udc *dev = platform_get_drvdata(pdev); - DEBUG("%s: %p\n", __FUNCTION__, pdev); + DEBUG("%s: %p\n", __func__, pdev); if (dev->driver) return -EBUSY; @@ -2131,7 +2131,7 @@ static struct platform_driver udc_driver = { static int __init udc_init(void) { - DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION); + DEBUG("%s: %s version %s\n", __func__, driver_name, DRIVER_VERSION); return platform_driver_register(&udc_driver); } diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h index 17b792b7f6b..be0a4c1f80a 100644 --- a/drivers/usb/gadget/m66592-udc.h +++ b/drivers/usb/gadget/m66592-udc.h @@ -486,10 +486,10 @@ struct m66592 { struct usb_request *ep0_req; /* for internal request */ u16 ep0_data; /* for internal request */ + u16 old_vbus; struct timer_list timer; - u16 old_vbus; int scount; int old_dvsq; diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h index 44ca139983d..1f2af398a9a 100644 --- a/drivers/usb/gadget/net2280.h +++ b/drivers/usb/gadget/net2280.h @@ -299,7 +299,7 @@ static inline void assert_out_naking (struct net2280_ep *ep, const char *where) &ep->regs->ep_rsp); } } -#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__FUNCTION__) +#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__func__) #else #define ASSERT_OUT_NAKING(ep) do {} while (0) #endif diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index ee1e9a314cd..95f7662376f 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c @@ -163,7 +163,7 @@ static int omap_ep_enable(struct usb_ep *_ep, || ep->bEndpointAddress != desc->bEndpointAddress || ep->maxpacket < le16_to_cpu (desc->wMaxPacketSize)) { - DBG("%s, bad ep or descriptor\n", __FUNCTION__); + DBG("%s, bad ep or descriptor\n", __func__); return -EINVAL; } maxp = le16_to_cpu (desc->wMaxPacketSize); @@ -171,7 +171,7 @@ static int omap_ep_enable(struct usb_ep *_ep, && maxp != ep->maxpacket) || le16_to_cpu(desc->wMaxPacketSize) > ep->maxpacket || !desc->wMaxPacketSize) { - DBG("%s, bad %s maxpacket\n", __FUNCTION__, _ep->name); + DBG("%s, bad %s maxpacket\n", __func__, _ep->name); return -ERANGE; } @@ -194,13 +194,13 @@ static int omap_ep_enable(struct usb_ep *_ep, if (ep->bmAttributes != desc->bmAttributes && ep->bmAttributes != USB_ENDPOINT_XFER_BULK && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { - DBG("%s, %s type mismatch\n", __FUNCTION__, _ep->name); + DBG("%s, %s type mismatch\n", __func__, _ep->name); return -EINVAL; } udc = ep->udc; if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { - DBG("%s, bogus device state\n", __FUNCTION__); + DBG("%s, bogus device state\n", __func__); return -ESHUTDOWN; } @@ -249,7 +249,7 @@ static int omap_ep_disable(struct usb_ep *_ep) unsigned long flags; if (!_ep || !ep->desc) { - DBG("%s, %s not enabled\n", __FUNCTION__, + DBG("%s, %s not enabled\n", __func__, _ep ? ep->ep.name : NULL); return -EINVAL; } @@ -936,11 +936,11 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) /* catch various bogus parameters */ if (!_req || !req->req.complete || !req->req.buf || !list_empty(&req->queue)) { - DBG("%s, bad params\n", __FUNCTION__); + DBG("%s, bad params\n", __func__); return -EINVAL; } if (!_ep || (!ep->desc && ep->bEndpointAddress)) { - DBG("%s, bad ep\n", __FUNCTION__); + DBG("%s, bad ep\n", __func__); return -EINVAL; } if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) { @@ -959,7 +959,7 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) && (ep->bEndpointAddress & USB_DIR_IN) == 0 && !cpu_class_is_omap2() && (req->req.length % ep->ep.maxpacket) != 0) { - DBG("%s, no partial packet OUT reads\n", __FUNCTION__); + DBG("%s, no partial packet OUT reads\n", __func__); return -EMSGSIZE; } @@ -1265,8 +1265,6 @@ static int can_pullup(struct omap_udc *udc) static void pullup_enable(struct omap_udc *udc) { - udc->gadget.dev.parent->power.power_state = PMSG_ON; - udc->gadget.dev.power.power_state = PMSG_ON; UDC_SYSCON1_REG |= UDC_PULLUP_EN; if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx()) OTG_CTRL_REG |= OTG_BSESSVLD; @@ -3061,8 +3059,6 @@ static int omap_udc_suspend(struct platform_device *dev, pm_message_t message) omap_pullup(&udc->gadget, 0); } - udc->gadget.dev.power.power_state = PMSG_SUSPEND; - udc->gadget.dev.parent->power.power_state = PMSG_SUSPEND; return 0; } diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 2c32bd08ee7..76be75e3ab8 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c @@ -390,9 +390,12 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req) /* normal completion */ case 0: - list_add_tail(&req->list, &dev->rx_buffers); - wake_up_interruptible(&dev->rx_wait); - DBG(dev, "G_Printer : rx length %d\n", req->actual); + if (req->actual > 0) { + list_add_tail(&req->list, &dev->rx_buffers); + DBG(dev, "G_Printer : rx length %d\n", req->actual); + } else { + list_add(&req->list, &dev->rx_reqs); + } break; /* software-driven interface shutdown */ @@ -417,6 +420,8 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req) list_add(&req->list, &dev->rx_reqs); break; } + + wake_up_interruptible(&dev->rx_wait); spin_unlock_irqrestore(&dev->lock, flags); } @@ -494,6 +499,39 @@ printer_close(struct inode *inode, struct file *fd) return 0; } +/* This function must be called with interrupts turned off. */ +static void +setup_rx_reqs(struct printer_dev *dev) +{ + struct usb_request *req; + + while (likely(!list_empty(&dev->rx_reqs))) { + int error; + + req = container_of(dev->rx_reqs.next, + struct usb_request, list); + list_del_init(&req->list); + + /* The USB Host sends us whatever amount of data it wants to + * so we always set the length field to the full USB_BUFSIZE. + * If the amount of data is more than the read() caller asked + * for it will be stored in the request buffer until it is + * asked for by read(). + */ + req->length = USB_BUFSIZE; + req->complete = rx_complete; + + error = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC); + if (error) { + DBG(dev, "rx submit --> %d\n", error); + list_add(&req->list, &dev->rx_reqs); + break; + } else { + list_add(&req->list, &dev->rx_reqs_active); + } + } +} + static ssize_t printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) { @@ -522,31 +560,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) */ dev->reset_printer = 0; - while (likely(!list_empty(&dev->rx_reqs))) { - int error; - - req = container_of(dev->rx_reqs.next, - struct usb_request, list); - list_del_init(&req->list); - - /* The USB Host sends us whatever amount of data it wants to - * so we always set the length field to the full USB_BUFSIZE. - * If the amount of data is more than the read() caller asked - * for it will be stored in the request buffer until it is - * asked for by read(). - */ - req->length = USB_BUFSIZE; - req->complete = rx_complete; - - error = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC); - if (error) { - DBG(dev, "rx submit --> %d\n", error); - list_add(&req->list, &dev->rx_reqs); - break; - } else { - list_add(&req->list, &dev->rx_reqs_active); - } - } + setup_rx_reqs(dev); bytes_copied = 0; current_rx_req = dev->current_rx_req; @@ -615,9 +629,9 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) spin_lock_irqsave(&dev->lock, flags); - /* We've disconnected or reset free the req and buffer */ + /* We've disconnected or reset so return. */ if (dev->reset_printer) { - printer_req_free(dev->out_ep, current_rx_req); + list_add(¤t_rx_req->list, &dev->rx_reqs); spin_unlock_irqrestore(&dev->lock, flags); spin_unlock(&dev->lock_printer_io); return -EAGAIN; @@ -735,7 +749,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) /* We've disconnected or reset so free the req and buffer */ if (dev->reset_printer) { - printer_req_free(dev->in_ep, req); + list_add(&req->list, &dev->tx_reqs); spin_unlock_irqrestore(&dev->lock, flags); spin_unlock(&dev->lock_printer_io); return -EAGAIN; @@ -791,6 +805,12 @@ printer_poll(struct file *fd, poll_table *wait) unsigned long flags; int status = 0; + spin_lock(&dev->lock_printer_io); + spin_lock_irqsave(&dev->lock, flags); + setup_rx_reqs(dev); + spin_unlock_irqrestore(&dev->lock, flags); + spin_unlock(&dev->lock_printer_io); + poll_wait(fd, &dev->rx_wait, wait); poll_wait(fd, &dev->tx_wait, wait); @@ -798,7 +818,8 @@ printer_poll(struct file *fd, poll_table *wait) if (likely(!list_empty(&dev->tx_reqs))) status |= POLLOUT | POLLWRNORM; - if (likely(!list_empty(&dev->rx_buffers))) + if (likely(dev->current_rx_bytes) || + likely(!list_empty(&dev->rx_buffers))) status |= POLLIN | POLLRDNORM; spin_unlock_irqrestore(&dev->lock, flags); @@ -894,7 +915,7 @@ static void printer_reset_interface(struct printer_dev *dev) if (dev->interface < 0) return; - DBG(dev, "%s\n", __FUNCTION__); + DBG(dev, "%s\n", __func__); if (dev->in) usb_ep_disable(dev->in_ep); @@ -1084,6 +1105,7 @@ static void printer_soft_reset(struct printer_dev *dev) if (usb_ep_enable(dev->out_ep, dev->out)) DBG(dev, "Failed to enable USB out_ep\n"); + wake_up_interruptible(&dev->rx_wait); wake_up_interruptible(&dev->tx_wait); wake_up_interruptible(&dev->tx_flush_wait); } @@ -1262,7 +1284,7 @@ printer_disconnect(struct usb_gadget *gadget) struct printer_dev *dev = get_gadget_data(gadget); unsigned long flags; - DBG(dev, "%s\n", __FUNCTION__); + DBG(dev, "%s\n", __func__); spin_lock_irqsave(&dev->lock, flags); @@ -1278,7 +1300,7 @@ printer_unbind(struct usb_gadget *gadget) struct usb_request *req; - DBG(dev, "%s\n", __FUNCTION__); + DBG(dev, "%s\n", __func__); /* Remove sysfs files */ device_destroy(usb_gadget_class, g_printer_devno); diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index c00cd8b9d3d..08f699b1fc5 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c @@ -235,7 +235,7 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep, || ep->bEndpointAddress != desc->bEndpointAddress || ep->fifo_size < le16_to_cpu (desc->wMaxPacketSize)) { - DMSG("%s, bad ep or descriptor\n", __FUNCTION__); + DMSG("%s, bad ep or descriptor\n", __func__); return -EINVAL; } @@ -243,7 +243,7 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep, if (ep->bmAttributes != desc->bmAttributes && ep->bmAttributes != USB_ENDPOINT_XFER_BULK && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { - DMSG("%s, %s type mismatch\n", __FUNCTION__, _ep->name); + DMSG("%s, %s type mismatch\n", __func__, _ep->name); return -EINVAL; } @@ -252,13 +252,13 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep, && le16_to_cpu (desc->wMaxPacketSize) != BULK_FIFO_SIZE) || !desc->wMaxPacketSize) { - DMSG("%s, bad %s maxpacket\n", __FUNCTION__, _ep->name); + DMSG("%s, bad %s maxpacket\n", __func__, _ep->name); return -ERANGE; } dev = ep->dev; if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { - DMSG("%s, bogus device state\n", __FUNCTION__); + DMSG("%s, bogus device state\n", __func__); return -ESHUTDOWN; } @@ -283,7 +283,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep) ep = container_of (_ep, struct pxa2xx_ep, ep); if (!_ep || !ep->desc) { - DMSG("%s, %s not enabled\n", __FUNCTION__, + DMSG("%s, %s not enabled\n", __func__, _ep ? ep->ep.name : NULL); return -EINVAL; } @@ -461,7 +461,7 @@ void ep0start(struct pxa2xx_udc *dev, u32 flags, const char *tag) USIR0 = USIR0_IR0; dev->req_pending = 0; DBG(DBG_VERY_NOISY, "%s %s, %02x/%02x\n", - __FUNCTION__, tag, UDCCS0, flags); + __func__, tag, UDCCS0, flags); } static int @@ -651,20 +651,20 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) req = container_of(_req, struct pxa2xx_request, req); if (unlikely (!_req || !_req->complete || !_req->buf || !list_empty(&req->queue))) { - DMSG("%s, bad params\n", __FUNCTION__); + DMSG("%s, bad params\n", __func__); return -EINVAL; } ep = container_of(_ep, struct pxa2xx_ep, ep); if (unlikely (!_ep || (!ep->desc && ep->ep.name != ep0name))) { - DMSG("%s, bad ep\n", __FUNCTION__); + DMSG("%s, bad ep\n", __func__); return -EINVAL; } dev = ep->dev; if (unlikely (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) { - DMSG("%s, bogus device state\n", __FUNCTION__); + DMSG("%s, bogus device state\n", __func__); return -ESHUTDOWN; } @@ -807,7 +807,7 @@ static int pxa2xx_ep_set_halt(struct usb_ep *_ep, int value) if (unlikely (!_ep || (!ep->desc && ep->ep.name != ep0name)) || ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) { - DMSG("%s, bad ep\n", __FUNCTION__); + DMSG("%s, bad ep\n", __func__); return -EINVAL; } if (value == 0) { @@ -859,7 +859,7 @@ static int pxa2xx_ep_fifo_status(struct usb_ep *_ep) ep = container_of(_ep, struct pxa2xx_ep, ep); if (!_ep) { - DMSG("%s, bad ep\n", __FUNCTION__); + DMSG("%s, bad ep\n", __func__); return -ENODEV; } /* pxa can't report unclaimed bytes from IN fifos */ @@ -878,7 +878,7 @@ static void pxa2xx_ep_fifo_flush(struct usb_ep *_ep) ep = container_of(_ep, struct pxa2xx_ep, ep); if (!_ep || ep->ep.name == ep0name || !list_empty(&ep->queue)) { - DMSG("%s, bad ep\n", __FUNCTION__); + DMSG("%s, bad ep\n", __func__); return; } @@ -1813,7 +1813,7 @@ pxa2xx_udc_irq(int irq, void *_dev) static void nop_release (struct device *dev) { - DMSG("%s %s\n", __FUNCTION__, dev->bus_id); + DMSG("%s %s\n", __func__, dev->bus_id); } /* this uses load-time allocation and initialization (instead of diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 3d036647431..bd58dd504f6 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -204,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_SUPPORTED_LIST: - DBG("%s: OID_GEN_SUPPORTED_LIST\n", __FUNCTION__); + DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__); length = sizeof (oid_supported_list); count = length / sizeof (u32); for (i = 0; i < count; i++) @@ -214,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_HARDWARE_STATUS: - DBG("%s: OID_GEN_HARDWARE_STATUS\n", __FUNCTION__); + DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__); /* Bogus question! * Hardware must be ready to receive high level protocols. * BTW: @@ -227,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_MEDIA_SUPPORTED: - DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __FUNCTION__); + DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); retval = 0; break; /* mandatory */ case OID_GEN_MEDIA_IN_USE: - DBG("%s: OID_GEN_MEDIA_IN_USE\n", __FUNCTION__); + DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__); /* one medium, one transport... (maybe you do it better) */ *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); retval = 0; @@ -242,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_MAXIMUM_FRAME_SIZE: - DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __FUNCTION__); + DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); if (rndis_per_dev_params [configNr].dev) { *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].dev->mtu); @@ -253,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_LINK_SPEED: if (rndis_debug > 1) - DBG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); + DBG("%s: OID_GEN_LINK_SPEED\n", __func__); if (rndis_per_dev_params [configNr].media_state == NDIS_MEDIA_STATE_DISCONNECTED) *outbuf = __constant_cpu_to_le32 (0); @@ -265,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_TRANSMIT_BLOCK_SIZE: - DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __FUNCTION__); + DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); if (rndis_per_dev_params [configNr].dev) { *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].dev->mtu); @@ -275,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_RECEIVE_BLOCK_SIZE: - DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __FUNCTION__); + DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); if (rndis_per_dev_params [configNr].dev) { *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].dev->mtu); @@ -285,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_VENDOR_ID: - DBG("%s: OID_GEN_VENDOR_ID\n", __FUNCTION__); + DBG("%s: OID_GEN_VENDOR_ID\n", __func__); *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].vendorID); retval = 0; @@ -293,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_VENDOR_DESCRIPTION: - DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __FUNCTION__); + DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); length = strlen (rndis_per_dev_params [configNr].vendorDescr); memcpy (outbuf, rndis_per_dev_params [configNr].vendorDescr, length); @@ -301,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_VENDOR_DRIVER_VERSION: - DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __FUNCTION__); + DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); /* Created as LE */ *outbuf = rndis_driver_version; retval = 0; @@ -309,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_CURRENT_PACKET_FILTER: - DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __FUNCTION__); + DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); retval = 0; break; /* mandatory */ case OID_GEN_MAXIMUM_TOTAL_SIZE: - DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __FUNCTION__); + DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); retval = 0; break; @@ -324,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_MEDIA_CONNECT_STATUS: if (rndis_debug > 1) - DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __FUNCTION__); + DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .media_state); retval = 0; break; case OID_GEN_PHYSICAL_MEDIUM: - DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __FUNCTION__); + DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); *outbuf = __constant_cpu_to_le32 (0); retval = 0; break; @@ -341,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! */ case OID_GEN_MAC_OPTIONS: /* from WinME */ - DBG("%s: OID_GEN_MAC_OPTIONS\n", __FUNCTION__); + DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__); *outbuf = __constant_cpu_to_le32( NDIS_MAC_OPTION_RECEIVE_SERIALIZED | NDIS_MAC_OPTION_FULL_DUPLEX); @@ -353,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_XMIT_OK: if (rndis_debug > 1) - DBG("%s: OID_GEN_XMIT_OK\n", __FUNCTION__); + DBG("%s: OID_GEN_XMIT_OK\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].stats->tx_packets - @@ -366,7 +366,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_RCV_OK: if (rndis_debug > 1) - DBG("%s: OID_GEN_RCV_OK\n", __FUNCTION__); + DBG("%s: OID_GEN_RCV_OK\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].stats->rx_packets - @@ -379,7 +379,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_XMIT_ERROR: if (rndis_debug > 1) - DBG("%s: OID_GEN_XMIT_ERROR\n", __FUNCTION__); + DBG("%s: OID_GEN_XMIT_ERROR\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->tx_errors); @@ -390,7 +390,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_RCV_ERROR: if (rndis_debug > 1) - DBG("%s: OID_GEN_RCV_ERROR\n", __FUNCTION__); + DBG("%s: OID_GEN_RCV_ERROR\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->rx_errors); @@ -400,7 +400,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_RCV_NO_BUFFER: - DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __FUNCTION__); + DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->rx_dropped); @@ -410,7 +410,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, #ifdef RNDIS_OPTIONAL_STATS case OID_GEN_DIRECTED_BYTES_XMIT: - DBG("%s: OID_GEN_DIRECTED_BYTES_XMIT\n", __FUNCTION__); + DBG("%s: OID_GEN_DIRECTED_BYTES_XMIT\n", __func__); /* * Aunt Tilly's size of shoes * minus antarctica count of penguins @@ -430,7 +430,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_DIRECTED_FRAMES_XMIT: - DBG("%s: OID_GEN_DIRECTED_FRAMES_XMIT\n", __FUNCTION__); + DBG("%s: OID_GEN_DIRECTED_FRAMES_XMIT\n", __func__); /* dito */ if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 ( @@ -446,7 +446,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_MULTICAST_BYTES_XMIT: - DBG("%s: OID_GEN_MULTICAST_BYTES_XMIT\n", __FUNCTION__); + DBG("%s: OID_GEN_MULTICAST_BYTES_XMIT\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->multicast*1234); @@ -455,7 +455,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_MULTICAST_FRAMES_XMIT: - DBG("%s: OID_GEN_MULTICAST_FRAMES_XMIT\n", __FUNCTION__); + DBG("%s: OID_GEN_MULTICAST_FRAMES_XMIT\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->multicast); @@ -464,7 +464,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_BROADCAST_BYTES_XMIT: - DBG("%s: OID_GEN_BROADCAST_BYTES_XMIT\n", __FUNCTION__); + DBG("%s: OID_GEN_BROADCAST_BYTES_XMIT\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->tx_packets/42*255); @@ -473,7 +473,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_BROADCAST_FRAMES_XMIT: - DBG("%s: OID_GEN_BROADCAST_FRAMES_XMIT\n", __FUNCTION__); + DBG("%s: OID_GEN_BROADCAST_FRAMES_XMIT\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->tx_packets/42); @@ -482,19 +482,19 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_DIRECTED_BYTES_RCV: - DBG("%s: OID_GEN_DIRECTED_BYTES_RCV\n", __FUNCTION__); + DBG("%s: OID_GEN_DIRECTED_BYTES_RCV\n", __func__); *outbuf = __constant_cpu_to_le32 (0); retval = 0; break; case OID_GEN_DIRECTED_FRAMES_RCV: - DBG("%s: OID_GEN_DIRECTED_FRAMES_RCV\n", __FUNCTION__); + DBG("%s: OID_GEN_DIRECTED_FRAMES_RCV\n", __func__); *outbuf = __constant_cpu_to_le32 (0); retval = 0; break; case OID_GEN_MULTICAST_BYTES_RCV: - DBG("%s: OID_GEN_MULTICAST_BYTES_RCV\n", __FUNCTION__); + DBG("%s: OID_GEN_MULTICAST_BYTES_RCV\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->multicast * 1111); @@ -503,7 +503,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_MULTICAST_FRAMES_RCV: - DBG("%s: OID_GEN_MULTICAST_FRAMES_RCV\n", __FUNCTION__); + DBG("%s: OID_GEN_MULTICAST_FRAMES_RCV\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->multicast); @@ -512,7 +512,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_BROADCAST_BYTES_RCV: - DBG("%s: OID_GEN_BROADCAST_BYTES_RCV\n", __FUNCTION__); + DBG("%s: OID_GEN_BROADCAST_BYTES_RCV\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->rx_packets/42*255); @@ -521,7 +521,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_BROADCAST_FRAMES_RCV: - DBG("%s: OID_GEN_BROADCAST_FRAMES_RCV\n", __FUNCTION__); + DBG("%s: OID_GEN_BROADCAST_FRAMES_RCV\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->rx_packets/42); @@ -530,7 +530,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_RCV_CRC_ERROR: - DBG("%s: OID_GEN_RCV_CRC_ERROR\n", __FUNCTION__); + DBG("%s: OID_GEN_RCV_CRC_ERROR\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->rx_crc_errors); @@ -539,7 +539,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_GEN_TRANSMIT_QUEUE_LENGTH: - DBG("%s: OID_GEN_TRANSMIT_QUEUE_LENGTH\n", __FUNCTION__); + DBG("%s: OID_GEN_TRANSMIT_QUEUE_LENGTH\n", __func__); *outbuf = __constant_cpu_to_le32 (0); retval = 0; break; @@ -549,7 +549,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_802_3_PERMANENT_ADDRESS: - DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __FUNCTION__); + DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); if (rndis_per_dev_params [configNr].dev) { length = ETH_ALEN; memcpy (outbuf, @@ -561,7 +561,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_802_3_CURRENT_ADDRESS: - DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __FUNCTION__); + DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); if (rndis_per_dev_params [configNr].dev) { length = ETH_ALEN; memcpy (outbuf, @@ -573,7 +573,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_802_3_MULTICAST_LIST: - DBG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__); + DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); /* Multicast base address only */ *outbuf = __constant_cpu_to_le32 (0xE0000000); retval = 0; @@ -581,21 +581,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_802_3_MAXIMUM_LIST_SIZE: - DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __FUNCTION__); + DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); /* Multicast base address only */ *outbuf = __constant_cpu_to_le32 (1); retval = 0; break; case OID_802_3_MAC_OPTIONS: - DBG("%s: OID_802_3_MAC_OPTIONS\n", __FUNCTION__); + DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__); break; /* ieee802.3 statistics OIDs (table 4-4) */ /* mandatory */ case OID_802_3_RCV_ERROR_ALIGNMENT: - DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __FUNCTION__); + DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); if (rndis_per_dev_params [configNr].stats) { *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] .stats->rx_frame_errors); @@ -605,51 +605,51 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_802_3_XMIT_ONE_COLLISION: - DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); *outbuf = __constant_cpu_to_le32 (0); retval = 0; break; /* mandatory */ case OID_802_3_XMIT_MORE_COLLISIONS: - DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); *outbuf = __constant_cpu_to_le32 (0); retval = 0; break; #ifdef RNDIS_OPTIONAL_STATS case OID_802_3_XMIT_DEFERRED: - DBG("%s: OID_802_3_XMIT_DEFERRED\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_DEFERRED\n", __func__); /* TODO */ break; case OID_802_3_XMIT_MAX_COLLISIONS: - DBG("%s: OID_802_3_XMIT_MAX_COLLISIONS\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_MAX_COLLISIONS\n", __func__); /* TODO */ break; case OID_802_3_RCV_OVERRUN: - DBG("%s: OID_802_3_RCV_OVERRUN\n", __FUNCTION__); + DBG("%s: OID_802_3_RCV_OVERRUN\n", __func__); /* TODO */ break; case OID_802_3_XMIT_UNDERRUN: - DBG("%s: OID_802_3_XMIT_UNDERRUN\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_UNDERRUN\n", __func__); /* TODO */ break; case OID_802_3_XMIT_HEARTBEAT_FAILURE: - DBG("%s: OID_802_3_XMIT_HEARTBEAT_FAILURE\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_HEARTBEAT_FAILURE\n", __func__); /* TODO */ break; case OID_802_3_XMIT_TIMES_CRS_LOST: - DBG("%s: OID_802_3_XMIT_TIMES_CRS_LOST\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_TIMES_CRS_LOST\n", __func__); /* TODO */ break; case OID_802_3_XMIT_LATE_COLLISIONS: - DBG("%s: OID_802_3_XMIT_LATE_COLLISIONS\n", __FUNCTION__); + DBG("%s: OID_802_3_XMIT_LATE_COLLISIONS\n", __func__); /* TODO */ break; #endif /* RNDIS_OPTIONAL_STATS */ @@ -657,7 +657,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, #ifdef RNDIS_PM /* power management OIDs (table 4-5) */ case OID_PNP_CAPABILITIES: - DBG("%s: OID_PNP_CAPABILITIES\n", __FUNCTION__); + DBG("%s: OID_PNP_CAPABILITIES\n", __func__); /* for now, no wakeup capabilities */ length = sizeof (struct NDIS_PNP_CAPABILITIES); @@ -665,7 +665,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, retval = 0; break; case OID_PNP_QUERY_POWER: - DBG("%s: OID_PNP_QUERY_POWER D%d\n", __FUNCTION__, + DBG("%s: OID_PNP_QUERY_POWER D%d\n", __func__, le32_to_cpu(get_unaligned((__le32 *)buf)) - 1); /* only suspend is a real power state, and * it can't be entered by OID_PNP_SET_POWER... @@ -677,7 +677,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, default: pr_warning("%s: query unknown OID 0x%08X\n", - __FUNCTION__, OID); + __func__, OID); } if (retval < 0) length = 0; @@ -729,7 +729,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, *params->filter = (u16) le32_to_cpu(get_unaligned( (__le32 *)buf)); DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", - __FUNCTION__, *params->filter); + __func__, *params->filter); /* this call has a significant side effect: it's * what makes the packet flow start and stop, like @@ -753,7 +753,7 @@ update_linkstate: case OID_802_3_MULTICAST_LIST: /* I think we can ignore this */ - DBG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__); + DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); retval = 0; break; #if 0 @@ -762,7 +762,7 @@ update_linkstate: struct rndis_config_parameter *param; param = (struct rndis_config_parameter *) buf; DBG("%s: OID_GEN_RNDIS_CONFIG_PARAMETER '%*s'\n", - __FUNCTION__, + __func__, min(cpu_to_le32(param->ParameterNameLength),80), buf + param->ParameterNameOffset); retval = 0; @@ -778,7 +778,7 @@ update_linkstate: * FIXME ... then things go batty; Windows wedges itself. */ i = le32_to_cpu(get_unaligned((__le32 *)buf)); - DBG("%s: OID_PNP_SET_POWER D%d\n", __FUNCTION__, i - 1); + DBG("%s: OID_PNP_SET_POWER D%d\n", __func__, i - 1); switch (i) { case NdisDeviceStateD0: *params->filter = params->saved_filter; @@ -802,7 +802,7 @@ update_linkstate: default: pr_warning("%s: set unknown OID 0x%08X, size %d\n", - __FUNCTION__, OID, buf_len); + __func__, OID, buf_len); } return retval; @@ -855,7 +855,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) rndis_query_cmplt_type *resp; rndis_resp_t *r; - // DBG("%s: OID = %08X\n", __FUNCTION__, cpu_to_le32(buf->OID)); + // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); if (!rndis_per_dev_params [configNr].dev) return -ENOTSUPP; /* @@ -908,9 +908,9 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf) BufOffset = le32_to_cpu (buf->InformationBufferOffset); #ifdef VERBOSE - DBG("%s: Length: %d\n", __FUNCTION__, BufLength); - DBG("%s: Offset: %d\n", __FUNCTION__, BufOffset); - DBG("%s: InfoBuffer: ", __FUNCTION__); + DBG("%s: Length: %d\n", __func__, BufLength); + DBG("%s: Offset: %d\n", __func__, BufOffset); + DBG("%s: InfoBuffer: ", __func__); for (i = 0; i < BufLength; i++) { DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); @@ -1080,14 +1080,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf) switch (MsgType) { case REMOTE_NDIS_INITIALIZE_MSG: DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", - __FUNCTION__ ); + __func__ ); params->state = RNDIS_INITIALIZED; return rndis_init_response (configNr, (rndis_init_msg_type *) buf); case REMOTE_NDIS_HALT_MSG: DBG("%s: REMOTE_NDIS_HALT_MSG\n", - __FUNCTION__ ); + __func__ ); params->state = RNDIS_UNINITIALIZED; if (params->dev) { netif_carrier_off (params->dev); @@ -1105,7 +1105,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) case REMOTE_NDIS_RESET_MSG: DBG("%s: REMOTE_NDIS_RESET_MSG\n", - __FUNCTION__ ); + __func__ ); return rndis_reset_response (configNr, (rndis_reset_msg_type *) buf); @@ -1113,7 +1113,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) /* For USB: host does this every 5 seconds */ if (rndis_debug > 1) DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", - __FUNCTION__ ); + __func__ ); return rndis_keepalive_response (configNr, (rndis_keepalive_msg_type *) buf); @@ -1124,7 +1124,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) * suspending itself. */ pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", - __FUNCTION__ , MsgType, MsgLength); + __func__ , MsgType, MsgLength); { unsigned i; for (i = 0; i < MsgLength; i += 16) { @@ -1159,7 +1159,7 @@ int rndis_register (int (* rndis_control_ack) (struct net_device *)) if (!rndis_per_dev_params [i].used) { rndis_per_dev_params [i].used = 1; rndis_per_dev_params [i].ack = rndis_control_ack; - DBG("%s: configNr = %d\n", __FUNCTION__, i); + DBG("%s: configNr = %d\n", __func__, i); return i; } } @@ -1170,7 +1170,7 @@ int rndis_register (int (* rndis_control_ack) (struct net_device *)) void rndis_deregister (int configNr) { - DBG("%s: \n", __FUNCTION__ ); + DBG("%s: \n", __func__ ); if (configNr >= RNDIS_MAX_CONFIGS) return; rndis_per_dev_params [configNr].used = 0; @@ -1182,7 +1182,7 @@ int rndis_set_param_dev (u8 configNr, struct net_device *dev, struct net_device_stats *stats, u16 *cdc_filter) { - DBG("%s:\n", __FUNCTION__ ); + DBG("%s:\n", __func__ ); if (!dev || !stats) return -1; if (configNr >= RNDIS_MAX_CONFIGS) return -1; @@ -1195,7 +1195,7 @@ int rndis_set_param_dev (u8 configNr, struct net_device *dev, int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) { - DBG("%s:\n", __FUNCTION__ ); + DBG("%s:\n", __func__ ); if (!vendorDescr) return -1; if (configNr >= RNDIS_MAX_CONFIGS) return -1; @@ -1207,7 +1207,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) { - DBG("%s: %u %u\n", __FUNCTION__, medium, speed); + DBG("%s: %u %u\n", __func__, medium, speed); if (configNr >= RNDIS_MAX_CONFIGS) return -1; rndis_per_dev_params [configNr].medium = medium; @@ -1403,7 +1403,7 @@ static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ -int __devinit rndis_init (void) +int __init rndis_init (void) { u8 i; @@ -1415,7 +1415,7 @@ int __devinit rndis_init (void) if (!(rndis_connect_state [i] = create_proc_entry (name, 0660, NULL))) { - DBG("%s :remove entries", __FUNCTION__); + DBG("%s :remove entries", __func__); while (i) { sprintf (name, NAME_TEMPLATE, --i); remove_proc_entry (name, NULL); diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index f5c3896b1d9..433b3f44f42 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -2163,8 +2163,7 @@ static void gs_free_ports(struct gs_dev *dev) port->port_dev = NULL; wake_up_interruptible(&port->port_write_wait); if (port->port_tty) { - wake_up_interruptible(&port->port_tty->read_wait); - wake_up_interruptible(&port->port_tty->write_wait); + tty_hangup(port->port_tty); } spin_unlock_irqrestore(&port->port_lock, flags); } else { diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index bf8be2a41a4..0b87480dd71 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -30,8 +30,8 @@ config USB_EHCI_HCD module will be called ehci-hcd. config USB_EHCI_ROOT_HUB_TT - bool "Root Hub Transaction Translators (EXPERIMENTAL)" - depends on USB_EHCI_HCD && EXPERIMENTAL + bool "Root Hub Transaction Translators" + depends on USB_EHCI_HCD ---help--- Some EHCI chips have vendor-specific extensions to integrate transaction translators, so that no OHCI or UHCI companion @@ -260,3 +260,9 @@ config USB_R8A66597_HCD To compile this driver as a module, choose M here: the module will be called r8a66597-hcd. +config SUPERH_ON_CHIP_R8A66597 + boolean "Enable SuperH on-chip USB like the R8A66597" + depends on USB_R8A66597_HCD && CPU_SUBTYPE_SH7366 + help + Renesas SuperH processor has USB like the R8A66597. + This driver supported processor is SH7366. diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index da7532d38bf..8b5f991e949 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c @@ -237,6 +237,7 @@ static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) if (usb_disabled()) return -ENODEV; + /* FIXME we only want one one probe() not two */ ret = usb_ehci_au1xxx_probe(&ehci_au1xxx_hc_driver, &hcd, pdev); return ret; } @@ -245,6 +246,7 @@ static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); + /* FIXME we only want one one remove() not two */ usb_ehci_au1xxx_remove(hcd, pdev); return 0; } @@ -265,7 +267,7 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev) return 0; } */ -MODULE_ALIAS("au1xxx-ehci"); +MODULE_ALIAS("platform:au1xxx-ehci"); static struct platform_driver ehci_hcd_au1xxx_driver = { .probe = ehci_hcd_au1xxx_drv_probe, .remove = ehci_hcd_au1xxx_drv_remove, @@ -274,6 +276,5 @@ static struct platform_driver ehci_hcd_au1xxx_driver = { /*.resume = ehci_hcd_au1xxx_drv_resume, */ .driver = { .name = "au1xxx-ehci", - .bus = &platform_bus_type } }; diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 64ebfc5548a..4af90df8e7d 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c @@ -27,7 +27,7 @@ #define ehci_warn(ehci, fmt, args...) \ dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) -#ifdef EHCI_VERBOSE_DEBUG +#ifdef VERBOSE_DEBUG # define vdbg dbg # define ehci_vdbg ehci_dbg #else @@ -670,7 +670,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) spin_lock_irqsave (&ehci->lock, flags); - if (buf->bus->controller->power.power_state.event) { + if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { size = scnprintf (next, size, "bus %s, device %s (driver " DRIVER_VERSION ")\n" "%s\n" diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index adb0defa163..6d9bed6c1f4 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -1,5 +1,4 @@ /* - * (C) Copyright David Brownell 2000-2002 * Copyright (c) 2005 MontaVista Software * * This program is free software; you can redistribute it and/or modify it @@ -28,7 +27,6 @@ /* FIXME: Power Management is un-ported so temporarily disable it */ #undef CONFIG_PM -/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ /* configure so an HC device and id are always provided */ /* always called with process context; sleeping is OK */ @@ -331,6 +329,7 @@ static int ehci_fsl_drv_probe(struct platform_device *pdev) if (usb_disabled()) return -ENODEV; + /* FIXME we only want one one probe() not two */ return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev); } @@ -338,12 +337,12 @@ static int ehci_fsl_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); + /* FIXME we only want one one remove() not two */ usb_hcd_fsl_remove(hcd, pdev); - return 0; } -MODULE_ALIAS("fsl-ehci"); +MODULE_ALIAS("platform:fsl-ehci"); static struct platform_driver ehci_fsl_driver = { .probe = ehci_fsl_drv_probe, @@ -351,5 +350,5 @@ static struct platform_driver ehci_fsl_driver = { .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "fsl-ehci", - }, + }, }; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 85074cb36f3..369a8a5ea7b 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -57,35 +57,6 @@ * Special thanks to Intel and VIA for providing host controllers to * test this driver on, and Cypress (including In-System Design) for * providing early devices for those host controllers to talk to! - * - * HISTORY: - * - * 2004-05-10 Root hub and PCI suspend/resume support; remote wakeup. (db) - * 2004-02-24 Replace pci_* with generic dma_* API calls (dsaxena@plexity.net) - * 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka, - * <sojkam@centrum.cz>, updates by DB). - * - * 2002-11-29 Correct handling for hw async_next register. - * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared; - * only scheduling is different, no arbitrary limitations. - * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support, - * clean up HC run state handshaking. - * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts - * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other - * missing pieces: enabling 64bit dma, handoff from BIOS/SMM. - * 2002-05-07 Some error path cleanups to report better errors; wmb(); - * use non-CVS version id; better iso bandwidth claim. - * 2002-04-19 Control/bulk/interrupt submit no longer uses giveback() on - * errors in submit path. Bugfixes to interrupt scheduling/processing. - * 2002-03-05 Initial high-speed ISO support; reduce ITD memory; shift - * more checking to generic hcd framework (db). Make it work with - * Philips EHCI; reduce PCI traffic; shorten IRQ path (Rory Bolt). - * 2002-01-14 Minor cleanup; version synch. - * 2002-01-08 Fix roothub handoff of FS/LS to companion controllers. - * 2002-01-04 Control/Bulk queuing behaves. - * - * 2001-12-12 Initial patch version for Linux 2.5.1 kernel. - * 2001-June Works with usb-storage and NEC EHCI on 2.4 */ #define DRIVER_VERSION "10 Dec 2004" @@ -95,7 +66,7 @@ static const char hcd_name [] = "ehci_hcd"; -#undef EHCI_VERBOSE_DEBUG +#undef VERBOSE_DEBUG #undef EHCI_URB_TRACE #ifdef DEBUG @@ -174,6 +145,16 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr, return -ETIMEDOUT; } +static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, + u32 mask, u32 done, int usec) +{ + int error = handshake(ehci, ptr, mask, done, usec); + if (error) + ehci_to_hcd(ehci)->state = HC_STATE_HALT; + + return error; +} + /* force HC to halt state from unknown (EHCI spec section 2.3) */ static int ehci_halt (struct ehci_hcd *ehci) { @@ -246,11 +227,9 @@ static void ehci_quiesce (struct ehci_hcd *ehci) /* wait for any schedule enables/disables to take effect */ temp = ehci_readl(ehci, &ehci->regs->command) << 10; temp &= STS_ASS | STS_PSS; - if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, - temp, 16 * 125) != 0) { - ehci_to_hcd(ehci)->state = HC_STATE_HALT; + if (handshake_on_error_set_halt(ehci, &ehci->regs->status, + STS_ASS | STS_PSS, temp, 16 * 125)) return; - } /* then disable anything that's still active */ temp = ehci_readl(ehci, &ehci->regs->command); @@ -258,11 +237,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci) ehci_writel(ehci, temp, &ehci->regs->command); /* hardware can take 16 microframes to turn off ... */ - if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, - 0, 16 * 125) != 0) { - ehci_to_hcd(ehci)->state = HC_STATE_HALT; - return; - } + handshake_on_error_set_halt(ehci, &ehci->regs->status, + STS_ASS | STS_PSS, 0, 16 * 125); } /*-------------------------------------------------------------------------*/ @@ -355,17 +331,13 @@ static void ehci_turn_off_all_ports(struct ehci_hcd *ehci) &ehci->regs->port_status[port]); } -/* ehci_shutdown kick in for silicon on any bus (not just pci, etc). - * This forcibly disables dma and IRQs, helping kexec and other cases - * where the next system software may expect clean state. +/* + * Halt HC, turn off all ports, and let the BIOS use the companion controllers. + * Should be called with ehci->lock held. */ -static void -ehci_shutdown (struct usb_hcd *hcd) +static void ehci_silence_controller(struct ehci_hcd *ehci) { - struct ehci_hcd *ehci; - - ehci = hcd_to_ehci (hcd); - (void) ehci_halt (ehci); + ehci_halt(ehci); ehci_turn_off_all_ports(ehci); /* make BIOS/etc use companion controller during reboot */ @@ -375,6 +347,22 @@ ehci_shutdown (struct usb_hcd *hcd) ehci_readl(ehci, &ehci->regs->configured_flag); } +/* ehci_shutdown kick in for silicon on any bus (not just pci, etc). + * This forcibly disables dma and IRQs, helping kexec and other cases + * where the next system software may expect clean state. + */ +static void ehci_shutdown(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + + del_timer_sync(&ehci->watchdog); + del_timer_sync(&ehci->iaa_watchdog); + + spin_lock_irq(&ehci->lock); + ehci_silence_controller(ehci); + spin_unlock_irq(&ehci->lock); +} + static void ehci_port_power (struct ehci_hcd *ehci, int is_on) { unsigned port; @@ -425,15 +413,15 @@ static void ehci_work (struct ehci_hcd *ehci) timer_action (ehci, TIMER_IO_WATCHDOG); } +/* + * Called when the ehci_hcd module is removed. + */ static void ehci_stop (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); ehci_dbg (ehci, "stop\n"); - /* Turn off port power on all root hub ports. */ - ehci_port_power (ehci, 0); - /* no more interrupts ... */ del_timer_sync (&ehci->watchdog); del_timer_sync(&ehci->iaa_watchdog); @@ -442,13 +430,10 @@ static void ehci_stop (struct usb_hcd *hcd) if (HC_IS_RUNNING (hcd->state)) ehci_quiesce (ehci); + ehci_silence_controller(ehci); ehci_reset (ehci); - ehci_writel(ehci, 0, &ehci->regs->intr_enable); spin_unlock_irq(&ehci->lock); - /* let companion controllers work when we aren't */ - ehci_writel(ehci, 0, &ehci->regs->configured_flag); - remove_companion_file(ehci); remove_debug_files (ehci); @@ -676,7 +661,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) cmd = ehci_readl(ehci, &ehci->regs->command); bh = 0; -#ifdef EHCI_VERBOSE_DEBUG +#ifdef VERBOSE_DEBUG /* unrequested/ignored: Frame List Rollover */ dbg_status (ehci, "irq", status); #endif @@ -710,6 +695,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) /* remote wakeup [4.3.1] */ if (status & STS_PCD) { unsigned i = HCS_N_PORTS (ehci->hcs_params); + + /* kick root hub later */ pcd_status = status; /* resume root hub? */ @@ -738,8 +725,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) /* PCI errors [4.15.2.4] */ if (unlikely ((status & STS_FATAL) != 0)) { - /* bogus "fatal" IRQs appear on some chips... why? */ - status = ehci_readl(ehci, &ehci->regs->status); dbg_cmd (ehci, "fatal", ehci_readl(ehci, &ehci->regs->command)); dbg_status (ehci, "fatal", status); @@ -758,7 +743,7 @@ dead: if (bh) ehci_work (ehci); spin_unlock (&ehci->lock); - if (pcd_status & STS_PCD) + if (pcd_status) usb_hcd_poll_rh_status(hcd); return IRQ_HANDLED; } @@ -788,8 +773,14 @@ static int ehci_urb_enqueue ( INIT_LIST_HEAD (&qtd_list); switch (usb_pipetype (urb->pipe)) { - // case PIPE_CONTROL: - // case PIPE_BULK: + case PIPE_CONTROL: + /* qh_completions() code doesn't handle all the fault cases + * in multi-TD control transfers. Even 1KB is rare anyway. + */ + if (urb->transfer_buffer_length > (16 * 1024)) + return -EMSGSIZE; + /* FALLTHROUGH */ + /* case PIPE_BULK: */ default: if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) return -ENOMEM; diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 4e065e556e4..efffef64f59 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -28,7 +28,9 @@ /*-------------------------------------------------------------------------*/ -#ifdef CONFIG_USB_PERSIST +#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) + +#ifdef CONFIG_PM static int ehci_hub_control( struct usb_hcd *hcd, @@ -104,15 +106,6 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) ehci->owned_ports = 0; } -#else /* CONFIG_USB_PERSIST */ - -static inline void ehci_handover_companion_ports(struct ehci_hcd *ehci) -{ } - -#endif - -#ifdef CONFIG_PM - static int ehci_bus_suspend (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); @@ -158,10 +151,10 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) } /* enable remote wakeup on all ports */ - if (device_may_wakeup(&hcd->self.root_hub->dev)) - t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; + if (hcd->self.root_hub->do_remote_wakeup) + t2 |= PORT_WAKE_BITS; else - t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E); + t2 &= ~PORT_WAKE_BITS; if (t1 != t2) { ehci_vdbg (ehci, "port %d, %08x -> %08x\n", @@ -183,7 +176,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) /* allow remote wakeup */ mask = INTR_MASK; - if (!device_may_wakeup(&hcd->self.root_hub->dev)) + if (!hcd->self.root_hub->do_remote_wakeup) mask &= ~STS_PCD; ehci_writel(ehci, mask, &ehci->regs->intr_enable); ehci_readl(ehci, &ehci->regs->intr_enable); @@ -241,8 +234,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) i = HCS_N_PORTS (ehci->hcs_params); while (i--) { temp = ehci_readl(ehci, &ehci->regs->port_status [i]); - temp &= ~(PORT_RWC_BITS - | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); + temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); if (test_bit(i, &ehci->bus_suspended) && (temp & PORT_SUSPEND)) { ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); @@ -281,9 +273,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); spin_unlock_irq (&ehci->lock); - - if (!power_okay) - ehci_handover_companion_ports(ehci); + ehci_handover_companion_ports(ehci); return 0; } @@ -545,8 +535,6 @@ ehci_hub_descriptor ( /*-------------------------------------------------------------------------*/ -#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) - static int ehci_hub_control ( struct usb_hcd *hcd, u16 typeReq, @@ -778,7 +766,7 @@ static int ehci_hub_control ( if (temp & PORT_POWER) status |= 1 << USB_PORT_FEAT_POWER; -#ifndef EHCI_VERBOSE_DEBUG +#ifndef VERBOSE_DEBUG if (status & ~0xffff) /* only if wPortChange is interesting */ #endif dbg_port (ehci, "GetStatus", wIndex + 1, temp); @@ -812,8 +800,6 @@ static int ehci_hub_control ( if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) goto error; - if (device_may_wakeup(&hcd->self.root_hub->dev)) - temp |= PORT_WAKE_BITS; ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); break; case USB_PORT_FEAT_POWER: diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c index 3041d8f055f..601c8795a85 100644 --- a/drivers/usb/host/ehci-ixp4xx.c +++ b/drivers/usb/host/ehci-ixp4xx.c @@ -140,13 +140,12 @@ static int ixp4xx_ehci_remove(struct platform_device *pdev) return 0; } -MODULE_ALIAS("ixp4xx-ehci"); +MODULE_ALIAS("platform:ixp4xx-ehci"); static struct platform_driver ixp4xx_ehci_driver = { .probe = ixp4xx_ehci_probe, .remove = ixp4xx_ehci_remove, .driver = { .name = "ixp4xx-ehci", - .bus = &platform_bus_type }, }; diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 72ccd56e36d..5bb7f6bb13f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -130,6 +130,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) case PCI_VENDOR_ID_TDI: if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { ehci->is_tdi_rh_tt = 1; + hcd->has_tt = 1; tdi_reset(ehci); } break; @@ -221,6 +222,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); #endif + ehci_port_power(ehci, 1); retval = ehci_pci_reinit(ehci, pdev); done: return retval; @@ -299,7 +301,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd) if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { int mask = INTR_MASK; - if (!device_may_wakeup(&hcd->self.root_hub->dev)) + if (!hcd->self.root_hub->do_remote_wakeup) mask &= ~STS_PCD; ehci_writel(ehci, mask, &ehci->regs->intr_enable); ehci_readl(ehci, &ehci->regs->intr_enable); @@ -329,7 +331,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd) /* here we "know" root ports should always stay powered */ ehci_port_power(ehci, 1); - ehci_handover_companion_ports(ehci); hcd->state = HC_STATE_SUSPENDED; return 0; @@ -353,8 +354,8 @@ static const struct hc_driver ehci_pci_hc_driver = { .reset = ehci_pci_setup, .start = ehci_run, #ifdef CONFIG_PM - .suspend = ehci_pci_suspend, - .resume = ehci_pci_resume, + .pci_suspend = ehci_pci_suspend, + .pci_resume = ehci_pci_resume, #endif .stop = ehci_stop, .shutdown = ehci_shutdown, diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c index a3249078c80..6c76036783a 100644 --- a/drivers/usb/host/ehci-ppc-soc.c +++ b/drivers/usb/host/ehci-ppc-soc.c @@ -175,6 +175,7 @@ static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) if (usb_disabled()) return -ENODEV; + /* FIXME we only want one one probe() not two */ ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev); return ret; } @@ -183,17 +184,17 @@ static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); + /* FIXME we only want one one remove() not two */ usb_ehci_ppc_soc_remove(hcd, pdev); return 0; } -MODULE_ALIAS("ppc-soc-ehci"); +MODULE_ALIAS("platform:ppc-soc-ehci"); static struct platform_driver ehci_ppc_soc_driver = { .probe = ehci_hcd_ppc_soc_drv_probe, .remove = ehci_hcd_ppc_soc_drv_remove, .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "ppc-soc-ehci", - .bus = &platform_bus_type } }; diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index bbda58eb881..69782221bcf 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c @@ -125,7 +125,6 @@ static int ps3_ehci_probe(struct ps3_system_bus_device *dev) goto fail_irq; } - dev->core.power.power_state = PMSG_ON; dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev->core.bus_id); diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 2e49de820b1..5ae689139dd 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -242,7 +242,8 @@ __acquires(ehci->lock) if (unlikely(urb->unlinked)) { COUNT(ehci->stats.unlink); } else { - if (likely(status == -EINPROGRESS)) + /* report non-error and short read status as zero */ + if (status == -EINPROGRESS || status == -EREMOTEIO) status = 0; COUNT(ehci->stats.complete); } @@ -250,7 +251,7 @@ __acquires(ehci->lock) #ifdef EHCI_URB_TRACE ehci_dbg (ehci, "%s %s urb %p ep%d%s status %d len %d/%d\n", - __FUNCTION__, urb->dev->devpath, urb, + __func__, urb->dev->devpath, urb, usb_pipeendpoint (urb->pipe), usb_pipein (urb->pipe) ? "in" : "out", status, @@ -283,7 +284,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) int last_status = -EINPROGRESS; int stopped; unsigned count = 0; - int do_status = 0; u8 state; u32 halt = HALT_BIT(ehci); @@ -309,7 +309,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) struct ehci_qtd *qtd; struct urb *urb; u32 token = 0; - int qtd_status; qtd = list_entry (entry, struct ehci_qtd, qtd_list); urb = qtd->urb; @@ -336,11 +335,20 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) /* always clean up qtds the hc de-activated */ if ((token & QTD_STS_ACTIVE) == 0) { + /* on STALL, error, and short reads this urb must + * complete and all its qtds must be recycled. + */ if ((token & QTD_STS_HALT) != 0) { stopped = 1; /* magic dummy for some short reads; qh won't advance. * that silicon quirk can kick in with this dummy too. + * + * other short reads won't stop the queue, including + * control transfers (status stage handles that) or + * most other single-qtd reads ... the queue stops if + * URB_SHORT_NOT_OK was set so the driver submitting + * the urbs could clean it up. */ } else if (IS_SHORT_READ (token) && !(qtd->hw_alt_next @@ -354,28 +362,21 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) { break; + /* scan the whole queue for unlinks whenever it stops */ } else { stopped = 1; - if (unlikely (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) + /* cancel everything if we halt, suspend, etc */ + if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) last_status = -ESHUTDOWN; - /* ignore active urbs unless some previous qtd - * for the urb faulted (including short read) or - * its urb was canceled. we may patch qh or qtds. + /* this qtd is active; skip it unless a previous qtd + * for its urb faulted, or its urb was canceled. */ - if (likely(last_status == -EINPROGRESS && - !urb->unlinked)) - continue; - - /* issue status after short control reads */ - if (unlikely (do_status != 0) - && QTD_PID (token) == 0 /* OUT */) { - do_status = 0; + else if (last_status == -EINPROGRESS && !urb->unlinked) continue; - } - /* token in overlay may be most current */ + /* qh unlinked; token in overlay may be most current */ if (state == QH_STATE_IDLE && cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw_current) @@ -392,21 +393,32 @@ halt: } } - /* remove it from the queue */ - qtd_status = qtd_copy_status(ehci, urb, qtd->length, token); - if (unlikely(qtd_status == -EREMOTEIO)) { - do_status = (!urb->unlinked && - usb_pipecontrol(urb->pipe)); - qtd_status = 0; + /* unless we already know the urb's status, collect qtd status + * and update count of bytes transferred. in common short read + * cases with only one data qtd (including control transfers), + * queue processing won't halt. but with two or more qtds (for + * example, with a 32 KB transfer), when the first qtd gets a + * short read the second must be removed by hand. + */ + if (last_status == -EINPROGRESS) { + last_status = qtd_copy_status(ehci, urb, + qtd->length, token); + if (last_status == -EREMOTEIO + && (qtd->hw_alt_next + & EHCI_LIST_END(ehci))) + last_status = -EINPROGRESS; } - if (likely(last_status == -EINPROGRESS)) - last_status = qtd_status; + /* if we're removing something not at the queue head, + * patch the hardware queue pointer. + */ if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { last = list_entry (qtd->qtd_list.prev, struct ehci_qtd, qtd_list); last->hw_next = qtd->hw_next; } + + /* remove qtd; it's recycled after possible urb completion */ list_del (&qtd->qtd_list); last = qtd; } @@ -431,7 +443,15 @@ halt: qh_refresh(ehci, qh); break; case QH_STATE_LINKED: - /* should be rare for periodic transfers, + /* We won't refresh a QH that's linked (after the HC + * stopped the queue). That avoids a race: + * - HC reads first part of QH; + * - CPU updates that first part and the token; + * - HC reads rest of that QH, including token + * Result: HC gets an inconsistent image, and then + * DMAs to/from the wrong memory (corrupting it). + * + * That should be rare for interrupt transfers, * except maybe high bandwidth ... */ if ((cpu_to_hc32(ehci, QH_SMASK) @@ -549,6 +569,12 @@ qh_urb_transaction ( this_qtd_len = qtd_fill(ehci, qtd, buf, len, token, maxpacket); len -= this_qtd_len; buf += this_qtd_len; + + /* + * short reads advance to a "magic" dummy instead of the next + * qtd ... that forces the queue to stop, for manual cleanup. + * (this will usually be overridden later.) + */ if (is_input) qtd->hw_alt_next = ehci->async->hw_alt_next; @@ -568,8 +594,10 @@ qh_urb_transaction ( list_add_tail (&qtd->qtd_list, head); } - /* unless the bulk/interrupt caller wants a chance to clean - * up after short reads, hc should advance qh past this urb + /* + * unless the caller requires manual cleanup after short reads, + * have the alt_next mechanism keep the queue running after the + * last data qtd (the only one, for control and most other cases). */ if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 || usb_pipecontrol (urb->pipe))) @@ -657,6 +685,14 @@ qh_make ( type = usb_pipetype (urb->pipe); maxp = usb_maxpacket (urb->dev, urb->pipe, !is_input); + /* 1024 byte maxpacket is a hardware ceiling. High bandwidth + * acts like up to 3KB, but is built from smaller packets. + */ + if (max_packet(maxp) > 1024) { + ehci_dbg(ehci, "bogus qh maxpacket %d\n", max_packet(maxp)); + goto done; + } + /* Compute interrupt scheduling parameters just once, and save. * - allowing for high bandwidth, how many nsec/uframe are used? * - split transactions need a second CSPLIT uframe; same question @@ -757,7 +793,13 @@ qh_make ( info2 |= (EHCI_TUNE_MULT_HS << 30); } else if (type == PIPE_BULK) { info1 |= (EHCI_TUNE_RL_HS << 28); - info1 |= 512 << 16; /* usb2 fixed maxpacket */ + /* The USB spec says that high speed bulk endpoints + * always use 512 byte maxpacket. But some device + * vendors decided to ignore that, and MSFT is happy + * to help them do so. So now people expect to use + * such nonconformant devices with Linux too; sigh. + */ + info1 |= max_packet(maxp) << 16; info2 |= (EHCI_TUNE_MULT_HS << 30); } else { /* PIPE_INTERRUPT */ info1 |= max_packet (maxp) << 16; @@ -932,7 +974,7 @@ submit_async ( #ifdef EHCI_URB_TRACE ehci_dbg (ehci, "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", - __FUNCTION__, urb->dev->devpath, urb, + __func__, urb->dev->devpath, urb, epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", urb->transfer_buffer_length, qtd, urb->ep->hcpriv); diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 8a8e08a51ba..be575e46eac 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -440,11 +440,10 @@ static int enable_periodic (struct ehci_hcd *ehci) /* did clearing PSE did take effect yet? * takes effect only at frame boundaries... */ - status = handshake(ehci, &ehci->regs->status, STS_PSS, 0, 9 * 125); - if (status != 0) { - ehci_to_hcd(ehci)->state = HC_STATE_HALT; + status = handshake_on_error_set_halt(ehci, &ehci->regs->status, + STS_PSS, 0, 9 * 125); + if (status) return status; - } cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE; ehci_writel(ehci, cmd, &ehci->regs->command); @@ -465,11 +464,10 @@ static int disable_periodic (struct ehci_hcd *ehci) /* did setting PSE not take effect yet? * takes effect only at frame boundaries... */ - status = handshake(ehci, &ehci->regs->status, STS_PSS, STS_PSS, 9 * 125); - if (status != 0) { - ehci_to_hcd(ehci)->state = HC_STATE_HALT; + status = handshake_on_error_set_halt(ehci, &ehci->regs->status, + STS_PSS, STS_PSS, 9 * 125); + if (status) return status; - } cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE; ehci_writel(ehci, cmd, &ehci->regs->command); @@ -1183,21 +1181,18 @@ itd_urb_transaction ( struct ehci_itd, itd_list); list_del (&itd->itd_list); itd_dma = itd->itd_dma; - } else - itd = NULL; - - if (!itd) { + } else { spin_unlock_irqrestore (&ehci->lock, flags); itd = dma_pool_alloc (ehci->itd_pool, mem_flags, &itd_dma); spin_lock_irqsave (&ehci->lock, flags); + if (!itd) { + iso_sched_free(stream, sched); + spin_unlock_irqrestore(&ehci->lock, flags); + return -ENOMEM; + } } - if (unlikely (NULL == itd)) { - iso_sched_free (stream, sched); - spin_unlock_irqrestore (&ehci->lock, flags); - return -ENOMEM; - } memset (itd, 0, sizeof *itd); itd->itd_dma = itd_dma; list_add (&itd->itd_list, &sched->td_list); @@ -1682,7 +1677,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, #ifdef EHCI_URB_TRACE ehci_dbg (ehci, "%s %s urb %p ep%d%s len %d, %d pkts %d uframes [%p]\n", - __FUNCTION__, urb->dev->devpath, urb, + __func__, urb->dev->devpath, urb, usb_pipeendpoint (urb->pipe), usb_pipein (urb->pipe) ? "in" : "out", urb->transfer_buffer_length, @@ -1816,21 +1811,18 @@ sitd_urb_transaction ( struct ehci_sitd, sitd_list); list_del (&sitd->sitd_list); sitd_dma = sitd->sitd_dma; - } else - sitd = NULL; - - if (!sitd) { + } else { spin_unlock_irqrestore (&ehci->lock, flags); sitd = dma_pool_alloc (ehci->sitd_pool, mem_flags, &sitd_dma); spin_lock_irqsave (&ehci->lock, flags); + if (!sitd) { + iso_sched_free(stream, iso_sched); + spin_unlock_irqrestore(&ehci->lock, flags); + return -ENOMEM; + } } - if (!sitd) { - iso_sched_free (stream, iso_sched); - spin_unlock_irqrestore (&ehci->lock, flags); - return -ENOMEM; - } memset (sitd, 0, sizeof *sitd); sitd->sitd_dma = sitd_dma; list_add (&sitd->sitd_list, &iso_sched->td_list); diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 203a3359a64..20b9a0d0742 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1400,7 +1400,7 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd) spin_unlock_irqrestore(&isp116x->lock, flags); val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); val |= HCCONTROL_USB_SUSPEND; - if (device_may_wakeup(&hcd->self.root_hub->dev)) + if (hcd->self.root_hub->do_remote_wakeup) val |= HCCONTROL_RWE; /* Wait for usb transfers to finish */ msleep(2); @@ -1442,11 +1442,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) break; case HCCONTROL_USB_OPER: spin_unlock_irq(&isp116x->lock); - /* Without setting power_state here the - SUSPENDED state won't be removed from - sysfs/usbN/power.state as a response to remote - wakeup. Maybe in the future. */ - hcd->self.root_hub->dev.power.power_state = PMSG_ON; return 0; default: /* HCCONTROL_USB_RESET: this may happen, when during @@ -1460,7 +1455,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) if ((isp116x->rhdesca & RH_A_NDP) == 2) isp116x_hub_control(hcd, SetPortFeature, USB_PORT_FEAT_POWER, 2, NULL, 0); - hcd->self.root_hub->dev.power.power_state = PMSG_ON; return 0; } @@ -1486,8 +1480,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) isp116x_write_reg32(isp116x, HCCONTROL, (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER); spin_unlock_irq(&isp116x->lock); - /* see analogous comment above */ - hcd->self.root_hub->dev.power.power_state = PMSG_ON; hcd->state = HC_STATE_RUNNING; return 0; @@ -1663,7 +1655,6 @@ static int __devinit isp116x_probe(struct platform_device *pdev) static int isp116x_suspend(struct platform_device *dev, pm_message_t state) { VDBG("%s: state %x\n", __func__, state.event); - dev->dev.power.power_state = state; return 0; } @@ -1672,8 +1663,7 @@ static int isp116x_suspend(struct platform_device *dev, pm_message_t state) */ static int isp116x_resume(struct platform_device *dev) { - VDBG("%s: state %x\n", __func__, dev->power.power_state.event); - dev->dev.power.power_state = PMSG_ON; + VDBG("%s\n", __func__); return 0; } diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index d72dc07dda0..c96db1153dc 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -261,7 +261,6 @@ static const struct hc_driver ohci_at91_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, @@ -348,6 +347,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) if (!clocked) at91_start_clock(); + ohci_finish_controller_resume(hcd); return 0; } #else diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index f90fe0c7373..1b9abdba920 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c @@ -288,7 +288,6 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index a22c30aa745..e06bfaebec5 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c @@ -655,7 +655,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) hcd->product_desc, hcd_name); - if (bus->controller->power.power_state.event) { + if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { size -= scnprintf (next, size, "SUSPENDED (no register access)\n"); goto done; diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 156e93a9d0d..06aadfb0ec2 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c @@ -135,7 +135,6 @@ static struct hc_driver ohci_ep93xx_hc_driver = { .get_frame_number = ohci_get_frame, .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, @@ -177,7 +176,6 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_ ep93xx_stop_hc(&pdev->dev); hcd->state = HC_STATE_SUSPENDED; - pdev->dev.power.power_state = PMSG_SUSPEND; return 0; } @@ -193,9 +191,8 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) ohci->next_statechange = jiffies; ep93xx_start_hc(&pdev->dev); - pdev->dev.power.power_state = PMSG_ON; - usb_hcd_resume_root_hub(hcd); + ohci_finish_controller_resume(hcd); return 0; } #endif diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 48e4b11f4d3..5be3bb3e6a9 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c @@ -36,18 +36,6 @@ /*-------------------------------------------------------------------------*/ -/* hcd->hub_irq_enable() */ -static void ohci_rhsc_enable (struct usb_hcd *hcd) -{ - struct ohci_hcd *ohci = hcd_to_ohci (hcd); - - spin_lock_irq(&ohci->lock); - if (!ohci->autostop) - del_timer(&hcd->rh_timer); /* Prevent next poll */ - ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); - spin_unlock_irq(&ohci->lock); -} - #define OHCI_SCHED_ENABLES \ (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) @@ -103,11 +91,11 @@ __acquires(ohci->lock) finish_unlinks (ohci, ohci_frame_no(ohci)); /* maybe resume can wake root hub */ - if (device_may_wakeup(&ohci_to_hcd(ohci)->self.root_hub->dev) || - autostop) + if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) { ohci->hc_control |= OHCI_CTRL_RWE; - else { - ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable); + } else { + ohci_writel(ohci, OHCI_INTR_RHSC | OHCI_INTR_RD, + &ohci->regs->intrdisable); ohci->hc_control &= ~OHCI_CTRL_RWE; } @@ -326,23 +314,76 @@ static int ohci_bus_resume (struct usb_hcd *hcd) return rc; } +/* Carry out the final steps of resuming the controller device */ +static void ohci_finish_controller_resume(struct usb_hcd *hcd) +{ + struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int port; + bool need_reinit = false; + + /* See if the controller is already running or has been reset */ + ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); + if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { + need_reinit = true; + } else { + switch (ohci->hc_control & OHCI_CTRL_HCFS) { + case OHCI_USB_OPER: + case OHCI_USB_RESET: + need_reinit = true; + } + } + + /* If needed, reinitialize and suspend the root hub */ + if (need_reinit) { + spin_lock_irq(&ohci->lock); + hcd->state = HC_STATE_RESUMING; + ohci_rh_resume(ohci); + hcd->state = HC_STATE_QUIESCING; + ohci_rh_suspend(ohci, 0); + hcd->state = HC_STATE_SUSPENDED; + spin_unlock_irq(&ohci->lock); + } + + /* Normally just turn on port power and enable interrupts */ + else { + ohci_dbg(ohci, "powerup ports\n"); + for (port = 0; port < ohci->num_ports; port++) + ohci_writel(ohci, RH_PS_PPS, + &ohci->regs->roothub.portstatus[port]); + + ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); + ohci_readl(ohci, &ohci->regs->intrenable); + msleep(20); + } +} + /* Carry out polling-, autostop-, and autoresume-related state changes */ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, int any_connected) { int poll_rh = 1; + int rhsc; + rhsc = ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC; switch (ohci->hc_control & OHCI_CTRL_HCFS) { case OHCI_USB_OPER: - /* keep on polling until we know a device is connected - * and RHSC is enabled */ + /* If no status changes are pending, enable status-change + * interrupts. + */ + if (!rhsc && !changed) { + rhsc = OHCI_INTR_RHSC; + ohci_writel(ohci, rhsc, &ohci->regs->intrenable); + } + + /* Keep on polling until we know a device is connected + * and RHSC is enabled, or until we autostop. + */ if (!ohci->autostop) { if (any_connected || !device_may_wakeup(&ohci_to_hcd(ohci) ->self.root_hub->dev)) { - if (ohci_readl(ohci, &ohci->regs->intrenable) & - OHCI_INTR_RHSC) + if (rhsc) poll_rh = 0; } else { ohci->autostop = 1; @@ -355,12 +396,13 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, ohci->autostop = 0; ohci->next_statechange = jiffies + STATECHANGE_DELAY; - } else if (time_after_eq(jiffies, + } else if (rhsc && time_after_eq(jiffies, ohci->next_statechange) && !ohci->ed_rm_list && !(ohci->hc_control & OHCI_SCHED_ENABLES)) { ohci_rh_suspend(ohci, 1); + poll_rh = 0; } } break; @@ -374,6 +416,12 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, else usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); } else { + if (!rhsc && (ohci->autostop || + ohci_to_hcd(ohci)->self.root_hub-> + do_remote_wakeup)) + ohci_writel(ohci, OHCI_INTR_RHSC, + &ohci->regs->intrenable); + /* everything is idle, no need for polling */ poll_rh = 0; } @@ -395,12 +443,16 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci) static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, int any_connected) { - int poll_rh = 1; - - /* keep on polling until RHSC is enabled */ + /* If RHSC is enabled, don't poll */ if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) - poll_rh = 0; - return poll_rh; + return 0; + + /* If no status changes are pending, enable status-change interrupts */ + if (!changed) { + ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); + return 0; + } + return 1; } #endif /* CONFIG_PM */ @@ -564,14 +616,18 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) u32 temp; u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); u16 reset_done = now + PORT_RESET_MSEC; + int limit_1 = DIV_ROUND_UP(PORT_RESET_MSEC, PORT_RESET_HW_MSEC); /* build a "continuous enough" reset signal, with up to * 3msec gap between pulses. scheduler HZ==100 must work; * this might need to be deadline-scheduled. */ do { + int limit_2; + /* spin until any current reset finishes */ - for (;;) { + limit_2 = PORT_RESET_HW_MSEC * 2; + while (--limit_2 >= 0) { temp = ohci_readl (ohci, portstat); /* handle e.g. CardBus eject */ if (temp == ~(u32)0) @@ -581,6 +637,17 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) udelay (500); } + /* timeout (a hardware error) has been observed when + * EHCI sets CF while this driver is resetting a port; + * presumably other disconnect paths might do it too. + */ + if (limit_2 < 0) { + ohci_dbg(ohci, + "port[%d] reset timeout, stat %08x\n", + port, temp); + break; + } + if (!(temp & RH_PS_CCS)) break; if (temp & RH_PS_PRSC) @@ -590,8 +657,11 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) ohci_writel (ohci, RH_PS_PRS, portstat); msleep(PORT_RESET_HW_MSEC); now = ohci_readl(ohci, &ohci->regs->fmnumber); - } while (tick_before(now, reset_done)); - /* caller synchronizes using PRSC */ + } while (tick_before(now, reset_done) && --limit_1 >= 0); + + /* caller synchronizes using PRSC ... and handles PRS + * still being set when this returns. + */ return 0; } diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 13c12ed2225..96d14fa1d83 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c @@ -193,7 +193,6 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 7bfca1ed1b5..6859fb5f1d6 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -466,7 +466,6 @@ static const struct hc_driver ohci_omap_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, @@ -505,21 +504,20 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) omap_ohci_clock_power(0); ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; - dev->dev.power.power_state = PMSG_SUSPEND; return 0; } static int ohci_omap_resume(struct platform_device *dev) { - struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev)); + struct usb_hcd *hcd = platform_get_drvdata(dev); + struct ohci_hcd *ohci = hcd_to_ohci(hcd); if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; omap_ohci_clock_power(1); - dev->dev.power.power_state = PMSG_ON; - usb_hcd_resume_root_hub(platform_get_drvdata(dev)); + ohci_finish_controller_resume(hcd); return 0; } diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index d0360f65ebd..3bf175d95a2 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -238,42 +238,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd) return ret; } -#if defined(CONFIG_USB_PERSIST) && (defined(CONFIG_USB_EHCI_HCD) || \ - defined(CONFIG_USB_EHCI_HCD_MODULE)) - -/* Following a power loss, we must prepare to regain control of the ports - * we used to own. This means turning on the port power before ehci-hcd - * tries to switch ownership. - * - * This isn't a 100% perfect solution. On most systems the OHCI controllers - * lie at lower PCI addresses than the EHCI controller, so they will be - * discovered (and hence resumed) first. But there is no guarantee things - * will always work this way. If the EHCI controller is resumed first and - * the OHCI ports are unpowered, then the handover will fail. - */ -static void prepare_for_handover(struct usb_hcd *hcd) -{ - struct ohci_hcd *ohci = hcd_to_ohci(hcd); - int port; - - /* Here we "know" root ports should always stay powered */ - ohci_dbg(ohci, "powerup ports\n"); - for (port = 0; port < ohci->num_ports; port++) - ohci_writel(ohci, RH_PS_PPS, - &ohci->regs->roothub.portstatus[port]); - - /* Flush those writes */ - ohci_readl(ohci, &ohci->regs->control); - msleep(20); -} - -#else - -static inline void prepare_for_handover(struct usb_hcd *hcd) -{ } - -#endif /* CONFIG_USB_PERSIST etc. */ - #ifdef CONFIG_PM static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) @@ -313,10 +277,7 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) static int ohci_pci_resume (struct usb_hcd *hcd) { set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - - /* FIXME: we should try to detect loss of VBUS power here */ - prepare_for_handover(hcd); - + ohci_finish_controller_resume(hcd); return 0; } @@ -345,9 +306,8 @@ static const struct hc_driver ohci_pci_hc_driver = { .shutdown = ohci_shutdown, #ifdef CONFIG_PM - /* these suspend/resume entries are for upstream PCI glue ONLY */ - .suspend = ohci_pci_suspend, - .resume = ohci_pci_resume, + .pci_suspend = ohci_pci_suspend, + .pci_resume = ohci_pci_resume, #endif /* @@ -367,7 +327,6 @@ static const struct hc_driver ohci_pci_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c index 28b458f20cc..664f07ee873 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-pnx4008.c @@ -280,7 +280,6 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c index 605d59cba28..28467e288a9 100644 --- a/drivers/usb/host/ohci-pnx8550.c +++ b/drivers/usb/host/ohci-pnx8550.c @@ -201,7 +201,6 @@ static const struct hc_driver ohci_pnx8550_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index a6725279122..50e55db1363 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c @@ -72,7 +72,6 @@ static const struct hc_driver ohci_ppc_of_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 523c3012557..cd3398b675b 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c @@ -172,7 +172,6 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c index 01a0caeaa6b..bfdeb0d22d0 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c @@ -68,7 +68,6 @@ static const struct hc_driver ps3_ohci_hc_driver = { .get_frame_number = ohci_get_frame, .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, .start_port_reset = ohci_start_port_reset, #if defined(CONFIG_PM) .bus_suspend = ohci_bus_suspend, @@ -127,7 +126,6 @@ static int ps3_ohci_probe(struct ps3_system_bus_device *dev) goto fail_irq; } - dev->core.power.power_state = PMSG_ON; dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ hcd = usb_create_hcd(&ps3_ohci_hc_driver, &dev->core, dev->core.bus_id); diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 8ad9b3b604b..70b0d4b459e 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -298,7 +298,6 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, @@ -339,7 +338,6 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_ pxa27x_stop_hc(&pdev->dev); hcd->state = HC_STATE_SUSPENDED; - pdev->dev.power.power_state = PMSG_SUSPEND; return 0; } @@ -357,9 +355,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) if ((status = pxa27x_start_hc(&pdev->dev)) < 0) return status; - pdev->dev.power.power_state = PMSG_ON; - usb_hcd_resume_root_hub(hcd); - + ohci_finish_controller_resume(hcd); return 0; } #endif diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index ead4772f0f2..a73d2ff322e 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -466,7 +466,6 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { */ .hub_status_data = ohci_s3c2410_hub_status_data, .hub_control = ohci_s3c2410_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index 0f48f2d9922..99438c65981 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c @@ -231,7 +231,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c index e7ee607278f..60f03cc7ec4 100644 --- a/drivers/usb/host/ohci-sh.c +++ b/drivers/usb/host/ohci-sh.c @@ -68,7 +68,6 @@ static const struct hc_driver ohci_sh_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index 4ea92762fb2..77204f001b9 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c @@ -75,7 +75,6 @@ static const struct hc_driver ohci_sm501_hc_driver = { */ .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, @@ -199,7 +198,8 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev) usb_put_hcd(hcd); dma_release_declared_memory(&pdev->dev); mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); - release_mem_region(mem->start, mem->end - mem->start + 1); + if (mem) + release_mem_region(mem->start, mem->end - mem->start + 1); /* mask interrupts and disable power */ @@ -224,24 +224,26 @@ static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg) sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; - dev->power.power_state = PMSG_SUSPEND; return 0; } static int ohci_sm501_resume(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ohci_hcd *ohci = hcd_to_ohci(hcd); if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); - dev->power.power_state = PMSG_ON; - usb_hcd_resume_root_hub(platform_get_drvdata(pdev)); + ohci_finish_controller_resume(hcd); return 0; } +#else +#define ohci_sm501_suspend NULL +#define ohci_sm501_resume NULL #endif /*-------------------------------------------------------------------------*/ @@ -253,10 +255,8 @@ static struct platform_driver ohci_hcd_sm501_driver = { .probe = ohci_hcd_sm501_drv_probe, .remove = ohci_hcd_sm501_drv_remove, .shutdown = usb_hcd_platform_shutdown, -#ifdef CONFIG_PM .suspend = ohci_sm501_suspend, .resume = ohci_sm501_resume, -#endif .driver = { .owner = THIS_MODULE, .name = "sm501-usb", diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c index 6e9c2d6db88..c4265caec78 100644 --- a/drivers/usb/host/ohci-ssb.c +++ b/drivers/usb/host/ohci-ssb.c @@ -60,36 +60,6 @@ static int ssb_ohci_start(struct usb_hcd *hcd) return err; } -#ifdef CONFIG_PM -static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) -{ - struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); - struct ohci_hcd *ohci = &ohcidev->ohci; - unsigned long flags; - - spin_lock_irqsave(&ohci->lock, flags); - - ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); - ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */ - - /* make sure snapshot being resumed re-enumerates everything */ - if (message.event == PM_EVENT_PRETHAW) - ohci_usb_reset(ohci); - - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - - spin_unlock_irqrestore(&ohci->lock, flags); - return 0; -} - -static int ssb_ohci_hcd_resume(struct usb_hcd *hcd) -{ - set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - usb_hcd_resume_root_hub(hcd); - return 0; -} -#endif /* CONFIG_PM */ - static const struct hc_driver ssb_ohci_hc_driver = { .description = "ssb-usb-ohci", .product_desc = "SSB OHCI Controller", @@ -103,11 +73,6 @@ static const struct hc_driver ssb_ohci_hc_driver = { .stop = ohci_stop, .shutdown = ohci_shutdown, -#ifdef CONFIG_PM - .suspend = ssb_ohci_hcd_suspend, - .resume = ssb_ohci_hcd_resume, -#endif - .urb_enqueue = ohci_urb_enqueue, .urb_dequeue = ohci_urb_dequeue, .endpoint_disable = ohci_endpoint_disable, @@ -116,7 +81,6 @@ static const struct hc_driver ssb_ohci_hc_driver = { .hub_status_data = ohci_hub_status_data, .hub_control = ohci_hub_control, - .hub_irq_enable = ohci_rhsc_enable, #ifdef CONFIG_PM .bus_suspend = ohci_bus_suspend, .bus_resume = ohci_bus_resume, @@ -224,6 +188,7 @@ static int ssb_ohci_resume(struct ssb_device *dev) ssb_device_enable(dev, ohcidev->enable_flags); + ohci_finish_controller_resume(hcd); return 0; } diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 0ee694f043c..ae6e70edd74 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -106,7 +106,7 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup); if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) { dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n", - __FUNCTION__, legsup); + __func__, legsup); goto reset_needed; } @@ -114,14 +114,14 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) || !(cmd & UHCI_USBCMD_EGSM)) { dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n", - __FUNCTION__, cmd); + __func__, cmd); goto reset_needed; } intr = inw(base + UHCI_USBINTR); if (intr & (~UHCI_USBINTR_RESUME)) { dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n", - __FUNCTION__, intr); + __func__, intr); goto reset_needed; } return 0; diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 9f80e528557..f4fa93dabdd 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -46,15 +46,17 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Yoshihiro Shimoda"); MODULE_ALIAS("platform:r8a66597_hcd"); -#define DRIVER_VERSION "29 May 2007" +#define DRIVER_VERSION "10 Apr 2008" static const char hcd_name[] = "r8a66597_hcd"; /* module parameters */ +#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) static unsigned short clock = XTAL12; module_param(clock, ushort, 0644); MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " "(default=0)"); +#endif static unsigned short vif = LDRV; module_param(vif, ushort, 0644); @@ -106,11 +108,22 @@ static void set_devadd_reg(struct r8a66597 *r8a66597, u8 r8a66597_address, r8a66597_write(r8a66597, val, devadd_reg); } -static int enable_controller(struct r8a66597 *r8a66597) +static int r8a66597_clock_enable(struct r8a66597 *r8a66597) { u16 tmp; int i = 0; +#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) + do { + r8a66597_write(r8a66597, SCKE, SYSCFG0); + tmp = r8a66597_read(r8a66597, SYSCFG0); + if (i++ > 1000) { + err("register access fail."); + return -ENXIO; + } + } while ((tmp & SCKE) != SCKE); + r8a66597_write(r8a66597, 0x04, 0x02); +#else do { r8a66597_write(r8a66597, USBE, SYSCFG0); tmp = r8a66597_read(r8a66597, SYSCFG0); @@ -132,13 +145,63 @@ static int enable_controller(struct r8a66597 *r8a66597) return -ENXIO; } } while ((tmp & SCKE) != SCKE); +#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ + + return 0; +} + +static void r8a66597_clock_disable(struct r8a66597 *r8a66597) +{ + r8a66597_bclr(r8a66597, SCKE, SYSCFG0); + udelay(1); +#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) + r8a66597_bclr(r8a66597, PLLC, SYSCFG0); + r8a66597_bclr(r8a66597, XCKE, SYSCFG0); + r8a66597_bclr(r8a66597, USBE, SYSCFG0); +#endif +} + +static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) +{ + u16 val; + + val = port ? DRPD : DCFM | DRPD; + r8a66597_bset(r8a66597, val, get_syscfg_reg(port)); + r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); + + r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, get_dmacfg_reg(port)); + r8a66597_bclr(r8a66597, DTCHE, get_intenb_reg(port)); + r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); +} - r8a66597_bset(r8a66597, DCFM | DRPD, SYSCFG0); - r8a66597_bset(r8a66597, DRPD, SYSCFG1); +static void r8a66597_disable_port(struct r8a66597 *r8a66597, int port) +{ + u16 val, tmp; + + r8a66597_write(r8a66597, 0, get_intenb_reg(port)); + r8a66597_write(r8a66597, 0, get_intsts_reg(port)); + + r8a66597_port_power(r8a66597, port, 0); + + do { + tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS; + udelay(640); + } while (tmp == EDGESTS); + + val = port ? DRPD : DCFM | DRPD; + r8a66597_bclr(r8a66597, val, get_syscfg_reg(port)); + r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port)); +} + +static int enable_controller(struct r8a66597 *r8a66597) +{ + int ret, port; + + ret = r8a66597_clock_enable(r8a66597); + if (ret < 0) + return ret; r8a66597_bset(r8a66597, vif & LDRV, PINCFG); - r8a66597_bset(r8a66597, HSE, SYSCFG0); - r8a66597_bset(r8a66597, HSE, SYSCFG1); r8a66597_bset(r8a66597, USBE, SYSCFG0); r8a66597_bset(r8a66597, BEMPE | NRDYE | BRDYE, INTENB0); @@ -146,53 +209,30 @@ static int enable_controller(struct r8a66597 *r8a66597) r8a66597_bset(r8a66597, BRDY0, BRDYENB); r8a66597_bset(r8a66597, BEMP0, BEMPENB); - r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, DMA0CFG); - r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, DMA1CFG); - r8a66597_bset(r8a66597, endian & BIGEND, CFIFOSEL); r8a66597_bset(r8a66597, endian & BIGEND, D0FIFOSEL); r8a66597_bset(r8a66597, endian & BIGEND, D1FIFOSEL); - r8a66597_bset(r8a66597, TRNENSEL, SOFCFG); r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); - r8a66597_bclr(r8a66597, DTCHE, INTENB1); - r8a66597_bset(r8a66597, ATTCHE, INTENB1); - r8a66597_bclr(r8a66597, DTCHE, INTENB2); - r8a66597_bset(r8a66597, ATTCHE, INTENB2); + + for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) + r8a66597_enable_port(r8a66597, port); return 0; } static void disable_controller(struct r8a66597 *r8a66597) { - u16 tmp; + int port; r8a66597_write(r8a66597, 0, INTENB0); - r8a66597_write(r8a66597, 0, INTENB1); - r8a66597_write(r8a66597, 0, INTENB2); r8a66597_write(r8a66597, 0, INTSTS0); - r8a66597_write(r8a66597, 0, INTSTS1); - r8a66597_write(r8a66597, 0, INTSTS2); - - r8a66597_port_power(r8a66597, 0, 0); - r8a66597_port_power(r8a66597, 1, 0); - - do { - tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS; - udelay(640); - } while (tmp == EDGESTS); - r8a66597_bclr(r8a66597, DCFM | DRPD, SYSCFG0); - r8a66597_bclr(r8a66597, DRPD, SYSCFG1); - r8a66597_bclr(r8a66597, HSE, SYSCFG0); - r8a66597_bclr(r8a66597, HSE, SYSCFG1); + for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) + r8a66597_disable_port(r8a66597, port); - r8a66597_bclr(r8a66597, SCKE, SYSCFG0); - udelay(1); - r8a66597_bclr(r8a66597, PLLC, SYSCFG0); - r8a66597_bclr(r8a66597, XCKE, SYSCFG0); - r8a66597_bclr(r8a66597, USBE, SYSCFG0); + r8a66597_clock_disable(r8a66597); } static int get_parent_r8a66597_address(struct r8a66597 *r8a66597, @@ -577,13 +617,9 @@ static void pipe_buffer_setting(struct r8a66597 *r8a66597, PIPEBUF); r8a66597_write(r8a66597, make_devsel(info->address) | info->maxpacket, PIPEMAXP); - if (info->interval) - info->interval--; r8a66597_write(r8a66597, info->interval, PIPEPERI); } - - /* this function must be called with interrupt disabled */ static void pipe_setting(struct r8a66597 *r8a66597, struct r8a66597_td *td) { @@ -715,6 +751,7 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, struct r8a66597_pipe *pipe, struct urb *urb) { +#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) int i; struct r8a66597_pipe_info *info = &pipe->info; @@ -742,6 +779,7 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, break; } } +#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ } /* this function must be called with interrupt disabled */ @@ -825,6 +863,25 @@ static void disable_r8a66597_pipe_all(struct r8a66597 *r8a66597, dev->dma_map = 0; } +static unsigned long get_timer_interval(struct urb *urb, __u8 interval) +{ + __u8 i; + unsigned long time = 1; + + if (usb_pipeisoc(urb->pipe)) + return 0; + + if (get_r8a66597_usb_speed(urb->dev->speed) == HSMODE) { + for (i = 0; i < (interval - 1); i++) + time *= 2; + time = time * 125 / 1000; /* uSOF -> msec */ + } else { + time = interval; + } + + return time; +} + /* this function must be called with interrupt disabled */ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, struct usb_host_endpoint *hep, @@ -840,7 +897,16 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, & USB_ENDPOINT_XFERTYPE_MASK); info.bufnum = get_bufnum(info.pipenum); info.buf_bsize = get_buf_bsize(info.pipenum); - info.interval = ep->bInterval; + if (info.type == R8A66597_BULK) { + info.interval = 0; + info.timer_interval = 0; + } else { + if (ep->bInterval > IITV) + info.interval = IITV; + else + info.interval = ep->bInterval ? ep->bInterval - 1 : 0; + info.timer_interval = get_timer_interval(urb, ep->bInterval); + } if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) info.dir_in = 1; else @@ -876,10 +942,19 @@ static void pipe_irq_disable(struct r8a66597 *r8a66597, u16 pipenum) } /* this function must be called with interrupt disabled */ -static void r8a66597_usb_preconnect(struct r8a66597 *r8a66597, int port) +static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port, + u16 syssts) { - r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) - | (1 << USB_PORT_FEAT_C_CONNECTION); + if (syssts == SE0) { + r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); + return; + } + + if (syssts == FS_JSTS) + r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); + else if (syssts == LS_JSTS) + r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port)); + r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); } @@ -960,9 +1035,9 @@ static void prepare_packet_read(struct r8a66597 *r8a66597, r8a66597_write(r8a66597, TRCLR, td->pipe->pipetre); r8a66597_write(r8a66597, - (urb->transfer_buffer_length - + td->maxpacket - 1) - / td->maxpacket, + DIV_ROUND_UP + (urb->transfer_buffer_length, + td->maxpacket), td->pipe->pipetrn); r8a66597_bset(r8a66597, TRENB, td->pipe->pipetre); @@ -1021,8 +1096,7 @@ static void prepare_status_packet(struct r8a66597 *r8a66597, r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); r8a66597_write(r8a66597, ~BEMP0, BEMPSTS); - r8a66597_write(r8a66597, BCLR, CFIFOCTR); - r8a66597_write(r8a66597, BVAL, CFIFOCTR); + r8a66597_write(r8a66597, BCLR | BVAL, CFIFOCTR); enable_irq_empty(r8a66597, 0); } else { r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); @@ -1454,13 +1528,21 @@ static void irq_pipe_nrdy(struct r8a66597 *r8a66597) } } +static void r8a66597_root_hub_start_polling(struct r8a66597 *r8a66597) +{ + mod_timer(&r8a66597->rh_timer, + jiffies + msecs_to_jiffies(R8A66597_RH_POLL_TIME)); +} + static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port) { struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; rh->scount = R8A66597_MAX_SAMPLING; - mod_timer(&r8a66597->rh_timer, jiffies + msecs_to_jiffies(50)); + r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) + | (1 << USB_PORT_FEAT_C_CONNECTION); + r8a66597_root_hub_start_polling(r8a66597); } static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) @@ -1547,41 +1629,55 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port) if ((tmp & USBRST) == USBRST) { r8a66597_mdfy(r8a66597, UACT, USBRST | UACT, dvstctr_reg); - mod_timer(&r8a66597->rh_timer, - jiffies + msecs_to_jiffies(50)); + r8a66597_root_hub_start_polling(r8a66597); } else r8a66597_usb_connect(r8a66597, port); } + if (!(rh->port & (1 << USB_PORT_FEAT_CONNECTION))) { + r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port)); + r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); + } + if (rh->scount > 0) { tmp = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; if (tmp == rh->old_syssts) { rh->scount--; - if (rh->scount == 0) { - if (tmp == FS_JSTS) { - r8a66597_bset(r8a66597, HSE, - get_syscfg_reg(port)); - r8a66597_usb_preconnect(r8a66597, port); - } else if (tmp == LS_JSTS) { - r8a66597_bclr(r8a66597, HSE, - get_syscfg_reg(port)); - r8a66597_usb_preconnect(r8a66597, port); - } else if (tmp == SE0) - r8a66597_bset(r8a66597, ATTCHE, - get_intenb_reg(port)); - } else { - mod_timer(&r8a66597->rh_timer, - jiffies + msecs_to_jiffies(50)); - } + if (rh->scount == 0) + r8a66597_check_syssts(r8a66597, port, tmp); + else + r8a66597_root_hub_start_polling(r8a66597); } else { rh->scount = R8A66597_MAX_SAMPLING; rh->old_syssts = tmp; - mod_timer(&r8a66597->rh_timer, - jiffies + msecs_to_jiffies(50)); + r8a66597_root_hub_start_polling(r8a66597); } } } +static void r8a66597_interval_timer(unsigned long _r8a66597) +{ + struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; + unsigned long flags; + u16 pipenum; + struct r8a66597_td *td; + + spin_lock_irqsave(&r8a66597->lock, flags); + + for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { + if (!(r8a66597->interval_map & (1 << pipenum))) + continue; + if (timer_pending(&r8a66597->interval_timer[pipenum])) + continue; + + td = r8a66597_get_td(r8a66597, pipenum); + if (td) + start_transfer(r8a66597, td); + } + + spin_unlock_irqrestore(&r8a66597->lock, flags); +} + static void r8a66597_td_timer(unsigned long _r8a66597) { struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; @@ -1763,10 +1859,17 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd, urb->hcpriv = td; if (request) { - ret = start_transfer(r8a66597, td); - if (ret < 0) { - list_del(&td->queue); - kfree(td); + if (td->pipe->info.timer_interval) { + r8a66597->interval_map |= 1 << td->pipenum; + mod_timer(&r8a66597->interval_timer[td->pipenum], + jiffies + msecs_to_jiffies( + td->pipe->info.timer_interval)); + } else { + ret = start_transfer(r8a66597, td); + if (ret < 0) { + list_del(&td->queue); + kfree(td); + } } } else set_td_timer(r8a66597, td); @@ -2107,13 +2210,11 @@ static struct hc_driver r8a66597_hc_driver = { #if defined(CONFIG_PM) static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) { - pdev->dev.power.power_state = state; return 0; } static int r8a66597_resume(struct platform_device *pdev) { - pdev->dev.power.power_state = PMSG_ON; return 0; } #else /* if defined(CONFIG_PM) */ @@ -2194,6 +2295,9 @@ static int __init r8a66597_probe(struct platform_device *pdev) init_timer(&r8a66597->td_timer[i]); r8a66597->td_timer[i].function = r8a66597_td_timer; r8a66597->td_timer[i].data = (unsigned long)r8a66597; + setup_timer(&r8a66597->interval_timer[i], + r8a66597_interval_timer, + (unsigned long)r8a66597); } INIT_LIST_HEAD(&r8a66597->child_device); diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index 57388252b69..84ee0141731 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h @@ -187,7 +187,11 @@ #define REW 0x4000 /* b14: Buffer rewind */ #define DCLRM 0x2000 /* b13: DMA buffer clear mode */ #define DREQE 0x1000 /* b12: DREQ output enable */ +#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) +#define MBW 0x0800 +#else #define MBW 0x0400 /* b10: Maximum bit width for FIFO access */ +#endif #define MBW_8 0x0000 /* 8bit */ #define MBW_16 0x0400 /* 16bit */ #define BIGEND 0x0100 /* b8: Big endian mode */ @@ -395,8 +399,13 @@ #define R8A66597_MAX_NUM_PIPE 10 #define R8A66597_BUF_BSIZE 8 #define R8A66597_MAX_DEVICE 10 +#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) +#define R8A66597_MAX_ROOT_HUB 1 +#else #define R8A66597_MAX_ROOT_HUB 2 -#define R8A66597_MAX_SAMPLING 10 +#endif +#define R8A66597_MAX_SAMPLING 5 +#define R8A66597_RH_POLL_TIME 10 #define R8A66597_MAX_DMA_CHANNEL 2 #define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL #define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5)) @@ -404,6 +413,7 @@ #define make_devsel(addr) (addr << 12) struct r8a66597_pipe_info { + unsigned long timer_interval; u16 pipenum; u16 address; /* R8A66597 HCD usb address */ u16 epnum; @@ -478,9 +488,11 @@ struct r8a66597 { struct timer_list rh_timer; struct timer_list td_timer[R8A66597_MAX_NUM_PIPE]; + struct timer_list interval_timer[R8A66597_MAX_NUM_PIPE]; unsigned short address_map; unsigned short timeout_map; + unsigned short interval_map; unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; unsigned char dma_map; @@ -526,8 +538,21 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, unsigned long offset, u16 *buf, int len) { +#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) + unsigned long fifoaddr = r8a66597->reg + offset; + unsigned long count; + + count = len / 4; + insl(fifoaddr, buf, count); + + if (len & 0x00000003) { + unsigned long tmp = inl(fifoaddr); + memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03); + } +#else len = (len + 1) / 2; insw(r8a66597->reg + offset, buf, len); +#endif } static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, @@ -541,6 +566,24 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, int len) { unsigned long fifoaddr = r8a66597->reg + offset; +#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) + unsigned long count; + unsigned char *pb; + int i; + + count = len / 4; + outsl(fifoaddr, buf, count); + + if (len & 0x00000003) { + pb = (unsigned char *)buf + count * 4; + for (i = 0; i < (len & 0x00000003); i++) { + if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) + outb(pb[i], fifoaddr + i); + else + outb(pb[i], fifoaddr + 3 - i); + } + } +#else int odd = len & 0x0001; len = len / 2; @@ -549,6 +592,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, buf = &buf[len]; outb((unsigned char)*buf, fifoaddr); } +#endif } static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, @@ -581,6 +625,11 @@ static inline unsigned long get_dvstctr_reg(int port) return port == 0 ? DVSTCTR0 : DVSTCTR1; } +static inline unsigned long get_dmacfg_reg(int port) +{ + return port == 0 ? DMA0CFG : DMA1CFG; +} + static inline unsigned long get_intenb_reg(int port) { return port == 0 ? INTENB1 : INTENB2; diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 629bca0ebe8..274276cf862 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -94,12 +94,10 @@ static void port_power(struct sl811 *sl811, int is_on) sl811->port1 = (1 << USB_PORT_FEAT_POWER); sl811->irq_enable = SL11H_INTMASK_INSRMV; - hcd->self.controller->power.power_state = PMSG_ON; } else { sl811->port1 = 0; sl811->irq_enable = 0; hcd->state = HC_STATE_HALT; - hcd->self.controller->power.power_state = PMSG_SUSPEND; } sl811->ctrl1 = 0; sl811_write(sl811, SL11H_IRQ_ENABLE, 0); @@ -1337,7 +1335,7 @@ static int sl811h_bus_suspend(struct usb_hcd *hcd) { // SOFs off - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); return 0; } @@ -1345,7 +1343,7 @@ static int sl811h_bus_resume(struct usb_hcd *hcd) { // SOFs on - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); return 0; } @@ -1772,8 +1770,6 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state) port_power(sl811, 0); break; } - if (retval == 0) - dev->dev.power.power_state = state; return retval; } @@ -1786,15 +1782,13 @@ sl811h_resume(struct platform_device *dev) /* with no "check to see if VBUS is still powered" board hook, * let's assume it'd only be powered to enable remote wakeup. */ - if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND - || !device_can_wakeup(&hcd->self.root_hub->dev)) { + if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) { sl811->port1 = 0; port_power(sl811, 1); usb_root_hub_lost_power(hcd->self.root_hub); return 0; } - dev->dev.power.power_state = PMSG_ON; return sl811h_bus_resume(hcd); } diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 8e117a795e9..f29307405bb 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c @@ -67,7 +67,7 @@ #include "ohci.h" #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ - OHCI_INTR_WDH) + OHCI_INTR_WDH) MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); MODULE_DESCRIPTION("U132 USB Host Controller Driver"); MODULE_LICENSE("GPL"); @@ -77,15 +77,15 @@ INT_MODULE_PARM(testing, 0); static int distrust_firmware = 1; module_param(distrust_firmware, bool, 0); MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" - "t setup"); + "t setup"); static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); /* * u132_module_lock exists to protect access to global variables * */ static struct mutex u132_module_lock; -static int u132_exiting = 0; -static int u132_instances = 0; +static int u132_exiting; +static int u132_instances; static struct list_head u132_static_list; /* * end of the global variables protected by u132_module_lock @@ -97,115 +97,115 @@ static struct workqueue_struct *workqueue; #define MAX_U132_ENDPS 100 #define MAX_U132_RINGS 4 static const char *cc_to_text[16] = { - "No Error ", - "CRC Error ", - "Bit Stuff ", - "Data Togg ", - "Stall ", - "DevNotResp ", - "PIDCheck ", - "UnExpPID ", - "DataOver ", - "DataUnder ", - "(for hw) ", - "(for hw) ", - "BufferOver ", - "BuffUnder ", - "(for HCD) ", - "(for HCD) " + "No Error ", + "CRC Error ", + "Bit Stuff ", + "Data Togg ", + "Stall ", + "DevNotResp ", + "PIDCheck ", + "UnExpPID ", + "DataOver ", + "DataUnder ", + "(for hw) ", + "(for hw) ", + "BufferOver ", + "BuffUnder ", + "(for HCD) ", + "(for HCD) " }; struct u132_port { - struct u132 *u132; - int reset; - int enable; - int power; - int Status; + struct u132 *u132; + int reset; + int enable; + int power; + int Status; }; struct u132_addr { - u8 address; + u8 address; }; struct u132_udev { - struct kref kref; - struct usb_device *usb_device; - u8 enumeration; - u8 udev_number; - u8 usb_addr; - u8 portnumber; - u8 endp_number_in[16]; - u8 endp_number_out[16]; + struct kref kref; + struct usb_device *usb_device; + u8 enumeration; + u8 udev_number; + u8 usb_addr; + u8 portnumber; + u8 endp_number_in[16]; + u8 endp_number_out[16]; }; #define ENDP_QUEUE_SHIFT 3 #define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) #define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) struct u132_urbq { - struct list_head urb_more; - struct urb *urb; + struct list_head urb_more; + struct urb *urb; }; struct u132_spin { - spinlock_t slock; + spinlock_t slock; }; struct u132_endp { - struct kref kref; - u8 udev_number; - u8 endp_number; - u8 usb_addr; - u8 usb_endp; - struct u132 *u132; - struct list_head endp_ring; - struct u132_ring *ring; - unsigned toggle_bits:2; - unsigned active:1; - unsigned delayed:1; - unsigned input:1; - unsigned output:1; - unsigned pipetype:2; - unsigned dequeueing:1; - unsigned edset_flush:1; - unsigned spare_bits:14; - unsigned long jiffies; - struct usb_host_endpoint *hep; - struct u132_spin queue_lock; - u16 queue_size; - u16 queue_last; - u16 queue_next; - struct urb *urb_list[ENDP_QUEUE_SIZE]; - struct list_head urb_more; - struct delayed_work scheduler; + struct kref kref; + u8 udev_number; + u8 endp_number; + u8 usb_addr; + u8 usb_endp; + struct u132 *u132; + struct list_head endp_ring; + struct u132_ring *ring; + unsigned toggle_bits:2; + unsigned active:1; + unsigned delayed:1; + unsigned input:1; + unsigned output:1; + unsigned pipetype:2; + unsigned dequeueing:1; + unsigned edset_flush:1; + unsigned spare_bits:14; + unsigned long jiffies; + struct usb_host_endpoint *hep; + struct u132_spin queue_lock; + u16 queue_size; + u16 queue_last; + u16 queue_next; + struct urb *urb_list[ENDP_QUEUE_SIZE]; + struct list_head urb_more; + struct delayed_work scheduler; }; struct u132_ring { - unsigned in_use:1; - unsigned length:7; - u8 number; - struct u132 *u132; - struct u132_endp *curr_endp; - struct delayed_work scheduler; + unsigned in_use:1; + unsigned length:7; + u8 number; + struct u132 *u132; + struct u132_endp *curr_endp; + struct delayed_work scheduler; }; struct u132 { - struct kref kref; - struct list_head u132_list; - struct mutex sw_lock; - struct semaphore scheduler_lock; - struct u132_platform_data *board; - struct platform_device *platform_dev; - struct u132_ring ring[MAX_U132_RINGS]; - int sequence_num; - int going; - int power; - int reset; - int num_ports; - u32 hc_control; - u32 hc_fminterval; - u32 hc_roothub_status; - u32 hc_roothub_a; - u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; - int flags; - unsigned long next_statechange; - struct delayed_work monitor; - int num_endpoints; - struct u132_addr addr[MAX_U132_ADDRS]; - struct u132_udev udev[MAX_U132_UDEVS]; - struct u132_port port[MAX_U132_PORTS]; - struct u132_endp *endp[MAX_U132_ENDPS]; + struct kref kref; + struct list_head u132_list; + struct mutex sw_lock; + struct mutex scheduler_lock; + struct u132_platform_data *board; + struct platform_device *platform_dev; + struct u132_ring ring[MAX_U132_RINGS]; + int sequence_num; + int going; + int power; + int reset; + int num_ports; + u32 hc_control; + u32 hc_fminterval; + u32 hc_roothub_status; + u32 hc_roothub_a; + u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; + int flags; + unsigned long next_statechange; + struct delayed_work monitor; + int num_endpoints; + struct u132_addr addr[MAX_U132_ADDRS]; + struct u132_udev udev[MAX_U132_UDEVS]; + struct u132_port port[MAX_U132_PORTS]; + struct u132_endp *endp[MAX_U132_ENDPS]; }; /* @@ -213,34 +213,34 @@ struct u132 { * Does anyone have a better way????? */ #define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \ - offsetof(struct ohci_regs, member), 0, data); + offsetof(struct ohci_regs, member), 0, data); #define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \ - offsetof(struct ohci_regs, member), 0, data); + offsetof(struct ohci_regs, member), 0, data); #define u132_read_pcimem(u132, member, data) \ - usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ - ohci_regs, member), 0, data); + usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ + ohci_regs, member), 0, data); #define u132_write_pcimem(u132, member, data) \ - usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ - ohci_regs, member), 0, data); + usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ + ohci_regs, member), 0, data); static inline struct u132 *udev_to_u132(struct u132_udev *udev) { - u8 udev_number = udev->udev_number; - return container_of(udev, struct u132, udev[udev_number]); + u8 udev_number = udev->udev_number; + return container_of(udev, struct u132, udev[udev_number]); } static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) { - return (struct u132 *)(hcd->hcd_priv); + return (struct u132 *)(hcd->hcd_priv); } static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) { - return container_of((void *)u132, struct usb_hcd, hcd_priv); + return container_of((void *)u132, struct usb_hcd, hcd_priv); } static inline void u132_disable(struct u132 *u132) { - u132_to_hcd(u132)->state = HC_STATE_HALT; + u132_to_hcd(u132)->state = HC_STATE_HALT; } @@ -250,147 +250,147 @@ static inline void u132_disable(struct u132 *u132) #include "../misc/usb_u132.h" static const char hcd_name[] = "u132_hcd"; #define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ - USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ - USB_PORT_STAT_C_RESET) << 16) + USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ + USB_PORT_STAT_C_RESET) << 16) static void u132_hcd_delete(struct kref *kref) { - struct u132 *u132 = kref_to_u132(kref); - struct platform_device *pdev = u132->platform_dev; - struct usb_hcd *hcd = u132_to_hcd(u132); - u132->going += 1; - mutex_lock(&u132_module_lock); - list_del_init(&u132->u132_list); - u132_instances -= 1; - mutex_unlock(&u132_module_lock); - dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" - "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); - usb_put_hcd(hcd); + struct u132 *u132 = kref_to_u132(kref); + struct platform_device *pdev = u132->platform_dev; + struct usb_hcd *hcd = u132_to_hcd(u132); + u132->going += 1; + mutex_lock(&u132_module_lock); + list_del_init(&u132->u132_list); + u132_instances -= 1; + mutex_unlock(&u132_module_lock); + dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" + "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); + usb_put_hcd(hcd); } static inline void u132_u132_put_kref(struct u132 *u132) { - kref_put(&u132->kref, u132_hcd_delete); + kref_put(&u132->kref, u132_hcd_delete); } static inline void u132_u132_init_kref(struct u132 *u132) { - kref_init(&u132->kref); + kref_init(&u132->kref); } static void u132_udev_delete(struct kref *kref) { - struct u132_udev *udev = kref_to_u132_udev(kref); - udev->udev_number = 0; - udev->usb_device = NULL; - udev->usb_addr = 0; - udev->enumeration = 0; + struct u132_udev *udev = kref_to_u132_udev(kref); + udev->udev_number = 0; + udev->usb_device = NULL; + udev->usb_addr = 0; + udev->enumeration = 0; } static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) { - kref_put(&udev->kref, u132_udev_delete); + kref_put(&udev->kref, u132_udev_delete); } static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) { - kref_get(&udev->kref); + kref_get(&udev->kref); } static inline void u132_udev_init_kref(struct u132 *u132, - struct u132_udev *udev) + struct u132_udev *udev) { - kref_init(&udev->kref); + kref_init(&udev->kref); } static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) { - kref_put(&u132->kref, u132_hcd_delete); + kref_put(&u132->kref, u132_hcd_delete); } static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, - unsigned int delta) + unsigned int delta) { - if (delta > 0) { - if (queue_delayed_work(workqueue, &ring->scheduler, delta)) - return; - } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) - return; - kref_put(&u132->kref, u132_hcd_delete); - return; + if (delta > 0) { + if (queue_delayed_work(workqueue, &ring->scheduler, delta)) + return; + } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) + return; + kref_put(&u132->kref, u132_hcd_delete); + return; } static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, - unsigned int delta) + unsigned int delta) { - kref_get(&u132->kref); - u132_ring_requeue_work(u132, ring, delta); - return; + kref_get(&u132->kref); + u132_ring_requeue_work(u132, ring, delta); + return; } static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) { - if (cancel_delayed_work(&ring->scheduler)) { - kref_put(&u132->kref, u132_hcd_delete); - } + if (cancel_delayed_work(&ring->scheduler)) + kref_put(&u132->kref, u132_hcd_delete); } static void u132_endp_delete(struct kref *kref) { - struct u132_endp *endp = kref_to_u132_endp(kref); - struct u132 *u132 = endp->u132; - u8 usb_addr = endp->usb_addr; - u8 usb_endp = endp->usb_endp; - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - u8 endp_number = endp->endp_number; - struct usb_host_endpoint *hep = endp->hep; - struct u132_ring *ring = endp->ring; - struct list_head *head = &endp->endp_ring; - ring->length -= 1; - if (endp == ring->curr_endp) { - if (list_empty(head)) { - ring->curr_endp = NULL; - list_del(head); - } else { - struct u132_endp *next_endp = list_entry(head->next, - struct u132_endp, endp_ring); - ring->curr_endp = next_endp; - list_del(head); - }} else - list_del(head); - if (endp->input) { - udev->endp_number_in[usb_endp] = 0; - u132_udev_put_kref(u132, udev); - } - if (endp->output) { - udev->endp_number_out[usb_endp] = 0; - u132_udev_put_kref(u132, udev); - } - u132->endp[endp_number - 1] = NULL; - hep->hcpriv = NULL; - kfree(endp); - u132_u132_put_kref(u132); + struct u132_endp *endp = kref_to_u132_endp(kref); + struct u132 *u132 = endp->u132; + u8 usb_addr = endp->usb_addr; + u8 usb_endp = endp->usb_endp; + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + u8 endp_number = endp->endp_number; + struct usb_host_endpoint *hep = endp->hep; + struct u132_ring *ring = endp->ring; + struct list_head *head = &endp->endp_ring; + ring->length -= 1; + if (endp == ring->curr_endp) { + if (list_empty(head)) { + ring->curr_endp = NULL; + list_del(head); + } else { + struct u132_endp *next_endp = list_entry(head->next, + struct u132_endp, endp_ring); + ring->curr_endp = next_endp; + list_del(head); + } + } else + list_del(head); + if (endp->input) { + udev->endp_number_in[usb_endp] = 0; + u132_udev_put_kref(u132, udev); + } + if (endp->output) { + udev->endp_number_out[usb_endp] = 0; + u132_udev_put_kref(u132, udev); + } + u132->endp[endp_number - 1] = NULL; + hep->hcpriv = NULL; + kfree(endp); + u132_u132_put_kref(u132); } static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) { - kref_put(&endp->kref, u132_endp_delete); + kref_put(&endp->kref, u132_endp_delete); } static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) { - kref_get(&endp->kref); + kref_get(&endp->kref); } static inline void u132_endp_init_kref(struct u132 *u132, - struct u132_endp *endp) + struct u132_endp *endp) { - kref_init(&endp->kref); - kref_get(&u132->kref); + kref_init(&endp->kref); + kref_get(&u132->kref); } static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, - unsigned int delta) + unsigned int delta) { if (queue_delayed_work(workqueue, &endp->scheduler, delta)) kref_get(&endp->kref); @@ -398,13 +398,13 @@ static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) { - if (cancel_delayed_work(&endp->scheduler)) - kref_put(&endp->kref, u132_endp_delete); + if (cancel_delayed_work(&endp->scheduler)) + kref_put(&endp->kref, u132_endp_delete); } static inline void u132_monitor_put_kref(struct u132 *u132) { - kref_put(&u132->kref, u132_hcd_delete); + kref_put(&u132->kref, u132_hcd_delete); } static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) @@ -421,200 +421,201 @@ static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) static void u132_monitor_cancel_work(struct u132 *u132) { - if (cancel_delayed_work(&u132->monitor)) - kref_put(&u132->kref, u132_hcd_delete); + if (cancel_delayed_work(&u132->monitor)) + kref_put(&u132->kref, u132_hcd_delete); } static int read_roothub_info(struct u132 *u132) { - u32 revision; - int retval; - retval = u132_read_pcimem(u132, revision, &revision); - if (retval) { - dev_err(&u132->platform_dev->dev, "error %d accessing device co" - "ntrol\n", retval); - return retval; - } else if ((revision & 0xFF) == 0x10) { - } else if ((revision & 0xFF) == 0x11) { - } else { - dev_err(&u132->platform_dev->dev, "device revision is not valid" - " %08X\n", revision); - return -ENODEV; - } - retval = u132_read_pcimem(u132, control, &u132->hc_control); - if (retval) { - dev_err(&u132->platform_dev->dev, "error %d accessing device co" - "ntrol\n", retval); - return retval; - } - retval = u132_read_pcimem(u132, roothub.status, - &u132->hc_roothub_status); - if (retval) { - dev_err(&u132->platform_dev->dev, "error %d accessing device re" - "g roothub.status\n", retval); - return retval; - } - retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); - if (retval) { - dev_err(&u132->platform_dev->dev, "error %d accessing device re" - "g roothub.a\n", retval); - return retval; - } - { - int I = u132->num_ports; - int i = 0; - while (I-- > 0) { - retval = u132_read_pcimem(u132, roothub.portstatus[i], - &u132->hc_roothub_portstatus[i]); - if (retval) { - dev_err(&u132->platform_dev->dev, "error %d acc" - "essing device roothub.portstatus[%d]\n" - , retval, i); - return retval; - } else - i += 1; - } - } - return 0; + u32 revision; + int retval; + retval = u132_read_pcimem(u132, revision, &revision); + if (retval) { + dev_err(&u132->platform_dev->dev, "error %d accessing device co" + "ntrol\n", retval); + return retval; + } else if ((revision & 0xFF) == 0x10) { + } else if ((revision & 0xFF) == 0x11) { + } else { + dev_err(&u132->platform_dev->dev, "device revision is not valid" + " %08X\n", revision); + return -ENODEV; + } + retval = u132_read_pcimem(u132, control, &u132->hc_control); + if (retval) { + dev_err(&u132->platform_dev->dev, "error %d accessing device co" + "ntrol\n", retval); + return retval; + } + retval = u132_read_pcimem(u132, roothub.status, + &u132->hc_roothub_status); + if (retval) { + dev_err(&u132->platform_dev->dev, "error %d accessing device re" + "g roothub.status\n", retval); + return retval; + } + retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); + if (retval) { + dev_err(&u132->platform_dev->dev, "error %d accessing device re" + "g roothub.a\n", retval); + return retval; + } + { + int I = u132->num_ports; + int i = 0; + while (I-- > 0) { + retval = u132_read_pcimem(u132, roothub.portstatus[i], + &u132->hc_roothub_portstatus[i]); + if (retval) { + dev_err(&u132->platform_dev->dev, "error %d acc" + "essing device roothub.portstatus[%d]\n" + , retval, i); + return retval; + } else + i += 1; + } + } + return 0; } static void u132_hcd_monitor_work(struct work_struct *work) { - struct u132 *u132 = container_of(work, struct u132, monitor.work); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - u132_monitor_put_kref(u132); - return; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - u132_monitor_put_kref(u132); - return; - } else { - int retval; - mutex_lock(&u132->sw_lock); - retval = read_roothub_info(u132); - if (retval) { - struct usb_hcd *hcd = u132_to_hcd(u132); - u132_disable(u132); - u132->going = 1; - mutex_unlock(&u132->sw_lock); - usb_hc_died(hcd); - ftdi_elan_gone_away(u132->platform_dev); - u132_monitor_put_kref(u132); - return; - } else { - u132_monitor_requeue_work(u132, 500); - mutex_unlock(&u132->sw_lock); - return; - } - } + struct u132 *u132 = container_of(work, struct u132, monitor.work); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + u132_monitor_put_kref(u132); + return; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + u132_monitor_put_kref(u132); + return; + } else { + int retval; + mutex_lock(&u132->sw_lock); + retval = read_roothub_info(u132); + if (retval) { + struct usb_hcd *hcd = u132_to_hcd(u132); + u132_disable(u132); + u132->going = 1; + mutex_unlock(&u132->sw_lock); + usb_hc_died(hcd); + ftdi_elan_gone_away(u132->platform_dev); + u132_monitor_put_kref(u132); + return; + } else { + u132_monitor_requeue_work(u132, 500); + mutex_unlock(&u132->sw_lock); + return; + } + } } static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, - struct urb *urb, int status) + struct urb *urb, int status) { - struct u132_ring *ring; - unsigned long irqs; - struct usb_hcd *hcd = u132_to_hcd(u132); - urb->error_count = 0; - spin_lock_irqsave(&endp->queue_lock.slock, irqs); + struct u132_ring *ring; + unsigned long irqs; + struct usb_hcd *hcd = u132_to_hcd(u132); + urb->error_count = 0; + spin_lock_irqsave(&endp->queue_lock.slock, irqs); usb_hcd_unlink_urb_from_ep(hcd, urb); - endp->queue_next += 1; - if (ENDP_QUEUE_SIZE > --endp->queue_size) { - endp->active = 0; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - } else { - struct list_head *next = endp->urb_more.next; - struct u132_urbq *urbq = list_entry(next, struct u132_urbq, - urb_more); - list_del(next); - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = - urbq->urb; - endp->active = 0; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - kfree(urbq); - } down(&u132->scheduler_lock); - ring = endp->ring; - ring->in_use = 0; - u132_ring_cancel_work(u132, ring); - u132_ring_queue_work(u132, ring, 0); - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); + endp->queue_next += 1; + if (ENDP_QUEUE_SIZE > --endp->queue_size) { + endp->active = 0; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + } else { + struct list_head *next = endp->urb_more.next; + struct u132_urbq *urbq = list_entry(next, struct u132_urbq, + urb_more); + list_del(next); + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = + urbq->urb; + endp->active = 0; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + kfree(urbq); + } + mutex_lock(&u132->scheduler_lock); + ring = endp->ring; + ring->in_use = 0; + u132_ring_cancel_work(u132, ring); + u132_ring_queue_work(u132, ring, 0); + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); usb_hcd_giveback_urb(hcd, urb, status); - return; + return; } static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, - struct urb *urb, int status) + struct urb *urb, int status) { - u132_endp_put_kref(u132, endp); + u132_endp_put_kref(u132, endp); } static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, - struct urb *urb, int status) + struct urb *urb, int status) { - unsigned long irqs; - struct usb_hcd *hcd = u132_to_hcd(u132); - urb->error_count = 0; - spin_lock_irqsave(&endp->queue_lock.slock, irqs); + unsigned long irqs; + struct usb_hcd *hcd = u132_to_hcd(u132); + urb->error_count = 0; + spin_lock_irqsave(&endp->queue_lock.slock, irqs); usb_hcd_unlink_urb_from_ep(hcd, urb); - endp->queue_next += 1; - if (ENDP_QUEUE_SIZE > --endp->queue_size) { - endp->active = 0; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - } else { - struct list_head *next = endp->urb_more.next; - struct u132_urbq *urbq = list_entry(next, struct u132_urbq, - urb_more); - list_del(next); - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = - urbq->urb; - endp->active = 0; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - kfree(urbq); + endp->queue_next += 1; + if (ENDP_QUEUE_SIZE > --endp->queue_size) { + endp->active = 0; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + } else { + struct list_head *next = endp->urb_more.next; + struct u132_urbq *urbq = list_entry(next, struct u132_urbq, + urb_more); + list_del(next); + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = + urbq->urb; + endp->active = 0; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + kfree(urbq); } usb_hcd_giveback_urb(hcd, urb, status); - return; + return; } static inline int edset_input(struct u132 *u132, struct u132_ring *ring, - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, - int toggle_bits, int error_count, int condition_code, int repeat_number, - int halted, int skipped, int actual, int non_null)) + struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, + void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, + int toggle_bits, int error_count, int condition_code, int repeat_number, + int halted, int skipped, int actual, int non_null)) { - return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, - urb, address, endp->usb_endp, toggle_bits, callback); + return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, + urb, address, endp->usb_endp, toggle_bits, callback); } static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, - int toggle_bits, int error_count, int condition_code, int repeat_number, - int halted, int skipped, int actual, int non_null)) + struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, + void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, + int toggle_bits, int error_count, int condition_code, int repeat_number, + int halted, int skipped, int actual, int non_null)) { - return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, - urb, address, endp->usb_endp, toggle_bits, callback); + return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, + urb, address, endp->usb_endp, toggle_bits, callback); } static inline int edset_single(struct u132 *u132, struct u132_ring *ring, - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, - int toggle_bits, int error_count, int condition_code, int repeat_number, - int halted, int skipped, int actual, int non_null)) + struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, + void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, + int toggle_bits, int error_count, int condition_code, int repeat_number, + int halted, int skipped, int actual, int non_null)) { - return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, - endp, urb, address, endp->usb_endp, toggle_bits, callback); + return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, + endp, urb, address, endp->usb_endp, toggle_bits, callback); } static inline int edset_output(struct u132 *u132, struct u132_ring *ring, - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, - int toggle_bits, int error_count, int condition_code, int repeat_number, - int halted, int skipped, int actual, int non_null)) + struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, + void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, + int toggle_bits, int error_count, int condition_code, int repeat_number, + int halted, int skipped, int actual, int non_null)) { - return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, - endp, urb, address, endp->usb_endp, toggle_bits, callback); + return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, + endp, urb, address, endp->usb_endp, toggle_bits, callback); } @@ -623,683 +624,678 @@ static inline int edset_output(struct u132 *u132, struct u132_ring *ring, * */ static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - struct u132_ring *ring = endp->ring; - u8 *u = urb->transfer_buffer + urb->actual_length; - u8 *b = buf; - int L = len; - while (L-- > 0) { - *u++ = *b++; - } - urb->actual_length += len; - if ((condition_code == TD_CC_NOERROR) && - (urb->transfer_buffer_length > urb->actual_length)) { - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, - 1 & toggle_bits); - if (urb->actual_length > 0) { - int retval; - up(&u132->scheduler_lock); - retval = edset_single(u132, ring, endp, urb, - address, endp->toggle_bits, - u132_hcd_interrupt_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, - retval); - } else { - ring->in_use = 0; - endp->active = 0; - endp->jiffies = jiffies + - msecs_to_jiffies(urb->interval); - u132_ring_cancel_work(u132, ring); - u132_ring_queue_work(u132, ring, 0); - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - } - return; - } else if ((condition_code == TD_DATAUNDERRUN) && - ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, - 1 & toggle_bits); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else { - if (condition_code == TD_CC_NOERROR) { - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, - 0, 1 & toggle_bits); - } else if (condition_code == TD_CC_STALL) { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, endp->usb_endp, - 0, 0); - } else { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, endp->usb_endp, - 0, 0); - dev_err(&u132->platform_dev->dev, "urb=%p givin" - "g back INTERRUPT %s\n", urb, - cc_to_text[condition_code]); - } - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, - cc_to_error[condition_code]); - return; - } - } else { + struct u132_ring *ring = endp->ring; + u8 *u = urb->transfer_buffer + urb->actual_length; + u8 *b = buf; + int L = len; + + while (L-- > 0) + *u++ = *b++; + + urb->actual_length += len; + if ((condition_code == TD_CC_NOERROR) && + (urb->transfer_buffer_length > urb->actual_length)) { + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, + 1 & toggle_bits); + if (urb->actual_length > 0) { + int retval; + mutex_unlock(&u132->scheduler_lock); + retval = edset_single(u132, ring, endp, urb, + address, endp->toggle_bits, + u132_hcd_interrupt_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, + retval); + } else { + ring->in_use = 0; + endp->active = 0; + endp->jiffies = jiffies + + msecs_to_jiffies(urb->interval); + u132_ring_cancel_work(u132, ring); + u132_ring_queue_work(u132, ring, 0); + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + } + return; + } else if ((condition_code == TD_DATAUNDERRUN) && + ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, + 1 & toggle_bits); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else { + if (condition_code == TD_CC_NOERROR) { + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, + 0, 1 & toggle_bits); + } else if (condition_code == TD_CC_STALL) { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, endp->usb_endp, + 0, 0); + } else { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, endp->usb_endp, + 0, 0); + dev_err(&u132->platform_dev->dev, "urb=%p givin" + "g back INTERRUPT %s\n", urb, + cc_to_text[condition_code]); + } + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, + cc_to_error[condition_code]); + return; + } + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - struct u132_ring *ring = endp->ring; - urb->actual_length += len; - endp->toggle_bits = toggle_bits; - if (urb->transfer_buffer_length > urb->actual_length) { - int retval; - up(&u132->scheduler_lock); - retval = edset_output(u132, ring, endp, urb, address, - endp->toggle_bits, u132_hcd_bulk_output_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else { - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } - } else { + struct u132_ring *ring = endp->ring; + urb->actual_length += len; + endp->toggle_bits = toggle_bits; + if (urb->transfer_buffer_length > urb->actual_length) { + int retval; + mutex_unlock(&u132->scheduler_lock); + retval = edset_output(u132, ring, endp, urb, address, + endp->toggle_bits, u132_hcd_bulk_output_sent); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else { + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - struct u132_ring *ring = endp->ring; - u8 *u = urb->transfer_buffer + urb->actual_length; - u8 *b = buf; - int L = len; - while (L-- > 0) { - *u++ = *b++; - } - urb->actual_length += len; - if ((condition_code == TD_CC_NOERROR) && - (urb->transfer_buffer_length > urb->actual_length)) { - int retval; - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, - 1 & toggle_bits); - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_input(u132->platform_dev, - ring->number, endp, urb, address, - endp->usb_endp, endp->toggle_bits, - u132_hcd_bulk_input_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else if (condition_code == TD_CC_NOERROR) { - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, - 1 & toggle_bits); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, - cc_to_error[condition_code]); - return; - } else if ((condition_code == TD_DATAUNDERRUN) && - ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, - 1 & toggle_bits); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else if (condition_code == TD_DATAUNDERRUN) { - endp->toggle_bits = toggle_bits; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, - 1 & toggle_bits); - dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" - ") giving back BULK IN %s\n", urb, - cc_to_text[condition_code]); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else if (condition_code == TD_CC_STALL) { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, - cc_to_error[condition_code]); - return; - } else { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); - dev_err(&u132->platform_dev->dev, "urb=%p giving back B" - "ULK IN code=%d %s\n", urb, condition_code, - cc_to_text[condition_code]); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, - cc_to_error[condition_code]); - return; - } - } else { + struct u132_ring *ring = endp->ring; + u8 *u = urb->transfer_buffer + urb->actual_length; + u8 *b = buf; + int L = len; + + while (L-- > 0) + *u++ = *b++; + + urb->actual_length += len; + if ((condition_code == TD_CC_NOERROR) && + (urb->transfer_buffer_length > urb->actual_length)) { + int retval; + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, + 1 & toggle_bits); + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_input(u132->platform_dev, + ring->number, endp, urb, address, + endp->usb_endp, endp->toggle_bits, + u132_hcd_bulk_input_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else if (condition_code == TD_CC_NOERROR) { + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, + 1 & toggle_bits); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, + cc_to_error[condition_code]); + return; + } else if ((condition_code == TD_DATAUNDERRUN) && + ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, + 1 & toggle_bits); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else if (condition_code == TD_DATAUNDERRUN) { + endp->toggle_bits = toggle_bits; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, + 1 & toggle_bits); + dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" + ") giving back BULK IN %s\n", urb, + cc_to_text[condition_code]); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else if (condition_code == TD_CC_STALL) { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, + cc_to_error[condition_code]); + return; + } else { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); + dev_err(&u132->platform_dev->dev, "urb=%p giving back B" + "ULK IN code=%d %s\n", urb, condition_code, + cc_to_text[condition_code]); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, + cc_to_error[condition_code]); + return; + } + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else { + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - struct u132_ring *ring = endp->ring; - u8 *u = urb->transfer_buffer; - u8 *b = buf; - int L = len; - while (L-- > 0) { - *u++ = *b++; - } - urb->actual_length = len; - if ((condition_code == TD_CC_NOERROR) || ((condition_code == - TD_DATAUNDERRUN) && ((urb->transfer_flags & - URB_SHORT_NOT_OK) == 0))) { - int retval; - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_empty(u132->platform_dev, - ring->number, endp, urb, address, - endp->usb_endp, 0x3, - u132_hcd_configure_empty_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else if (condition_code == TD_CC_STALL) { - up(&u132->scheduler_lock); - dev_warn(&u132->platform_dev->dev, "giving back SETUP I" - "NPUT STALL urb %p\n", urb); - u132_hcd_giveback_urb(u132, endp, urb, - cc_to_error[condition_code]); - return; - } else { - up(&u132->scheduler_lock); - dev_err(&u132->platform_dev->dev, "giving back SETUP IN" - "PUT %s urb %p\n", cc_to_text[condition_code], - urb); - u132_hcd_giveback_urb(u132, endp, urb, - cc_to_error[condition_code]); - return; - } - } else { + struct u132_ring *ring = endp->ring; + u8 *u = urb->transfer_buffer; + u8 *b = buf; + int L = len; + + while (L-- > 0) + *u++ = *b++; + + urb->actual_length = len; + if ((condition_code == TD_CC_NOERROR) || ((condition_code == + TD_DATAUNDERRUN) && ((urb->transfer_flags & + URB_SHORT_NOT_OK) == 0))) { + int retval; + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_empty(u132->platform_dev, + ring->number, endp, urb, address, + endp->usb_endp, 0x3, + u132_hcd_configure_empty_sent); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else if (condition_code == TD_CC_STALL) { + mutex_unlock(&u132->scheduler_lock); + dev_warn(&u132->platform_dev->dev, "giving back SETUP I" + "NPUT STALL urb %p\n", urb); + u132_hcd_giveback_urb(u132, endp, urb, + cc_to_error[condition_code]); + return; + } else { + mutex_unlock(&u132->scheduler_lock); + dev_err(&u132->platform_dev->dev, "giving back SETUP IN" + "PUT %s urb %p\n", cc_to_text[condition_code], + urb); + u132_hcd_giveback_urb(u132, endp, urb, + cc_to_error[condition_code]); + return; + } + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else { + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - if (usb_pipein(urb->pipe)) { - int retval; - struct u132_ring *ring = endp->ring; - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_input(u132->platform_dev, - ring->number, endp, urb, address, - endp->usb_endp, 0, - u132_hcd_configure_input_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else { - int retval; - struct u132_ring *ring = endp->ring; - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_input(u132->platform_dev, - ring->number, endp, urb, address, - endp->usb_endp, 0, - u132_hcd_configure_empty_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } - } else { + if (usb_pipein(urb->pipe)) { + int retval; + struct u132_ring *ring = endp->ring; + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_input(u132->platform_dev, + ring->number, endp, urb, address, + endp->usb_endp, 0, + u132_hcd_configure_input_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else { + int retval; + struct u132_ring *ring = endp->ring; + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_input(u132->platform_dev, + ring->number, endp, urb, address, + endp->usb_endp, 0, + u132_hcd_configure_empty_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, - u8 *buf, int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + u8 *buf, int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - u132->addr[0].address = 0; - endp->usb_addr = udev->usb_addr; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else { + u132->addr[0].address = 0; + endp->usb_addr = udev->usb_addr; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, - u8 *buf, int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + u8 *buf, int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - int retval; - struct u132_ring *ring = endp->ring; - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_input(u132->platform_dev, - ring->number, endp, urb, 0, endp->usb_endp, 0, - u132_hcd_enumeration_empty_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else { + int retval; + struct u132_ring *ring = endp->ring; + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_input(u132->platform_dev, + ring->number, endp, urb, 0, endp->usb_endp, 0, + u132_hcd_enumeration_empty_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } else { + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, 0); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - int retval; - struct u132_ring *ring = endp->ring; - u8 *u = urb->transfer_buffer; - u8 *b = buf; - int L = len; - while (L-- > 0) { - *u++ = *b++; - } - urb->actual_length = len; - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_empty(u132->platform_dev, - ring->number, endp, urb, address, endp->usb_endp, 0x3, - u132_hcd_initial_empty_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else { + int retval; + struct u132_ring *ring = endp->ring; + u8 *u = urb->transfer_buffer; + u8 *b = buf; + int L = len; + + while (L-- > 0) + *u++ = *b++; + + urb->actual_length = len; + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_empty(u132->platform_dev, + ring->number, endp, urb, address, endp->usb_endp, 0x3, + u132_hcd_initial_empty_sent); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, - int len, int toggle_bits, int error_count, int condition_code, - int repeat_number, int halted, int skipped, int actual, int non_null) -{ - struct u132_endp *endp = data; - struct u132 *u132 = endp->u132; - u8 address = u132->addr[endp->usb_addr].address; - down(&u132->scheduler_lock); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - up(&u132->scheduler_lock); - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); - return; - } else if (endp->dequeueing) { - endp->dequeueing = 0; - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); - return; - } else if (u132->going > 0) { + int len, int toggle_bits, int error_count, int condition_code, + int repeat_number, int halted, int skipped, int actual, int non_null) +{ + struct u132_endp *endp = data; + struct u132 *u132 = endp->u132; + u8 address = u132->addr[endp->usb_addr].address; + mutex_lock(&u132->scheduler_lock); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + mutex_unlock(&u132->scheduler_lock); + u132_hcd_forget_urb(u132, endp, urb, -ENODEV); + return; + } else if (endp->dequeueing) { + endp->dequeueing = 0; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -EINTR); + return; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - up(&u132->scheduler_lock); - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); - return; + mutex_unlock(&u132->scheduler_lock); + u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); + return; } else if (!urb->unlinked) { - int retval; - struct u132_ring *ring = endp->ring; - up(&u132->scheduler_lock); - retval = usb_ftdi_elan_edset_input(u132->platform_dev, - ring->number, endp, urb, address, endp->usb_endp, 0, - u132_hcd_initial_input_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else { + int retval; + struct u132_ring *ring = endp->ring; + mutex_unlock(&u132->scheduler_lock); + retval = usb_ftdi_elan_edset_input(u132->platform_dev, + ring->number, endp, urb, address, endp->usb_endp, 0, + u132_hcd_initial_input_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); - up(&u132->scheduler_lock); + mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); - return; - } + return; + } } /* @@ -1308,302 +1304,296 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, */ static void u132_hcd_ring_work_scheduler(struct work_struct *work) { - struct u132_ring *ring = + struct u132_ring *ring = container_of(work, struct u132_ring, scheduler.work); - struct u132 *u132 = ring->u132; - down(&u132->scheduler_lock); - if (ring->in_use) { - up(&u132->scheduler_lock); - u132_ring_put_kref(u132, ring); - return; - } else if (ring->curr_endp) { - struct u132_endp *last_endp = ring->curr_endp; - struct list_head *scan; - struct list_head *head = &last_endp->endp_ring; - unsigned long wakeup = 0; - list_for_each(scan, head) { - struct u132_endp *endp = list_entry(scan, - struct u132_endp, endp_ring); - if (endp->queue_next == endp->queue_last) { - } else if ((endp->delayed == 0) - || time_after_eq(jiffies, endp->jiffies)) { - ring->curr_endp = endp; - u132_endp_cancel_work(u132, last_endp); - u132_endp_queue_work(u132, last_endp, 0); - up(&u132->scheduler_lock); - u132_ring_put_kref(u132, ring); - return; - } else { - unsigned long delta = endp->jiffies - jiffies; - if (delta > wakeup) - wakeup = delta; - } - } - if (last_endp->queue_next == last_endp->queue_last) { - } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, - last_endp->jiffies)) { - u132_endp_cancel_work(u132, last_endp); - u132_endp_queue_work(u132, last_endp, 0); - up(&u132->scheduler_lock); - u132_ring_put_kref(u132, ring); - return; - } else { - unsigned long delta = last_endp->jiffies - jiffies; - if (delta > wakeup) - wakeup = delta; - } - if (wakeup > 0) { - u132_ring_requeue_work(u132, ring, wakeup); - up(&u132->scheduler_lock); - return; - } else { - up(&u132->scheduler_lock); - u132_ring_put_kref(u132, ring); - return; - } - } else { - up(&u132->scheduler_lock); - u132_ring_put_kref(u132, ring); - return; - } + struct u132 *u132 = ring->u132; + mutex_lock(&u132->scheduler_lock); + if (ring->in_use) { + mutex_unlock(&u132->scheduler_lock); + u132_ring_put_kref(u132, ring); + return; + } else if (ring->curr_endp) { + struct u132_endp *last_endp = ring->curr_endp; + struct list_head *scan; + struct list_head *head = &last_endp->endp_ring; + unsigned long wakeup = 0; + list_for_each(scan, head) { + struct u132_endp *endp = list_entry(scan, + struct u132_endp, endp_ring); + if (endp->queue_next == endp->queue_last) { + } else if ((endp->delayed == 0) + || time_after_eq(jiffies, endp->jiffies)) { + ring->curr_endp = endp; + u132_endp_cancel_work(u132, last_endp); + u132_endp_queue_work(u132, last_endp, 0); + mutex_unlock(&u132->scheduler_lock); + u132_ring_put_kref(u132, ring); + return; + } else { + unsigned long delta = endp->jiffies - jiffies; + if (delta > wakeup) + wakeup = delta; + } + } + if (last_endp->queue_next == last_endp->queue_last) { + } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, + last_endp->jiffies)) { + u132_endp_cancel_work(u132, last_endp); + u132_endp_queue_work(u132, last_endp, 0); + mutex_unlock(&u132->scheduler_lock); + u132_ring_put_kref(u132, ring); + return; + } else { + unsigned long delta = last_endp->jiffies - jiffies; + if (delta > wakeup) + wakeup = delta; + } + if (wakeup > 0) { + u132_ring_requeue_work(u132, ring, wakeup); + mutex_unlock(&u132->scheduler_lock); + return; + } else { + mutex_unlock(&u132->scheduler_lock); + u132_ring_put_kref(u132, ring); + return; + } + } else { + mutex_unlock(&u132->scheduler_lock); + u132_ring_put_kref(u132, ring); + return; + } } static void u132_hcd_endp_work_scheduler(struct work_struct *work) { - struct u132_ring *ring; - struct u132_endp *endp = + struct u132_ring *ring; + struct u132_endp *endp = container_of(work, struct u132_endp, scheduler.work); - struct u132 *u132 = endp->u132; - down(&u132->scheduler_lock); - ring = endp->ring; - if (endp->edset_flush) { - endp->edset_flush = 0; - if (endp->dequeueing) - usb_ftdi_elan_edset_flush(u132->platform_dev, - ring->number, endp); - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else if (endp->active) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else if (ring->in_use) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else if (endp->queue_next == endp->queue_last) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else if (endp->pipetype == PIPE_INTERRUPT) { - u8 address = u132->addr[endp->usb_addr].address; - if (ring->in_use) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else { - int retval; - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & - endp->queue_next]; - endp->active = 1; - ring->curr_endp = endp; - ring->in_use = 1; - up(&u132->scheduler_lock); - retval = edset_single(u132, ring, endp, urb, address, - endp->toggle_bits, u132_hcd_interrupt_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } - } else if (endp->pipetype == PIPE_CONTROL) { - u8 address = u132->addr[endp->usb_addr].address; - if (ring->in_use) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else if (address == 0) { - int retval; - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & - endp->queue_next]; - endp->active = 1; - ring->curr_endp = endp; - ring->in_use = 1; - up(&u132->scheduler_lock); - retval = edset_setup(u132, ring, endp, urb, address, - 0x2, u132_hcd_initial_setup_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else if (endp->usb_addr == 0) { - int retval; - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & - endp->queue_next]; - endp->active = 1; - ring->curr_endp = endp; - ring->in_use = 1; - up(&u132->scheduler_lock); - retval = edset_setup(u132, ring, endp, urb, 0, 0x2, - u132_hcd_enumeration_address_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } else { - int retval; - u8 address = u132->addr[endp->usb_addr].address; - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & - endp->queue_next]; - endp->active = 1; - ring->curr_endp = endp; - ring->in_use = 1; - up(&u132->scheduler_lock); - retval = edset_setup(u132, ring, endp, urb, address, - 0x2, u132_hcd_configure_setup_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, retval); - return; - } - } else { - if (endp->input) { - u8 address = u132->addr[endp->usb_addr].address; - if (ring->in_use) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else { - int retval; - struct urb *urb = endp->urb_list[ - ENDP_QUEUE_MASK & endp->queue_next]; - endp->active = 1; - ring->curr_endp = endp; - ring->in_use = 1; - up(&u132->scheduler_lock); - retval = edset_input(u132, ring, endp, urb, - address, endp->toggle_bits, - u132_hcd_bulk_input_recv); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, - retval); - return; - } - } else { /* output pipe */ - u8 address = u132->addr[endp->usb_addr].address; - if (ring->in_use) { - up(&u132->scheduler_lock); - u132_endp_put_kref(u132, endp); - return; - } else { - int retval; - struct urb *urb = endp->urb_list[ - ENDP_QUEUE_MASK & endp->queue_next]; - endp->active = 1; - ring->curr_endp = endp; - ring->in_use = 1; - up(&u132->scheduler_lock); - retval = edset_output(u132, ring, endp, urb, - address, endp->toggle_bits, - u132_hcd_bulk_output_sent); - if (retval == 0) { - } else - u132_hcd_giveback_urb(u132, endp, urb, - retval); - return; - } - } - } + struct u132 *u132 = endp->u132; + mutex_lock(&u132->scheduler_lock); + ring = endp->ring; + if (endp->edset_flush) { + endp->edset_flush = 0; + if (endp->dequeueing) + usb_ftdi_elan_edset_flush(u132->platform_dev, + ring->number, endp); + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else if (endp->active) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else if (ring->in_use) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else if (endp->queue_next == endp->queue_last) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else if (endp->pipetype == PIPE_INTERRUPT) { + u8 address = u132->addr[endp->usb_addr].address; + if (ring->in_use) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else { + int retval; + struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & + endp->queue_next]; + endp->active = 1; + ring->curr_endp = endp; + ring->in_use = 1; + mutex_unlock(&u132->scheduler_lock); + retval = edset_single(u132, ring, endp, urb, address, + endp->toggle_bits, u132_hcd_interrupt_recv); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } + } else if (endp->pipetype == PIPE_CONTROL) { + u8 address = u132->addr[endp->usb_addr].address; + if (ring->in_use) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else if (address == 0) { + int retval; + struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & + endp->queue_next]; + endp->active = 1; + ring->curr_endp = endp; + ring->in_use = 1; + mutex_unlock(&u132->scheduler_lock); + retval = edset_setup(u132, ring, endp, urb, address, + 0x2, u132_hcd_initial_setup_sent); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else if (endp->usb_addr == 0) { + int retval; + struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & + endp->queue_next]; + endp->active = 1; + ring->curr_endp = endp; + ring->in_use = 1; + mutex_unlock(&u132->scheduler_lock); + retval = edset_setup(u132, ring, endp, urb, 0, 0x2, + u132_hcd_enumeration_address_sent); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } else { + int retval; + u8 address = u132->addr[endp->usb_addr].address; + struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & + endp->queue_next]; + endp->active = 1; + ring->curr_endp = endp; + ring->in_use = 1; + mutex_unlock(&u132->scheduler_lock); + retval = edset_setup(u132, ring, endp, urb, address, + 0x2, u132_hcd_configure_setup_sent); + if (retval != 0) + u132_hcd_giveback_urb(u132, endp, urb, retval); + return; + } + } else { + if (endp->input) { + u8 address = u132->addr[endp->usb_addr].address; + if (ring->in_use) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else { + int retval; + struct urb *urb = endp->urb_list[ + ENDP_QUEUE_MASK & endp->queue_next]; + endp->active = 1; + ring->curr_endp = endp; + ring->in_use = 1; + mutex_unlock(&u132->scheduler_lock); + retval = edset_input(u132, ring, endp, urb, + address, endp->toggle_bits, + u132_hcd_bulk_input_recv); + if (retval == 0) { + } else + u132_hcd_giveback_urb(u132, endp, urb, + retval); + return; + } + } else { /* output pipe */ + u8 address = u132->addr[endp->usb_addr].address; + if (ring->in_use) { + mutex_unlock(&u132->scheduler_lock); + u132_endp_put_kref(u132, endp); + return; + } else { + int retval; + struct urb *urb = endp->urb_list[ + ENDP_QUEUE_MASK & endp->queue_next]; + endp->active = 1; + ring->curr_endp = endp; + ring->in_use = 1; + mutex_unlock(&u132->scheduler_lock); + retval = edset_output(u132, ring, endp, urb, + address, endp->toggle_bits, + u132_hcd_bulk_output_sent); + if (retval == 0) { + } else + u132_hcd_giveback_urb(u132, endp, urb, + retval); + return; + } + } + } } #ifdef CONFIG_PM static void port_power(struct u132 *u132, int pn, int is_on) { - u132->port[pn].power = is_on; + u132->port[pn].power = is_on; } #endif static void u132_power(struct u132 *u132, int is_on) { - struct usb_hcd *hcd = u132_to_hcd(u132) - ; /* hub is inactive unless the port is powered */ - if (is_on) { - if (u132->power) - return; - u132->power = 1; - hcd->self.controller->power.power_state = PMSG_ON; - } else { - u132->power = 0; - hcd->state = HC_STATE_HALT; - hcd->self.controller->power.power_state = PMSG_SUSPEND; - } + struct usb_hcd *hcd = u132_to_hcd(u132) + ; /* hub is inactive unless the port is powered */ + if (is_on) { + if (u132->power) + return; + u132->power = 1; + } else { + u132->power = 0; + hcd->state = HC_STATE_HALT; + } } static int u132_periodic_reinit(struct u132 *u132) { - int retval; - u32 fi = u132->hc_fminterval & 0x03fff; - u32 fit; - u32 fminterval; - retval = u132_read_pcimem(u132, fminterval, &fminterval); - if (retval) - return retval; - fit = fminterval & FIT; - retval = u132_write_pcimem(u132, fminterval, - (fit ^ FIT) | u132->hc_fminterval); - if (retval) - return retval; - retval = u132_write_pcimem(u132, periodicstart, - ((9 *fi) / 10) & 0x3fff); - if (retval) - return retval; - return 0; + int retval; + u32 fi = u132->hc_fminterval & 0x03fff; + u32 fit; + u32 fminterval; + retval = u132_read_pcimem(u132, fminterval, &fminterval); + if (retval) + return retval; + fit = fminterval & FIT; + retval = u132_write_pcimem(u132, fminterval, + (fit ^ FIT) | u132->hc_fminterval); + if (retval) + return retval; + retval = u132_write_pcimem(u132, periodicstart, + ((9 * fi) / 10) & 0x3fff); + if (retval) + return retval; + return 0; } static char *hcfs2string(int state) { - switch (state) { - case OHCI_USB_RESET: - return "reset"; - case OHCI_USB_RESUME: - return "resume"; - case OHCI_USB_OPER: - return "operational"; - case OHCI_USB_SUSPEND: - return "suspend"; - } - return "?"; + switch (state) { + case OHCI_USB_RESET: + return "reset"; + case OHCI_USB_RESUME: + return "resume"; + case OHCI_USB_OPER: + return "operational"; + case OHCI_USB_SUSPEND: + return "suspend"; + } + return "?"; } static int u132_init(struct u132 *u132) { - int retval; - u32 control; - u132_disable(u132); - u132->next_statechange = jiffies; - retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); - if (retval) - return retval; - retval = u132_read_pcimem(u132, control, &control); - if (retval) - return retval; - if (u132->num_ports == 0) { - u32 rh_a = -1; - retval = u132_read_pcimem(u132, roothub.a, &rh_a); - if (retval) - return retval; - u132->num_ports = rh_a & RH_A_NDP; - retval = read_roothub_info(u132); - if (retval) - return retval; - } - if (u132->num_ports > MAX_U132_PORTS) { - return -EINVAL; - } - return 0; + int retval; + u32 control; + u132_disable(u132); + u132->next_statechange = jiffies; + retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); + if (retval) + return retval; + retval = u132_read_pcimem(u132, control, &control); + if (retval) + return retval; + if (u132->num_ports == 0) { + u32 rh_a = -1; + retval = u132_read_pcimem(u132, roothub.a, &rh_a); + if (retval) + return retval; + u132->num_ports = rh_a & RH_A_NDP; + retval = read_roothub_info(u132); + if (retval) + return retval; + } + if (u132->num_ports > MAX_U132_PORTS) + return -EINVAL; + + return 0; } @@ -1613,280 +1603,278 @@ static int u132_init(struct u132 *u132) */ static int u132_run(struct u132 *u132) { - int retval; - u32 control; - u32 status; - u32 fminterval; - u32 periodicstart; - u32 cmdstatus; - u32 roothub_a; - int mask = OHCI_INTR_INIT; - int first = u132->hc_fminterval == 0; - int sleep_time = 0; - int reset_timeout = 30; /* ... allow extra time */ - u132_disable(u132); - if (first) { - u32 temp; - retval = u132_read_pcimem(u132, fminterval, &temp); - if (retval) - return retval; - u132->hc_fminterval = temp & 0x3fff; - if (u132->hc_fminterval != FI) { - } - u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; - } - retval = u132_read_pcimem(u132, control, &u132->hc_control); - if (retval) - return retval; - dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " - "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), - u132->hc_control); - switch (u132->hc_control & OHCI_CTRL_HCFS) { - case OHCI_USB_OPER: - sleep_time = 0; - break; - case OHCI_USB_SUSPEND: - case OHCI_USB_RESUME: - u132->hc_control &= OHCI_CTRL_RWC; - u132->hc_control |= OHCI_USB_RESUME; - sleep_time = 10; - break; - default: - u132->hc_control &= OHCI_CTRL_RWC; - u132->hc_control |= OHCI_USB_RESET; - sleep_time = 50; - break; - } - retval = u132_write_pcimem(u132, control, u132->hc_control); - if (retval) - return retval; - retval = u132_read_pcimem(u132, control, &control); - if (retval) - return retval; - msleep(sleep_time); - retval = u132_read_pcimem(u132, roothub.a, &roothub_a); - if (retval) - return retval; - if (!(roothub_a & RH_A_NPS)) { - int temp; /* power down each port */ - for (temp = 0; temp < u132->num_ports; temp++) { - retval = u132_write_pcimem(u132, - roothub.portstatus[temp], RH_PS_LSDA); - if (retval) - return retval; - } - } - retval = u132_read_pcimem(u132, control, &control); - if (retval) - return retval; - retry:retval = u132_read_pcimem(u132, cmdstatus, &status); - if (retval) - return retval; - retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); - if (retval) - return retval; - extra:{ - retval = u132_read_pcimem(u132, cmdstatus, &status); - if (retval) - return retval; - if (0 != (status & OHCI_HCR)) { - if (--reset_timeout == 0) { - dev_err(&u132->platform_dev->dev, "USB HC reset" - " timed out!\n"); - return -ENODEV; - } else { - msleep(5); - goto extra; - } - } - } - if (u132->flags & OHCI_QUIRK_INITRESET) { - retval = u132_write_pcimem(u132, control, u132->hc_control); - if (retval) - return retval; - retval = u132_read_pcimem(u132, control, &control); - if (retval) - return retval; - } - retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); - if (retval) - return retval; - retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); - if (retval) - return retval; - retval = u132_write_pcimem(u132, hcca, 0x00000000); - if (retval) - return retval; - retval = u132_periodic_reinit(u132); - if (retval) - return retval; - retval = u132_read_pcimem(u132, fminterval, &fminterval); - if (retval) - return retval; - retval = u132_read_pcimem(u132, periodicstart, &periodicstart); - if (retval) - return retval; - if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { - if (!(u132->flags & OHCI_QUIRK_INITRESET)) { - u132->flags |= OHCI_QUIRK_INITRESET; - goto retry; - } else - dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" - "\n", fminterval, periodicstart); - } /* start controller operations */ - u132->hc_control &= OHCI_CTRL_RWC; - u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; - retval = u132_write_pcimem(u132, control, u132->hc_control); - if (retval) - return retval; - retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); - if (retval) - return retval; - retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); - if (retval) - return retval; - retval = u132_read_pcimem(u132, control, &control); - if (retval) - return retval; - u132_to_hcd(u132)->state = HC_STATE_RUNNING; - retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); - if (retval) - return retval; - retval = u132_write_pcimem(u132, intrstatus, mask); - if (retval) - return retval; - retval = u132_write_pcimem(u132, intrdisable, - OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | - OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | - OHCI_INTR_SO); - if (retval) - return retval; /* handle root hub init quirks ... */ - retval = u132_read_pcimem(u132, roothub.a, &roothub_a); - if (retval) - return retval; - roothub_a &= ~(RH_A_PSM | RH_A_OCPM); - if (u132->flags & OHCI_QUIRK_SUPERIO) { - roothub_a |= RH_A_NOCP; - roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); - retval = u132_write_pcimem(u132, roothub.a, roothub_a); - if (retval) - return retval; - } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { - roothub_a |= RH_A_NPS; - retval = u132_write_pcimem(u132, roothub.a, roothub_a); - if (retval) - return retval; - } - retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); - if (retval) - return retval; - retval = u132_write_pcimem(u132, roothub.b, - (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); - if (retval) - return retval; - retval = u132_read_pcimem(u132, control, &control); - if (retval) - return retval; - mdelay((roothub_a >> 23) & 0x1fe); - u132_to_hcd(u132)->state = HC_STATE_RUNNING; - return 0; + int retval; + u32 control; + u32 status; + u32 fminterval; + u32 periodicstart; + u32 cmdstatus; + u32 roothub_a; + int mask = OHCI_INTR_INIT; + int first = u132->hc_fminterval == 0; + int sleep_time = 0; + int reset_timeout = 30; /* ... allow extra time */ + u132_disable(u132); + if (first) { + u32 temp; + retval = u132_read_pcimem(u132, fminterval, &temp); + if (retval) + return retval; + u132->hc_fminterval = temp & 0x3fff; + u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; + } + retval = u132_read_pcimem(u132, control, &u132->hc_control); + if (retval) + return retval; + dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " + "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), + u132->hc_control); + switch (u132->hc_control & OHCI_CTRL_HCFS) { + case OHCI_USB_OPER: + sleep_time = 0; + break; + case OHCI_USB_SUSPEND: + case OHCI_USB_RESUME: + u132->hc_control &= OHCI_CTRL_RWC; + u132->hc_control |= OHCI_USB_RESUME; + sleep_time = 10; + break; + default: + u132->hc_control &= OHCI_CTRL_RWC; + u132->hc_control |= OHCI_USB_RESET; + sleep_time = 50; + break; + } + retval = u132_write_pcimem(u132, control, u132->hc_control); + if (retval) + return retval; + retval = u132_read_pcimem(u132, control, &control); + if (retval) + return retval; + msleep(sleep_time); + retval = u132_read_pcimem(u132, roothub.a, &roothub_a); + if (retval) + return retval; + if (!(roothub_a & RH_A_NPS)) { + int temp; /* power down each port */ + for (temp = 0; temp < u132->num_ports; temp++) { + retval = u132_write_pcimem(u132, + roothub.portstatus[temp], RH_PS_LSDA); + if (retval) + return retval; + } + } + retval = u132_read_pcimem(u132, control, &control); + if (retval) + return retval; +retry: + retval = u132_read_pcimem(u132, cmdstatus, &status); + if (retval) + return retval; + retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); + if (retval) + return retval; +extra: { + retval = u132_read_pcimem(u132, cmdstatus, &status); + if (retval) + return retval; + if (0 != (status & OHCI_HCR)) { + if (--reset_timeout == 0) { + dev_err(&u132->platform_dev->dev, "USB HC reset" + " timed out!\n"); + return -ENODEV; + } else { + msleep(5); + goto extra; + } + } + } + if (u132->flags & OHCI_QUIRK_INITRESET) { + retval = u132_write_pcimem(u132, control, u132->hc_control); + if (retval) + return retval; + retval = u132_read_pcimem(u132, control, &control); + if (retval) + return retval; + } + retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); + if (retval) + return retval; + retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); + if (retval) + return retval; + retval = u132_write_pcimem(u132, hcca, 0x00000000); + if (retval) + return retval; + retval = u132_periodic_reinit(u132); + if (retval) + return retval; + retval = u132_read_pcimem(u132, fminterval, &fminterval); + if (retval) + return retval; + retval = u132_read_pcimem(u132, periodicstart, &periodicstart); + if (retval) + return retval; + if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { + if (!(u132->flags & OHCI_QUIRK_INITRESET)) { + u132->flags |= OHCI_QUIRK_INITRESET; + goto retry; + } else + dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" + "\n", fminterval, periodicstart); + } /* start controller operations */ + u132->hc_control &= OHCI_CTRL_RWC; + u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; + retval = u132_write_pcimem(u132, control, u132->hc_control); + if (retval) + return retval; + retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); + if (retval) + return retval; + retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); + if (retval) + return retval; + retval = u132_read_pcimem(u132, control, &control); + if (retval) + return retval; + u132_to_hcd(u132)->state = HC_STATE_RUNNING; + retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); + if (retval) + return retval; + retval = u132_write_pcimem(u132, intrstatus, mask); + if (retval) + return retval; + retval = u132_write_pcimem(u132, intrdisable, + OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | + OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | + OHCI_INTR_SO); + if (retval) + return retval; /* handle root hub init quirks ... */ + retval = u132_read_pcimem(u132, roothub.a, &roothub_a); + if (retval) + return retval; + roothub_a &= ~(RH_A_PSM | RH_A_OCPM); + if (u132->flags & OHCI_QUIRK_SUPERIO) { + roothub_a |= RH_A_NOCP; + roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); + retval = u132_write_pcimem(u132, roothub.a, roothub_a); + if (retval) + return retval; + } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { + roothub_a |= RH_A_NPS; + retval = u132_write_pcimem(u132, roothub.a, roothub_a); + if (retval) + return retval; + } + retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); + if (retval) + return retval; + retval = u132_write_pcimem(u132, roothub.b, + (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); + if (retval) + return retval; + retval = u132_read_pcimem(u132, control, &control); + if (retval) + return retval; + mdelay((roothub_a >> 23) & 0x1fe); + u132_to_hcd(u132)->state = HC_STATE_RUNNING; + return 0; } static void u132_hcd_stop(struct usb_hcd *hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" - "een removed %d\n", u132, hcd, u132->going); - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" - "ed\n", hcd); - } else { - mutex_lock(&u132->sw_lock); - msleep(100); - u132_power(u132, 0); - mutex_unlock(&u132->sw_lock); - } + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" + "een removed %d\n", u132, hcd, u132->going); + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" + "ed\n", hcd); + } else { + mutex_lock(&u132->sw_lock); + msleep(100); + u132_power(u132, 0); + mutex_unlock(&u132->sw_lock); + } } static int u132_hcd_start(struct usb_hcd *hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else if (hcd->self.controller) { - int retval; - struct platform_device *pdev = - to_platform_device(hcd->self.controller); - u16 vendor = ((struct u132_platform_data *) - (pdev->dev.platform_data))->vendor; - u16 device = ((struct u132_platform_data *) - (pdev->dev.platform_data))->device; - mutex_lock(&u132->sw_lock); - msleep(10); - if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { - u132->flags = OHCI_QUIRK_AMD756; - } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { - dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" - "ounds unavailable\n"); - } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) - u132->flags |= OHCI_QUIRK_ZFMICRO; - retval = u132_run(u132); - if (retval) { - u132_disable(u132); - u132->going = 1; - } - msleep(100); - mutex_unlock(&u132->sw_lock); - return retval; - } else { - dev_err(&u132->platform_dev->dev, "platform_device missing\n"); - return -ENODEV; - } + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else if (hcd->self.controller) { + int retval; + struct platform_device *pdev = + to_platform_device(hcd->self.controller); + u16 vendor = ((struct u132_platform_data *) + (pdev->dev.platform_data))->vendor; + u16 device = ((struct u132_platform_data *) + (pdev->dev.platform_data))->device; + mutex_lock(&u132->sw_lock); + msleep(10); + if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { + u132->flags = OHCI_QUIRK_AMD756; + } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { + dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" + "ounds unavailable\n"); + } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) + u132->flags |= OHCI_QUIRK_ZFMICRO; + retval = u132_run(u132); + if (retval) { + u132_disable(u132); + u132->going = 1; + } + msleep(100); + mutex_unlock(&u132->sw_lock); + return retval; + } else { + dev_err(&u132->platform_dev->dev, "platform_device missing\n"); + return -ENODEV; + } } static int u132_hcd_reset(struct usb_hcd *hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else { - int retval; - mutex_lock(&u132->sw_lock); - retval = u132_init(u132); - if (retval) { - u132_disable(u132); - u132->going = 1; - } - mutex_unlock(&u132->sw_lock); - return retval; - } + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else { + int retval; + mutex_lock(&u132->sw_lock); + retval = u132_init(u132); + if (retval) { + u132_disable(u132); + u132->going = 1; + } + mutex_unlock(&u132->sw_lock); + return retval; + } } static int create_endpoint_and_queue_int(struct u132 *u132, struct u132_udev *udev, struct urb *urb, - struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, - gfp_t mem_flags) + struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, + gfp_t mem_flags) { - struct u132_ring *ring; - unsigned long irqs; + struct u132_ring *ring; + unsigned long irqs; int rc; u8 endp_number; struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); - if (!endp) { - return -ENOMEM; - } + if (!endp) + return -ENOMEM; spin_lock_init(&endp->queue_lock.slock); spin_lock_irqsave(&endp->queue_lock.slock, irqs); @@ -1899,94 +1887,93 @@ static int create_endpoint_and_queue_int(struct u132 *u132, endp_number = ++u132->num_endpoints; urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; - INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); - INIT_LIST_HEAD(&endp->urb_more); - ring = endp->ring = &u132->ring[0]; - if (ring->curr_endp) { - list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); - } else { - INIT_LIST_HEAD(&endp->endp_ring); - ring->curr_endp = endp; - } - ring->length += 1; - endp->dequeueing = 0; - endp->edset_flush = 0; - endp->active = 0; - endp->delayed = 0; - endp->endp_number = endp_number; - endp->u132 = u132; + INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); + INIT_LIST_HEAD(&endp->urb_more); + ring = endp->ring = &u132->ring[0]; + if (ring->curr_endp) { + list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); + } else { + INIT_LIST_HEAD(&endp->endp_ring); + ring->curr_endp = endp; + } + ring->length += 1; + endp->dequeueing = 0; + endp->edset_flush = 0; + endp->active = 0; + endp->delayed = 0; + endp->endp_number = endp_number; + endp->u132 = u132; endp->hep = urb->ep; - endp->pipetype = usb_pipetype(urb->pipe); - u132_endp_init_kref(u132, endp); - if (usb_pipein(urb->pipe)) { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, usb_endp, 0, 0); - endp->input = 1; - endp->output = 0; - udev->endp_number_in[usb_endp] = endp_number; - u132_udev_get_kref(u132, udev); - } else { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, usb_endp, 1, 0); - endp->input = 0; - endp->output = 1; - udev->endp_number_out[usb_endp] = endp_number; - u132_udev_get_kref(u132, udev); - } - urb->hcpriv = u132; - endp->delayed = 1; - endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); - endp->udev_number = address; - endp->usb_addr = usb_addr; - endp->usb_endp = usb_endp; - endp->queue_size = 1; - endp->queue_last = 0; - endp->queue_next = 0; - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); - return 0; + endp->pipetype = usb_pipetype(urb->pipe); + u132_endp_init_kref(u132, endp); + if (usb_pipein(urb->pipe)) { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, usb_endp, 0, 0); + endp->input = 1; + endp->output = 0; + udev->endp_number_in[usb_endp] = endp_number; + u132_udev_get_kref(u132, udev); + } else { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, usb_endp, 1, 0); + endp->input = 0; + endp->output = 1; + udev->endp_number_out[usb_endp] = endp_number; + u132_udev_get_kref(u132, udev); + } + urb->hcpriv = u132; + endp->delayed = 1; + endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); + endp->udev_number = address; + endp->usb_addr = usb_addr; + endp->usb_endp = usb_endp; + endp->queue_size = 1; + endp->queue_last = 0; + endp->queue_next = 0; + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); + return 0; } static int queue_int_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, struct urb *urb, - struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, - u8 usb_endp, u8 address) -{ - urb->hcpriv = u132; - endp->delayed = 1; - endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; - } else { - struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), - GFP_ATOMIC); - if (urbq == NULL) { - endp->queue_size -= 1; - return -ENOMEM; - } else { - list_add_tail(&urbq->urb_more, &endp->urb_more); - urbq->urb = urb; - } - } - return 0; + struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, + u8 usb_endp, u8 address) +{ + urb->hcpriv = u132; + endp->delayed = 1; + endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); + if (endp->queue_size++ < ENDP_QUEUE_SIZE) { + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; + } else { + struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), + GFP_ATOMIC); + if (urbq == NULL) { + endp->queue_size -= 1; + return -ENOMEM; + } else { + list_add_tail(&urbq->urb_more, &endp->urb_more); + urbq->urb = urb; + } + } + return 0; } static int create_endpoint_and_queue_bulk(struct u132 *u132, struct u132_udev *udev, struct urb *urb, - struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, - gfp_t mem_flags) + struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, + gfp_t mem_flags) { - int ring_number; - struct u132_ring *ring; - unsigned long irqs; + int ring_number; + struct u132_ring *ring; + unsigned long irqs; int rc; u8 endp_number; struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); - if (!endp) { - return -ENOMEM; - } + if (!endp) + return -ENOMEM; spin_lock_init(&endp->queue_lock.slock); spin_lock_irqsave(&endp->queue_lock.slock, irqs); @@ -1999,91 +1986,90 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132, endp_number = ++u132->num_endpoints; urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; - INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); - INIT_LIST_HEAD(&endp->urb_more); - endp->dequeueing = 0; - endp->edset_flush = 0; - endp->active = 0; - endp->delayed = 0; - endp->endp_number = endp_number; - endp->u132 = u132; + INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); + INIT_LIST_HEAD(&endp->urb_more); + endp->dequeueing = 0; + endp->edset_flush = 0; + endp->active = 0; + endp->delayed = 0; + endp->endp_number = endp_number; + endp->u132 = u132; endp->hep = urb->ep; - endp->pipetype = usb_pipetype(urb->pipe); - u132_endp_init_kref(u132, endp); - if (usb_pipein(urb->pipe)) { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, usb_endp, 0, 0); - ring_number = 3; - endp->input = 1; - endp->output = 0; - udev->endp_number_in[usb_endp] = endp_number; - u132_udev_get_kref(u132, udev); - } else { - endp->toggle_bits = 0x2; - usb_settoggle(udev->usb_device, usb_endp, 1, 0); - ring_number = 2; - endp->input = 0; - endp->output = 1; - udev->endp_number_out[usb_endp] = endp_number; - u132_udev_get_kref(u132, udev); - } - ring = endp->ring = &u132->ring[ring_number - 1]; - if (ring->curr_endp) { - list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); - } else { - INIT_LIST_HEAD(&endp->endp_ring); - ring->curr_endp = endp; - } - ring->length += 1; - urb->hcpriv = u132; - endp->udev_number = address; - endp->usb_addr = usb_addr; - endp->usb_endp = usb_endp; - endp->queue_size = 1; - endp->queue_last = 0; - endp->queue_next = 0; - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - u132_endp_queue_work(u132, endp, 0); - return 0; + endp->pipetype = usb_pipetype(urb->pipe); + u132_endp_init_kref(u132, endp); + if (usb_pipein(urb->pipe)) { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, usb_endp, 0, 0); + ring_number = 3; + endp->input = 1; + endp->output = 0; + udev->endp_number_in[usb_endp] = endp_number; + u132_udev_get_kref(u132, udev); + } else { + endp->toggle_bits = 0x2; + usb_settoggle(udev->usb_device, usb_endp, 1, 0); + ring_number = 2; + endp->input = 0; + endp->output = 1; + udev->endp_number_out[usb_endp] = endp_number; + u132_udev_get_kref(u132, udev); + } + ring = endp->ring = &u132->ring[ring_number - 1]; + if (ring->curr_endp) { + list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); + } else { + INIT_LIST_HEAD(&endp->endp_ring); + ring->curr_endp = endp; + } + ring->length += 1; + urb->hcpriv = u132; + endp->udev_number = address; + endp->usb_addr = usb_addr; + endp->usb_endp = usb_endp; + endp->queue_size = 1; + endp->queue_last = 0; + endp->queue_next = 0; + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + u132_endp_queue_work(u132, endp, 0); + return 0; } static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, struct urb *urb, - struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, - u8 usb_endp, u8 address) -{ - urb->hcpriv = u132; - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; - } else { - struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), - GFP_ATOMIC); - if (urbq == NULL) { - endp->queue_size -= 1; - return -ENOMEM; - } else { - list_add_tail(&urbq->urb_more, &endp->urb_more); - urbq->urb = urb; - } - } - return 0; + struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, + u8 usb_endp, u8 address) +{ + urb->hcpriv = u132; + if (endp->queue_size++ < ENDP_QUEUE_SIZE) { + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; + } else { + struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), + GFP_ATOMIC); + if (urbq == NULL) { + endp->queue_size -= 1; + return -ENOMEM; + } else { + list_add_tail(&urbq->urb_more, &endp->urb_more); + urbq->urb = urb; + } + } + return 0; } static int create_endpoint_and_queue_control(struct u132 *u132, struct urb *urb, - struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, - gfp_t mem_flags) + struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, + gfp_t mem_flags) { - struct u132_ring *ring; + struct u132_ring *ring; unsigned long irqs; int rc; u8 endp_number; struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); - if (!endp) { - return -ENOMEM; - } + if (!endp) + return -ENOMEM; spin_lock_init(&endp->queue_lock.slock); spin_lock_irqsave(&endp->queue_lock.slock, irqs); @@ -2096,204 +2082,203 @@ static int create_endpoint_and_queue_control(struct u132 *u132, endp_number = ++u132->num_endpoints; urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; - INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); - INIT_LIST_HEAD(&endp->urb_more); - ring = endp->ring = &u132->ring[0]; - if (ring->curr_endp) { - list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); - } else { - INIT_LIST_HEAD(&endp->endp_ring); - ring->curr_endp = endp; - } - ring->length += 1; - endp->dequeueing = 0; - endp->edset_flush = 0; - endp->active = 0; - endp->delayed = 0; - endp->endp_number = endp_number; - endp->u132 = u132; + INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); + INIT_LIST_HEAD(&endp->urb_more); + ring = endp->ring = &u132->ring[0]; + if (ring->curr_endp) { + list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); + } else { + INIT_LIST_HEAD(&endp->endp_ring); + ring->curr_endp = endp; + } + ring->length += 1; + endp->dequeueing = 0; + endp->edset_flush = 0; + endp->active = 0; + endp->delayed = 0; + endp->endp_number = endp_number; + endp->u132 = u132; endp->hep = urb->ep; - u132_endp_init_kref(u132, endp); - u132_endp_get_kref(u132, endp); - if (usb_addr == 0) { - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - endp->udev_number = address; - endp->usb_addr = usb_addr; - endp->usb_endp = usb_endp; - endp->input = 1; - endp->output = 1; - endp->pipetype = usb_pipetype(urb->pipe); - u132_udev_init_kref(u132, udev); - u132_udev_get_kref(u132, udev); - udev->endp_number_in[usb_endp] = endp_number; - udev->endp_number_out[usb_endp] = endp_number; - urb->hcpriv = u132; - endp->queue_size = 1; - endp->queue_last = 0; - endp->queue_next = 0; - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - u132_endp_queue_work(u132, endp, 0); - return 0; - } else { /*(usb_addr > 0) */ - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - endp->udev_number = address; - endp->usb_addr = usb_addr; - endp->usb_endp = usb_endp; - endp->input = 1; - endp->output = 1; - endp->pipetype = usb_pipetype(urb->pipe); - u132_udev_get_kref(u132, udev); - udev->enumeration = 2; - udev->endp_number_in[usb_endp] = endp_number; - udev->endp_number_out[usb_endp] = endp_number; - urb->hcpriv = u132; - endp->queue_size = 1; - endp->queue_last = 0; - endp->queue_next = 0; - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - u132_endp_queue_work(u132, endp, 0); - return 0; - } + u132_endp_init_kref(u132, endp); + u132_endp_get_kref(u132, endp); + if (usb_addr == 0) { + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + endp->udev_number = address; + endp->usb_addr = usb_addr; + endp->usb_endp = usb_endp; + endp->input = 1; + endp->output = 1; + endp->pipetype = usb_pipetype(urb->pipe); + u132_udev_init_kref(u132, udev); + u132_udev_get_kref(u132, udev); + udev->endp_number_in[usb_endp] = endp_number; + udev->endp_number_out[usb_endp] = endp_number; + urb->hcpriv = u132; + endp->queue_size = 1; + endp->queue_last = 0; + endp->queue_next = 0; + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + u132_endp_queue_work(u132, endp, 0); + return 0; + } else { /*(usb_addr > 0) */ + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + endp->udev_number = address; + endp->usb_addr = usb_addr; + endp->usb_endp = usb_endp; + endp->input = 1; + endp->output = 1; + endp->pipetype = usb_pipetype(urb->pipe); + u132_udev_get_kref(u132, udev); + udev->enumeration = 2; + udev->endp_number_in[usb_endp] = endp_number; + udev->endp_number_out[usb_endp] = endp_number; + urb->hcpriv = u132; + endp->queue_size = 1; + endp->queue_last = 0; + endp->queue_next = 0; + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + u132_endp_queue_work(u132, endp, 0); + return 0; + } } static int queue_control_on_old_endpoint(struct u132 *u132, struct urb *urb, - struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, - u8 usb_endp) -{ - if (usb_addr == 0) { - if (usb_pipein(urb->pipe)) { - urb->hcpriv = u132; - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { - endp->urb_list[ENDP_QUEUE_MASK & - endp->queue_last++] = urb; - } else { - struct u132_urbq *urbq = - kmalloc(sizeof(struct u132_urbq), - GFP_ATOMIC); - if (urbq == NULL) { - endp->queue_size -= 1; - return -ENOMEM; - } else { - list_add_tail(&urbq->urb_more, - &endp->urb_more); - urbq->urb = urb; - } - } - return 0; - } else { /* usb_pipeout(urb->pipe) */ - struct u132_addr *addr = &u132->addr[usb_dev->devnum]; - int I = MAX_U132_UDEVS; - int i = 0; - while (--I > 0) { - struct u132_udev *udev = &u132->udev[++i]; - if (udev->usb_device) { - continue; - } else { - udev->enumeration = 1; - u132->addr[0].address = i; - endp->udev_number = i; - udev->udev_number = i; - udev->usb_addr = usb_dev->devnum; - u132_udev_init_kref(u132, udev); - udev->endp_number_in[usb_endp] = - endp->endp_number; - u132_udev_get_kref(u132, udev); - udev->endp_number_out[usb_endp] = - endp->endp_number; - udev->usb_device = usb_dev; - ((u8 *) (urb->setup_packet))[2] = - addr->address = i; - u132_udev_get_kref(u132, udev); - break; - } - } - if (I == 0) { - dev_err(&u132->platform_dev->dev, "run out of d" - "evice space\n"); - return -EINVAL; - } - urb->hcpriv = u132; - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { - endp->urb_list[ENDP_QUEUE_MASK & - endp->queue_last++] = urb; - } else { - struct u132_urbq *urbq = - kmalloc(sizeof(struct u132_urbq), - GFP_ATOMIC); - if (urbq == NULL) { - endp->queue_size -= 1; - return -ENOMEM; - } else { - list_add_tail(&urbq->urb_more, - &endp->urb_more); - urbq->urb = urb; - } - } - return 0; - } - } else { /*(usb_addr > 0) */ - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - urb->hcpriv = u132; - if (udev->enumeration == 2) { - } else - udev->enumeration = 2; - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = - urb; - } else { - struct u132_urbq *urbq = - kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); - if (urbq == NULL) { - endp->queue_size -= 1; - return -ENOMEM; - } else { - list_add_tail(&urbq->urb_more, &endp->urb_more); - urbq->urb = urb; - } - } - return 0; - } + struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, + u8 usb_endp) +{ + if (usb_addr == 0) { + if (usb_pipein(urb->pipe)) { + urb->hcpriv = u132; + if (endp->queue_size++ < ENDP_QUEUE_SIZE) { + endp->urb_list[ENDP_QUEUE_MASK & + endp->queue_last++] = urb; + } else { + struct u132_urbq *urbq = + kmalloc(sizeof(struct u132_urbq), + GFP_ATOMIC); + if (urbq == NULL) { + endp->queue_size -= 1; + return -ENOMEM; + } else { + list_add_tail(&urbq->urb_more, + &endp->urb_more); + urbq->urb = urb; + } + } + return 0; + } else { /* usb_pipeout(urb->pipe) */ + struct u132_addr *addr = &u132->addr[usb_dev->devnum]; + int I = MAX_U132_UDEVS; + int i = 0; + while (--I > 0) { + struct u132_udev *udev = &u132->udev[++i]; + if (udev->usb_device) { + continue; + } else { + udev->enumeration = 1; + u132->addr[0].address = i; + endp->udev_number = i; + udev->udev_number = i; + udev->usb_addr = usb_dev->devnum; + u132_udev_init_kref(u132, udev); + udev->endp_number_in[usb_endp] = + endp->endp_number; + u132_udev_get_kref(u132, udev); + udev->endp_number_out[usb_endp] = + endp->endp_number; + udev->usb_device = usb_dev; + ((u8 *) (urb->setup_packet))[2] = + addr->address = i; + u132_udev_get_kref(u132, udev); + break; + } + } + if (I == 0) { + dev_err(&u132->platform_dev->dev, "run out of d" + "evice space\n"); + return -EINVAL; + } + urb->hcpriv = u132; + if (endp->queue_size++ < ENDP_QUEUE_SIZE) { + endp->urb_list[ENDP_QUEUE_MASK & + endp->queue_last++] = urb; + } else { + struct u132_urbq *urbq = + kmalloc(sizeof(struct u132_urbq), + GFP_ATOMIC); + if (urbq == NULL) { + endp->queue_size -= 1; + return -ENOMEM; + } else { + list_add_tail(&urbq->urb_more, + &endp->urb_more); + urbq->urb = urb; + } + } + return 0; + } + } else { /*(usb_addr > 0) */ + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + urb->hcpriv = u132; + if (udev->enumeration != 2) + udev->enumeration = 2; + if (endp->queue_size++ < ENDP_QUEUE_SIZE) { + endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = + urb; + } else { + struct u132_urbq *urbq = + kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); + if (urbq == NULL) { + endp->queue_size -= 1; + return -ENOMEM; + } else { + list_add_tail(&urbq->urb_more, &endp->urb_more); + urbq->urb = urb; + } + } + return 0; + } } static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { - struct u132 *u132 = hcd_to_u132(hcd); - if (irqs_disabled()) { - if (__GFP_WAIT & mem_flags) { - printk(KERN_ERR "invalid context for function that migh" - "t sleep\n"); - return -EINVAL; - } - } - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { + struct u132 *u132 = hcd_to_u132(hcd); + if (irqs_disabled()) { + if (__GFP_WAIT & mem_flags) { + printk(KERN_ERR "invalid context for function that migh" + "t sleep\n"); + return -EINVAL; + } + } + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); - return -ESHUTDOWN; - } else { - u8 usb_addr = usb_pipedevice(urb->pipe); - u8 usb_endp = usb_pipeendpoint(urb->pipe); - struct usb_device *usb_dev = urb->dev; - if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - struct u132_endp *endp = urb->ep->hcpriv; - urb->actual_length = 0; - if (endp) { - unsigned long irqs; - int retval; - spin_lock_irqsave(&endp->queue_lock.slock, - irqs); + return -ESHUTDOWN; + } else { + u8 usb_addr = usb_pipedevice(urb->pipe); + u8 usb_endp = usb_pipeendpoint(urb->pipe); + struct usb_device *usb_dev = urb->dev; + if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + struct u132_endp *endp = urb->ep->hcpriv; + urb->actual_length = 0; + if (endp) { + unsigned long irqs; + int retval; + spin_lock_irqsave(&endp->queue_lock.slock, + irqs); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval == 0) { retval = queue_int_on_old_endpoint( @@ -2303,39 +2288,39 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, address); if (retval) usb_hcd_unlink_urb_from_ep( - hcd, urb); + hcd, urb); } - spin_unlock_irqrestore(&endp->queue_lock.slock, - irqs); - if (retval) { - return retval; - } else { - u132_endp_queue_work(u132, endp, - msecs_to_jiffies(urb->interval)) - ; - return 0; - } - } else if (u132->num_endpoints == MAX_U132_ENDPS) { - return -EINVAL; - } else { /*(endp == NULL) */ - return create_endpoint_and_queue_int(u132, udev, + spin_unlock_irqrestore(&endp->queue_lock.slock, + irqs); + if (retval) { + return retval; + } else { + u132_endp_queue_work(u132, endp, + msecs_to_jiffies(urb->interval)) + ; + return 0; + } + } else if (u132->num_endpoints == MAX_U132_ENDPS) { + return -EINVAL; + } else { /*(endp == NULL) */ + return create_endpoint_and_queue_int(u132, udev, urb, usb_dev, usb_addr, usb_endp, address, mem_flags); - } - } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { - dev_err(&u132->platform_dev->dev, "the hardware does no" - "t support PIPE_ISOCHRONOUS\n"); - return -EINVAL; - } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - struct u132_endp *endp = urb->ep->hcpriv; - urb->actual_length = 0; - if (endp) { - unsigned long irqs; - int retval; - spin_lock_irqsave(&endp->queue_lock.slock, - irqs); + } + } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { + dev_err(&u132->platform_dev->dev, "the hardware does no" + "t support PIPE_ISOCHRONOUS\n"); + return -EINVAL; + } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + struct u132_endp *endp = urb->ep->hcpriv; + urb->actual_length = 0; + if (endp) { + unsigned long irqs; + int retval; + spin_lock_irqsave(&endp->queue_lock.slock, + irqs); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval == 0) { retval = queue_bulk_on_old_endpoint( @@ -2345,46 +2330,46 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, address); if (retval) usb_hcd_unlink_urb_from_ep( - hcd, urb); + hcd, urb); + } + spin_unlock_irqrestore(&endp->queue_lock.slock, + irqs); + if (retval) { + return retval; + } else { + u132_endp_queue_work(u132, endp, 0); + return 0; } - spin_unlock_irqrestore(&endp->queue_lock.slock, - irqs); - if (retval) { - return retval; - } else { - u132_endp_queue_work(u132, endp, 0); - return 0; - } - } else if (u132->num_endpoints == MAX_U132_ENDPS) { - return -EINVAL; - } else - return create_endpoint_and_queue_bulk(u132, + } else if (u132->num_endpoints == MAX_U132_ENDPS) { + return -EINVAL; + } else + return create_endpoint_and_queue_bulk(u132, udev, urb, usb_dev, usb_addr, - usb_endp, address, mem_flags); - } else { - struct u132_endp *endp = urb->ep->hcpriv; - u16 urb_size = 8; - u8 *b = urb->setup_packet; - int i = 0; - char data[30 *3 + 4]; - char *d = data; - int m = (sizeof(data) - 1) / 3; - int l = 0; - data[0] = 0; - while (urb_size-- > 0) { - if (i > m) { - } else if (i++ < m) { - int w = sprintf(d, " %02X", *b++); - d += w; - l += w; - } else - d += sprintf(d, " .."); - } - if (endp) { - unsigned long irqs; - int retval; - spin_lock_irqsave(&endp->queue_lock.slock, - irqs); + usb_endp, address, mem_flags); + } else { + struct u132_endp *endp = urb->ep->hcpriv; + u16 urb_size = 8; + u8 *b = urb->setup_packet; + int i = 0; + char data[30 * 3 + 4]; + char *d = data; + int m = (sizeof(data) - 1) / 3; + int l = 0; + data[0] = 0; + while (urb_size-- > 0) { + if (i > m) { + } else if (i++ < m) { + int w = sprintf(d, " %02X", *b++); + d += w; + l += w; + } else + d += sprintf(d, " .."); + } + if (endp) { + unsigned long irqs; + int retval; + spin_lock_irqsave(&endp->queue_lock.slock, + irqs); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval == 0) { retval = queue_control_on_old_endpoint( @@ -2395,267 +2380,267 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, usb_hcd_unlink_urb_from_ep( hcd, urb); } - spin_unlock_irqrestore(&endp->queue_lock.slock, - irqs); - if (retval) { - return retval; - } else { - u132_endp_queue_work(u132, endp, 0); - return 0; - } - } else if (u132->num_endpoints == MAX_U132_ENDPS) { - return -EINVAL; - } else - return create_endpoint_and_queue_control(u132, + spin_unlock_irqrestore(&endp->queue_lock.slock, + irqs); + if (retval) { + return retval; + } else { + u132_endp_queue_work(u132, endp, 0); + return 0; + } + } else if (u132->num_endpoints == MAX_U132_ENDPS) { + return -EINVAL; + } else + return create_endpoint_and_queue_control(u132, urb, usb_dev, usb_addr, usb_endp, - mem_flags); - } - } + mem_flags); + } + } } static int dequeue_from_overflow_chain(struct u132 *u132, - struct u132_endp *endp, struct urb *urb) -{ - struct list_head *scan; - struct list_head *head = &endp->urb_more; - list_for_each(scan, head) { - struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, - urb_more); - if (urbq->urb == urb) { - struct usb_hcd *hcd = u132_to_hcd(u132); - list_del(scan); - endp->queue_size -= 1; - urb->error_count = 0; + struct u132_endp *endp, struct urb *urb) +{ + struct list_head *scan; + struct list_head *head = &endp->urb_more; + list_for_each(scan, head) { + struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, + urb_more); + if (urbq->urb == urb) { + struct usb_hcd *hcd = u132_to_hcd(u132); + list_del(scan); + endp->queue_size -= 1; + urb->error_count = 0; usb_hcd_giveback_urb(hcd, urb, 0); - return 0; - } else - continue; - } - dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" - "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" - "\n", urb, endp->endp_number, endp, endp->ring->number, - endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', - endp->usb_endp, endp->usb_addr, endp->queue_size, - endp->queue_next, endp->queue_last); - return -EINVAL; + return 0; + } else + continue; + } + dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" + "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" + "\n", urb, endp->endp_number, endp, endp->ring->number, + endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', + endp->usb_endp, endp->usb_addr, endp->queue_size, + endp->queue_next, endp->queue_last); + return -EINVAL; } static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, struct urb *urb, int status) { - unsigned long irqs; + unsigned long irqs; int rc; - spin_lock_irqsave(&endp->queue_lock.slock, irqs); + spin_lock_irqsave(&endp->queue_lock.slock, irqs); rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); if (rc) { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); return rc; } - if (endp->queue_size == 0) { - dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" - "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, - endp->endp_number, endp, endp->ring->number, - endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', - endp->usb_endp, endp->usb_addr); - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - return -EINVAL; - } - if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { - if (endp->active) { - endp->dequeueing = 1; - endp->edset_flush = 1; - u132_endp_queue_work(u132, endp, 0); - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - return 0; - } else { - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + if (endp->queue_size == 0) { + dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" + "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, + endp->endp_number, endp, endp->ring->number, + endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', + endp->usb_endp, endp->usb_addr); + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + return -EINVAL; + } + if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { + if (endp->active) { + endp->dequeueing = 1; + endp->edset_flush = 1; + u132_endp_queue_work(u132, endp, 0); + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + return 0; + } else { + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); u132_hcd_abandon_urb(u132, endp, urb, status); - return 0; - } - } else { - u16 queue_list = 0; - u16 queue_size = endp->queue_size; - u16 queue_scan = endp->queue_next; - struct urb **urb_slot = NULL; - while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { - if (urb == endp->urb_list[ENDP_QUEUE_MASK & - ++queue_scan]) { - urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & - queue_scan]; - break; - } else - continue; - } - while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { - *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & - ++queue_scan]; - urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & - queue_scan]; - } - if (urb_slot) { - struct usb_hcd *hcd = u132_to_hcd(u132); + return 0; + } + } else { + u16 queue_list = 0; + u16 queue_size = endp->queue_size; + u16 queue_scan = endp->queue_next; + struct urb **urb_slot = NULL; + while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { + if (urb == endp->urb_list[ENDP_QUEUE_MASK & + ++queue_scan]) { + urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & + queue_scan]; + break; + } else + continue; + } + while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { + *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & + ++queue_scan]; + urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & + queue_scan]; + } + if (urb_slot) { + struct usb_hcd *hcd = u132_to_hcd(u132); usb_hcd_unlink_urb_from_ep(hcd, urb); - endp->queue_size -= 1; - if (list_empty(&endp->urb_more)) { - spin_unlock_irqrestore(&endp->queue_lock.slock, - irqs); - } else { - struct list_head *next = endp->urb_more.next; - struct u132_urbq *urbq = list_entry(next, - struct u132_urbq, urb_more); - list_del(next); - *urb_slot = urbq->urb; - spin_unlock_irqrestore(&endp->queue_lock.slock, - irqs); - kfree(urbq); - } urb->error_count = 0; + endp->queue_size -= 1; + if (list_empty(&endp->urb_more)) { + spin_unlock_irqrestore(&endp->queue_lock.slock, + irqs); + } else { + struct list_head *next = endp->urb_more.next; + struct u132_urbq *urbq = list_entry(next, + struct u132_urbq, urb_more); + list_del(next); + *urb_slot = urbq->urb; + spin_unlock_irqrestore(&endp->queue_lock.slock, + irqs); + kfree(urbq); + } urb->error_count = 0; usb_hcd_giveback_urb(hcd, urb, status); - return 0; - } else if (list_empty(&endp->urb_more)) { - dev_err(&u132->platform_dev->dev, "urb=%p not found in " - "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" - "=%d size=%d next=%04X last=%04X\n", urb, - endp->endp_number, endp, endp->ring->number, - endp->input ? 'I' : ' ', - endp->output ? 'O' : ' ', endp->usb_endp, - endp->usb_addr, endp->queue_size, - endp->queue_next, endp->queue_last); - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - return -EINVAL; - } else { + return 0; + } else if (list_empty(&endp->urb_more)) { + dev_err(&u132->platform_dev->dev, "urb=%p not found in " + "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" + "=%d size=%d next=%04X last=%04X\n", urb, + endp->endp_number, endp, endp->ring->number, + endp->input ? 'I' : ' ', + endp->output ? 'O' : ' ', endp->usb_endp, + endp->usb_addr, endp->queue_size, + endp->queue_next, endp->queue_last); + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + return -EINVAL; + } else { int retval; usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); retval = dequeue_from_overflow_chain(u132, endp, - urb); - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); - return retval; - } - } + urb); + spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); + return retval; + } + } } static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 2) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else { - u8 usb_addr = usb_pipedevice(urb->pipe); - u8 usb_endp = usb_pipeendpoint(urb->pipe); - u8 address = u132->addr[usb_addr].address; - struct u132_udev *udev = &u132->udev[address]; - if (usb_pipein(urb->pipe)) { - u8 endp_number = udev->endp_number_in[usb_endp]; - struct u132_endp *endp = u132->endp[endp_number - 1]; - return u132_endp_urb_dequeue(u132, endp, urb, status); - } else { - u8 endp_number = udev->endp_number_out[usb_endp]; - struct u132_endp *endp = u132->endp[endp_number - 1]; - return u132_endp_urb_dequeue(u132, endp, urb, status); - } - } + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 2) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else { + u8 usb_addr = usb_pipedevice(urb->pipe); + u8 usb_endp = usb_pipeendpoint(urb->pipe); + u8 address = u132->addr[usb_addr].address; + struct u132_udev *udev = &u132->udev[address]; + if (usb_pipein(urb->pipe)) { + u8 endp_number = udev->endp_number_in[usb_endp]; + struct u132_endp *endp = u132->endp[endp_number - 1]; + return u132_endp_urb_dequeue(u132, endp, urb, status); + } else { + u8 endp_number = udev->endp_number_out[usb_endp]; + struct u132_endp *endp = u132->endp[endp_number - 1]; + return u132_endp_urb_dequeue(u132, endp, urb, status); + } + } } static void u132_endpoint_disable(struct usb_hcd *hcd, - struct usb_host_endpoint *hep) -{ - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 2) { - dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" - ") has been removed %d\n", u132, hcd, hep, - u132->going); - } else { - struct u132_endp *endp = hep->hcpriv; - if (endp) - u132_endp_put_kref(u132, endp); - } + struct usb_host_endpoint *hep) +{ + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 2) { + dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" + ") has been removed %d\n", u132, hcd, hep, + u132->going); + } else { + struct u132_endp *endp = hep->hcpriv; + if (endp) + u132_endp_put_kref(u132, endp); + } } static int u132_get_frame(struct usb_hcd *hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else { - int frame = 0; - dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); - msleep(100); - return frame; - } + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else { + int frame = 0; + dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); + msleep(100); + return frame; + } } static int u132_roothub_descriptor(struct u132 *u132, - struct usb_hub_descriptor *desc) -{ - int retval; - u16 temp; - u32 rh_a = -1; - u32 rh_b = -1; - retval = u132_read_pcimem(u132, roothub.a, &rh_a); - if (retval) - return retval; - desc->bDescriptorType = 0x29; - desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; - desc->bHubContrCurrent = 0; - desc->bNbrPorts = u132->num_ports; - temp = 1 + (u132->num_ports / 8); - desc->bDescLength = 7 + 2 *temp; - temp = 0; - if (rh_a & RH_A_NPS) - temp |= 0x0002; - if (rh_a & RH_A_PSM) - temp |= 0x0001; - if (rh_a & RH_A_NOCP) { - temp |= 0x0010; - } else if (rh_a & RH_A_OCPM) - temp |= 0x0008; - desc->wHubCharacteristics = cpu_to_le16(temp); - retval = u132_read_pcimem(u132, roothub.b, &rh_b); - if (retval) - return retval; - memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); - desc->bitmap[0] = rh_b & RH_B_DR; - if (u132->num_ports > 7) { - desc->bitmap[1] = (rh_b & RH_B_DR) >> 8; - desc->bitmap[2] = 0xff; - } else - desc->bitmap[1] = 0xff; - return 0; + struct usb_hub_descriptor *desc) +{ + int retval; + u16 temp; + u32 rh_a = -1; + u32 rh_b = -1; + retval = u132_read_pcimem(u132, roothub.a, &rh_a); + if (retval) + return retval; + desc->bDescriptorType = 0x29; + desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; + desc->bHubContrCurrent = 0; + desc->bNbrPorts = u132->num_ports; + temp = 1 + (u132->num_ports / 8); + desc->bDescLength = 7 + 2 * temp; + temp = 0; + if (rh_a & RH_A_NPS) + temp |= 0x0002; + if (rh_a & RH_A_PSM) + temp |= 0x0001; + if (rh_a & RH_A_NOCP) + temp |= 0x0010; + else if (rh_a & RH_A_OCPM) + temp |= 0x0008; + desc->wHubCharacteristics = cpu_to_le16(temp); + retval = u132_read_pcimem(u132, roothub.b, &rh_b); + if (retval) + return retval; + memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); + desc->bitmap[0] = rh_b & RH_B_DR; + if (u132->num_ports > 7) { + desc->bitmap[1] = (rh_b & RH_B_DR) >> 8; + desc->bitmap[2] = 0xff; + } else + desc->bitmap[1] = 0xff; + return 0; } static int u132_roothub_status(struct u132 *u132, __le32 *desc) { - u32 rh_status = -1; - int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); - *desc = cpu_to_le32(rh_status); - return ret_status; + u32 rh_status = -1; + int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); + *desc = cpu_to_le32(rh_status); + return ret_status; } static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) { - if (wIndex == 0 || wIndex > u132->num_ports) { - return -EINVAL; - } else { - int port = wIndex - 1; - u32 rh_portstatus = -1; - int ret_portstatus = u132_read_pcimem(u132, - roothub.portstatus[port], &rh_portstatus); - *desc = cpu_to_le32(rh_portstatus); - if (*(u16 *) (desc + 2)) { - dev_info(&u132->platform_dev->dev, "Port %d Status Chan" - "ge = %08X\n", port, *desc); - } - return ret_portstatus; - } + if (wIndex == 0 || wIndex > u132->num_ports) { + return -EINVAL; + } else { + int port = wIndex - 1; + u32 rh_portstatus = -1; + int ret_portstatus = u132_read_pcimem(u132, + roothub.portstatus[port], &rh_portstatus); + *desc = cpu_to_le32(rh_portstatus); + if (*(u16 *) (desc + 2)) { + dev_info(&u132->platform_dev->dev, "Port %d Status Chan" + "ge = %08X\n", port, *desc); + } + return ret_portstatus; + } } @@ -2666,381 +2651,340 @@ static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) #define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) static int u132_roothub_portreset(struct u132 *u132, int port_index) { - int retval; - u32 fmnumber; - u16 now; - u16 reset_done; - retval = u132_read_pcimem(u132, fmnumber, &fmnumber); - if (retval) - return retval; - now = fmnumber; - reset_done = now + PORT_RESET_MSEC; - do { - u32 portstat; - do { - retval = u132_read_pcimem(u132, - roothub.portstatus[port_index], &portstat); - if (retval) - return retval; - if (RH_PS_PRS & portstat) { - continue; - } else - break; - } while (tick_before(now, reset_done)); - if (RH_PS_PRS & portstat) - return -ENODEV; - if (RH_PS_CCS & portstat) { - if (RH_PS_PRSC & portstat) { - retval = u132_write_pcimem(u132, - roothub.portstatus[port_index], - RH_PS_PRSC); - if (retval) - return retval; - } - } else - break; /* start the next reset, - sleep till it's probably done */ - retval = u132_write_pcimem(u132, roothub.portstatus[port_index], - RH_PS_PRS); - if (retval) - return retval; - msleep(PORT_RESET_HW_MSEC); - retval = u132_read_pcimem(u132, fmnumber, &fmnumber); - if (retval) - return retval; - now = fmnumber; - } while (tick_before(now, reset_done)); - return 0; + int retval; + u32 fmnumber; + u16 now; + u16 reset_done; + retval = u132_read_pcimem(u132, fmnumber, &fmnumber); + if (retval) + return retval; + now = fmnumber; + reset_done = now + PORT_RESET_MSEC; + do { + u32 portstat; + do { + retval = u132_read_pcimem(u132, + roothub.portstatus[port_index], &portstat); + if (retval) + return retval; + if (RH_PS_PRS & portstat) + continue; + else + break; + } while (tick_before(now, reset_done)); + if (RH_PS_PRS & portstat) + return -ENODEV; + if (RH_PS_CCS & portstat) { + if (RH_PS_PRSC & portstat) { + retval = u132_write_pcimem(u132, + roothub.portstatus[port_index], + RH_PS_PRSC); + if (retval) + return retval; + } + } else + break; /* start the next reset, + sleep till it's probably done */ + retval = u132_write_pcimem(u132, roothub.portstatus[port_index], + RH_PS_PRS); + if (retval) + return retval; + msleep(PORT_RESET_HW_MSEC); + retval = u132_read_pcimem(u132, fmnumber, &fmnumber); + if (retval) + return retval; + now = fmnumber; + } while (tick_before(now, reset_done)); + return 0; } static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, - u16 wIndex) -{ - if (wIndex == 0 || wIndex > u132->num_ports) { - return -EINVAL; - } else { - int retval; - int port_index = wIndex - 1; - struct u132_port *port = &u132->port[port_index]; - port->Status &= ~(1 << wValue); - switch (wValue) { - case USB_PORT_FEAT_SUSPEND: - retval = u132_write_pcimem(u132, - roothub.portstatus[port_index], RH_PS_PSS); - if (retval) - return retval; - return 0; - case USB_PORT_FEAT_POWER: - retval = u132_write_pcimem(u132, - roothub.portstatus[port_index], RH_PS_PPS); - if (retval) - return retval; - return 0; - case USB_PORT_FEAT_RESET: - retval = u132_roothub_portreset(u132, port_index); - if (retval) - return retval; - return 0; - default: - return -EPIPE; - } - } + u16 wIndex) +{ + if (wIndex == 0 || wIndex > u132->num_ports) { + return -EINVAL; + } else { + int retval; + int port_index = wIndex - 1; + struct u132_port *port = &u132->port[port_index]; + port->Status &= ~(1 << wValue); + switch (wValue) { + case USB_PORT_FEAT_SUSPEND: + retval = u132_write_pcimem(u132, + roothub.portstatus[port_index], RH_PS_PSS); + if (retval) + return retval; + return 0; + case USB_PORT_FEAT_POWER: + retval = u132_write_pcimem(u132, + roothub.portstatus[port_index], RH_PS_PPS); + if (retval) + return retval; + return 0; + case USB_PORT_FEAT_RESET: + retval = u132_roothub_portreset(u132, port_index); + if (retval) + return retval; + return 0; + default: + return -EPIPE; + } + } } static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, - u16 wIndex) -{ - if (wIndex == 0 || wIndex > u132->num_ports) { - return -EINVAL; - } else { - int port_index = wIndex - 1; - u32 temp; - int retval; - struct u132_port *port = &u132->port[port_index]; - port->Status &= ~(1 << wValue); - switch (wValue) { - case USB_PORT_FEAT_ENABLE: - temp = RH_PS_CCS; - break; - case USB_PORT_FEAT_C_ENABLE: - temp = RH_PS_PESC; - break; - case USB_PORT_FEAT_SUSPEND: - temp = RH_PS_POCI; - if ((u132->hc_control & OHCI_CTRL_HCFS) - != OHCI_USB_OPER) { - dev_err(&u132->platform_dev->dev, "TODO resume_" - "root_hub\n"); - } - break; - case USB_PORT_FEAT_C_SUSPEND: - temp = RH_PS_PSSC; - break; - case USB_PORT_FEAT_POWER: - temp = RH_PS_LSDA; - break; - case USB_PORT_FEAT_C_CONNECTION: - temp = RH_PS_CSC; - break; - case USB_PORT_FEAT_C_OVER_CURRENT: - temp = RH_PS_OCIC; - break; - case USB_PORT_FEAT_C_RESET: - temp = RH_PS_PRSC; - break; - default: - return -EPIPE; - } - retval = u132_write_pcimem(u132, roothub.portstatus[port_index], - temp); - if (retval) - return retval; - return 0; - } + u16 wIndex) +{ + if (wIndex == 0 || wIndex > u132->num_ports) { + return -EINVAL; + } else { + int port_index = wIndex - 1; + u32 temp; + int retval; + struct u132_port *port = &u132->port[port_index]; + port->Status &= ~(1 << wValue); + switch (wValue) { + case USB_PORT_FEAT_ENABLE: + temp = RH_PS_CCS; + break; + case USB_PORT_FEAT_C_ENABLE: + temp = RH_PS_PESC; + break; + case USB_PORT_FEAT_SUSPEND: + temp = RH_PS_POCI; + if ((u132->hc_control & OHCI_CTRL_HCFS) + != OHCI_USB_OPER) { + dev_err(&u132->platform_dev->dev, "TODO resume_" + "root_hub\n"); + } + break; + case USB_PORT_FEAT_C_SUSPEND: + temp = RH_PS_PSSC; + break; + case USB_PORT_FEAT_POWER: + temp = RH_PS_LSDA; + break; + case USB_PORT_FEAT_C_CONNECTION: + temp = RH_PS_CSC; + break; + case USB_PORT_FEAT_C_OVER_CURRENT: + temp = RH_PS_OCIC; + break; + case USB_PORT_FEAT_C_RESET: + temp = RH_PS_PRSC; + break; + default: + return -EPIPE; + } + retval = u132_write_pcimem(u132, roothub.portstatus[port_index], + temp); + if (retval) + return retval; + return 0; + } } /* the virtual root hub timer IRQ checks for hub status*/ static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" - "ed %d\n", hcd, u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" - "ed\n", hcd); - return -ESHUTDOWN; - } else { - int i, changed = 0, length = 1; - if (u132->flags & OHCI_QUIRK_AMD756) { - if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { - dev_err(&u132->platform_dev->dev, "bogus NDP, r" - "ereads as NDP=%d\n", - u132->hc_roothub_a & RH_A_NDP); - goto done; - } - } - if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) { - buf[0] = changed = 1; - } else - buf[0] = 0; - if (u132->num_ports > 7) { - buf[1] = 0; - length++; - } - for (i = 0; i < u132->num_ports; i++) { - if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | - RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | - RH_PS_PRSC)) { - changed = 1; - if (i < 7) { - buf[0] |= 1 << (i + 1); - } else - buf[1] |= 1 << (i - 7); - continue; - } - if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) { - continue; - } - if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) { - continue; - } - } - done:return changed ? length : 0; - } + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" + "ed %d\n", hcd, u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" + "ed\n", hcd); + return -ESHUTDOWN; + } else { + int i, changed = 0, length = 1; + if (u132->flags & OHCI_QUIRK_AMD756) { + if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { + dev_err(&u132->platform_dev->dev, "bogus NDP, r" + "ereads as NDP=%d\n", + u132->hc_roothub_a & RH_A_NDP); + goto done; + } + } + if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) + buf[0] = changed = 1; + else + buf[0] = 0; + if (u132->num_ports > 7) { + buf[1] = 0; + length++; + } + for (i = 0; i < u132->num_ports; i++) { + if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | + RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | + RH_PS_PRSC)) { + changed = 1; + if (i < 7) + buf[0] |= 1 << (i + 1); + else + buf[1] |= 1 << (i - 7); + continue; + } + if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) + continue; + + if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) + continue; + } +done: + return changed ? length : 0; + } } static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, - u16 wIndex, char *buf, u16 wLength) -{ - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else { - int retval = 0; - mutex_lock(&u132->sw_lock); - switch (typeReq) { - case ClearHubFeature: - switch (wValue) { - case C_HUB_OVER_CURRENT: - case C_HUB_LOCAL_POWER: - break; - default: - goto stall; - } - break; - case SetHubFeature: - switch (wValue) { - case C_HUB_OVER_CURRENT: - case C_HUB_LOCAL_POWER: - break; - default: - goto stall; - } - break; - case ClearPortFeature:{ - retval = u132_roothub_clearportfeature(u132, - wValue, wIndex); - if (retval) - goto error; - break; - } - case GetHubDescriptor:{ - retval = u132_roothub_descriptor(u132, - (struct usb_hub_descriptor *)buf); - if (retval) - goto error; - break; - } - case GetHubStatus:{ - retval = u132_roothub_status(u132, - (__le32 *) buf); - if (retval) - goto error; - break; - } - case GetPortStatus:{ - retval = u132_roothub_portstatus(u132, - (__le32 *) buf, wIndex); - if (retval) - goto error; - break; - } - case SetPortFeature:{ - retval = u132_roothub_setportfeature(u132, - wValue, wIndex); - if (retval) - goto error; - break; - } - default: - goto stall; - error:u132_disable(u132); - u132->going = 1; - break; - stall:retval = -EPIPE; - break; - } - mutex_unlock(&u132->sw_lock); - return retval; - } + u16 wIndex, char *buf, u16 wLength) +{ + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else { + int retval = 0; + mutex_lock(&u132->sw_lock); + switch (typeReq) { + case ClearHubFeature: + switch (wValue) { + case C_HUB_OVER_CURRENT: + case C_HUB_LOCAL_POWER: + break; + default: + goto stall; + } + break; + case SetHubFeature: + switch (wValue) { + case C_HUB_OVER_CURRENT: + case C_HUB_LOCAL_POWER: + break; + default: + goto stall; + } + break; + case ClearPortFeature:{ + retval = u132_roothub_clearportfeature(u132, + wValue, wIndex); + if (retval) + goto error; + break; + } + case GetHubDescriptor:{ + retval = u132_roothub_descriptor(u132, + (struct usb_hub_descriptor *)buf); + if (retval) + goto error; + break; + } + case GetHubStatus:{ + retval = u132_roothub_status(u132, + (__le32 *) buf); + if (retval) + goto error; + break; + } + case GetPortStatus:{ + retval = u132_roothub_portstatus(u132, + (__le32 *) buf, wIndex); + if (retval) + goto error; + break; + } + case SetPortFeature:{ + retval = u132_roothub_setportfeature(u132, + wValue, wIndex); + if (retval) + goto error; + break; + } + default: + goto stall; + error: + u132_disable(u132); + u132->going = 1; + break; + stall: + retval = -EPIPE; + break; + } + mutex_unlock(&u132->sw_lock); + return retval; + } } static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else - return 0; -} - -static void u132_hub_irq_enable(struct usb_hcd *hcd) -{ - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - } else if (u132->going > 0) - dev_err(&u132->platform_dev->dev, "device is being removed\n"); + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else + return 0; } #ifdef CONFIG_PM -static int u132_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) -{ - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else - return 0; -} - -static int u132_hcd_resume(struct usb_hcd *hcd) -{ - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else - return 0; -} - static int u132_bus_suspend(struct usb_hcd *hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else - return 0; + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else + return 0; } static int u132_bus_resume(struct usb_hcd *hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else - return 0; + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else + return 0; } #else -#define u132_hcd_suspend NULL -#define u132_hcd_resume NULL #define u132_bus_suspend NULL #define u132_bus_resume NULL #endif static struct hc_driver u132_hc_driver = { - .description = hcd_name, - .hcd_priv_size = sizeof(struct u132), - .irq = NULL, - .flags = HCD_USB11 | HCD_MEMORY, - .reset = u132_hcd_reset, - .start = u132_hcd_start, - .suspend = u132_hcd_suspend, - .resume = u132_hcd_resume, - .stop = u132_hcd_stop, - .urb_enqueue = u132_urb_enqueue, - .urb_dequeue = u132_urb_dequeue, - .endpoint_disable = u132_endpoint_disable, - .get_frame_number = u132_get_frame, - .hub_status_data = u132_hub_status_data, - .hub_control = u132_hub_control, - .bus_suspend = u132_bus_suspend, - .bus_resume = u132_bus_resume, - .start_port_reset = u132_start_port_reset, - .hub_irq_enable = u132_hub_irq_enable, + .description = hcd_name, + .hcd_priv_size = sizeof(struct u132), + .irq = NULL, + .flags = HCD_USB11 | HCD_MEMORY, + .reset = u132_hcd_reset, + .start = u132_hcd_start, + .stop = u132_hcd_stop, + .urb_enqueue = u132_urb_enqueue, + .urb_dequeue = u132_urb_dequeue, + .endpoint_disable = u132_endpoint_disable, + .get_frame_number = u132_get_frame, + .hub_status_data = u132_hub_status_data, + .hub_control = u132_hub_control, + .bus_suspend = u132_bus_suspend, + .bus_resume = u132_bus_resume, + .start_port_reset = u132_start_port_reset, }; /* @@ -3051,148 +2995,152 @@ static struct hc_driver u132_hc_driver = { */ static int __devexit u132_remove(struct platform_device *pdev) { - struct usb_hcd *hcd = platform_get_drvdata(pdev); - if (hcd) { - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going++ > 1) { - dev_err(&u132->platform_dev->dev, "already being remove" + struct usb_hcd *hcd = platform_get_drvdata(pdev); + if (hcd) { + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going++ > 1) { + dev_err(&u132->platform_dev->dev, "already being remove" "d\n"); - return -ENODEV; - } else { - int rings = MAX_U132_RINGS; - int endps = MAX_U132_ENDPS; - dev_err(&u132->platform_dev->dev, "removing device u132" + return -ENODEV; + } else { + int rings = MAX_U132_RINGS; + int endps = MAX_U132_ENDPS; + dev_err(&u132->platform_dev->dev, "removing device u132" ".%d\n", u132->sequence_num); - msleep(100); - mutex_lock(&u132->sw_lock); - u132_monitor_cancel_work(u132); - while (rings-- > 0) { - struct u132_ring *ring = &u132->ring[rings]; - u132_ring_cancel_work(u132, ring); - } while (endps-- > 0) { - struct u132_endp *endp = u132->endp[endps]; - if (endp) - u132_endp_cancel_work(u132, endp); - } - u132->going += 1; - printk(KERN_INFO "removing device u132.%d\n", - u132->sequence_num); - mutex_unlock(&u132->sw_lock); - usb_remove_hcd(hcd); - u132_u132_put_kref(u132); - return 0; - } - } else - return 0; + msleep(100); + mutex_lock(&u132->sw_lock); + u132_monitor_cancel_work(u132); + while (rings-- > 0) { + struct u132_ring *ring = &u132->ring[rings]; + u132_ring_cancel_work(u132, ring); + } while (endps-- > 0) { + struct u132_endp *endp = u132->endp[endps]; + if (endp) + u132_endp_cancel_work(u132, endp); + } + u132->going += 1; + printk(KERN_INFO "removing device u132.%d\n", + u132->sequence_num); + mutex_unlock(&u132->sw_lock); + usb_remove_hcd(hcd); + u132_u132_put_kref(u132); + return 0; + } + } else + return 0; } static void u132_initialise(struct u132 *u132, struct platform_device *pdev) { - int rings = MAX_U132_RINGS; - int ports = MAX_U132_PORTS; - int addrs = MAX_U132_ADDRS; - int udevs = MAX_U132_UDEVS; - int endps = MAX_U132_ENDPS; - u132->board = pdev->dev.platform_data; - u132->platform_dev = pdev; - u132->power = 0; - u132->reset = 0; - mutex_init(&u132->sw_lock); - init_MUTEX(&u132->scheduler_lock); - while (rings-- > 0) { - struct u132_ring *ring = &u132->ring[rings]; - ring->u132 = u132; - ring->number = rings + 1; - ring->length = 0; - ring->curr_endp = NULL; - INIT_DELAYED_WORK(&ring->scheduler, + int rings = MAX_U132_RINGS; + int ports = MAX_U132_PORTS; + int addrs = MAX_U132_ADDRS; + int udevs = MAX_U132_UDEVS; + int endps = MAX_U132_ENDPS; + u132->board = pdev->dev.platform_data; + u132->platform_dev = pdev; + u132->power = 0; + u132->reset = 0; + mutex_init(&u132->sw_lock); + mutex_init(&u132->scheduler_lock); + while (rings-- > 0) { + struct u132_ring *ring = &u132->ring[rings]; + ring->u132 = u132; + ring->number = rings + 1; + ring->length = 0; + ring->curr_endp = NULL; + INIT_DELAYED_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler); - } mutex_lock(&u132->sw_lock); - INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); - while (ports-- > 0) { - struct u132_port *port = &u132->port[ports]; - port->u132 = u132; - port->reset = 0; - port->enable = 0; - port->power = 0; - port->Status = 0; - } while (addrs-- > 0) { - struct u132_addr *addr = &u132->addr[addrs]; - addr->address = 0; - } while (udevs-- > 0) { - struct u132_udev *udev = &u132->udev[udevs]; - int i = ARRAY_SIZE(udev->endp_number_in); - int o = ARRAY_SIZE(udev->endp_number_out); - udev->usb_device = NULL; - udev->udev_number = 0; - udev->usb_addr = 0; - udev->portnumber = 0; - while (i-- > 0) { - udev->endp_number_in[i] = 0; - } - while (o-- > 0) { - udev->endp_number_out[o] = 0; - } - } - while (endps-- > 0) { - u132->endp[endps] = NULL; - } - mutex_unlock(&u132->sw_lock); - return; + } + mutex_lock(&u132->sw_lock); + INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); + while (ports-- > 0) { + struct u132_port *port = &u132->port[ports]; + port->u132 = u132; + port->reset = 0; + port->enable = 0; + port->power = 0; + port->Status = 0; + } + while (addrs-- > 0) { + struct u132_addr *addr = &u132->addr[addrs]; + addr->address = 0; + } + while (udevs-- > 0) { + struct u132_udev *udev = &u132->udev[udevs]; + int i = ARRAY_SIZE(udev->endp_number_in); + int o = ARRAY_SIZE(udev->endp_number_out); + udev->usb_device = NULL; + udev->udev_number = 0; + udev->usb_addr = 0; + udev->portnumber = 0; + while (i-- > 0) + udev->endp_number_in[i] = 0; + + while (o-- > 0) + udev->endp_number_out[o] = 0; + + } + while (endps-- > 0) + u132->endp[endps] = NULL; + + mutex_unlock(&u132->sw_lock); + return; } static int __devinit u132_probe(struct platform_device *pdev) { - struct usb_hcd *hcd; - int retval; - u32 control; - u32 rh_a = -1; - u32 num_ports; - msleep(100); - if (u132_exiting > 0) { - return -ENODEV; - } - retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); - if (retval) - return retval; - retval = ftdi_read_pcimem(pdev, control, &control); - if (retval) - return retval; - retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); - if (retval) - return retval; - num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */ - if (pdev->dev.dma_mask) { - return -EINVAL; - } - hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id); - if (!hcd) { - printk(KERN_ERR "failed to create the usb hcd struct for U132\n" - ); - ftdi_elan_gone_away(pdev); - return -ENOMEM; - } else { - int retval = 0; - struct u132 *u132 = hcd_to_u132(hcd); - hcd->rsrc_start = 0; - mutex_lock(&u132_module_lock); - list_add_tail(&u132->u132_list, &u132_static_list); - u132->sequence_num = ++u132_instances; - mutex_unlock(&u132_module_lock); - u132_u132_init_kref(u132); - u132_initialise(u132, pdev); - hcd->product_desc = "ELAN U132 Host Controller"; - retval = usb_add_hcd(hcd, 0, 0); - if (retval != 0) { - dev_err(&u132->platform_dev->dev, "init error %d\n", - retval); - u132_u132_put_kref(u132); - return retval; - } else { - u132_monitor_queue_work(u132, 100); - return 0; - } - } + struct usb_hcd *hcd; + int retval; + u32 control; + u32 rh_a = -1; + u32 num_ports; + + msleep(100); + if (u132_exiting > 0) + return -ENODEV; + + retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); + if (retval) + return retval; + retval = ftdi_read_pcimem(pdev, control, &control); + if (retval) + return retval; + retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); + if (retval) + return retval; + num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */ + if (pdev->dev.dma_mask) + return -EINVAL; + + hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id); + if (!hcd) { + printk(KERN_ERR "failed to create the usb hcd struct for U132\n" + ); + ftdi_elan_gone_away(pdev); + return -ENOMEM; + } else { + int retval = 0; + struct u132 *u132 = hcd_to_u132(hcd); + hcd->rsrc_start = 0; + mutex_lock(&u132_module_lock); + list_add_tail(&u132->u132_list, &u132_static_list); + u132->sequence_num = ++u132_instances; + mutex_unlock(&u132_module_lock); + u132_u132_init_kref(u132); + u132_initialise(u132, pdev); + hcd->product_desc = "ELAN U132 Host Controller"; + retval = usb_add_hcd(hcd, 0, 0); + if (retval != 0) { + dev_err(&u132->platform_dev->dev, "init error %d\n", + retval); + u132_u132_put_kref(u132); + return retval; + } else { + u132_monitor_queue_work(u132, 100); + return 0; + } + } } @@ -3203,61 +3151,58 @@ static int __devinit u132_probe(struct platform_device *pdev) */ static int u132_suspend(struct platform_device *pdev, pm_message_t state) { - struct usb_hcd *hcd = platform_get_drvdata(pdev); - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else { + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else { int retval = 0, ports; switch (state.event) { case PM_EVENT_FREEZE: - retval = u132_bus_suspend(hcd); + retval = u132_bus_suspend(hcd); break; case PM_EVENT_SUSPEND: case PM_EVENT_HIBERNATE: ports = MAX_U132_PORTS; - while (ports-- > 0) { - port_power(u132, ports, 0); - } + while (ports-- > 0) { + port_power(u132, ports, 0); + } break; } - if (retval == 0) - pdev->dev.power.power_state = state; - return retval; - } + return retval; + } } static int u132_resume(struct platform_device *pdev) { - struct usb_hcd *hcd = platform_get_drvdata(pdev); - struct u132 *u132 = hcd_to_u132(hcd); - if (u132->going > 1) { - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" - , u132->going); - return -ENODEV; - } else if (u132->going > 0) { - dev_err(&u132->platform_dev->dev, "device is being removed\n"); - return -ESHUTDOWN; - } else { - int retval = 0; - if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { - int ports = MAX_U132_PORTS; - while (ports-- > 0) { - port_power(u132, ports, 1); - } - retval = 0; - } else { - pdev->dev.power.power_state = PMSG_ON; - retval = u132_bus_resume(hcd); - } - return retval; - } + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct u132 *u132 = hcd_to_u132(hcd); + if (u132->going > 1) { + dev_err(&u132->platform_dev->dev, "device has been removed %d\n" + , u132->going); + return -ENODEV; + } else if (u132->going > 0) { + dev_err(&u132->platform_dev->dev, "device is being removed\n"); + return -ESHUTDOWN; + } else { + int retval = 0; + if (!u132->port[0].power) { + int ports = MAX_U132_PORTS; + while (ports-- > 0) { + port_power(u132, ports, 1); + } + retval = 0; + } else { + retval = u132_bus_resume(hcd); + } + return retval; + } } #else @@ -3270,47 +3215,48 @@ static int u132_resume(struct platform_device *pdev) * the platform_driver struct is static because it is per type of module */ static struct platform_driver u132_platform_driver = { - .probe = u132_probe, - .remove = __devexit_p(u132_remove), - .suspend = u132_suspend, - .resume = u132_resume, - .driver = { - .name = (char *)hcd_name, - .owner = THIS_MODULE, - }, + .probe = u132_probe, + .remove = __devexit_p(u132_remove), + .suspend = u132_suspend, + .resume = u132_resume, + .driver = { + .name = (char *)hcd_name, + .owner = THIS_MODULE, + }, }; static int __init u132_hcd_init(void) { - int retval; - INIT_LIST_HEAD(&u132_static_list); - u132_instances = 0; - u132_exiting = 0; - mutex_init(&u132_module_lock); - if (usb_disabled()) - return -ENODEV; - printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, - __DATE__); - workqueue = create_singlethread_workqueue("u132"); - retval = platform_driver_register(&u132_platform_driver); - return retval; + int retval; + INIT_LIST_HEAD(&u132_static_list); + u132_instances = 0; + u132_exiting = 0; + mutex_init(&u132_module_lock); + if (usb_disabled()) + return -ENODEV; + printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, + __DATE__); + workqueue = create_singlethread_workqueue("u132"); + retval = platform_driver_register(&u132_platform_driver); + return retval; } module_init(u132_hcd_init); static void __exit u132_hcd_exit(void) { - struct u132 *u132; - struct u132 *temp; - mutex_lock(&u132_module_lock); - u132_exiting += 1; - mutex_unlock(&u132_module_lock); - list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { - platform_device_unregister(u132->platform_dev); - } platform_driver_unregister(&u132_platform_driver); - printk(KERN_INFO "u132-hcd driver deregistered\n"); - wait_event(u132_hcd_wait, u132_instances == 0); - flush_workqueue(workqueue); - destroy_workqueue(workqueue); + struct u132 *u132; + struct u132 *temp; + mutex_lock(&u132_module_lock); + u132_exiting += 1; + mutex_unlock(&u132_module_lock); + list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { + platform_device_unregister(u132->platform_dev); + } + platform_driver_unregister(&u132_platform_driver); + printk(KERN_INFO "u132-hcd driver deregistered\n"); + wait_event(u132_hcd_wait, u132_instances == 0); + flush_workqueue(workqueue); + destroy_workqueue(workqueue); } diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index ec987897b8e..d3e0d8aa398 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -262,20 +262,12 @@ __acquires(uhci->lock) { int auto_stop; int int_enable, egsm_enable; + struct usb_device *rhdev = uhci_to_hcd(uhci)->self.root_hub; auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); - dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, - "%s%s\n", __FUNCTION__, + dev_dbg(&rhdev->dev, "%s%s\n", __func__, (auto_stop ? " (auto-stop)" : "")); - /* If we get a suspend request when we're already auto-stopped - * then there's nothing to do. - */ - if (uhci->rh_state == UHCI_RH_AUTO_STOPPED) { - uhci->rh_state = new_state; - return; - } - /* Enable resume-detect interrupts if they work. * Then enter Global Suspend mode if _it_ works, still configured. */ @@ -285,8 +277,10 @@ __acquires(uhci->lock) if (remote_wakeup_is_broken(uhci)) egsm_enable = 0; if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable || - !device_may_wakeup( - &uhci_to_hcd(uhci)->self.root_hub->dev)) +#ifdef CONFIG_PM + (!auto_stop && !rhdev->do_remote_wakeup) || +#endif + (auto_stop && !device_may_wakeup(&rhdev->dev))) uhci->working_RD = int_enable = 0; outw(int_enable, uhci->io_addr + USBINTR); @@ -308,8 +302,7 @@ __acquires(uhci->lock) return; } if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH)) - dev_warn(&uhci_to_hcd(uhci)->self.root_hub->dev, - "Controller not stopped yet!\n"); + dev_warn(uhci_dev(uhci), "Controller not stopped yet!\n"); uhci_get_current_frame_number(uhci); @@ -342,7 +335,7 @@ __releases(uhci->lock) __acquires(uhci->lock) { dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, - "%s%s\n", __FUNCTION__, + "%s%s\n", __func__, uhci->rh_state == UHCI_RH_AUTO_STOPPED ? " (auto-start)" : ""); @@ -737,12 +730,12 @@ static int uhci_rh_resume(struct usb_hcd *hcd) return rc; } -static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) +static int uhci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) { struct uhci_hcd *uhci = hcd_to_uhci(hcd); int rc = 0; - dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); + dev_dbg(uhci_dev(uhci), "%s\n", __func__); spin_lock_irq(&uhci->lock); if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) @@ -774,11 +767,11 @@ done: return rc; } -static int uhci_resume(struct usb_hcd *hcd) +static int uhci_pci_resume(struct usb_hcd *hcd) { struct uhci_hcd *uhci = hcd_to_uhci(hcd); - dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); + dev_dbg(uhci_dev(uhci), "%s\n", __func__); /* Since we aren't in D3 any more, it's safe to set this flag * even if the controller was dead. @@ -872,8 +865,8 @@ static const struct hc_driver uhci_driver = { .reset = uhci_init, .start = uhci_start, #ifdef CONFIG_PM - .suspend = uhci_suspend, - .resume = uhci_resume, + .pci_suspend = uhci_pci_suspend, + .pci_resume = uhci_pci_resume, .bus_suspend = uhci_rh_suspend, .bus_resume = uhci_rh_resume, #endif diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index 60379b17bbc..db645936eed 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c @@ -1171,7 +1171,7 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb) /* Some debugging code */ dev_dbg(&urb->dev->dev, "%s: failed with status %x\n", - __FUNCTION__, status); + __func__, status); if (debug > 1 && errbuf) { /* Print the chain for debugging */ diff --git a/drivers/usb/image/Kconfig b/drivers/usb/image/Kconfig index 7595dfb38e3..33350f9dd34 100644 --- a/drivers/usb/image/Kconfig +++ b/drivers/usb/image/Kconfig @@ -5,8 +5,8 @@ comment "USB Imaging devices" depends on USB config USB_MDC800 - tristate "USB Mustek MDC800 Digital Camera support (EXPERIMENTAL)" - depends on USB && EXPERIMENTAL + tristate "USB Mustek MDC800 Digital Camera support" + depends on USB ---help--- Say Y here if you want to connect this type of still camera to your computer's USB port. This driver can be used with gphoto 0.4.3 diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index bc207e3c21f..885867a86de 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -185,7 +185,7 @@ static struct usb_driver mts_usb_driver = { printk( KERN_DEBUG MTS_NAME x ) #define MTS_DEBUG_GOT_HERE() \ - MTS_DEBUG("got to %s:%d (%s)\n", __FILE__, (int)__LINE__, __PRETTY_FUNCTION__ ) + MTS_DEBUG("got to %s:%d (%s)\n", __FILE__, (int)__LINE__, __func__ ) #define MTS_DEBUG_INT() \ do { MTS_DEBUG_GOT_HERE(); \ MTS_DEBUG("transfer = 0x%x context = 0x%x\n",(int)transfer,(int)context ); \ @@ -794,7 +794,6 @@ static int mts_usb_probe(struct usb_interface *intf, new_desc->usb_dev = dev; new_desc->usb_intf = intf; - init_MUTEX(&new_desc->lock); /* endpoints */ new_desc->ep_out = ep_out; diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h index d5d62a93905..ccce318f20a 100644 --- a/drivers/usb/image/microtek.h +++ b/drivers/usb/image/microtek.h @@ -39,7 +39,6 @@ struct mts_desc { u8 ep_image; struct Scsi_Host * host; - struct semaphore lock; struct urb *urb; struct mts_transfer_context context; diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 9c7eb6144d0..a53db1d4e07 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -33,8 +33,8 @@ config USB_EMI26 module will be called emi26. config USB_ADUTUX - tristate "ADU devices from Ontrak Control Systems (EXPERIMENTAL)" - depends on USB && EXPERIMENTAL + tristate "ADU devices from Ontrak Control Systems" + depends on USB help Say Y if you want to use an ADU device from Ontrak Control Systems. @@ -43,8 +43,8 @@ config USB_ADUTUX will be called adutux. config USB_AUERSWALD - tristate "USB Auerswald ISDN support (EXPERIMENTAL)" - depends on USB && EXPERIMENTAL + tristate "USB Auerswald ISDN support" + depends on USB help Say Y here if you want to connect an Auerswald USB ISDN Device to your computer's USB port. @@ -53,8 +53,8 @@ config USB_AUERSWALD module will be called auerswald. config USB_RIO500 - tristate "USB Diamond Rio500 support (EXPERIMENTAL)" - depends on USB && EXPERIMENTAL + tristate "USB Diamond Rio500 support" + depends on USB help Say Y here if you want to connect a USB Rio500 mp3 player to your computer's USB port. Please read <file:Documentation/usb/rio.txt> @@ -64,8 +64,8 @@ config USB_RIO500 module will be called rio500. config USB_LEGOTOWER - tristate "USB Lego Infrared Tower support (EXPERIMENTAL)" - depends on USB && EXPERIMENTAL + tristate "USB Lego Infrared Tower support" + depends on USB help Say Y here if you want to connect a USB Lego Infrared Tower to your computer's USB port. @@ -259,8 +259,8 @@ config USB_IOWARRIOR module will be called iowarrior. config USB_TEST - tristate "USB testing driver (DEVELOPMENT)" - depends on USB && USB_DEVICEFS && EXPERIMENTAL + tristate "USB testing driver" + depends on USB && USB_DEVICEFS help This driver is for testing host controller software. It is used with specialized device firmware for regression and stress testing, diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 5a2c44e4c1f..965f6eaea6a 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -147,10 +147,10 @@ static void adu_abort_transfers(struct adu_device *dev) { unsigned long flags; - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); if (dev->udev == NULL) { - dbg(1," %s : udev is null", __FUNCTION__); + dbg(1," %s : udev is null", __func__); goto exit; } @@ -172,12 +172,12 @@ static void adu_abort_transfers(struct adu_device *dev) spin_unlock_irqrestore(&dev->buflock, flags); exit: - dbg(2," %s : leave", __FUNCTION__); + dbg(2," %s : leave", __func__); } static void adu_delete(struct adu_device *dev) { - dbg(2, "%s enter", __FUNCTION__); + dbg(2, "%s enter", __func__); /* free data structures */ usb_free_urb(dev->interrupt_in_urb); @@ -188,7 +188,7 @@ static void adu_delete(struct adu_device *dev) kfree(dev->interrupt_out_buffer); kfree(dev); - dbg(2, "%s : leave", __FUNCTION__); + dbg(2, "%s : leave", __func__); } static void adu_interrupt_in_callback(struct urb *urb) @@ -196,8 +196,8 @@ static void adu_interrupt_in_callback(struct urb *urb) struct adu_device *dev = urb->context; int status = urb->status; - dbg(4," %s : enter, status %d", __FUNCTION__, status); - adu_debug_data(5, __FUNCTION__, urb->actual_length, + dbg(4," %s : enter, status %d", __func__, status); + adu_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); spin_lock(&dev->buflock); @@ -206,7 +206,7 @@ static void adu_interrupt_in_callback(struct urb *urb) if ((status != -ENOENT) && (status != -ECONNRESET) && (status != -ESHUTDOWN)) { dbg(1," %s : nonzero status received: %d", - __FUNCTION__, status); + __func__, status); } goto exit; } @@ -220,10 +220,10 @@ static void adu_interrupt_in_callback(struct urb *urb) dev->interrupt_in_buffer, urb->actual_length); dev->read_buffer_length += urb->actual_length; - dbg(2," %s reading %d ", __FUNCTION__, + dbg(2," %s reading %d ", __func__, urb->actual_length); } else { - dbg(1," %s : read_buffer overflow", __FUNCTION__); + dbg(1," %s : read_buffer overflow", __func__); } } @@ -232,9 +232,9 @@ exit: spin_unlock(&dev->buflock); /* always wake up so we recover from errors */ wake_up_interruptible(&dev->read_wait); - adu_debug_data(5, __FUNCTION__, urb->actual_length, + adu_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); - dbg(4," %s : leave, status %d", __FUNCTION__, status); + dbg(4," %s : leave, status %d", __func__, status); } static void adu_interrupt_out_callback(struct urb *urb) @@ -242,14 +242,14 @@ static void adu_interrupt_out_callback(struct urb *urb) struct adu_device *dev = urb->context; int status = urb->status; - dbg(4," %s : enter, status %d", __FUNCTION__, status); - adu_debug_data(5,__FUNCTION__, urb->actual_length, urb->transfer_buffer); + dbg(4," %s : enter, status %d", __func__, status); + adu_debug_data(5,__func__, urb->actual_length, urb->transfer_buffer); if (status != 0) { if ((status != -ENOENT) && (status != -ECONNRESET)) { dbg(1, " %s :nonzero status received: %d", - __FUNCTION__, status); + __func__, status); } goto exit; } @@ -260,9 +260,9 @@ static void adu_interrupt_out_callback(struct urb *urb) spin_unlock(&dev->buflock); exit: - adu_debug_data(5, __FUNCTION__, urb->actual_length, + adu_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); - dbg(4," %s : leave, status %d", __FUNCTION__, status); + dbg(4," %s : leave, status %d", __func__, status); } static int adu_open(struct inode *inode, struct file *file) @@ -272,19 +272,19 @@ static int adu_open(struct inode *inode, struct file *file) int subminor; int retval; - dbg(2,"%s : enter", __FUNCTION__); + dbg(2,"%s : enter", __func__); subminor = iminor(inode); if ((retval = mutex_lock_interruptible(&adutux_mutex))) { - dbg(2, "%s : mutex lock failed", __FUNCTION__); + dbg(2, "%s : mutex lock failed", __func__); goto exit_no_lock; } interface = usb_find_interface(&adu_driver, subminor); if (!interface) { err("%s - error, can't find device for minor %d", - __FUNCTION__, subminor); + __func__, subminor); retval = -ENODEV; goto exit_no_device; } @@ -302,7 +302,7 @@ static int adu_open(struct inode *inode, struct file *file) } ++dev->open_count; - dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count); + dbg(2,"%s : open count %d", __func__, dev->open_count); /* save device in the file's private structure */ file->private_data = dev; @@ -332,23 +332,23 @@ static int adu_open(struct inode *inode, struct file *file) exit_no_device: mutex_unlock(&adutux_mutex); exit_no_lock: - dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval); + dbg(2,"%s : leave, return value %d ", __func__, retval); return retval; } static void adu_release_internal(struct adu_device *dev) { - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); /* decrement our usage count for the device */ --dev->open_count; - dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); + dbg(2," %s : open count %d", __func__, dev->open_count); if (dev->open_count <= 0) { adu_abort_transfers(dev); dev->open_count = 0; } - dbg(2," %s : leave", __FUNCTION__); + dbg(2," %s : leave", __func__); } static int adu_release(struct inode *inode, struct file *file) @@ -356,17 +356,17 @@ static int adu_release(struct inode *inode, struct file *file) struct adu_device *dev; int retval = 0; - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); if (file == NULL) { - dbg(1," %s : file is NULL", __FUNCTION__); + dbg(1," %s : file is NULL", __func__); retval = -ENODEV; goto exit; } dev = file->private_data; if (dev == NULL) { - dbg(1," %s : object is NULL", __FUNCTION__); + dbg(1," %s : object is NULL", __func__); retval = -ENODEV; goto exit; } @@ -374,7 +374,7 @@ static int adu_release(struct inode *inode, struct file *file) mutex_lock(&adutux_mutex); /* not interruptible */ if (dev->open_count <= 0) { - dbg(1," %s : device not opened", __FUNCTION__); + dbg(1," %s : device not opened", __func__); retval = -ENODEV; goto exit; } @@ -388,7 +388,7 @@ static int adu_release(struct inode *inode, struct file *file) exit: mutex_unlock(&adutux_mutex); - dbg(2," %s : leave, return value %d", __FUNCTION__, retval); + dbg(2," %s : leave, return value %d", __func__, retval); return retval; } @@ -405,10 +405,10 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, unsigned long flags; DECLARE_WAITQUEUE(wait, current); - dbg(2," %s : enter, count = %Zd, file=%p", __FUNCTION__, count, file); + dbg(2," %s : enter, count = %Zd, file=%p", __func__, count, file); dev = file->private_data; - dbg(2," %s : dev=%p", __FUNCTION__, dev); + dbg(2," %s : dev=%p", __func__, dev); if (mutex_lock_interruptible(&dev->mtx)) return -ERESTARTSYS; @@ -422,16 +422,16 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, /* verify that some data was requested */ if (count == 0) { - dbg(1," %s : read request of 0 bytes", __FUNCTION__); + dbg(1," %s : read request of 0 bytes", __func__); goto exit; } timeout = COMMAND_TIMEOUT; - dbg(2," %s : about to start looping", __FUNCTION__); + dbg(2," %s : about to start looping", __func__); while (bytes_to_read) { int data_in_secondary = dev->secondary_tail - dev->secondary_head; dbg(2," %s : while, data_in_secondary=%d, status=%d", - __FUNCTION__, data_in_secondary, + __func__, data_in_secondary, dev->interrupt_in_urb->status); if (data_in_secondary) { @@ -456,7 +456,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, /* we secure access to the primary */ char *tmp; dbg(2," %s : swap, read_buffer_length = %d", - __FUNCTION__, dev->read_buffer_length); + __func__, dev->read_buffer_length); tmp = dev->read_buffer_secondary; dev->read_buffer_secondary = dev->read_buffer_primary; dev->read_buffer_primary = tmp; @@ -471,10 +471,10 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, if (!dev->read_urb_finished) { /* somebody is doing IO */ spin_unlock_irqrestore(&dev->buflock, flags); - dbg(2," %s : submitted already", __FUNCTION__); + dbg(2," %s : submitted already", __func__); } else { /* we must initiate input */ - dbg(2," %s : initiate input", __FUNCTION__); + dbg(2," %s : initiate input", __func__); dev->read_urb_finished = 0; spin_unlock_irqrestore(&dev->buflock, flags); @@ -492,7 +492,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, if (retval == -ENOMEM) { retval = bytes_read ? bytes_read : -ENOMEM; } - dbg(2," %s : submit failed", __FUNCTION__); + dbg(2," %s : submit failed", __func__); goto exit; } } @@ -511,13 +511,13 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, remove_wait_queue(&dev->read_wait, &wait); if (timeout <= 0) { - dbg(2," %s : timeout", __FUNCTION__); + dbg(2," %s : timeout", __func__); retval = bytes_read ? bytes_read : -ETIMEDOUT; goto exit; } if (signal_pending(current)) { - dbg(2," %s : signal pending", __FUNCTION__); + dbg(2," %s : signal pending", __func__); retval = bytes_read ? bytes_read : -EINTR; goto exit; } @@ -550,7 +550,7 @@ exit: /* unlock the device */ mutex_unlock(&dev->mtx); - dbg(2," %s : leave, return value %d", __FUNCTION__, retval); + dbg(2," %s : leave, return value %d", __func__, retval); return retval; } @@ -565,7 +565,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, unsigned long flags; int retval; - dbg(2," %s : enter, count = %Zd", __FUNCTION__, count); + dbg(2," %s : enter, count = %Zd", __func__, count); dev = file->private_data; @@ -582,7 +582,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, /* verify that we actually have some data to write */ if (count == 0) { - dbg(1," %s : write request of 0 bytes", __FUNCTION__); + dbg(1," %s : write request of 0 bytes", __func__); goto exit; } @@ -595,13 +595,13 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, mutex_unlock(&dev->mtx); if (signal_pending(current)) { - dbg(1," %s : interrupted", __FUNCTION__); + dbg(1," %s : interrupted", __func__); set_current_state(TASK_RUNNING); retval = -EINTR; goto exit_onqueue; } if (schedule_timeout(COMMAND_TIMEOUT) == 0) { - dbg(1, "%s - command timed out.", __FUNCTION__); + dbg(1, "%s - command timed out.", __func__); retval = -ETIMEDOUT; goto exit_onqueue; } @@ -612,18 +612,18 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, goto exit_nolock; } - dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count); + dbg(4," %s : in progress, count = %Zd", __func__, count); } else { spin_unlock_irqrestore(&dev->buflock, flags); set_current_state(TASK_RUNNING); remove_wait_queue(&dev->write_wait, &waita); - dbg(4," %s : sending, count = %Zd", __FUNCTION__, count); + dbg(4," %s : sending, count = %Zd", __func__, count); /* write the data into interrupt_out_buffer from userspace */ buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); bytes_to_write = count > buffer_size ? buffer_size : count; dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd", - __FUNCTION__, buffer_size, count, bytes_to_write); + __func__, buffer_size, count, bytes_to_write); if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) { retval = -EFAULT; @@ -661,7 +661,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, exit: mutex_unlock(&dev->mtx); exit_nolock: - dbg(2," %s : leave, return value %d", __FUNCTION__, retval); + dbg(2," %s : leave, return value %d", __func__, retval); return retval; exit_onqueue: @@ -706,7 +706,7 @@ static int adu_probe(struct usb_interface *interface, int out_end_size; int i; - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); if (udev == NULL) { dev_err(&interface->dev, "udev is NULL.\n"); @@ -807,7 +807,7 @@ static int adu_probe(struct usb_interface *interface, dev_err(&interface->dev, "Could not retrieve serial number\n"); goto error; } - dbg(2," %s : serial_number=%s", __FUNCTION__, dev->serial_number); + dbg(2," %s : serial_number=%s", __func__, dev->serial_number); /* we can register the device now, as it is ready */ usb_set_intfdata(interface, dev); @@ -828,7 +828,7 @@ static int adu_probe(struct usb_interface *interface, udev->descriptor.idProduct, dev->serial_number, (dev->minor - ADU_MINOR_BASE)); exit: - dbg(2," %s : leave, return value %p (dev)", __FUNCTION__, dev); + dbg(2," %s : leave, return value %p (dev)", __func__, dev); return retval; @@ -847,7 +847,7 @@ static void adu_disconnect(struct usb_interface *interface) struct adu_device *dev; int minor; - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); dev = usb_get_intfdata(interface); @@ -861,7 +861,7 @@ static void adu_disconnect(struct usb_interface *interface) usb_set_intfdata(interface, NULL); /* if the device is not opened, then we clean up right now */ - dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); + dbg(2," %s : open count %d", __func__, dev->open_count); if (!dev->open_count) adu_delete(dev); @@ -870,7 +870,7 @@ static void adu_disconnect(struct usb_interface *interface) dev_info(&interface->dev, "ADU device adutux%d now disconnected\n", (minor - ADU_MINOR_BASE)); - dbg(2," %s : leave", __FUNCTION__); + dbg(2," %s : leave", __func__); } /* usb specific object needed to register this driver with the usb subsystem */ @@ -885,7 +885,7 @@ static int __init adu_init(void) { int result; - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); /* register this driver with the USB subsystem */ result = usb_register(&adu_driver); @@ -899,17 +899,17 @@ static int __init adu_init(void) info("adutux is an experimental driver. Use at your own risk"); exit: - dbg(2," %s : leave, return value %d", __FUNCTION__, result); + dbg(2," %s : leave, return value %d", __func__, result); return result; } static void __exit adu_exit(void) { - dbg(2," %s : enter", __FUNCTION__); + dbg(2," %s : enter", __func__); /* deregister this driver with the USB subsystem */ usb_deregister(&adu_driver); - dbg(2," %s : leave", __FUNCTION__); + dbg(2," %s : leave", __func__); } module_init(adu_init); diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index a5e4c3545c7..a076c24a312 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c @@ -103,11 +103,11 @@ static void appledisplay_complete(struct urb *urb) case -ESHUTDOWN: /* This urb is terminated, clean up */ dbg("%s - urb shuttingdown with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } @@ -131,7 +131,7 @@ exit: retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); if (retval) { err("%s - usb_submit_urb failed with result %d", - __FUNCTION__, retval); + __func__, retval); } } diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index df7e1ecc810..09393869742 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -31,6 +31,7 @@ #include <linux/init.h> #include <linux/wait.h> #include <linux/usb.h> +#include <linux/mutex.h> /*-------------------------------------------------------------------*/ /* Debug support */ @@ -232,7 +233,7 @@ typedef struct auerscon /* USB device context */ typedef struct { - struct semaphore mutex; /* protection in user context */ + struct mutex mutex; /* protection in user context */ char name[20]; /* name of the /dev/usb entry */ unsigned int dtindex; /* index in the device table */ struct usb_device * usbdev; /* USB device handle */ @@ -253,12 +254,12 @@ typedef struct /* character device context */ typedef struct { - struct semaphore mutex; /* protection in user context */ + struct mutex mutex; /* protection in user context */ pauerswald_t auerdev; /* context pointer of assigned device */ auerbufctl_t bufctl; /* controls the buffer chain */ auerscon_t scontext; /* service context */ wait_queue_head_t readwait; /* for synchronous reading */ - struct semaphore readmutex; /* protection against multiple reads */ + struct mutex readmutex; /* protection against multiple reads */ pauerbuf_t readbuf; /* buffer held for partial reading */ unsigned int readoffset; /* current offset in readbuf */ unsigned int removed; /* is != 0 if device is removed */ @@ -283,7 +284,7 @@ static void auerchain_complete (struct urb * urb) int result; /* get pointer to element and to chain */ - pauerchainelement_t acep = (pauerchainelement_t) urb->context; + pauerchainelement_t acep = urb->context; pauerchain_t acp = acep->chain; /* restore original entries in urb */ @@ -593,7 +594,7 @@ ac_fail:/* free the elements */ /* completion handler for synchronous chained URBs */ static void auerchain_blocking_completion (struct urb *urb) { - pauerchain_chs_t pchs = (pauerchain_chs_t)urb->context; + pauerchain_chs_t pchs = urb->context; pchs->done = 1; wmb(); wake_up (&pchs->wqh); @@ -846,7 +847,7 @@ static int auerswald_status_retry (int status) /* Completion of asynchronous write block */ static void auerchar_ctrlwrite_complete (struct urb * urb) { - pauerbuf_t bp = (pauerbuf_t) urb->context; + pauerbuf_t bp = urb->context; pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl))); dbg ("auerchar_ctrlwrite_complete called"); @@ -859,7 +860,7 @@ static void auerchar_ctrlwrite_complete (struct urb * urb) /* Completion handler for dummy retry packet */ static void auerswald_ctrlread_wretcomplete (struct urb * urb) { - pauerbuf_t bp = (pauerbuf_t) urb->context; + pauerbuf_t bp = urb->context; pauerswald_t cp; int ret; int status = urb->status; @@ -903,7 +904,7 @@ static void auerswald_ctrlread_complete (struct urb * urb) unsigned int serviceid; pauerswald_t cp; pauerscon_t scp; - pauerbuf_t bp = (pauerbuf_t) urb->context; + pauerbuf_t bp = urb->context; int status = urb->status; int ret; @@ -980,9 +981,9 @@ static void auerswald_int_complete (struct urb * urb) int ret; int status = urb->status; pauerbuf_t bp = NULL; - pauerswald_t cp = (pauerswald_t) urb->context; + pauerswald_t cp = urb->context; - dbg ("%s called", __FUNCTION__); + dbg ("%s called", __func__); switch (status) { case 0: @@ -992,10 +993,10 @@ static void auerswald_int_complete (struct urb * urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, status); + dbg("%s - urb shutting down with status: %d", __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", __FUNCTION__, status); + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } @@ -1080,7 +1081,7 @@ exit: ret = usb_submit_urb (urb, GFP_ATOMIC); if (ret) err ("%s - usb_submit_urb failed with result %d", - __FUNCTION__, ret); + __func__, ret); } /* int memory deallocation @@ -1376,7 +1377,7 @@ static int auerchar_open (struct inode *inode, struct file *file) if (cp == NULL) { return -ENODEV; } - if (down_interruptible (&cp->mutex)) { + if (mutex_lock_interruptible(&cp->mutex)) { return -ERESTARTSYS; } @@ -1389,8 +1390,8 @@ static int auerchar_open (struct inode *inode, struct file *file) } /* Initialize device descriptor */ - init_MUTEX( &ccp->mutex); - init_MUTEX( &ccp->readmutex); + mutex_init(&ccp->mutex); + mutex_init(&ccp->readmutex); auerbuf_init (&ccp->bufctl); ccp->scontext.id = AUH_UNASSIGNED; ccp->scontext.dispatch = auerchar_ctrlread_dispatch; @@ -1405,7 +1406,7 @@ static int auerchar_open (struct inode *inode, struct file *file) cp->open_count++; ccp->auerdev = cp; dbg("open %s as /dev/%s", cp->dev_desc, cp->name); - up (&cp->mutex); + mutex_unlock(&cp->mutex); /* file IO stuff */ file->f_pos = 0; @@ -1413,7 +1414,7 @@ static int auerchar_open (struct inode *inode, struct file *file) return nonseekable_open(inode, file); /* Error exit */ -ofail: up (&cp->mutex); +ofail: mutex_unlock(&cp->mutex); auerchar_delete (ccp); return ret; } @@ -1432,23 +1433,23 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int dbg ("ioctl"); /* get the mutexes */ - if (down_interruptible (&ccp->mutex)) { + if (mutex_lock_interruptible(&ccp->mutex)) { return -ERESTARTSYS; } cp = ccp->auerdev; if (!cp) { - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); return -ENODEV; } - if (down_interruptible (&cp->mutex)) { - up(&ccp->mutex); + if (mutex_lock_interruptible(&cp->mutex)) { + mutex_unlock(&ccp->mutex); return -ERESTARTSYS; } /* Check for removal */ if (!cp->usbdev) { - up(&cp->mutex); - up(&ccp->mutex); + mutex_unlock(&cp->mutex); + mutex_unlock(&ccp->mutex); return -ENODEV; } @@ -1550,8 +1551,8 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int break; } /* release the mutexes */ - up(&cp->mutex); - up(&ccp->mutex); + mutex_unlock(&cp->mutex); + mutex_unlock(&ccp->mutex); return ret; } @@ -1574,18 +1575,18 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count, return 0; /* get the mutex */ - if (down_interruptible (&ccp->mutex)) + if (mutex_lock_interruptible(&ccp->mutex)) return -ERESTARTSYS; /* Can we expect to read something? */ if (ccp->scontext.id == AUH_UNASSIGNED) { - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); return -EIO; } /* only one reader per device allowed */ - if (down_interruptible (&ccp->readmutex)) { - up (&ccp->mutex); + if (mutex_lock_interruptible(&ccp->readmutex)) { + mutex_unlock(&ccp->mutex); return -ERESTARTSYS; } @@ -1602,8 +1603,8 @@ doreadbuf: if (count) { if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) { dbg ("auerswald_read: copy_to_user failed"); - up (&ccp->readmutex); - up (&ccp->mutex); + mutex_unlock(&ccp->readmutex); + mutex_unlock(&ccp->mutex); return -EFAULT; } } @@ -1617,8 +1618,8 @@ doreadbuf: } /* return with number of bytes read */ if (count) { - up (&ccp->readmutex); - up (&ccp->mutex); + mutex_unlock(&ccp->readmutex); + mutex_unlock(&ccp->mutex); return count; } } @@ -1654,29 +1655,29 @@ doreadlist: dbg ("No read buffer available, returning -EAGAIN"); set_current_state (TASK_RUNNING); remove_wait_queue (&ccp->readwait, &wait); - up (&ccp->readmutex); - up (&ccp->mutex); + mutex_unlock(&ccp->readmutex); + mutex_unlock(&ccp->mutex); return -EAGAIN; /* nonblocking, no data available */ } /* yes, we should wait! */ - up (&ccp->mutex); /* allow other operations while we wait */ + mutex_unlock(&ccp->mutex); /* allow other operations while we wait */ schedule(); remove_wait_queue (&ccp->readwait, &wait); if (signal_pending (current)) { /* waked up by a signal */ - up (&ccp->readmutex); + mutex_unlock(&ccp->readmutex); return -ERESTARTSYS; } /* Anything left to read? */ if ((ccp->scontext.id == AUH_UNASSIGNED) || ccp->removed) { - up (&ccp->readmutex); + mutex_unlock(&ccp->readmutex); return -EIO; } - if (down_interruptible (&ccp->mutex)) { - up (&ccp->readmutex); + if (mutex_lock_interruptible(&ccp->mutex)) { + mutex_unlock(&ccp->readmutex); return -ERESTARTSYS; } @@ -1707,27 +1708,27 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t write_again: /* get the mutex */ - if (down_interruptible (&ccp->mutex)) + if (mutex_lock_interruptible(&ccp->mutex)) return -ERESTARTSYS; /* Can we expect to write something? */ if (ccp->scontext.id == AUH_UNASSIGNED) { - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); return -EIO; } cp = ccp->auerdev; if (!cp) { - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); return -ERESTARTSYS; } - if (down_interruptible (&cp->mutex)) { - up (&ccp->mutex); + if (mutex_lock_interruptible(&cp->mutex)) { + mutex_unlock(&ccp->mutex); return -ERESTARTSYS; } if (!cp->usbdev) { - up (&cp->mutex); - up (&ccp->mutex); + mutex_unlock(&cp->mutex); + mutex_unlock(&ccp->mutex); return -EIO; } /* Prepare for sleep */ @@ -1750,8 +1751,8 @@ write_again: /* are there any buffers left? */ if (!bp) { - up (&cp->mutex); - up (&ccp->mutex); + mutex_unlock(&cp->mutex); + mutex_unlock(&ccp->mutex); /* NONBLOCK: don't wait */ if (file->f_flags & O_NONBLOCK) { @@ -1783,8 +1784,8 @@ write_again: auerbuf_releasebuf (bp); /* Wake up all processes waiting for a buffer */ wake_up (&cp->bufferwait); - up (&cp->mutex); - up (&ccp->mutex); + mutex_unlock(&cp->mutex); + mutex_unlock(&ccp->mutex); return -EFAULT; } @@ -1803,18 +1804,18 @@ write_again: auerchar_ctrlwrite_complete, bp); /* up we go */ ret = auerchain_submit_urb (&cp->controlchain, bp->urbp); - up (&cp->mutex); + mutex_unlock(&cp->mutex); if (ret) { dbg ("auerchar_write: nonzero result of auerchain_submit_urb %d", ret); auerbuf_releasebuf (bp); /* Wake up all processes waiting for a buffer */ wake_up (&cp->bufferwait); - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); return -EIO; } else { dbg ("auerchar_write: Write OK"); - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); return len; } } @@ -1827,24 +1828,24 @@ static int auerchar_release (struct inode *inode, struct file *file) pauerswald_t cp; dbg("release"); - down(&ccp->mutex); + mutex_lock(&ccp->mutex); cp = ccp->auerdev; if (cp) { - down(&cp->mutex); + mutex_lock(&cp->mutex); /* remove an open service */ auerswald_removeservice (cp, &ccp->scontext); /* detach from device */ if ((--cp->open_count <= 0) && (cp->usbdev == NULL)) { /* usb device waits for removal */ - up (&cp->mutex); + mutex_unlock(&cp->mutex); auerswald_delete (cp); } else { - up (&cp->mutex); + mutex_unlock(&cp->mutex); } cp = NULL; ccp->auerdev = NULL; } - up (&ccp->mutex); + mutex_unlock(&ccp->mutex); auerchar_delete (ccp); return 0; @@ -1917,7 +1918,7 @@ static int auerswald_probe (struct usb_interface *intf, } /* Initialize device descriptor */ - init_MUTEX (&cp->mutex); + mutex_init(&cp->mutex); cp->usbdev = usbdev; auerchain_init (&cp->controlchain); auerbuf_init (&cp->bufctl); @@ -2042,7 +2043,7 @@ static void auerswald_disconnect (struct usb_interface *intf) /* give back our USB minor number */ usb_deregister_dev(intf, &auerswald_class); - down (&cp->mutex); + mutex_lock(&cp->mutex); info ("device /dev/%s now disconnecting", cp->name); /* Stop the interrupt endpoint */ @@ -2057,16 +2058,18 @@ static void auerswald_disconnect (struct usb_interface *intf) if (cp->open_count == 0) { /* nobody is using this device. So we can clean up now */ - up (&cp->mutex);/* up() is possible here because no other task - can open the device (see above). I don't want - to kfree() a locked mutex. */ + mutex_unlock(&cp->mutex); + /* mutex_unlock() is possible here because no other task + can open the device (see above). I don't want + to kfree() a locked mutex. */ + auerswald_delete (cp); } else { /* device is used. Remove the pointer to the usb device (it's not valid any more). The last release() will do the clean up */ cp->usbdev = NULL; - up (&cp->mutex); + mutex_unlock(&cp->mutex); /* Terminate waiting writers */ wake_up (&cp->bufferwait); /* Inform all waiting readers */ diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 4a09b87bdd2..4b9dc81b845 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c @@ -70,8 +70,8 @@ static int emi26_writememory (struct usb_device *dev, int address, unsigned char static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) { int response; - info("%s - %d", __FUNCTION__, reset_bit); - /* printk(KERN_DEBUG "%s - %d", __FUNCTION__, reset_bit); */ + info("%s - %d", __func__, reset_bit); + /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); if (response < 0) { err("emi26: set_reset (%d) failed", reset_bit); @@ -91,7 +91,7 @@ static int emi26_load_firmware (struct usb_device *dev) buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); if (!buf) { - err( "%s - error loading firmware: error = %d", __FUNCTION__, -ENOMEM); + err( "%s - error loading firmware: error = %d", __func__, -ENOMEM); err = -ENOMEM; goto wraperr; } @@ -99,7 +99,7 @@ static int emi26_load_firmware (struct usb_device *dev) /* Assert reset (stop the CPU in the EMI) */ err = emi26_set_reset(dev,1); if (err < 0) { - err( "%s - error loading firmware: error = %d", __FUNCTION__, err); + err( "%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -107,7 +107,7 @@ static int emi26_load_firmware (struct usb_device *dev) for (i=0; g_Loader[i].type == 0; i++) { err = emi26_writememory(dev, g_Loader[i].address, g_Loader[i].data, g_Loader[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -115,7 +115,7 @@ static int emi26_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi26_set_reset(dev,0); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } msleep(250); /* let device settle */ @@ -135,7 +135,7 @@ static int emi26_load_firmware (struct usb_device *dev) } err = emi26_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } while (i > 0); @@ -143,7 +143,7 @@ static int emi26_load_firmware (struct usb_device *dev) /* Assert reset (stop the CPU in the EMI) */ err = emi26_set_reset(dev,1); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -151,7 +151,7 @@ static int emi26_load_firmware (struct usb_device *dev) for (i=0; g_Loader[i].type == 0; i++) { err = emi26_writememory(dev, g_Loader[i].address, g_Loader[i].data, g_Loader[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -160,7 +160,7 @@ static int emi26_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi26_set_reset(dev,0); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -169,7 +169,7 @@ static int emi26_load_firmware (struct usb_device *dev) if (!INTERNAL_RAM(g_Firmware[i].address)) { err = emi26_writememory(dev, g_Firmware[i].address, g_Firmware[i].data, g_Firmware[i].length, ANCHOR_LOAD_EXTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -178,7 +178,7 @@ static int emi26_load_firmware (struct usb_device *dev) /* Assert reset (stop the CPU in the EMI) */ err = emi26_set_reset(dev,1); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -186,7 +186,7 @@ static int emi26_load_firmware (struct usb_device *dev) if (INTERNAL_RAM(g_Firmware[i].address)) { err = emi26_writememory(dev, g_Firmware[i].address, g_Firmware[i].data, g_Firmware[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -195,7 +195,7 @@ static int emi26_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi26_set_reset(dev,0); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } msleep(250); /* let device settle */ @@ -221,7 +221,7 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i { struct usb_device *dev = interface_to_usbdev(intf); - info("%s start", __FUNCTION__); + info("%s start", __func__); emi26_load_firmware(dev); diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index d1362415922..1a2b79ac5e1 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -78,7 +78,7 @@ static int emi62_writememory (struct usb_device *dev, int address, unsigned char static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) { int response; - info("%s - %d", __FUNCTION__, reset_bit); + info("%s - %d", __func__, reset_bit); response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); if (response < 0) { @@ -100,7 +100,7 @@ static int emi62_load_firmware (struct usb_device *dev) dev_dbg(&dev->dev, "load_firmware\n"); buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); if (!buf) { - err( "%s - error loading firmware: error = %d", __FUNCTION__, -ENOMEM); + err( "%s - error loading firmware: error = %d", __func__, -ENOMEM); err = -ENOMEM; goto wraperr; } @@ -108,7 +108,7 @@ static int emi62_load_firmware (struct usb_device *dev) /* Assert reset (stop the CPU in the EMI) */ err = emi62_set_reset(dev,1); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -116,7 +116,7 @@ static int emi62_load_firmware (struct usb_device *dev) for (i=0; g_emi62_loader[i].type == 0; i++) { err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -124,7 +124,7 @@ static int emi62_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi62_set_reset(dev,0); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } msleep(250); /* let device settle */ @@ -144,7 +144,7 @@ static int emi62_load_firmware (struct usb_device *dev) } err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } while (i > 0); @@ -152,7 +152,7 @@ static int emi62_load_firmware (struct usb_device *dev) /* Assert reset (stop the CPU in the EMI) */ err = emi62_set_reset(dev,1); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -160,7 +160,7 @@ static int emi62_load_firmware (struct usb_device *dev) for (i=0; g_emi62_loader[i].type == 0; i++) { err = emi62_writememory(dev, g_emi62_loader[i].address, g_emi62_loader[i].data, g_emi62_loader[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -168,7 +168,7 @@ static int emi62_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi62_set_reset(dev,0); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } msleep(250); /* let device settle */ @@ -181,7 +181,7 @@ static int emi62_load_firmware (struct usb_device *dev) if (!INTERNAL_RAM(g_HexSpdifFw62[i].address)) { err = emi62_writememory(dev, g_HexSpdifFw62[i].address, g_HexSpdifFw62[i].data, g_HexSpdifFw62[i].length, ANCHOR_LOAD_EXTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -191,7 +191,7 @@ static int emi62_load_firmware (struct usb_device *dev) if (!INTERNAL_RAM(g_HexMidiFw62[i].address)) { err = emi62_writememory(dev, g_HexMidiFw62[i].address, g_HexMidiFw62[i].data, g_HexMidiFw62[i].length, ANCHOR_LOAD_EXTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d\n", __FUNCTION__, err); + err("%s - error loading firmware: error = %d\n", __func__, err); goto wraperr; return err; } @@ -201,7 +201,7 @@ static int emi62_load_firmware (struct usb_device *dev) /* Assert reset (stop the CPU in the EMI) */ err = emi62_set_reset(dev,1); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } @@ -211,7 +211,7 @@ static int emi62_load_firmware (struct usb_device *dev) if (INTERNAL_RAM(g_HexSpdifFw62[i].address)) { err = emi62_writememory(dev, g_HexSpdifFw62[i].address, g_HexSpdifFw62[i].data, g_HexSpdifFw62[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } } @@ -221,7 +221,7 @@ static int emi62_load_firmware (struct usb_device *dev) if (INTERNAL_RAM(g_HexMidiFw62[i].address)) { err = emi62_writememory(dev, g_HexMidiFw62[i].address, g_HexMidiFw62[i].data, g_HexMidiFw62[i].length, ANCHOR_LOAD_INTERNAL); if (err < 0) { - err("%s - error loading firmware: error = %d\n", __FUNCTION__, err); + err("%s - error loading firmware: error = %d\n", __func__, err); goto wraperr; } } @@ -231,7 +231,7 @@ static int emi62_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi62_set_reset(dev,0); if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); + err("%s - error loading firmware: error = %d", __func__, err); goto wraperr; } msleep(250); /* let device settle */ @@ -260,7 +260,7 @@ static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *i struct usb_device *dev = interface_to_usbdev(intf); dev_dbg(&intf->dev, "emi62_probe\n"); - info("%s start", __FUNCTION__); + info("%s start", __func__); emi62_load_firmware(dev); diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 148b7fe639b..ec88b3bfee4 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c @@ -746,7 +746,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer, static void ftdi_elan_write_bulk_callback(struct urb *urb) { - struct usb_ftdi *ftdi = (struct usb_ftdi *)urb->context; + struct usb_ftdi *ftdi = urb->context; int status = urb->status; if (status && !(status == -ENOENT || status == -ECONNRESET || diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 801070502cc..1cb54a28347 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -154,7 +154,7 @@ MODULE_DEVICE_TABLE(usb, iowarrior_ids); */ static void iowarrior_callback(struct urb *urb) { - struct iowarrior *dev = (struct iowarrior *)urb->context; + struct iowarrior *dev = urb->context; int intr_idx; int read_idx; int aux_idx; @@ -218,7 +218,7 @@ exit: retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) dev_err(&dev->interface->dev, "%s - usb_submit_urb failed with result %d\n", - __FUNCTION__, retval); + __func__, retval); } @@ -230,7 +230,7 @@ static void iowarrior_write_callback(struct urb *urb) struct iowarrior *dev; int status = urb->status; - dev = (struct iowarrior *)urb->context; + dev = urb->context; /* sync/async unlink faults aren't errors */ if (status && !(status == -ENOENT || @@ -453,7 +453,7 @@ static ssize_t iowarrior_write(struct file *file, default: /* what do we have here ? An unsupported Product-ID ? */ dev_err(&dev->interface->dev, "%s - not supported for product=0x%x\n", - __FUNCTION__, dev->product_id); + __func__, dev->product_id); retval = -EFAULT; goto exit; break; @@ -604,7 +604,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) interface = usb_find_interface(&iowarrior_driver, subminor); if (!interface) { - err("%s - error, can't find device for minor %d", __FUNCTION__, + err("%s - error, can't find device for minor %d", __func__, subminor); return -ENODEV; } diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index c730d20eec6..11580e81e2c 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -231,7 +231,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) goto exit; } else { dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n", - __FUNCTION__, status); + __func__, status); spin_lock(&dev->rbsl); goto resubmit; /* maybe we can recover */ } @@ -247,7 +247,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) memcpy(actual_buffer+1, dev->interrupt_in_buffer, urb->actual_length); dev->ring_head = next_ring_head; dbg_info(&dev->intf->dev, "%s: received %d bytes\n", - __FUNCTION__, urb->actual_length); + __func__, urb->actual_length); } else { dev_warn(&dev->intf->dev, "Ring buffer overflow, %d bytes dropped\n", @@ -286,7 +286,7 @@ static void ld_usb_interrupt_out_callback(struct urb *urb) status == -ESHUTDOWN)) dbg_info(&dev->intf->dev, "%s - nonzero write interrupt status received: %d\n", - __FUNCTION__, status); + __func__, status); dev->interrupt_out_busy = 0; wake_up_interruptible(&dev->write_wait); @@ -309,7 +309,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) if (!interface) { err("%s - error, can't find device for minor %d\n", - __FUNCTION__, subminor); + __func__, subminor); return -ENODEV; } @@ -556,7 +556,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size); if (bytes_to_write < count) dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write); - dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __FUNCTION__, count, bytes_to_write); + dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __func__, count, bytes_to_write); if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { retval = -EFAULT; diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 6664043f464..9370326a594 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -31,7 +31,7 @@ * - imported into lejos project * - changed wake_up to wake_up_interruptible * - changed to use lego0 rather than tower0 - * - changed dbg() to use __func__ rather than deprecated __FUNCTION__ + * - changed dbg() to use __func__ rather than deprecated __func__ * 2003-01-12 - 0.53 david (david@csse.uwa.edu.au) * - changed read and write to write everything or * timeout (from a patch by Chris Riesen and Brett Thaeler driver) @@ -49,7 +49,7 @@ * - added poll * - forbid seeking * - added nonblocking I/O - * - changed back __func__ to __FUNCTION__ + * - changed back __func__ to __func__ * - read and log tower firmware version * - reset tower on probe, avoids failure of first write * 2004-03-09 - 0.7 Juergen Stuber <starblue@users.sourceforge.net> @@ -309,7 +309,7 @@ static inline void lego_usb_tower_debug_data (int level, const char *function, i */ static inline void tower_delete (struct lego_usb_tower *dev) { - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); tower_abort_transfers (dev); @@ -321,7 +321,7 @@ static inline void tower_delete (struct lego_usb_tower *dev) kfree (dev->interrupt_out_buffer); kfree (dev); - dbg(2, "%s: leave", __FUNCTION__); + dbg(2, "%s: leave", __func__); } @@ -337,7 +337,7 @@ static int tower_open (struct inode *inode, struct file *file) struct tower_reset_reply reset_reply; int result; - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); nonseekable_open(inode, file); subminor = iminor(inode); @@ -346,7 +346,7 @@ static int tower_open (struct inode *inode, struct file *file) if (!interface) { err ("%s - error, can't find device for minor %d", - __FUNCTION__, subminor); + __func__, subminor); retval = -ENODEV; goto exit; } @@ -424,7 +424,7 @@ unlock_exit: mutex_unlock(&dev->lock); exit: - dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); + dbg(2, "%s: leave, return value %d ", __func__, retval); return retval; } @@ -437,12 +437,12 @@ static int tower_release (struct inode *inode, struct file *file) struct lego_usb_tower *dev; int retval = 0; - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); dev = (struct lego_usb_tower *)file->private_data; if (dev == NULL) { - dbg(1, "%s: object is NULL", __FUNCTION__); + dbg(1, "%s: object is NULL", __func__); retval = -ENODEV; goto exit_nolock; } @@ -454,7 +454,7 @@ static int tower_release (struct inode *inode, struct file *file) } if (dev->open_count != 1) { - dbg(1, "%s: device not opened exactly once", __FUNCTION__); + dbg(1, "%s: device not opened exactly once", __func__); retval = -ENODEV; goto unlock_exit; } @@ -480,7 +480,7 @@ unlock_exit: exit: mutex_unlock(&open_disc_mutex); exit_nolock: - dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); + dbg(2, "%s: leave, return value %d", __func__, retval); return retval; } @@ -491,10 +491,10 @@ exit_nolock: */ static void tower_abort_transfers (struct lego_usb_tower *dev) { - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); if (dev == NULL) { - dbg(1, "%s: dev is null", __FUNCTION__); + dbg(1, "%s: dev is null", __func__); goto exit; } @@ -509,7 +509,7 @@ static void tower_abort_transfers (struct lego_usb_tower *dev) usb_kill_urb(dev->interrupt_out_urb); exit: - dbg(2, "%s: leave", __FUNCTION__); + dbg(2, "%s: leave", __func__); } @@ -542,7 +542,7 @@ static unsigned int tower_poll (struct file *file, poll_table *wait) struct lego_usb_tower *dev; unsigned int mask = 0; - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); dev = file->private_data; @@ -557,7 +557,7 @@ static unsigned int tower_poll (struct file *file, poll_table *wait) mask |= POLLOUT | POLLWRNORM; } - dbg(2, "%s: leave, mask = %d", __FUNCTION__, mask); + dbg(2, "%s: leave, mask = %d", __func__, mask); return mask; } @@ -583,7 +583,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, int retval = 0; unsigned long timeout = 0; - dbg(2, "%s: enter, count = %Zd", __FUNCTION__, count); + dbg(2, "%s: enter, count = %Zd", __func__, count); dev = (struct lego_usb_tower *)file->private_data; @@ -602,7 +602,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, /* verify that we actually have some data to read */ if (count == 0) { - dbg(1, "%s: read request of 0 bytes", __FUNCTION__); + dbg(1, "%s: read request of 0 bytes", __func__); goto unlock_exit; } @@ -658,7 +658,7 @@ unlock_exit: mutex_unlock(&dev->lock); exit: - dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); + dbg(2, "%s: leave, return value %d", __func__, retval); return retval; } @@ -672,7 +672,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t size_t bytes_to_write; int retval = 0; - dbg(2, "%s: enter, count = %Zd", __FUNCTION__, count); + dbg(2, "%s: enter, count = %Zd", __func__, count); dev = (struct lego_usb_tower *)file->private_data; @@ -691,7 +691,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t /* verify that we actually have some data to write */ if (count == 0) { - dbg(1, "%s: write request of 0 bytes", __FUNCTION__); + dbg(1, "%s: write request of 0 bytes", __func__); goto unlock_exit; } @@ -709,7 +709,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t /* write the data into interrupt_out_buffer from userspace */ bytes_to_write = min_t(int, count, write_buffer_size); - dbg(4, "%s: count = %Zd, bytes_to_write = %Zd", __FUNCTION__, count, bytes_to_write); + dbg(4, "%s: count = %Zd, bytes_to_write = %Zd", __func__, count, bytes_to_write); if (copy_from_user (dev->interrupt_out_buffer, buffer, bytes_to_write)) { retval = -EFAULT; @@ -742,7 +742,7 @@ unlock_exit: mutex_unlock(&dev->lock); exit: - dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); + dbg(2, "%s: leave, return value %d", __func__, retval); return retval; } @@ -753,13 +753,13 @@ exit: */ static void tower_interrupt_in_callback (struct urb *urb) { - struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context; + struct lego_usb_tower *dev = urb->context; int status = urb->status; int retval; - dbg(4, "%s: enter, status %d", __FUNCTION__, status); + dbg(4, "%s: enter, status %d", __func__, status); - lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); + lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); if (status) { if (status == -ENOENT || @@ -767,7 +767,7 @@ static void tower_interrupt_in_callback (struct urb *urb) status == -ESHUTDOWN) { goto exit; } else { - dbg(1, "%s: nonzero status received: %d", __FUNCTION__, status); + dbg(1, "%s: nonzero status received: %d", __func__, status); goto resubmit; /* maybe we can recover */ } } @@ -780,9 +780,9 @@ static void tower_interrupt_in_callback (struct urb *urb) urb->actual_length); dev->read_buffer_length += urb->actual_length; dev->read_last_arrival = jiffies; - dbg(3, "%s: received %d bytes", __FUNCTION__, urb->actual_length); + dbg(3, "%s: received %d bytes", __func__, urb->actual_length); } else { - printk(KERN_WARNING "%s: read_buffer overflow, %d bytes dropped", __FUNCTION__, urb->actual_length); + printk(KERN_WARNING "%s: read_buffer overflow, %d bytes dropped", __func__, urb->actual_length); } spin_unlock (&dev->read_buffer_lock); } @@ -792,7 +792,7 @@ resubmit: if (dev->interrupt_in_running && dev->udev) { retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC); if (retval) { - err("%s: usb_submit_urb failed (%d)", __FUNCTION__, retval); + err("%s: usb_submit_urb failed (%d)", __func__, retval); } } @@ -800,8 +800,8 @@ exit: dev->interrupt_in_done = 1; wake_up_interruptible (&dev->read_wait); - lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); - dbg(4, "%s: leave, status %d", __FUNCTION__, status); + lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); + dbg(4, "%s: leave, status %d", __func__, status); } @@ -810,25 +810,25 @@ exit: */ static void tower_interrupt_out_callback (struct urb *urb) { - struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context; + struct lego_usb_tower *dev = urb->context; int status = urb->status; - dbg(4, "%s: enter, status %d", __FUNCTION__, status); - lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); + dbg(4, "%s: enter, status %d", __func__, status); + lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); /* sync/async unlink faults aren't errors */ if (status && !(status == -ENOENT || status == -ECONNRESET || status == -ESHUTDOWN)) { dbg(1, "%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); } dev->interrupt_out_busy = 0; wake_up_interruptible(&dev->write_wait); - lego_usb_tower_debug_data(5, __FUNCTION__, urb->actual_length, urb->transfer_buffer); - dbg(4, "%s: leave, status %d", __FUNCTION__, status); + lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer); + dbg(4, "%s: leave, status %d", __func__, status); } @@ -849,7 +849,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device int retval = -ENOMEM; int result; - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); if (udev == NULL) { info ("udev is NULL."); @@ -978,7 +978,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device exit: - dbg(2, "%s: leave, return value 0x%.8lx (dev)", __FUNCTION__, (long) dev); + dbg(2, "%s: leave, return value 0x%.8lx (dev)", __func__, (long) dev); return retval; @@ -998,7 +998,7 @@ static void tower_disconnect (struct usb_interface *interface) struct lego_usb_tower *dev; int minor; - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); dev = usb_get_intfdata (interface); mutex_lock(&open_disc_mutex); @@ -1023,7 +1023,7 @@ static void tower_disconnect (struct usb_interface *interface) info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); - dbg(2, "%s: leave", __FUNCTION__); + dbg(2, "%s: leave", __func__); } @@ -1036,7 +1036,7 @@ static int __init lego_usb_tower_init(void) int result; int retval = 0; - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); /* register this driver with the USB subsystem */ result = usb_register(&tower_driver); @@ -1049,7 +1049,7 @@ static int __init lego_usb_tower_init(void) info(DRIVER_DESC " " DRIVER_VERSION); exit: - dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); + dbg(2, "%s: leave, return value %d", __func__, retval); return retval; } @@ -1060,12 +1060,12 @@ exit: */ static void __exit lego_usb_tower_exit(void) { - dbg(2, "%s: enter", __FUNCTION__); + dbg(2, "%s: enter", __func__); /* deregister this driver with the USB subsystem */ usb_deregister (&tower_driver); - dbg(2, "%s: leave", __FUNCTION__); + dbg(2, "%s: leave", __func__); } module_init (lego_usb_tower_init); diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c index aa9bcceabe7..24230c638b8 100644 --- a/drivers/usb/misc/phidgetkit.c +++ b/drivers/usb/misc/phidgetkit.c @@ -113,7 +113,7 @@ static int set_outputs(struct interfacekit *kit) buffer = kzalloc(4, GFP_KERNEL); if (!buffer) { - dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&kit->udev->dev, "%s - out of memory\n", __func__); return -ENOMEM; } buffer[0] = (u8)kit->outputs; @@ -146,7 +146,7 @@ static int change_string(struct interfacekit *kit, const char *display, unsigned buffer = kmalloc(8, GFP_KERNEL); form_buffer = kmalloc(30, GFP_KERNEL); if ((!buffer) || (!form_buffer)) { - dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&kit->udev->dev, "%s - out of memory\n", __func__); goto exit; } @@ -216,7 +216,7 @@ static ssize_t set_backlight(struct device *dev, struct device_attribute *attr, buffer = kzalloc(8, GFP_KERNEL); if (!buffer) { - dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&kit->udev->dev, "%s - out of memory\n", __func__); goto exit; } diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c index 2ad09b1f484..f0113c17cc5 100644 --- a/drivers/usb/misc/phidgetmotorcontrol.c +++ b/drivers/usb/misc/phidgetmotorcontrol.c @@ -61,7 +61,7 @@ static int set_motor(struct motorcontrol *mc, int motor) buffer = kzalloc(8, GFP_KERNEL); if (!buffer) { - dev_err(&mc->intf->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&mc->intf->dev, "%s - out of memory\n", __func__); return -ENOMEM; } diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c index 0d9de2f7393..7d590c09434 100644 --- a/drivers/usb/misc/phidgetservo.c +++ b/drivers/usb/misc/phidgetservo.c @@ -89,7 +89,7 @@ change_position_v30(struct phidget_servo *servo, int servo_no, int degrees, buffer = kmalloc(6, GFP_KERNEL); if (!buffer) { dev_err(&servo->udev->dev, "%s - out of memory\n", - __FUNCTION__); + __func__); return -ENOMEM; } @@ -162,7 +162,7 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees, buffer = kmalloc(2, GFP_KERNEL); if (!buffer) { dev_err(&servo->udev->dev, "%s - out of memory\n", - __FUNCTION__); + __func__); return -ENOMEM; } @@ -259,7 +259,7 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id) dev = kzalloc(sizeof (struct phidget_servo), GFP_KERNEL); if (dev == NULL) { - dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&interface->dev, "%s - out of memory\n", __func__); rc = -ENOMEM; goto out; } diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 20777d01db6..7f7021ee418 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c @@ -78,7 +78,7 @@ static int lcd_open(struct inode *inode, struct file *file) interface = usb_find_interface(&lcd_driver, subminor); if (!interface) { err ("USBLCD: %s - error, can't find device for minor %d", - __FUNCTION__, subminor); + __func__, subminor); return -ENODEV; } @@ -185,7 +185,7 @@ static void lcd_write_bulk_callback(struct urb *urb) struct usb_lcd *dev; int status = urb->status; - dev = (struct usb_lcd *)urb->context; + dev = urb->context; /* sync/async unlink faults aren't errors */ if (status && @@ -193,7 +193,7 @@ static void lcd_write_bulk_callback(struct urb *urb) status == -ECONNRESET || status == -ESHUTDOWN)) { dbg("USBLCD: %s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); } /* free up our allocated buffer */ @@ -248,7 +248,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, siz /* send the data out the bulk port */ retval = usb_submit_urb(urb, GFP_KERNEL); if (retval) { - err("USBLCD: %s - failed submitting write urb, error %d", __FUNCTION__, retval); + err("USBLCD: %s - failed submitting write urb, error %d", __func__, retval); goto error_unanchor; } diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index b6b5b2affad..a51983854ca 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -201,7 +201,7 @@ found: static void simple_callback (struct urb *urb) { - complete ((struct completion *) urb->context); + complete(urb->context); } static struct urb *simple_alloc_urb ( @@ -1046,7 +1046,7 @@ static void unlink1_callback (struct urb *urb) status = usb_submit_urb (urb, GFP_ATOMIC); if (status) { urb->status = status; - complete ((struct completion *) urb->context); + complete(urb->context); } } @@ -1136,7 +1136,7 @@ static int verify_not_halted (int ep, struct urb *urb) dbg ("ep %02x bogus status: %04x != 0", ep, status); return -EINVAL; } - retval = simple_io (urb, 1, 0, 0, __FUNCTION__); + retval = simple_io (urb, 1, 0, 0, __func__); if (retval != 0) return -EINVAL; return 0; @@ -1158,7 +1158,7 @@ static int verify_halted (int ep, struct urb *urb) dbg ("ep %02x bogus status: %04x != 1", ep, status); return -EINVAL; } - retval = simple_io (urb, 1, 0, -EPIPE, __FUNCTION__); + retval = simple_io (urb, 1, 0, -EPIPE, __func__); if (retval != -EPIPE) return -EINVAL; retval = simple_io (urb, 1, 0, -EPIPE, "verify_still_halted"); @@ -1404,7 +1404,7 @@ static struct urb *iso_alloc_urb ( return NULL; maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); - packets = (bytes + maxp - 1) / maxp; + packets = DIV_ROUND_UP(bytes, maxp); urb = usb_alloc_urb (packets, GFP_KERNEL); if (!urb) @@ -1564,7 +1564,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) if (mutex_lock_interruptible(&dev->lock)) return -ERESTARTSYS; - if (intf->dev.power.power_state.event != PM_EVENT_ON) { + /* FIXME: What if a system sleep starts while a test is running? */ + if (!intf->is_active) { mutex_unlock(&dev->lock); return -EHOSTUNREACH; } diff --git a/drivers/usb/mon/Makefile b/drivers/usb/mon/Makefile index 90c59535778..0f76ed5e161 100644 --- a/drivers/usb/mon/Makefile +++ b/drivers/usb/mon/Makefile @@ -1,5 +1,5 @@ # -# Makefile for USB Core files and filesystem +# Makefile for USB monitor # usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o mon_dma.o diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 1774ba5c4c3..49145534e06 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -1026,8 +1026,6 @@ mon_bin_poll(struct file *file, struct poll_table_struct *wait) return mask; } -#if 0 - /* * open and close: just keep track of how many times the device is * mapped, to use the proper memory allocation function. @@ -1063,13 +1061,13 @@ static int mon_bin_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) return 0; } -struct vm_operations_struct mon_bin_vm_ops = { +static struct vm_operations_struct mon_bin_vm_ops = { .open = mon_bin_vma_open, .close = mon_bin_vma_close, .fault = mon_bin_vma_fault, }; -int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) +static int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) { /* don't do anything here: "fault" will set up page table entries */ vma->vm_ops = &mon_bin_vm_ops; @@ -1079,8 +1077,6 @@ int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) return 0; } -#endif /* 0 */ - static const struct file_operations mon_fops_binary = { .owner = THIS_MODULE, .open = mon_bin_open, @@ -1090,6 +1086,7 @@ static const struct file_operations mon_fops_binary = { .poll = mon_bin_poll, .ioctl = mon_bin_ioctl, .release = mon_bin_release, + .mmap = mon_bin_mmap, }; static int mon_bin_wait_event(struct file *file, struct mon_reader_bin *rp) diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index b371ffd39d3..442d8076b20 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c @@ -129,8 +129,7 @@ static void mon_submit_error(struct usb_bus *ubus, struct urb *urb, int error) /* */ -static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb, - int status) +static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb, int status) { unsigned long flags; struct list_head *pos; diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c index f6d1491256c..c7a595cd648 100644 --- a/drivers/usb/mon/mon_stat.c +++ b/drivers/usb/mon/mon_stat.c @@ -59,6 +59,9 @@ static ssize_t mon_stat_read(struct file *file, char __user *buf, static int mon_stat_release(struct inode *inode, struct file *file) { + struct snap *sp = file->private_data; + file->private_data = NULL; + kfree(sp); return 0; } diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index c1e65dfd935..2cffec85ee7 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -20,8 +20,8 @@ menuconfig USB_SERIAL if USB_SERIAL config USB_SERIAL_CONSOLE - bool "USB Serial Console device support (EXPERIMENTAL)" - depends on USB_SERIAL=y && EXPERIMENTAL + bool "USB Serial Console device support" + depends on USB_SERIAL=y ---help--- If you say Y here, it will be possible to use a USB to serial converter port as the system console (the system console is the @@ -44,13 +44,11 @@ config USB_SERIAL_CONSOLE config USB_EZUSB bool "Functions for loading firmware on EZUSB chips" - depends on USB_SERIAL help Say Y here if you need EZUSB device support. config USB_SERIAL_GENERIC bool "USB Generic Serial Driver" - depends on USB_SERIAL help Say Y here if you want to use the generic USB serial driver. Please read <file:Documentation/usb/usb-serial.txt> for more information on @@ -59,8 +57,7 @@ config USB_SERIAL_GENERIC properly. config USB_SERIAL_AIRCABLE - tristate "USB AIRcable Bluetooth Dongle Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB AIRcable Bluetooth Dongle Driver" help Say Y here if you want to use USB AIRcable Bluetooth Dongle. @@ -69,7 +66,6 @@ config USB_SERIAL_AIRCABLE config USB_SERIAL_AIRPRIME tristate "USB AirPrime CDMA Wireless Driver" - depends on USB_SERIAL help Say Y here if you want to use a AirPrime CDMA Wireless PC card. @@ -77,8 +73,7 @@ config USB_SERIAL_AIRPRIME module will be called airprime. config USB_SERIAL_ARK3116 - tristate "USB ARK Micro 3116 USB Serial Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB ARK Micro 3116 USB Serial Driver" help Say Y here if you want to use a ARK Micro 3116 USB to Serial device. @@ -88,7 +83,6 @@ config USB_SERIAL_ARK3116 config USB_SERIAL_BELKIN tristate "USB Belkin and Peracom Single Port Serial Driver" - depends on USB_SERIAL help Say Y here if you want to use a Belkin USB Serial single port adaptor (F5U103 is one of the model numbers) or the Peracom single @@ -99,7 +93,6 @@ config USB_SERIAL_BELKIN config USB_SERIAL_CH341 tristate "USB Winchiphead CH341 Single Port Serial Driver" - depends on USB_SERIAL help Say Y here if you want to use a Winchiphead CH341 single port USB to serial adapter. @@ -109,7 +102,6 @@ config USB_SERIAL_CH341 config USB_SERIAL_WHITEHEAT tristate "USB ConnectTech WhiteHEAT Serial Driver" - depends on USB_SERIAL select USB_EZUSB help Say Y here if you want to use a ConnectTech WhiteHEAT 4 port @@ -120,7 +112,6 @@ config USB_SERIAL_WHITEHEAT config USB_SERIAL_DIGI_ACCELEPORT tristate "USB Digi International AccelePort USB Serial Driver" - depends on USB_SERIAL ---help--- Say Y here if you want to use Digi AccelePort USB 2 or 4 devices, 2 port (plus parallel port) and 4 port USB serial converters. The @@ -135,7 +126,6 @@ config USB_SERIAL_DIGI_ACCELEPORT config USB_SERIAL_CP2101 tristate "USB CP2101 UART Bridge Controller" - depends on USB_SERIAL && EXPERIMENTAL help Say Y here if you want to use a CP2101/CP2102 based USB to RS232 converter. @@ -145,7 +135,6 @@ config USB_SERIAL_CP2101 config USB_SERIAL_CYPRESS_M8 tristate "USB Cypress M8 USB Serial Driver" - depends on USB_SERIAL && EXPERIMENTAL help Say Y here if you want to use a device that contains the Cypress USB to Serial microcontroller, such as the DeLorme Earthmate GPS. @@ -160,7 +149,6 @@ config USB_SERIAL_CYPRESS_M8 config USB_SERIAL_EMPEG tristate "USB Empeg empeg-car Mark I/II Driver" - depends on USB_SERIAL help Say Y here if you want to connect to your Empeg empeg-car Mark I/II mp3 player via USB. The driver uses a single ttyUSB{0,1,2,...} @@ -171,8 +159,7 @@ config USB_SERIAL_EMPEG module will be called empeg. config USB_SERIAL_FTDI_SIO - tristate "USB FTDI Single Port Serial Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB FTDI Single Port Serial Driver" ---help--- Say Y here if you want to use a FTDI SIO single port USB to serial converter device. The implementation I have is called the USC-1000. @@ -186,7 +173,6 @@ config USB_SERIAL_FTDI_SIO config USB_SERIAL_FUNSOFT tristate "USB Fundamental Software Dongle Driver" - depends on USB_SERIAL ---help--- Say Y here if you want to use the Fundamental Software dongle. @@ -195,7 +181,6 @@ config USB_SERIAL_FUNSOFT config USB_SERIAL_VISOR tristate "USB Handspring Visor / Palm m50x / Sony Clie Driver" - depends on USB_SERIAL help Say Y here if you want to connect to your HandSpring Visor, Palm m500 or m505 through its USB docking station. See @@ -207,7 +192,6 @@ config USB_SERIAL_VISOR config USB_SERIAL_IPAQ tristate "USB PocketPC PDA Driver" - depends on USB_SERIAL help Say Y here if you want to connect to your Compaq iPAQ, HP Jornada or any other PDA running Windows CE 3.0 or PocketPC 2002 @@ -218,8 +202,7 @@ config USB_SERIAL_IPAQ module will be called ipaq. config USB_SERIAL_IR - tristate "USB IR Dongle Serial Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB IR Dongle Serial Driver" help Say Y here if you want to enable simple serial support for USB IrDA devices. This is useful if you do not want to use the full IrDA @@ -230,7 +213,6 @@ config USB_SERIAL_IR config USB_SERIAL_EDGEPORT tristate "USB Inside Out Edgeport Serial Driver" - depends on USB_SERIAL ---help--- Say Y here if you want to use any of the following devices from Inside Out Networks (Digi): @@ -256,7 +238,6 @@ config USB_SERIAL_EDGEPORT config USB_SERIAL_EDGEPORT_TI tristate "USB Inside Out Edgeport Serial Driver (TI devices)" - depends on USB_SERIAL help Say Y here if you want to use any of the devices from Inside Out Networks (Digi) that are not supported by the io_edgeport driver. @@ -267,7 +248,6 @@ config USB_SERIAL_EDGEPORT_TI config USB_SERIAL_GARMIN tristate "USB Garmin GPS driver" - depends on USB_SERIAL help Say Y here if you want to connect to your Garmin GPS. Should work with most Garmin GPS devices which have a native USB port. @@ -279,8 +259,7 @@ config USB_SERIAL_GARMIN module will be called garmin_gps. config USB_SERIAL_IPW - tristate "USB IPWireless (3G UMTS TDD) Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB IPWireless (3G UMTS TDD) Driver" help Say Y here if you want to use a IPWireless USB modem such as the ones supplied by Axity3G/Sentech South Africa. @@ -289,8 +268,7 @@ config USB_SERIAL_IPW module will be called ipw. config USB_SERIAL_IUU - tristate "USB Infinity USB Unlimited Phoenix Driver (Experimental)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB Infinity USB Unlimited Phoenix Driver" help Say Y here if you want to use a IUU in phoenix mode and get an extra ttyUSBx device. More information available on @@ -301,7 +279,6 @@ config USB_SERIAL_IUU config USB_SERIAL_KEYSPAN_PDA tristate "USB Keyspan PDA Single Port Serial Driver" - depends on USB_SERIAL select USB_EZUSB help Say Y here if you want to use a Keyspan PDA single port USB to @@ -313,7 +290,6 @@ config USB_SERIAL_KEYSPAN_PDA config USB_SERIAL_KEYSPAN tristate "USB Keyspan USA-xxx Serial Driver" - depends on USB_SERIAL select USB_EZUSB ---help--- Say Y here if you want to use Keyspan USB to serial converter @@ -405,8 +381,7 @@ config USB_SERIAL_KEYSPAN_USA49WLC Say Y here to include firmware for the USA-49WLC converter. config USB_SERIAL_KLSI - tristate "USB KL5KUSB105 (Palmconnect) Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB KL5KUSB105 (Palmconnect) Driver" ---help--- Say Y here if you want to use a KL5KUSB105 - based single port serial adapter. The most widely known -- and currently the only @@ -422,7 +397,6 @@ config USB_SERIAL_KLSI config USB_SERIAL_KOBIL_SCT tristate "USB KOBIL chipcard reader" - depends on USB_SERIAL ---help--- Say Y here if you want to use one of the following KOBIL USB chipcard readers: @@ -440,7 +414,6 @@ config USB_SERIAL_KOBIL_SCT config USB_SERIAL_MCT_U232 tristate "USB MCT Single Port Serial Driver" - depends on USB_SERIAL ---help--- Say Y here if you want to use a USB Serial single port adapter from Magic Control Technology Corp. (U232 is one of the model numbers). @@ -453,7 +426,6 @@ config USB_SERIAL_MCT_U232 config USB_SERIAL_MOS7720 tristate "USB Moschip 7720 Serial Driver" - depends on USB_SERIAL ---help--- Say Y here if you want to use USB Serial single and double port adapters from Moschip Semiconductor Tech. @@ -463,7 +435,6 @@ config USB_SERIAL_MOS7720 config USB_SERIAL_MOS7840 tristate "USB Moschip 7840/7820 USB Serial Driver" - depends on USB_SERIAL ---help--- Say Y here if you want to use a MCS7840 Quad-Serial or MCS7820 Dual-Serial port device from MosChip Semiconductor. @@ -478,14 +449,12 @@ config USB_SERIAL_MOS7840 config USB_SERIAL_NAVMAN tristate "USB Navman GPS device" - depends on USB_SERIAL help To compile this driver as a module, choose M here: the module will be called navman. config USB_SERIAL_PL2303 tristate "USB Prolific 2303 Single Port Serial Driver" - depends on USB_SERIAL help Say Y here if you want to use the PL2303 USB Serial single port adapter from Prolific. @@ -494,8 +463,7 @@ config USB_SERIAL_PL2303 module will be called pl2303. config USB_SERIAL_OTI6858 - tristate "USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge Controller (EXPERIMENTAL)" - depends on USB_SERIAL + tristate "USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge Controller" help Say Y here if you want to use the OTi-6858 single port USB to serial converter device. @@ -503,9 +471,17 @@ config USB_SERIAL_OTI6858 To compile this driver as a module, choose M here: the module will be called oti6858. +config USB_SERIAL_SPCP8X5 + tristate "USB SPCP8x5 USB To Serial Driver" + help + Say Y here if you want to use the spcp8x5 converter chip. This is + commonly found in some Z-Wave USB devices. + + To compile this driver as a module, choose M here: the + module will be called spcp8x5. + config USB_SERIAL_HP4X tristate "USB HP4x Calculators support" - depends on USB_SERIAL help Say Y here if you want to use an Hewlett-Packard 4x Calculator. @@ -513,8 +489,7 @@ config USB_SERIAL_HP4X module will be called hp4x. config USB_SERIAL_SAFE - tristate "USB Safe Serial (Encapsulated) Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB Safe Serial (Encapsulated) Driver" config USB_SERIAL_SAFE_PADDED bool "USB Secure Encapsulated Driver - Padded" @@ -522,7 +497,6 @@ config USB_SERIAL_SAFE_PADDED config USB_SERIAL_SIERRAWIRELESS tristate "USB Sierra Wireless Driver" - depends on USB_SERIAL help Say M here if you want to use a Sierra Wireless device (if using an PC 5220 or AC580 please use the Airprime driver @@ -533,7 +507,6 @@ config USB_SERIAL_SIERRAWIRELESS config USB_SERIAL_TI tristate "USB TI 3410/5052 Serial Driver" - depends on USB_SERIAL help Say Y here if you want to use the TI USB 3410 or 5052 serial devices. @@ -542,8 +515,7 @@ config USB_SERIAL_TI module will be called ti_usb_3410_5052. config USB_SERIAL_CYBERJACK - tristate "USB REINER SCT cyberJack pinpad/e-com chipcard reader (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB REINER SCT cyberJack pinpad/e-com chipcard reader" ---help--- Say Y here if you want to use a cyberJack pinpad/e-com USB chipcard reader. This is an interface to ISO 7816 compatible contact-based @@ -556,7 +528,6 @@ config USB_SERIAL_CYBERJACK config USB_SERIAL_XIRCOM tristate "USB Xircom / Entregra Single Port Serial Driver" - depends on USB_SERIAL select USB_EZUSB help Say Y here if you want to use a Xircom or Entregra single port USB to @@ -568,7 +539,6 @@ config USB_SERIAL_XIRCOM config USB_SERIAL_OPTION tristate "USB driver for GSM and CDMA modems" - depends on USB_SERIAL help Say Y here if you have a GSM or CDMA modem that's connected to USB. @@ -586,8 +556,7 @@ config USB_SERIAL_OPTION it might be accessible via the FTDI_SIO driver. config USB_SERIAL_OMNINET - tristate "USB ZyXEL omni.net LCD Plus Driver (EXPERIMENTAL)" - depends on USB_SERIAL && EXPERIMENTAL + tristate "USB ZyXEL omni.net LCD Plus Driver" help Say Y here if you want to use a ZyXEL omni.net LCD ISDN TA. @@ -596,7 +565,6 @@ config USB_SERIAL_OMNINET config USB_SERIAL_DEBUG tristate "USB Debugging Device" - depends on USB_SERIAL help Say Y here if you have a USB debugging device used to receive debugging data from another machine. The most common of these diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 0db109a54d1..756859510d8 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -30,8 +30,8 @@ obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o -obj-$(CONFIG_USB_SERIAL_IUU) += iuu_phoenix.o obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o +obj-$(CONFIG_USB_SERIAL_IUU) += iuu_phoenix.o obj-$(CONFIG_USB_SERIAL_KEYSPAN) += keyspan.o obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o @@ -46,6 +46,7 @@ obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o +obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 1cd29cd6bd0..a238817762a 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c @@ -210,7 +210,7 @@ static void aircable_send(struct usb_serial_port *port) struct aircable_private *priv = usb_get_serial_port_data(port); unsigned char* buf; u16 *dbuf; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->write_urb_busy) return; @@ -220,7 +220,7 @@ static void aircable_send(struct usb_serial_port *port) buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC); if (!buf) { - err("%s- kzalloc(%d) failed.", __FUNCTION__, + err("%s- kzalloc(%d) failed.", __func__, count + HCI_HEADER_LENGTH); return; } @@ -236,7 +236,7 @@ static void aircable_send(struct usb_serial_port *port) kfree(buf); port->write_urb_busy = 1; - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, count + HCI_HEADER_LENGTH, port->write_urb->transfer_buffer); port->write_urb->transfer_buffer_length = count + HCI_HEADER_LENGTH; @@ -246,7 +246,7 @@ static void aircable_send(struct usb_serial_port *port) if (result) { dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", - __FUNCTION__, result); + __func__, result); port->write_urb_busy = 0; } @@ -275,7 +275,7 @@ static void aircable_read(struct work_struct *work) if (!tty) { schedule_work(&priv->rx_work); - err("%s - No tty available", __FUNCTION__); + err("%s - No tty available", __func__); return ; } @@ -286,7 +286,7 @@ static void aircable_read(struct work_struct *work) tty_prepare_flip_string(tty, &data, count); if (!data){ - err("%s- kzalloc(%d) failed.", __FUNCTION__, count); + err("%s- kzalloc(%d) failed.", __func__, count); return; } @@ -332,7 +332,7 @@ static int aircable_attach (struct usb_serial *serial) priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); if (!priv){ - err("%s- kmalloc(%Zd) failed.", __FUNCTION__, + err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct aircable_private)); return -ENOMEM; } @@ -366,7 +366,7 @@ static void aircable_shutdown(struct usb_serial *serial) struct usb_serial_port *port = serial->port[0]; struct aircable_private *priv = usb_get_serial_port_data(port); - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (priv) { serial_buf_free(priv->tx_buf); @@ -388,12 +388,12 @@ static int aircable_write(struct usb_serial_port *port, struct aircable_private *priv = usb_get_serial_port_data(port); int temp; - dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count); + dbg("%s - port %d, %d bytes", __func__, port->number, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, source); + usb_serial_debug_data(debug, &port->dev, __func__, count, source); if (!count){ - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return count; } @@ -414,7 +414,7 @@ static void aircable_write_bulk_callback(struct urb *urb) int status = urb->status; int result; - dbg("%s - urb status: %d", __FUNCTION__ , status); + dbg("%s - urb status: %d", __func__ , status); /* This has been taken from cypress_m8.c cypress_write_int_callback */ switch (status) { @@ -426,21 +426,21 @@ static void aircable_write_bulk_callback(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); port->write_urb_busy = 0; return; default: /* error in the urb, so we have to resubmit it */ - dbg("%s - Overflow in write", __FUNCTION__); + dbg("%s - Overflow in write", __func__); dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); port->write_urb->transfer_buffer_length = 1; port->write_urb->dev = port->serial->dev; result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", - __FUNCTION__, result); + __func__, result); else return; } @@ -460,17 +460,17 @@ static void aircable_read_bulk_callback(struct urb *urb) unsigned char *temp; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { - dbg("%s - urb status = %d", __FUNCTION__, status); + dbg("%s - urb status = %d", __func__, status); if (!port->open_count) { - dbg("%s - port is closed, exiting.", __FUNCTION__); + dbg("%s - port is closed, exiting.", __func__); return; } if (status == -EPROTO) { dbg("%s - caught -EPROTO, resubmitting the urb", - __FUNCTION__); + __func__); usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), @@ -482,14 +482,14 @@ static void aircable_read_bulk_callback(struct urb *urb) if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", - __FUNCTION__, result); + __func__, result); return; } - dbg("%s - unable to handle the error, exiting.", __FUNCTION__); + dbg("%s - unable to handle the error, exiting.", __func__); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length,urb->transfer_buffer); tty = port->tty; @@ -538,7 +538,7 @@ static void aircable_read_bulk_callback(struct urb *urb) if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", - __FUNCTION__, result); + __func__, result); } return; @@ -550,7 +550,7 @@ static void aircable_throttle(struct usb_serial_port *port) struct aircable_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->rx_lock, flags); priv->rx_flags |= THROTTLED; @@ -564,7 +564,7 @@ static void aircable_unthrottle(struct usb_serial_port *port) int actually_throttled; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->rx_lock, flags); actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index f156dba0300..725b6b94c27 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c @@ -53,7 +53,7 @@ static int airprime_send_setup(struct usb_serial_port *port) struct usb_serial *serial = port->serial; struct airprime_private *priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (port->number != 0) return 0; @@ -83,14 +83,14 @@ static void airprime_read_bulk_callback(struct urb *urb) int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); tty = port->tty; if (tty && urb->actual_length) { @@ -101,7 +101,7 @@ static void airprime_read_bulk_callback(struct urb *urb) result = usb_submit_urb (urb, GFP_ATOMIC); if (result) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", - __FUNCTION__, result); + __func__, result); return; } @@ -112,14 +112,14 @@ static void airprime_write_bulk_callback(struct urb *urb) int status = urb->status; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* free up the transfer buffer, as usb_free_urb() does not do this */ kfree (urb->transfer_buffer); if (status) dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); spin_lock_irqsave(&priv->lock, flags); --priv->outstanding_urbs; spin_unlock_irqrestore(&priv->lock, flags); @@ -136,7 +136,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) int i; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* initialize our private data structure if it isn't already created */ if (!priv) { @@ -157,7 +157,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) { dev_err(&port->dev, "%s - out of memory.\n", - __FUNCTION__); + __func__); result = -ENOMEM; goto errout; } @@ -165,7 +165,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) if (!urb) { kfree(buffer); dev_err(&port->dev, "%s - no more urbs?\n", - __FUNCTION__); + __func__); result = -ENOMEM; goto errout; } @@ -180,7 +180,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) kfree(buffer); dev_err(&port->dev, "%s - failed submitting read urb %d for port %d, error %d\n", - __FUNCTION__, i, port->number, result); + __func__, i, port->number, result); goto errout; } /* remember this urb so we can kill it when the port is closed */ @@ -212,7 +212,7 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp) struct airprime_private *priv = usb_get_serial_port_data(port); int i; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); priv->rts_state = 0; priv->dtr_state = 0; @@ -242,12 +242,12 @@ static int airprime_write(struct usb_serial_port *port, unsigned char *buffer; unsigned long flags; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); if (priv->outstanding_urbs > NUM_WRITE_URBS) { spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - write limit hit\n", __FUNCTION__); + dbg("%s - write limit hit\n", __func__); return 0; } spin_unlock_irqrestore(&priv->lock, flags); @@ -264,7 +264,7 @@ static int airprime_write(struct usb_serial_port *port, } memcpy (buffer, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, @@ -277,7 +277,7 @@ static int airprime_write(struct usb_serial_port *port, if (status) { dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", - __FUNCTION__, status); + __func__, status); count = status; kfree (buffer); } else { @@ -306,9 +306,6 @@ static struct usb_serial_driver airprime_device = { }, .usb_driver = &airprime_driver, .id_table = id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .open = airprime_open, .close = airprime_close, .write = airprime_write, @@ -331,7 +328,7 @@ static int __init airprime_init(void) static void __exit airprime_exit(void) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); usb_deregister(&airprime_driver); usb_serial_deregister(&airprime_device); diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index fe2bfd67ba8..599ab2e548a 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -173,7 +173,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, config = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { @@ -192,6 +192,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, buf = kmalloc(1, GFP_KERNEL); if (!buf) { dbg("error kmalloc"); + *port->tty->termios = *old_termios; return; } @@ -323,7 +324,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp) char *buf; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); buf = kmalloc(1, GFP_KERNEL); if (!buf) { @@ -395,7 +396,7 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, return -EFAULT; return 0; default: - dbg("%s cmd 0x%04x not supported", __FUNCTION__, cmd); + dbg("%s cmd 0x%04x not supported", __func__, cmd); break; } @@ -447,9 +448,6 @@ static struct usb_serial_driver ark3116_device = { }, .id_table = id_table, .usb_driver = &ark3116_driver, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .attach = ark3116_attach, .set_termios = ark3116_set_termios, diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index df0a2b3b029..0a322fc53d6 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -128,9 +128,6 @@ static struct usb_serial_driver belkin_device = { .description = "Belkin / Peracom / GoHubs USB Serial Adapter", .usb_driver = &belkin_driver, .id_table = id_table_combined, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = belkin_sa_open, .close = belkin_sa_close, @@ -198,7 +195,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial) struct belkin_sa_private *priv; int i; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { @@ -213,7 +210,7 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) { int retval = 0; - dbg("%s port %d", __FUNCTION__, port->number); + dbg("%s port %d", __func__, port->number); /*Start reading from the device*/ /* TODO: Look at possibility of submitting multiple URBs to device to @@ -240,7 +237,7 @@ exit: static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) { - dbg("%s port %d", __FUNCTION__, port->number); + dbg("%s port %d", __func__, port->number); /* shutdown our bulk reads and writes */ usb_kill_urb(port->write_urb); @@ -251,7 +248,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) static void belkin_sa_read_int_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct belkin_sa_private *priv; unsigned char *data = urb->transfer_buffer; int retval; @@ -267,15 +264,15 @@ static void belkin_sa_read_int_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); /* Handle known interrupt data */ /* ignore data[0] and data[1] */ @@ -334,7 +331,7 @@ exit: retval = usb_submit_urb (urb, GFP_ATOMIC); if (retval) err ("%s - usb_submit_urb failed with result %d", - __FUNCTION__, retval); + __func__, retval); } static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) @@ -481,7 +478,7 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file) unsigned long control_state; unsigned long flags; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); control_state = priv->control_state; @@ -502,7 +499,7 @@ static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, int rts = 0; int dtr = 0; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); control_state = priv->control_state; diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 42582d49b69..d947d955bce 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -318,9 +318,6 @@ static struct usb_serial_driver ch341_device = { }, .id_table = id_table, .usb_driver = &ch341_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = ch341_open, .set_termios = ch341_set_termios, diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 66ce30c1b75..201184c3fb8 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -67,7 +67,7 @@ static int usb_console_setup(struct console *co, char *options) struct tty_struct *tty = NULL; struct ktermios *termios = NULL, dummy; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); if (options) { baud = simple_strtoul(options, NULL, 10); @@ -225,10 +225,10 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun if (count == 0) return; - dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); + dbg("%s - port %d, %d byte(s)", __func__, port->number, count); if (!port->open_count) { - dbg ("%s - port not opened", __FUNCTION__); + dbg ("%s - port not opened", __func__); return; } @@ -248,7 +248,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun retval = serial->type->write(port, buf, i); else retval = usb_serial_generic_write(port, buf, i); - dbg("%s - return value : %d", __FUNCTION__, retval); + dbg("%s - return value : %d", __func__, retval); if (lf) { /* append CR after LF */ unsigned char cr = 13; @@ -256,7 +256,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun retval = serial->type->write(port, &cr, 1); else retval = usb_serial_generic_write(port, &cr, 1); - dbg("%s - return value : %d", __FUNCTION__, retval); + dbg("%s - return value : %d", __func__, retval); } buf += i; count -= i; diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 324bb61d68f..dc0ea08ed23 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -53,9 +53,11 @@ static void cp2101_shutdown(struct usb_serial*); static int debug; static struct usb_device_id id_table [] = { + { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ { USB_DEVICE(0x0FCF, 0x1004) }, /* Dynastream ANT2USB */ + { USB_DEVICE(0x0FCF, 0x1006) }, /* Dynastream ANT development board */ { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ @@ -71,6 +73,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ + { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ @@ -106,9 +109,6 @@ static struct usb_serial_driver cp2101_device = { }, .usb_driver = &cp2101_driver, .id_table = id_table, - .num_interrupt_in = 0, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .open = cp2101_open, .close = cp2101_close, @@ -193,7 +193,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); if (!buf) { - dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); + dev_err(&port->dev, "%s - out of memory.\n", __func__); return -ENOMEM; } @@ -214,7 +214,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, if (result != size) { dev_err(&port->dev, "%s - Unable to send config request, " "request=0x%x size=%d result=%d\n", - __FUNCTION__, request, size, result); + __func__, request, size, result); return -EPROTO; } @@ -240,7 +240,7 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); if (!buf) { dev_err(&port->dev, "%s - out of memory.\n", - __FUNCTION__); + __func__); return -ENOMEM; } @@ -265,7 +265,7 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, if ((size > 2 && result != size) || result < 0) { dev_err(&port->dev, "%s - Unable to send request, " "request=0x%x size=%d result=%d\n", - __FUNCTION__, request, size, result); + __func__, request, size, result); return -EPROTO; } @@ -293,11 +293,11 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) struct usb_serial *serial = port->serial; int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (cp2101_set_config_single(port, CP2101_UART, UART_ENABLE)) { dev_err(&port->dev, "%s - Unable to enable UART\n", - __FUNCTION__); + __func__); return -EPROTO; } @@ -312,7 +312,7 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { dev_err(&port->dev, "%s - failed resubmitting read urb, " - "error %d\n", __FUNCTION__, result); + "error %d\n", __func__, result); return result; } @@ -329,7 +329,7 @@ static void cp2101_cleanup (struct usb_serial_port *port) { struct usb_serial *serial = port->serial; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (serial->dev) { /* shutdown any bulk reads that might be going on */ @@ -342,10 +342,10 @@ static void cp2101_cleanup (struct usb_serial_port *port) static void cp2101_close (struct usb_serial_port *port, struct file * filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* shutdown our urbs */ - dbg("%s - shutting down urbs", __FUNCTION__); + dbg("%s - shutting down urbs", __func__); usb_kill_urb(port->write_urb); usb_kill_urb(port->read_urb); @@ -367,10 +367,10 @@ static void cp2101_get_termios (struct usb_serial_port *port) int baud; int bits; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->tty || !port->tty->termios) { - dbg("%s - no tty structures", __FUNCTION__); + dbg("%s - no tty structures", __func__); return; } @@ -379,7 +379,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) if (baud) baud = BAUD_RATE_GEN_FREQ / baud; - dbg("%s - baud rate = %d", __FUNCTION__, baud); + dbg("%s - baud rate = %d", __func__, baud); tty_encode_baud_rate(port->tty, baud, baud); cflag = port->tty->termios->c_cflag; @@ -388,24 +388,24 @@ static void cp2101_get_termios (struct usb_serial_port *port) cflag &= ~CSIZE; switch(bits & BITS_DATA_MASK) { case BITS_DATA_5: - dbg("%s - data bits = 5", __FUNCTION__); + dbg("%s - data bits = 5", __func__); cflag |= CS5; break; case BITS_DATA_6: - dbg("%s - data bits = 6", __FUNCTION__); + dbg("%s - data bits = 6", __func__); cflag |= CS6; break; case BITS_DATA_7: - dbg("%s - data bits = 7", __FUNCTION__); + dbg("%s - data bits = 7", __func__); cflag |= CS7; break; case BITS_DATA_8: - dbg("%s - data bits = 8", __FUNCTION__); + dbg("%s - data bits = 8", __func__); cflag |= CS8; break; case BITS_DATA_9: dbg("%s - data bits = 9 (not supported, " - "using 8 data bits)", __FUNCTION__); + "using 8 data bits)", __func__); cflag |= CS8; bits &= ~BITS_DATA_MASK; bits |= BITS_DATA_8; @@ -413,7 +413,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) break; default: dbg("%s - Unknown number of data bits, " - "using 8", __FUNCTION__); + "using 8", __func__); cflag |= CS8; bits &= ~BITS_DATA_MASK; bits |= BITS_DATA_8; @@ -423,35 +423,35 @@ static void cp2101_get_termios (struct usb_serial_port *port) switch(bits & BITS_PARITY_MASK) { case BITS_PARITY_NONE: - dbg("%s - parity = NONE", __FUNCTION__); + dbg("%s - parity = NONE", __func__); cflag &= ~PARENB; break; case BITS_PARITY_ODD: - dbg("%s - parity = ODD", __FUNCTION__); + dbg("%s - parity = ODD", __func__); cflag |= (PARENB|PARODD); break; case BITS_PARITY_EVEN: - dbg("%s - parity = EVEN", __FUNCTION__); + dbg("%s - parity = EVEN", __func__); cflag &= ~PARODD; cflag |= PARENB; break; case BITS_PARITY_MARK: dbg("%s - parity = MARK (not supported, " - "disabling parity)", __FUNCTION__); + "disabling parity)", __func__); cflag &= ~PARENB; bits &= ~BITS_PARITY_MASK; cp2101_set_config(port, CP2101_BITS, &bits, 2); break; case BITS_PARITY_SPACE: dbg("%s - parity = SPACE (not supported, " - "disabling parity)", __FUNCTION__); + "disabling parity)", __func__); cflag &= ~PARENB; bits &= ~BITS_PARITY_MASK; cp2101_set_config(port, CP2101_BITS, &bits, 2); break; default: dbg("%s - Unknown parity mode, " - "disabling parity", __FUNCTION__); + "disabling parity", __func__); cflag &= ~PARENB; bits &= ~BITS_PARITY_MASK; cp2101_set_config(port, CP2101_BITS, &bits, 2); @@ -461,21 +461,21 @@ static void cp2101_get_termios (struct usb_serial_port *port) cflag &= ~CSTOPB; switch(bits & BITS_STOP_MASK) { case BITS_STOP_1: - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); break; case BITS_STOP_1_5: dbg("%s - stop bits = 1.5 (not supported, " - "using 1 stop bit)", __FUNCTION__); + "using 1 stop bit)", __func__); bits &= ~BITS_STOP_MASK; cp2101_set_config(port, CP2101_BITS, &bits, 2); break; case BITS_STOP_2: - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); cflag |= CSTOPB; break; default: dbg("%s - Unknown number of stop bits, " - "using 1 stop bit", __FUNCTION__); + "using 1 stop bit", __func__); bits &= ~BITS_STOP_MASK; cp2101_set_config(port, CP2101_BITS, &bits, 2); break; @@ -483,10 +483,10 @@ static void cp2101_get_termios (struct usb_serial_port *port) cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); if (modem_ctl[0] & 0x0008) { - dbg("%s - flow control = CRTSCTS", __FUNCTION__); + dbg("%s - flow control = CRTSCTS", __func__); cflag |= CRTSCTS; } else { - dbg("%s - flow control = NONE", __FUNCTION__); + dbg("%s - flow control = NONE", __func__); cflag &= ~CRTSCTS; } @@ -500,10 +500,10 @@ static void cp2101_set_termios (struct usb_serial_port *port, int baud=0, bits; unsigned int modem_ctl[4]; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->tty || !port->tty->termios) { - dbg("%s - no tty structures", __FUNCTION__); + dbg("%s - no tty structures", __func__); return; } port->tty->termios->c_cflag &= ~CMSPAR; @@ -542,7 +542,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, } if (baud) { - dbg("%s - Setting baud rate to %d baud", __FUNCTION__, + dbg("%s - Setting baud rate to %d baud", __func__, baud); if (cp2101_set_config_single(port, CP2101_BAUDRATE, (BAUD_RATE_GEN_FREQ / baud))) { @@ -562,23 +562,23 @@ static void cp2101_set_termios (struct usb_serial_port *port, switch (cflag & CSIZE) { case CS5: bits |= BITS_DATA_5; - dbg("%s - data bits = 5", __FUNCTION__); + dbg("%s - data bits = 5", __func__); break; case CS6: bits |= BITS_DATA_6; - dbg("%s - data bits = 6", __FUNCTION__); + dbg("%s - data bits = 6", __func__); break; case CS7: bits |= BITS_DATA_7; - dbg("%s - data bits = 7", __FUNCTION__); + dbg("%s - data bits = 7", __func__); break; case CS8: bits |= BITS_DATA_8; - dbg("%s - data bits = 8", __FUNCTION__); + dbg("%s - data bits = 8", __func__); break; /*case CS9: bits |= BITS_DATA_9; - dbg("%s - data bits = 9", __FUNCTION__); + dbg("%s - data bits = 9", __func__); break;*/ default: dev_err(&port->dev, "cp2101 driver does not " @@ -598,10 +598,10 @@ static void cp2101_set_termios (struct usb_serial_port *port, if (cflag & PARENB) { if (cflag & PARODD) { bits |= BITS_PARITY_ODD; - dbg("%s - parity = ODD", __FUNCTION__); + dbg("%s - parity = ODD", __func__); } else { bits |= BITS_PARITY_EVEN; - dbg("%s - parity = EVEN", __FUNCTION__); + dbg("%s - parity = EVEN", __func__); } } if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) @@ -614,10 +614,10 @@ static void cp2101_set_termios (struct usb_serial_port *port, bits &= ~BITS_STOP_MASK; if (cflag & CSTOPB) { bits |= BITS_STOP_2; - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); } else { bits |= BITS_STOP_1; - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); } if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) dev_err(&port->dev, "Number of stop bits requested " @@ -627,23 +627,23 @@ static void cp2101_set_termios (struct usb_serial_port *port, if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", - __FUNCTION__, modem_ctl[0], modem_ctl[1], + __func__, modem_ctl[0], modem_ctl[1], modem_ctl[2], modem_ctl[3]); if (cflag & CRTSCTS) { modem_ctl[0] &= ~0x7B; modem_ctl[0] |= 0x09; modem_ctl[1] = 0x80; - dbg("%s - flow control = CRTSCTS", __FUNCTION__); + dbg("%s - flow control = CRTSCTS", __func__); } else { modem_ctl[0] &= ~0x7B; modem_ctl[0] |= 0x01; modem_ctl[1] |= 0x40; - dbg("%s - flow control = NONE", __FUNCTION__); + dbg("%s - flow control = NONE", __func__); } dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", - __FUNCTION__, modem_ctl[0], modem_ctl[1], + __func__, modem_ctl[0], modem_ctl[1], modem_ctl[2], modem_ctl[3]); cp2101_set_config(port, CP2101_MODEMCTL, modem_ctl, 16); } @@ -655,7 +655,7 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, { int control = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (set & TIOCM_RTS) { control |= CONTROL_RTS; @@ -674,7 +674,7 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, control |= CONTROL_WRITE_DTR; } - dbg("%s - control = 0x%.4x", __FUNCTION__, control); + dbg("%s - control = 0x%.4x", __func__, control); return cp2101_set_config(port, CP2101_CONTROL, &control, 2); @@ -684,7 +684,7 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) { int control, result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); cp2101_get_config(port, CP2101_CONTROL, &control, 1); @@ -695,7 +695,7 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) |((control & CONTROL_RING)? TIOCM_RI : 0) |((control & CONTROL_DCD) ? TIOCM_CD : 0); - dbg("%s - control = 0x%.2x", __FUNCTION__, control); + dbg("%s - control = 0x%.2x", __func__, control); return result; } @@ -704,12 +704,12 @@ static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) { int state; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (break_state == 0) state = BREAK_OFF; else state = BREAK_ON; - dbg("%s - turning break %s", __FUNCTION__, + dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on"); cp2101_set_config(port, CP2101_BREAK, &state, 2); } @@ -725,7 +725,7 @@ static void cp2101_shutdown (struct usb_serial *serial) { int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 8d9b045aa7e..c164e2cf275 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -90,9 +90,6 @@ static struct usb_serial_driver cyberjack_device = { .description = "Reiner SCT Cyberjack USB card reader", .usb_driver = &cyberjack_driver, .id_table = id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .attach = cyberjack_startup, .shutdown = cyberjack_shutdown, @@ -119,7 +116,7 @@ static int cyberjack_startup (struct usb_serial *serial) struct cyberjack_private *priv; int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* allocate the private data structure */ priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); @@ -142,7 +139,7 @@ static int cyberjack_startup (struct usb_serial *serial) GFP_KERNEL); if (result) err(" usb_submit_urb(read int) failed"); - dbg("%s - usb_submit_urb(int urb)", __FUNCTION__); + dbg("%s - usb_submit_urb(int urb)", __func__); } return( 0 ); @@ -152,9 +149,9 @@ static void cyberjack_shutdown (struct usb_serial *serial) { int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) { usb_kill_urb(serial->port[i]->interrupt_in_urb); /* My special items, the standard routines free my urbs */ kfree(usb_get_serial_port_data(serial->port[i])); @@ -168,9 +165,9 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) unsigned long flags; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); - dbg("%s - usb_clear_halt", __FUNCTION__ ); + dbg("%s - usb_clear_halt", __func__ ); usb_clear_halt(port->serial->dev, port->write_urb->pipe); /* force low_latency on so that our tty_push actually forces @@ -191,7 +188,7 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) static void cyberjack_close (struct usb_serial_port *port, struct file *filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->serial->dev) { /* shutdown any bulk reads that might be going on */ @@ -208,17 +205,17 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b int result; int wrexpected; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); - return (0); + dbg("%s - write request of 0 bytes", __func__); + return 0; } spin_lock_bh(&port->lock); if (port->write_urb_busy) { spin_unlock_bh(&port->lock); - dbg("%s - already writing", __FUNCTION__); + dbg("%s - already writing", __func__); return 0; } port->write_urb_busy = 1; @@ -226,24 +223,24 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b spin_lock_irqsave(&priv->lock, flags); - if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) { + if( (count+priv->wrfilled) > sizeof(priv->wrbuf) ) { /* To much data for buffer. Reset buffer. */ - priv->wrfilled=0; - spin_unlock_irqrestore(&priv->lock, flags); + priv->wrfilled = 0; port->write_urb_busy = 0; - return (0); + spin_unlock_irqrestore(&priv->lock, flags); + return 0; } /* Copy data */ memcpy (priv->wrbuf+priv->wrfilled, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, + usb_serial_debug_data(debug, &port->dev, __func__, count, priv->wrbuf+priv->wrfilled); priv->wrfilled += count; if( priv->wrfilled >= 3 ) { wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; - dbg("%s - expected data: %d", __FUNCTION__, wrexpected); + dbg("%s - expected data: %d", __func__, wrexpected); } else { wrexpected = sizeof(priv->wrbuf); } @@ -252,7 +249,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b /* We have enough data to begin transmission */ int length; - dbg("%s - transmitting data (frame 1)", __FUNCTION__); + dbg("%s - transmitting data (frame 1)", __func__); length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected; memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length ); @@ -270,23 +267,23 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b /* send the data out the bulk port */ result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); /* Throw away data. No better idea what to do with it. */ - priv->wrfilled=0; - priv->wrsent=0; + priv->wrfilled = 0; + priv->wrsent = 0; spin_unlock_irqrestore(&priv->lock, flags); port->write_urb_busy = 0; return 0; } - dbg("%s - priv->wrsent=%d", __FUNCTION__,priv->wrsent); - dbg("%s - priv->wrfilled=%d", __FUNCTION__,priv->wrfilled); + dbg("%s - priv->wrsent=%d", __func__,priv->wrsent); + dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled); if( priv->wrsent>=priv->wrfilled ) { - dbg("%s - buffer cleaned", __FUNCTION__); + dbg("%s - buffer cleaned", __func__); memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); - priv->wrfilled=0; - priv->wrsent=0; + priv->wrfilled = 0; + priv->wrsent = 0; } } @@ -297,27 +294,28 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b static int cyberjack_write_room( struct usb_serial_port *port ) { + /* FIXME: .... */ return CYBERJACK_LOCAL_BUF_SIZE; } static void cyberjack_read_int_callback( struct urb *urb ) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* the urb might have been killed. */ if (status) return; - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); /* React only to interrupts signaling a bulk_in transfer */ - if( (urb->actual_length==4) && (data[0]==0x01) ) { + if( (urb->actual_length == 4) && (data[0] == 0x01) ) { short old_rdtodo; /* This is a announcement of coming bulk_ins. */ @@ -336,7 +334,7 @@ static void cyberjack_read_int_callback( struct urb *urb ) /* "+=" is probably more fault tollerant than "=" */ priv->rdtodo += size; - dbg("%s - rdtodo: %d", __FUNCTION__, priv->rdtodo); + dbg("%s - rdtodo: %d", __func__, priv->rdtodo); spin_unlock(&priv->lock); @@ -344,8 +342,8 @@ static void cyberjack_read_int_callback( struct urb *urb ) port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if( result ) - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); - dbg("%s - usb_submit_urb(read urb)", __FUNCTION__); + err("%s - failed resubmitting read urb, error %d", __func__, result); + dbg("%s - usb_submit_urb(read urb)", __func__); } } @@ -354,12 +352,12 @@ resubmit: result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result) err(" usb_submit_urb(read int) failed"); - dbg("%s - usb_submit_urb(int urb)", __FUNCTION__); + dbg("%s - usb_submit_urb(int urb)", __func__); } static void cyberjack_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -367,18 +365,18 @@ static void cyberjack_read_bulk_callback (struct urb *urb) int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } tty = port->tty; if (!tty) { - dbg("%s - ignoring since device not open\n", __FUNCTION__); + dbg("%s - ignoring since device not open\n", __func__); return; } if (urb->actual_length) { @@ -397,30 +395,30 @@ static void cyberjack_read_bulk_callback (struct urb *urb) spin_unlock(&priv->lock); - dbg("%s - rdtodo: %d", __FUNCTION__, todo); + dbg("%s - rdtodo: %d", __func__, todo); /* Continue to read if we have still urbs to do. */ if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) { port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); - dbg("%s - usb_submit_urb(read urb)", __FUNCTION__); + err("%s - failed resubmitting read urb, error %d", __func__, result); + dbg("%s - usb_submit_urb(read urb)", __func__); } } static void cyberjack_write_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); port->write_urb_busy = 0; if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -430,7 +428,7 @@ static void cyberjack_write_bulk_callback (struct urb *urb) if( priv->wrfilled ) { int length, blksize, result; - dbg("%s - transmitting data (frame n)", __FUNCTION__); + dbg("%s - transmitting data (frame n)", __func__); length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? port->bulk_out_size : (priv->wrfilled - priv->wrsent); @@ -451,23 +449,23 @@ static void cyberjack_write_bulk_callback (struct urb *urb) /* send the data out the bulk port */ result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); /* Throw away data. No better idea what to do with it. */ - priv->wrfilled=0; - priv->wrsent=0; + priv->wrfilled = 0; + priv->wrsent = 0; goto exit; } - dbg("%s - priv->wrsent=%d", __FUNCTION__,priv->wrsent); - dbg("%s - priv->wrfilled=%d", __FUNCTION__,priv->wrfilled); + dbg("%s - priv->wrsent=%d", __func__,priv->wrsent); + dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled); blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) { - dbg("%s - buffer cleaned", __FUNCTION__); + dbg("%s - buffer cleaned", __func__); memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); - priv->wrfilled=0; - priv->wrsent=0; + priv->wrfilled = 0; + priv->wrsent = 0; } } diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 779d07851a4..32121794808 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -122,6 +122,11 @@ static struct usb_driver cypress_driver = { .no_dynamic_id = 1, }; +enum packet_format { + packet_format_1, /* b0:status, b1:payload count */ + packet_format_2 /* b0[7:3]:status, b0[2:0]:payload count */ +}; + struct cypress_private { spinlock_t lock; /* private lock */ int chiptype; /* identifier of device, for quirks/etc */ @@ -139,8 +144,9 @@ struct cypress_private { __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */ __u8 current_config; /* stores the current configuration byte */ __u8 rx_flags; /* throttling - used from whiteheat/ftdi_sio */ + enum packet_format pkt_fmt; /* format to use for packet send / receive */ + int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */ int baud_rate; /* stores current baud rate in integer form */ - int cbr_mask; /* stores current baud rate in masked form */ int isthrottled; /* if throttled, discard reads */ wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */ char prev_status, diff_status; /* used for TIOCMIWAIT */ @@ -176,9 +182,6 @@ static void cypress_unthrottle (struct usb_serial_port *port); static void cypress_set_dead (struct usb_serial_port *port); static void cypress_read_int_callback (struct urb *urb); static void cypress_write_int_callback (struct urb *urb); -/* baud helper functions */ -static int mask_to_rate (unsigned mask); -static unsigned rate_to_mask (int rate); /* write buffer functions */ static struct cypress_buf *cypress_buf_alloc(unsigned int size); static void cypress_buf_free(struct cypress_buf *cb); @@ -197,10 +200,6 @@ static struct usb_serial_driver cypress_earthmate_device = { .description = "DeLorme Earthmate USB", .usb_driver = &cypress_driver, .id_table = id_table_earthmate, - .num_interrupt_in = 1, - .num_interrupt_out = 1, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .attach = cypress_earthmate_startup, .shutdown = cypress_shutdown, @@ -227,10 +226,6 @@ static struct usb_serial_driver cypress_hidcom_device = { .description = "HID->COM RS232 Adapter", .usb_driver = &cypress_driver, .id_table = id_table_cyphidcomrs232, - .num_interrupt_in = 1, - .num_interrupt_out = 1, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .attach = cypress_hidcom_startup, .shutdown = cypress_shutdown, @@ -257,10 +252,6 @@ static struct usb_serial_driver cypress_ca42v2_device = { .description = "Nokia CA-42 V2 Adapter", .usb_driver = &cypress_driver, .id_table = id_table_nokiaca42v2, - .num_interrupt_in = 1, - .num_interrupt_out = 1, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .attach = cypress_ca42v2_startup, .shutdown = cypress_shutdown, @@ -284,16 +275,62 @@ static struct usb_serial_driver cypress_ca42v2_device = { *****************************************************************************/ +static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate) +{ + struct cypress_private *priv; + priv = usb_get_serial_port_data(port); + + /* + * The general purpose firmware for the Cypress M8 allows for + * a maximum speed of 57600bps (I have no idea whether DeLorme + * chose to use the general purpose firmware or not), if you + * need to modify this speed setting for your own project + * please add your own chiptype and modify the code likewise. + * The Cypress HID->COM device will work successfully up to + * 115200bps (but the actual throughput is around 3kBps). + */ + if (port->serial->dev->speed == USB_SPEED_LOW) { + /* + * Mike Isely <isely@pobox.com> 2-Feb-2008: The + * Cypress app note that describes this mechanism + * states the the low-speed part can't handle more + * than 800 bytes/sec, in which case 4800 baud is the + * safest speed for a part like that. + */ + if (new_rate > 4800) { + dbg("%s - failed setting baud rate, device incapable " + "speed %d", __func__, new_rate); + return -1; + } + } + switch (priv->chiptype) { + case CT_EARTHMATE: + if (new_rate <= 600) { + /* 300 and 600 baud rates are supported under + * the generic firmware, but are not used with + * NMEA and SiRF protocols */ + dbg("%s - failed setting baud rate, unsupported speed " + "of %d on Earthmate GPS", __func__, new_rate); + return -1; + } + break; + default: + break; + } + return new_rate; +} + + /* This function can either set or retrieve the current serial line settings */ -static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits, +static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits, int parity_enable, int parity_type, int reset, int cypress_request_type) { int new_baudrate = 0, retval = 0, tries = 0; struct cypress_private *priv; - __u8 feature_buffer[8]; + __u8 feature_buffer[5]; unsigned long flags; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); priv = usb_get_serial_port_data(port); @@ -302,58 +339,23 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m switch(cypress_request_type) { case CYPRESS_SET_CONFIG: - - /* - * The general purpose firmware for the Cypress M8 allows for a maximum speed - * of 57600bps (I have no idea whether DeLorme chose to use the general purpose - * firmware or not), if you need to modify this speed setting for your own - * project please add your own chiptype and modify the code likewise. The - * Cypress HID->COM device will work successfully up to 115200bps (but the - * actual throughput is around 3kBps). - */ - if (baud_mask != priv->cbr_mask) { - dbg("%s - baud rate is changing", __FUNCTION__); - if ( priv->chiptype == CT_EARTHMATE ) { - /* 300 and 600 baud rates are supported under the generic firmware, - * but are not used with NMEA and SiRF protocols */ - - if ( (baud_mask == B300) || (baud_mask == B600) ) { - err("%s - failed setting baud rate, unsupported speed", - __FUNCTION__); - new_baudrate = priv->baud_rate; - } else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) { - err("%s - failed setting baud rate, unsupported speed", - __FUNCTION__); - new_baudrate = priv->baud_rate; - } - } else if (priv->chiptype == CT_CYPHIDCOM) { - if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) { - err("%s - failed setting baud rate, unsupported speed", - __FUNCTION__); - new_baudrate = priv->baud_rate; - } - } else if (priv->chiptype == CT_CA42V2) { - if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) { - err("%s - failed setting baud rate, unsupported speed", - __FUNCTION__); - new_baudrate = priv->baud_rate; - } - } else if (priv->chiptype == CT_GENERIC) { - if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) { - err("%s - failed setting baud rate, unsupported speed", - __FUNCTION__); - new_baudrate = priv->baud_rate; - } - } else { - info("%s - please define your chiptype", __FUNCTION__); - new_baudrate = priv->baud_rate; - } - } else { /* baud rate not changing, keep the old */ + new_baudrate = priv->baud_rate; + /* 0 means 'Hang up' so doesn't change the true bit rate */ + if (baud_rate == 0) new_baudrate = priv->baud_rate; + /* Change of speed ? */ + else if (baud_rate != priv->baud_rate) { + dbg("%s - baud rate is changing", __func__); + retval = analyze_baud_rate(port, baud_rate); + if (retval >= 0) { + new_baudrate = retval; + dbg("%s - New baud rate set to %d", + __func__, new_baudrate); + } } - dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate); + dbg("%s - baud rate is being sent as %d", __func__, new_baudrate); - memset(feature_buffer, 0, 8); + memset(feature_buffer, 0, sizeof(feature_buffer)); /* fill the feature_buffer with new configuration */ *((u_int32_t *)feature_buffer) = new_baudrate; @@ -365,48 +367,65 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m /* 1 bit gap */ feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ - dbg("%s - device is being sent this feature report:", __FUNCTION__); - dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1], + dbg("%s - device is being sent this feature report:", __func__); + dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, feature_buffer[0], feature_buffer[1], feature_buffer[2], feature_buffer[3], feature_buffer[4]); do { - retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), - HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, 8, 500); + retval = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + HID_REQ_SET_REPORT, + USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, + 0x0300, 0, feature_buffer, + sizeof(feature_buffer), 500); if (tries++ >= 3) break; - } while (retval != 8 && retval != -ENODEV); + } while (retval != sizeof(feature_buffer) && + retval != -ENODEV); - if (retval != 8) { - err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); + if (retval != sizeof(feature_buffer)) { + err("%s - failed sending serial line settings - %d", __func__, retval); cypress_set_dead(port); } else { spin_lock_irqsave(&priv->lock, flags); priv->baud_rate = new_baudrate; - priv->cbr_mask = baud_mask; priv->current_config = feature_buffer[4]; spin_unlock_irqrestore(&priv->lock, flags); + /* If we asked for a speed change encode it */ + if (baud_rate) + tty_encode_baud_rate(port->tty, + new_baudrate, new_baudrate); } break; case CYPRESS_GET_CONFIG: - dbg("%s - retreiving serial line settings", __FUNCTION__); + if (priv->get_cfg_unsafe) { + /* Not implemented for this device, + and if we try to do it we're likely + to crash the hardware. */ + return -ENOTTY; + } + dbg("%s - retreiving serial line settings", __func__); /* set initial values in feature buffer */ - memset(feature_buffer, 0, 8); + memset(feature_buffer, 0, sizeof(feature_buffer)); do { - retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), - HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, 8, 500); - + retval = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + HID_REQ_GET_REPORT, + USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, + 0x0300, 0, feature_buffer, + sizeof(feature_buffer), 500); + if (tries++ >= 3) break; - } while (retval != 5 && retval != -ENODEV); + } while (retval != sizeof(feature_buffer) && + retval != -ENODEV); - if (retval != 5) { - err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval); + if (retval != sizeof(feature_buffer)) { + err("%s - failed to retrieve serial line settings - %d", __func__, retval); cypress_set_dead(port); return retval; } else { @@ -415,9 +434,6 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m /* store the config in one byte, and later use bit masks to check values */ priv->current_config = feature_buffer[4]; priv->baud_rate = *((u_int32_t *)feature_buffer); - - if ( (priv->cbr_mask = rate_to_mask(priv->baud_rate)) == 0x40) - dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__); spin_unlock_irqrestore(&priv->lock, flags); } } @@ -447,51 +463,6 @@ static void cypress_set_dead(struct usb_serial_port *port) } -/* given a baud mask, it will return integer baud on success */ -static int mask_to_rate (unsigned mask) -{ - int rate; - - switch (mask) { - case B0: rate = 0; break; - case B300: rate = 300; break; - case B600: rate = 600; break; - case B1200: rate = 1200; break; - case B2400: rate = 2400; break; - case B4800: rate = 4800; break; - case B9600: rate = 9600; break; - case B19200: rate = 19200; break; - case B38400: rate = 38400; break; - case B57600: rate = 57600; break; - case B115200: rate = 115200; break; - default: rate = -1; - } - - return rate; -} - - -static unsigned rate_to_mask (int rate) -{ - unsigned mask; - - switch (rate) { - case 0: mask = B0; break; - case 300: mask = B300; break; - case 600: mask = B600; break; - case 1200: mask = B1200; break; - case 2400: mask = B2400; break; - case 4800: mask = B4800; break; - case 9600: mask = B9600; break; - case 19200: mask = B19200; break; - case 38400: mask = B38400; break; - case 57600: mask = B57600; break; - case 115200: mask = B115200; break; - default: mask = 0x40; - } - - return mask; -} /***************************************************************************** * Cypress serial driver functions *****************************************************************************/ @@ -502,7 +473,7 @@ static int generic_startup (struct usb_serial *serial) struct cypress_private *priv; struct usb_serial_port *port = serial->port[0]; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL); if (!priv) @@ -523,17 +494,27 @@ static int generic_startup (struct usb_serial *serial) priv->line_control = 0; priv->termios_initialized = 0; priv->rx_flags = 0; - priv->cbr_mask = B300; + /* Default packet format setting is determined by packet size. + Anything with a size larger then 9 must have a separate + count field since the 3 bit count field is otherwise too + small. Otherwise we can use the slightly more compact + format. This is in accordance with the cypress_m8 serial + converter app note. */ + if (port->interrupt_out_size > 9) { + priv->pkt_fmt = packet_format_1; + } else { + priv->pkt_fmt = packet_format_2; + } if (interval > 0) { priv->write_urb_interval = interval; priv->read_urb_interval = interval; dbg("%s - port %d read & write intervals forced to %d", - __FUNCTION__,port->number,interval); + __func__,port->number,interval); } else { priv->write_urb_interval = port->interrupt_out_urb->interval; priv->read_urb_interval = port->interrupt_in_urb->interval; dbg("%s - port %d intervals: read=%d write=%d", - __FUNCTION__,port->number, + __func__,port->number, priv->read_urb_interval,priv->write_urb_interval); } usb_set_serial_port_data(port, priv); @@ -545,17 +526,30 @@ static int generic_startup (struct usb_serial *serial) static int cypress_earthmate_startup (struct usb_serial *serial) { struct cypress_private *priv; + struct usb_serial_port *port = serial->port[0]; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (generic_startup(serial)) { - dbg("%s - Failed setting up port %d", __FUNCTION__, - serial->port[0]->number); + dbg("%s - Failed setting up port %d", __func__, + port->number); return 1; } - priv = usb_get_serial_port_data(serial->port[0]); + priv = usb_get_serial_port_data(port); priv->chiptype = CT_EARTHMATE; + /* All Earthmate devices use the separated-count packet + format! Idiotic. */ + priv->pkt_fmt = packet_format_1; + if (serial->dev->descriptor.idProduct != PRODUCT_ID_EARTHMATEUSB) { + /* The old original USB Earthmate seemed able to + handle GET_CONFIG requests; everything they've + produced since that time crashes if this command is + attempted :-( */ + dbg("%s - Marking this device as unsafe for GET_CONFIG " + "commands", __func__); + priv->get_cfg_unsafe = !0; + } return 0; } /* cypress_earthmate_startup */ @@ -565,10 +559,10 @@ static int cypress_hidcom_startup (struct usb_serial *serial) { struct cypress_private *priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (generic_startup(serial)) { - dbg("%s - Failed setting up port %d", __FUNCTION__, + dbg("%s - Failed setting up port %d", __func__, serial->port[0]->number); return 1; } @@ -584,10 +578,10 @@ static int cypress_ca42v2_startup (struct usb_serial *serial) { struct cypress_private *priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (generic_startup(serial)) { - dbg("%s - Failed setting up port %d", __FUNCTION__, + dbg("%s - Failed setting up port %d", __func__, serial->port[0]->number); return 1; } @@ -603,7 +597,7 @@ static void cypress_shutdown (struct usb_serial *serial) { struct cypress_private *priv; - dbg ("%s - port %d", __FUNCTION__, serial->port[0]->number); + dbg ("%s - port %d", __func__, serial->port[0]->number); /* all open ports are closed at this point */ @@ -624,7 +618,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) unsigned long flags; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!priv->comm_is_ok) return -EIO; @@ -652,16 +646,16 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) result = cypress_write(port, NULL, 0); if (result) { - dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result); return result; } else - dbg("%s - success setting the control lines", __FUNCTION__); + dbg("%s - success setting the control lines", __func__); cypress_set_termios(port, &priv->tmp_termios); /* setup the port and start reading from the device */ if(!port->interrupt_in_urb){ - err("%s - interrupt_in_urb is empty!", __FUNCTION__); + err("%s - interrupt_in_urb is empty!", __func__); return(-1); } @@ -672,7 +666,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result){ - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); cypress_set_dead(port); } @@ -688,7 +682,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) long timeout; wait_queue_t wait; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* wait for data to drain from buffer */ spin_lock_irq(&priv->lock); @@ -726,7 +720,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) timeout = 2*HZ; schedule_timeout_interruptible(timeout); - dbg("%s - stopping urbs", __FUNCTION__); + dbg("%s - stopping urbs", __func__); usb_kill_urb (port->interrupt_in_urb); usb_kill_urb (port->interrupt_out_urb); @@ -755,7 +749,7 @@ static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count); + dbg("%s - port %d, %d bytes", __func__, port->number, count); /* line control commands, which need to be executed immediately, are not put into the buffer for obvious reasons. @@ -788,12 +782,12 @@ static void cypress_send(struct usb_serial_port *port) if (!priv->comm_is_ok) return; - dbg("%s - port %d", __FUNCTION__, port->number); - dbg("%s - interrupt out size is %d", __FUNCTION__, port->interrupt_out_size); + dbg("%s - port %d", __func__, port->number); + dbg("%s - interrupt out size is %d", __func__, port->interrupt_out_size); spin_lock_irqsave(&priv->lock, flags); if (priv->write_urb_in_use) { - dbg("%s - can't write, urb in use", __FUNCTION__); + dbg("%s - can't write, urb in use", __func__); spin_unlock_irqrestore(&priv->lock, flags); return; } @@ -803,21 +797,18 @@ static void cypress_send(struct usb_serial_port *port) memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size); spin_lock_irqsave(&priv->lock, flags); - switch (port->interrupt_out_size) { - case 32: - /* this is for the CY7C64013... */ - offset = 2; - port->interrupt_out_buffer[0] = priv->line_control; - break; - case 8: - /* this is for the CY7C63743... */ - offset = 1; - port->interrupt_out_buffer[0] = priv->line_control; - break; - default: - dbg("%s - wrong packet size", __FUNCTION__); - spin_unlock_irqrestore(&priv->lock, flags); - return; + switch (priv->pkt_fmt) { + default: + case packet_format_1: + /* this is for the CY7C64013... */ + offset = 2; + port->interrupt_out_buffer[0] = priv->line_control; + break; + case packet_format_2: + /* this is for the CY7C63743... */ + offset = 1; + port->interrupt_out_buffer[0] = priv->line_control; + break; } if (priv->line_control & CONTROL_RESET) @@ -825,7 +816,7 @@ static void cypress_send(struct usb_serial_port *port) if (priv->cmd_ctrl) { priv->cmd_count++; - dbg("%s - line control command being issued", __FUNCTION__); + dbg("%s - line control command being issued", __func__); spin_unlock_irqrestore(&priv->lock, flags); goto send; } else @@ -838,15 +829,16 @@ static void cypress_send(struct usb_serial_port *port) return; } - switch (port->interrupt_out_size) { - case 32: - port->interrupt_out_buffer[1] = count; - break; - case 8: - port->interrupt_out_buffer[0] |= count; + switch (priv->pkt_fmt) { + default: + case packet_format_1: + port->interrupt_out_buffer[1] = count; + break; + case packet_format_2: + port->interrupt_out_buffer[0] |= count; } - dbg("%s - count is %d", __FUNCTION__, count); + dbg("%s - count is %d", __func__, count); send: spin_lock_irqsave(&priv->lock, flags); @@ -856,9 +848,10 @@ send: if (priv->cmd_ctrl) actual_size = 1; else - actual_size = count + (port->interrupt_out_size == 32 ? 2 : 1); - - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, port->interrupt_out_size, + actual_size = count + + (priv->pkt_fmt == packet_format_1 ? 2 : 1); + + usb_serial_debug_data(debug, &port->dev, __func__, port->interrupt_out_size, port->interrupt_out_urb->transfer_buffer); usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev, @@ -867,7 +860,7 @@ send: cypress_write_int_callback, port, priv->write_urb_interval); result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, + dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); priv->write_urb_in_use = 0; cypress_set_dead(port); @@ -891,13 +884,13 @@ static int cypress_write_room(struct usb_serial_port *port) int room = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); room = cypress_buf_space_avail(priv->buf); spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -909,7 +902,7 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) unsigned int result = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); control = priv->line_control; @@ -923,7 +916,7 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) | ((status & UART_RI) ? TIOCM_RI : 0) | ((status & UART_CD) ? TIOCM_CD : 0); - dbg("%s - result = %x", __FUNCTION__, result); + dbg("%s - result = %x", __func__, result); return result; } @@ -935,7 +928,7 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); if (set & TIOCM_RTS) @@ -946,9 +939,9 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, priv->line_control &= ~CONTROL_RTS; if (clear & TIOCM_DTR) priv->line_control &= ~CONTROL_DTR; + priv->cmd_ctrl = 1; spin_unlock_irqrestore(&priv->lock, flags); - priv->cmd_ctrl = 1; return cypress_write(port, NULL, 0); } @@ -957,23 +950,9 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi { struct cypress_private *priv = usb_get_serial_port_data(port); - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); switch (cmd) { - case TIOCGSERIAL: - if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct ktermios))) { - return -EFAULT; - } - return (0); - break; - case TIOCSSERIAL: - if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct ktermios))) { - return -EFAULT; - } - /* here we need to call cypress_set_termios to invoke the new settings */ - cypress_set_termios(port, &priv->tmp_termios); - return (0); - break; /* This code comes from drivers/char/serial.c and ftdi_sio.c */ case TIOCMIWAIT: while (priv != NULL) { @@ -1009,7 +988,7 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi break; } - dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __FUNCTION__, cmd); + dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); return -ENOIOCTLCMD; } /* cypress_ioctl */ @@ -1021,18 +1000,14 @@ static void cypress_set_termios (struct usb_serial_port *port, struct cypress_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; int data_bits, stop_bits, parity_type, parity_enable; - unsigned cflag, iflag, baud_mask; + unsigned cflag, iflag; unsigned long flags; __u8 oldlines; int linechange = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); tty = port->tty; - if ((!tty) || (!tty->termios)) { - dbg("%s - no tty structures", __FUNCTION__); - return; - } spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { @@ -1040,40 +1015,37 @@ static void cypress_set_termios (struct usb_serial_port *port, *(tty->termios) = tty_std_termios; tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_ispeed = 4800; + tty->termios->c_ospeed = 4800; } else if (priv->chiptype == CT_CYPHIDCOM) { *(tty->termios) = tty_std_termios; tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_ispeed = 9600; + tty->termios->c_ospeed = 9600; } else if (priv->chiptype == CT_CA42V2) { *(tty->termios) = tty_std_termios; tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_ispeed = 9600; + tty->termios->c_ospeed = 9600; } priv->termios_initialized = 1; } spin_unlock_irqrestore(&priv->lock, flags); + /* Unsupported features need clearing */ + tty->termios->c_cflag &= ~(CMSPAR|CRTSCTS); + cflag = tty->termios->c_cflag; iflag = tty->termios->c_iflag; /* check if there are new settings */ if (old_termios) { - if ((cflag != old_termios->c_cflag) || - (RELEVANT_IFLAG(iflag) != - RELEVANT_IFLAG(old_termios->c_iflag))) { - dbg("%s - attempting to set new termios settings", - __FUNCTION__); - /* should make a copy of this in case something goes - * wrong in the function, we can restore it */ - spin_lock_irqsave(&priv->lock, flags); - priv->tmp_termios = *(tty->termios); - spin_unlock_irqrestore(&priv->lock, flags); - } else { - dbg("%s - nothing to do, exiting", __FUNCTION__); - return; - } - } else - return; + spin_lock_irqsave(&priv->lock, flags); + priv->tmp_termios = *(tty->termios); + spin_unlock_irqrestore(&priv->lock, flags); + } /* set number of data bits, parity, stop bits */ /* when parity is disabled the parity type bit is ignored */ @@ -1104,7 +1076,7 @@ static void cypress_set_termios (struct usb_serial_port *port, break; default: err("%s - CSIZE was set, but not CS5-CS8", - __FUNCTION__); + __func__); data_bits = 3; } } else @@ -1114,54 +1086,17 @@ static void cypress_set_termios (struct usb_serial_port *port, oldlines = priv->line_control; if ((cflag & CBAUD) == B0) { /* drop dtr and rts */ - dbg("%s - dropping the lines, baud rate 0bps", __FUNCTION__); - baud_mask = B0; + dbg("%s - dropping the lines, baud rate 0bps", __func__); priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); - } else { - baud_mask = (cflag & CBAUD); - switch(baud_mask) { - case B300: - dbg("%s - setting baud 300bps", __FUNCTION__); - break; - case B600: - dbg("%s - setting baud 600bps", __FUNCTION__); - break; - case B1200: - dbg("%s - setting baud 1200bps", __FUNCTION__); - break; - case B2400: - dbg("%s - setting baud 2400bps", __FUNCTION__); - break; - case B4800: - dbg("%s - setting baud 4800bps", __FUNCTION__); - break; - case B9600: - dbg("%s - setting baud 9600bps", __FUNCTION__); - break; - case B19200: - dbg("%s - setting baud 19200bps", __FUNCTION__); - break; - case B38400: - dbg("%s - setting baud 38400bps", __FUNCTION__); - break; - case B57600: - dbg("%s - setting baud 57600bps", __FUNCTION__); - break; - case B115200: - dbg("%s - setting baud 115200bps", __FUNCTION__); - break; - default: - dbg("%s - unknown masked baud rate", __FUNCTION__); - } + } else priv->line_control = (CONTROL_DTR | CONTROL_RTS); - } spin_unlock_irqrestore(&priv->lock, flags); dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, " - "%d data_bits (+5)", __FUNCTION__, stop_bits, + "%d data_bits (+5)", __func__, stop_bits, parity_enable, parity_type, data_bits); - cypress_serial_control(port, baud_mask, data_bits, stop_bits, + cypress_serial_control(port, tty_get_baud_rate(tty), data_bits, stop_bits, parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); /* we perform a CYPRESS_GET_CONFIG so that the current settings are @@ -1219,13 +1154,13 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port) int chars = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); chars = cypress_buf_data_avail(priv->buf); spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } @@ -1235,7 +1170,7 @@ static void cypress_throttle (struct usb_serial_port *port) struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->rx_flags = THROTTLED; @@ -1249,7 +1184,7 @@ static void cypress_unthrottle (struct usb_serial_port *port) int actually_throttled, result; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; @@ -1265,7 +1200,7 @@ static void cypress_unthrottle (struct usb_serial_port *port) result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result) { dev_err(&port->dev, "%s - failed submitting read urb, " - "error %d\n", __FUNCTION__, result); + "error %d\n", __func__, result); cypress_set_dead(port); } } @@ -1274,7 +1209,7 @@ static void cypress_unthrottle (struct usb_serial_port *port) static void cypress_read_int_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct cypress_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -1286,7 +1221,7 @@ static void cypress_read_int_callback(struct urb *urb) int i = 0; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); switch (status) { case 0: /* success */ @@ -1302,14 +1237,14 @@ static void cypress_read_int_callback(struct urb *urb) default: /* something ugly is going on... */ dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n", - __FUNCTION__, status); + __func__, status); cypress_set_dead(port); return; } spin_lock_irqsave(&priv->lock, flags); if (priv->rx_flags & THROTTLED) { - dbg("%s - now throttling", __FUNCTION__); + dbg("%s - now throttling", __func__); priv->rx_flags |= ACTUALLY_THROTTLED; spin_unlock_irqrestore(&priv->lock, flags); return; @@ -1318,48 +1253,48 @@ static void cypress_read_int_callback(struct urb *urb) tty = port->tty; if (!tty) { - dbg("%s - bad tty pointer - exiting", __FUNCTION__); + dbg("%s - bad tty pointer - exiting", __func__); return; } spin_lock_irqsave(&priv->lock, flags); - switch(urb->actual_length) { - case 32: - /* This is for the CY7C64013... */ - priv->current_status = data[0] & 0xF8; - bytes = data[1] + 2; - i = 2; - if (bytes > 2) - havedata = 1; - break; - case 8: - /* This is for the CY7C63743... */ - priv->current_status = data[0] & 0xF8; - bytes = (data[0] & 0x07) + 1; - i = 1; - if (bytes > 1) - havedata = 1; - break; - default: - dbg("%s - wrong packet size - received %d bytes", - __FUNCTION__, urb->actual_length); - spin_unlock_irqrestore(&priv->lock, flags); - goto continue_read; + result = urb->actual_length; + switch (priv->pkt_fmt) { + default: + case packet_format_1: + /* This is for the CY7C64013... */ + priv->current_status = data[0] & 0xF8; + bytes = data[1] + 2; + i = 2; + if (bytes > 2) + havedata = 1; + break; + case packet_format_2: + /* This is for the CY7C63743... */ + priv->current_status = data[0] & 0xF8; + bytes = (data[0] & 0x07) + 1; + i = 1; + if (bytes > 1) + havedata = 1; + break; } spin_unlock_irqrestore(&priv->lock, flags); + if (result < bytes) { + dbg("%s - wrong packet size - received %d bytes but packet " + "said %d bytes", __func__, result, bytes); + goto continue_read; + } - usb_serial_debug_data (debug, &port->dev, __FUNCTION__, + usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); spin_lock_irqsave(&priv->lock, flags); /* check to see if status has changed */ - if (priv != NULL) { - if (priv->current_status != priv->prev_status) { - priv->diff_status |= priv->current_status ^ - priv->prev_status; - wake_up_interruptible(&priv->delta_msr_wait); - priv->prev_status = priv->current_status; - } + if (priv->current_status != priv->prev_status) { + priv->diff_status |= priv->current_status ^ + priv->prev_status; + wake_up_interruptible(&priv->delta_msr_wait); + priv->prev_status = priv->current_status; } spin_unlock_irqrestore(&priv->lock, flags); @@ -1367,7 +1302,7 @@ static void cypress_read_int_callback(struct urb *urb) * though */ if (tty && !(tty->termios->c_cflag & CLOCAL) && !(priv->current_status & UART_CD)) { - dbg("%s - calling hangup", __FUNCTION__); + dbg("%s - calling hangup", __func__); tty_hangup(tty); goto continue_read; } @@ -1380,7 +1315,7 @@ static void cypress_read_int_callback(struct urb *urb) if (priv->current_status & CYP_ERROR) { spin_unlock_irqrestore(&priv->lock, flags); tty_flag = TTY_PARITY; - dbg("%s - Parity Error detected", __FUNCTION__); + dbg("%s - Parity Error detected", __func__); } else spin_unlock_irqrestore(&priv->lock, flags); @@ -1414,7 +1349,7 @@ continue_read: result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result) { dev_err(&urb->dev->dev, "%s - failed resubmitting " - "read urb, error %d\n", __FUNCTION__, + "read urb, error %d\n", __func__, result); cypress_set_dead(port); } @@ -1426,12 +1361,12 @@ continue_read: static void cypress_write_int_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct cypress_private *priv = usb_get_serial_port_data(port); int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); switch (status) { case 0: @@ -1442,7 +1377,7 @@ static void cypress_write_int_callback(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); priv->write_urb_in_use = 0; return; case -EPIPE: /* no break needed; clear halt and resubmit */ @@ -1451,19 +1386,19 @@ static void cypress_write_int_callback(struct urb *urb) usb_clear_halt(port->serial->dev, 0x02); /* error in the urb, so we have to resubmit it */ dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); port->interrupt_out_urb->transfer_buffer_length = 1; port->interrupt_out_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); if (!result) return; dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", - __FUNCTION__, result); + __func__, result); cypress_set_dead(port); break; default: dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n", - __FUNCTION__, status); + __func__, status); cypress_set_dead(port); break; } @@ -1668,7 +1603,7 @@ static int __init cypress_init(void) { int retval; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); retval = usb_serial_register(&cypress_earthmate_device); if (retval) @@ -1699,7 +1634,7 @@ failed_em_register: static void __exit cypress_exit (void) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); usb_deregister (&cypress_driver); usb_serial_deregister (&cypress_earthmate_device); diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 5f9c6e46bee..d17d1645714 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -508,9 +508,6 @@ static struct usb_serial_driver digi_acceleport_2_device = { .description = "Digi 2 port USB adapter", .usb_driver = &digi_driver, .id_table = id_table_2, - .num_interrupt_in = 0, - .num_bulk_in = 4, - .num_bulk_out = 4, .num_ports = 3, .open = digi_open, .close = digi_close, @@ -538,9 +535,6 @@ static struct usb_serial_driver digi_acceleport_4_device = { .description = "Digi 4 port USB adapter", .usb_driver = &digi_driver, .id_table = id_table_4, - .num_interrupt_in = 0, - .num_bulk_in = 5, - .num_bulk_out = 5, .num_ports = 4, .open = digi_open, .close = digi_close, @@ -665,7 +659,7 @@ static int digi_write_oob_command(struct usb_serial_port *port, } spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); if (ret) - err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret); + err("%s: usb_submit_urb failed, ret=%d", __func__, ret); return ret; } @@ -746,7 +740,7 @@ static int digi_write_inb_command(struct usb_serial_port *port, if (ret) err("%s: usb_submit_urb failed, ret=%d, port=%d", - __FUNCTION__, ret, priv->dp_port_num); + __func__, ret, priv->dp_port_num); return ret; } @@ -810,7 +804,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port, spin_unlock(&port_priv->dp_port_lock); spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); if (ret) - err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret); + err("%s: usb_submit_urb failed, ret=%d", __func__, ret); return ret; } @@ -903,7 +897,7 @@ static void digi_rx_unthrottle(struct usb_serial_port *port) if (ret) err("%s: usb_submit_urb failed, ret=%d, port=%d", - __FUNCTION__, ret, priv->dp_port_num); + __func__, ret, priv->dp_port_num); } @@ -1113,7 +1107,7 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file) unsigned int val; unsigned long flags; - dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); + dbg("%s: TOP: port=%d", __func__, priv->dp_port_num); spin_lock_irqsave(&priv->dp_port_lock, flags); val = priv->dp_modem_signals; @@ -1129,7 +1123,7 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file, unsigned int val; unsigned long flags; - dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); + dbg("%s: TOP: port=%d", __func__, priv->dp_port_num); spin_lock_irqsave(&priv->dp_port_lock, flags); val = (priv->dp_modem_signals & ~clear) | set; @@ -1224,7 +1218,7 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in spin_unlock_irqrestore(&priv->dp_port_lock, flags); if (ret < 0) err("%s: usb_submit_urb failed, ret=%d, port=%d", - __FUNCTION__, ret, priv->dp_port_num); + __func__, ret, priv->dp_port_num); dbg("digi_write: returning %d", ret); return ret; @@ -1233,7 +1227,7 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in static void digi_write_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct usb_serial *serial; struct digi_port *priv; struct digi_serial *serial_priv; @@ -1245,13 +1239,13 @@ static void digi_write_bulk_callback(struct urb *urb) /* port and serial sanity check */ if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) { err("%s: port or port->private is NULL, status=%d", - __FUNCTION__, status); + __func__, status); return; } serial = port->serial; if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) { err("%s: serial or serial->private is NULL, status=%d", - __FUNCTION__, status); + __func__, status); return; } @@ -1292,7 +1286,7 @@ static void digi_write_bulk_callback(struct urb *urb) spin_unlock(&priv->dp_port_lock); if (ret) err("%s: usb_submit_urb failed, ret=%d, port=%d", - __FUNCTION__, ret, priv->dp_port_num); + __func__, ret, priv->dp_port_num); } static int digi_write_room(struct usb_serial_port *port) @@ -1521,7 +1515,7 @@ static int digi_startup_device(struct usb_serial *serial) port->write_urb->dev = port->serial->dev; if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) { err("%s: usb_submit_urb failed, ret=%d, port=%d", - __FUNCTION__, ret, i); + __func__, ret, i); break; } } @@ -1611,7 +1605,7 @@ static void digi_shutdown(struct usb_serial *serial) static void digi_read_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct digi_port *priv; struct digi_serial *serial_priv; int ret; @@ -1622,20 +1616,20 @@ static void digi_read_bulk_callback(struct urb *urb) /* port sanity check, do not resubmit if port is not valid */ if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { err("%s: port or port->private is NULL, status=%d", - __FUNCTION__, status); + __func__, status); return; } if (port->serial == NULL || (serial_priv=usb_get_serial_data(port->serial)) == NULL) { err("%s: serial is bad or serial->private is NULL, status=%d", - __FUNCTION__, status); + __func__, status); return; } /* do not resubmit urb if it has any status error */ if (status) { err("%s: nonzero read bulk status: status=%d, port=%d", - __FUNCTION__, status, priv->dp_port_num); + __func__, status, priv->dp_port_num); return; } @@ -1652,7 +1646,7 @@ static void digi_read_bulk_callback(struct urb *urb) urb->dev = port->serial->dev; if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err("%s: failed resubmitting urb, ret=%d, port=%d", - __FUNCTION__, ret, priv->dp_port_num); + __func__, ret, priv->dp_port_num); } } @@ -1670,7 +1664,7 @@ static void digi_read_bulk_callback(struct urb *urb) static int digi_read_inb_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct tty_struct *tty = port->tty; struct digi_port *priv = usb_get_serial_port_data(port); int opcode = ((unsigned char *)urb->transfer_buffer)[0]; @@ -1690,7 +1684,7 @@ static int digi_read_inb_callback(struct urb *urb) if (urb->actual_length != len + 2) { err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " "port=%d, opcode=%d, len=%d, actual_length=%d, " - "status=%d", __FUNCTION__, status, priv->dp_port_num, + "status=%d", __func__, status, priv->dp_port_num, opcode, len, urb->actual_length, port_status); return -1; } @@ -1739,9 +1733,9 @@ static int digi_read_inb_callback(struct urb *urb) spin_unlock(&priv->dp_port_lock); if (opcode == DIGI_CMD_RECEIVE_DISABLE) - dbg("%s: got RECEIVE_DISABLE", __FUNCTION__); + dbg("%s: got RECEIVE_DISABLE", __func__); else if (opcode != DIGI_CMD_RECEIVE_DATA) - dbg("%s: unknown opcode: %d", __FUNCTION__, opcode); + dbg("%s: unknown opcode: %d", __func__, opcode); return(throttled ? 1 : 0); @@ -1760,7 +1754,7 @@ static int digi_read_inb_callback(struct urb *urb) static int digi_read_oob_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct usb_serial *serial = port->serial; struct digi_port *priv = usb_get_serial_port_data(port); int opcode, line, status, val; diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index a5c8e1e17ea..c5ec309a3cb 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -118,9 +118,6 @@ static struct usb_serial_driver empeg_device = { }, .id_table = id_table, .usb_driver = &empeg_driver, - .num_interrupt_in = 0, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = empeg_open, .close = empeg_close, @@ -153,7 +150,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) struct usb_serial *serial = port->serial; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* Force default termio settings */ empeg_set_termios (port, NULL) ; @@ -175,7 +172,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); return result; } @@ -183,7 +180,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) static void empeg_close (struct usb_serial_port *port, struct file * filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* shutdown our bulk read */ usb_kill_urb(port->read_urb); @@ -203,7 +200,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int bytes_sent = 0; int transfer_size; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); while (count > 0) { @@ -222,14 +219,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, spin_unlock_irqrestore (&write_urb_pool_lock, flags); if (urb == NULL) { - dbg("%s - no more free urbs", __FUNCTION__); + dbg("%s - no more free urbs", __func__); goto exit; } if (urb->transfer_buffer == NULL) { urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); if (urb->transfer_buffer == NULL) { - dev_err(&port->dev, "%s no more kernel memory...\n", __FUNCTION__); + dev_err(&port->dev, "%s no more kernel memory...\n", __func__); goto exit; } } @@ -238,7 +235,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, memcpy (urb->transfer_buffer, current_position, transfer_size); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer); /* build up our urb */ usb_fill_bulk_urb ( @@ -254,7 +251,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, /* send it down the pipe */ status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { - dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", __func__, status); bytes_sent = status; break; } @@ -278,7 +275,7 @@ static int empeg_write_room (struct usb_serial_port *port) int i; int room = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave (&write_urb_pool_lock, flags); @@ -291,7 +288,7 @@ static int empeg_write_room (struct usb_serial_port *port) spin_unlock_irqrestore (&write_urb_pool_lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return (room); @@ -304,7 +301,7 @@ static int empeg_chars_in_buffer (struct usb_serial_port *port) int i; int chars = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave (&write_urb_pool_lock, flags); @@ -317,7 +314,7 @@ static int empeg_chars_in_buffer (struct usb_serial_port *port) spin_unlock_irqrestore (&write_urb_pool_lock, flags); - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return (chars); @@ -329,11 +326,11 @@ static void empeg_write_bulk_callback (struct urb *urb) struct usb_serial_port *port = urb->context; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -343,21 +340,21 @@ static void empeg_write_bulk_callback (struct urb *urb) static void empeg_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); tty = port->tty; @@ -382,7 +379,7 @@ static void empeg_read_bulk_callback (struct urb *urb) result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); return; @@ -391,7 +388,7 @@ static void empeg_read_bulk_callback (struct urb *urb) static void empeg_throttle (struct usb_serial_port *port) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); } @@ -400,14 +397,14 @@ static void empeg_unthrottle (struct usb_serial_port *port) { int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); return; } @@ -417,14 +414,14 @@ static int empeg_startup (struct usb_serial *serial) { int r; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (serial->dev->actconfig->desc.bConfigurationValue != 1) { err("active config #%d != 1 ??", serial->dev->actconfig->desc.bConfigurationValue); return -ENODEV; } - dbg("%s - reset config", __FUNCTION__); + dbg("%s - reset config", __func__); r = usb_reset_configuration (serial->dev); /* continue on with initialization */ @@ -435,13 +432,13 @@ static int empeg_startup (struct usb_serial *serial) static void empeg_shutdown (struct usb_serial *serial) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) { - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); return -ENOIOCTLCMD; } @@ -450,7 +447,7 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { struct ktermios *termios = port->tty->termios; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * The empeg-car player wants these particular tty settings. @@ -517,7 +514,7 @@ static int __init empeg_init (void) urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (!urb->transfer_buffer) { err("%s - out of memory for urb buffers.", - __FUNCTION__); + __func__); continue; } } diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c index 3f698baa0ab..cc4fbd9d60b 100644 --- a/drivers/usb/serial/ezusb.c +++ b/drivers/usb/serial/ezusb.c @@ -27,13 +27,13 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da /* dbg("ezusb_writememory %x, %d", address, length); */ if (!serial->dev) { - err("%s - no physical device present, failing.", __FUNCTION__); + err("%s - no physical device present, failing.", __func__); return -ENODEV; } transfer_buffer = kmemdup(data, length, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, length); return -ENOMEM; } result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); @@ -45,10 +45,10 @@ int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit) { int response; - /* dbg("%s - %d", __FUNCTION__, reset_bit); */ + /* dbg("%s - %d", __func__, reset_bit); */ response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0); if (response < 0) - dev_err(&serial->dev->dev, "%s- %d failed\n", __FUNCTION__, reset_bit); + dev_err(&serial->dev->dev, "%s- %d failed\n", __func__, reset_bit); return response; } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 3abb3c86364..23f51a41093 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -439,9 +439,6 @@ static struct usb_serial_driver ftdi_sio_device = { .description = "FTDI USB Serial Device", .usb_driver = &ftdi_driver , .id_table = id_table_combined, - .num_interrupt_in = 0, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .probe = ftdi_sio_probe, .port_probe = ftdi_sio_port_probe, @@ -528,14 +525,13 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int rv; if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { - dbg("%s - DTR|RTS not being set|cleared", __FUNCTION__); + dbg("%s - DTR|RTS not being set|cleared", __func__); return 0; /* no change */ } buf = kmalloc(1, GFP_NOIO); - if (!buf) { + if (!buf) return -ENOMEM; - } clear &= ~set; /* 'set' takes precedence over 'clear' */ urb_value = 0; @@ -557,17 +553,18 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned kfree(buf); if (rv < 0) { err("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", - __FUNCTION__, + __func__, (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); } else { - dbg("%s - DTR %s, RTS %s", __FUNCTION__, + dbg("%s - DTR %s, RTS %s", __func__, (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); + /* FIXME: locking on last_dtr_rts */ priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; } return rv; @@ -642,7 +639,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ baud = tty_get_baud_rate(port->tty); - dbg("%s - tty_get_baud_rate reports speed %d", __FUNCTION__, baud); + dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ @@ -650,7 +647,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && (priv->custom_divisor)) { baud = priv->baud_base / priv->custom_divisor; - dbg("%s - custom divisor %d sets baud rate to %d", __FUNCTION__, priv->custom_divisor, baud); + dbg("%s - custom divisor %d sets baud rate to %d", __func__, priv->custom_divisor, baud); } /* 3. Convert baudrate to device-specific divisor */ @@ -671,7 +668,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) case 115200: div_value = ftdi_sio_b115200; break; } /* baud */ if (div_value == 0) { - dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); + dbg("%s - Baudrate (%d) requested is not supported", __func__, baud); div_value = ftdi_sio_b9600; baud = 9600; div_okay = 0; @@ -681,7 +678,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) if (baud <= 3000000) { div_value = ftdi_232am_baud_to_divisor(baud); } else { - dbg("%s - Baud rate too high!", __FUNCTION__); + dbg("%s - Baud rate too high!", __func__); baud = 9600; div_value = ftdi_232am_baud_to_divisor(9600); div_okay = 0; @@ -693,7 +690,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) if (baud <= 3000000) { div_value = ftdi_232bm_baud_to_divisor(baud); } else { - dbg("%s - Baud rate too high!", __FUNCTION__); + dbg("%s - Baud rate too high!", __func__); div_value = ftdi_232bm_baud_to_divisor(9600); div_okay = 0; baud = 9600; @@ -703,7 +700,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) if (div_okay) { dbg("%s - Baud rate set to %d (divisor 0x%lX) on chip %s", - __FUNCTION__, baud, (unsigned long)div_value, + __func__, baud, (unsigned long)div_value, ftdi_chip_name[priv->chip_type]); } @@ -804,7 +801,7 @@ static void ftdi_determine_type(struct usb_serial_port *port) version = le16_to_cpu(udev->descriptor.bcdDevice); interfaces = udev->actconfig->desc.bNumInterfaces; - dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __FUNCTION__, + dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __func__, version, interfaces); if (interfaces > 1) { int inter; @@ -822,7 +819,7 @@ static void ftdi_determine_type(struct usb_serial_port *port) * to 0x200 when iSerialNumber is 0. */ if (version < 0x500) { dbg("%s: something fishy - bcdDevice too low for multi-interface device", - __FUNCTION__); + __func__); } } else if (version < 0x200) { /* Old device. Assume its the original SIO. */ @@ -860,7 +857,7 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a int rv = 0; - dbg("%s",__FUNCTION__); + dbg("%s",__func__); rv = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -887,7 +884,7 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute * int v = simple_strtoul(valbuf, NULL, 10); int rv = 0; - dbg("%s: setting latency timer = %i", __FUNCTION__, v); + dbg("%s: setting latency timer = %i", __func__, v); rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -916,7 +913,7 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att int v = simple_strtoul(valbuf, NULL, 10); int rv = 0; - dbg("%s: setting event char = %i", __FUNCTION__, v); + dbg("%s: setting event char = %i", __func__, v); rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -941,7 +938,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port) struct ftdi_private *priv = usb_get_serial_port_data(port); int retval = 0; - dbg("%s",__FUNCTION__); + dbg("%s",__func__); /* XXX I've no idea if the original SIO supports the event_char * sysfs parameter, so I'm playing it safe. */ @@ -963,7 +960,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); - dbg("%s",__FUNCTION__); + dbg("%s",__func__); /* XXX see create_sysfs_attrs */ if (priv->chip_type != SIO) { @@ -1005,11 +1002,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); - dbg("%s",__FUNCTION__); + dbg("%s",__func__); priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); if (!priv){ - err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); + err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct ftdi_private)); return -ENOMEM; } @@ -1058,7 +1055,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) /* Called from usbserial:serial_probe */ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) { - dbg("%s",__FUNCTION__); + dbg("%s",__func__); priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 77; @@ -1069,7 +1066,7 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) { - dbg("%s",__FUNCTION__); + dbg("%s",__func__); priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 240; @@ -1087,7 +1084,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial) struct usb_device *udev = serial->dev; struct usb_interface *interface = serial->interface; - dbg("%s",__FUNCTION__); + dbg("%s",__func__); if (interface == udev->actconfig->interface[0]) { info("Ignoring serial port reserved for JTAG"); @@ -1123,14 +1120,14 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial) */ static void ftdi_shutdown (struct usb_serial *serial) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static int ftdi_sio_port_remove(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); - dbg("%s", __FUNCTION__); + dbg("%s", __func__); remove_sysfs_attrs(port); @@ -1155,7 +1152,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) int result = 0; char buf[1]; /* Needed for the usb_control_msg I think */ - dbg("%s", __FUNCTION__); + dbg("%s", __func__); spin_lock_irqsave(&priv->tx_lock, flags); priv->tx_bytes = 0; @@ -1200,7 +1197,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) ftdi_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - err("%s - failed submitting read urb, error %d", __FUNCTION__, result); + err("%s - failed submitting read urb, error %d", __func__, result); return result; @@ -1222,7 +1219,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) struct ftdi_private *priv = usb_get_serial_port_data(port); char buf[1]; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); mutex_lock(&port->serial->disc_mutex); if (c_cflag & HUPCL && !port->serial->disconnected){ @@ -1269,7 +1266,7 @@ static int ftdi_write (struct usb_serial_port *port, int transfer_size; unsigned long flags; - dbg("%s port %d, %d bytes", __FUNCTION__, port->number, count); + dbg("%s port %d, %d bytes", __func__, port->number, count); if (count == 0) { dbg("write request of 0 bytes"); @@ -1278,7 +1275,7 @@ static int ftdi_write (struct usb_serial_port *port, spin_lock_irqsave(&priv->tx_lock, flags); if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) { spin_unlock_irqrestore(&priv->tx_lock, flags); - dbg("%s - write limit hit\n", __FUNCTION__); + dbg("%s - write limit hit\n", __func__); return 0; } priv->tx_outstanding_urbs++; @@ -1298,14 +1295,14 @@ static int ftdi_write (struct usb_serial_port *port, buffer = kmalloc (transfer_size, GFP_ATOMIC); if (!buffer) { - err("%s ran out of kernel memory for urb ...", __FUNCTION__); + err("%s ran out of kernel memory for urb ...", __func__); count = -ENOMEM; goto error_no_buffer; } urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) { - err("%s - no more free urbs", __FUNCTION__); + err("%s - no more free urbs", __func__); count = -ENOMEM; goto error_no_urb; } @@ -1337,7 +1334,7 @@ static int ftdi_write (struct usb_serial_port *port, memcpy (buffer, buf, count); } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer); + usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, buffer); /* fill the buffer and send it */ usb_fill_bulk_urb(urb, port->serial->dev, @@ -1347,7 +1344,7 @@ static int ftdi_write (struct usb_serial_port *port, status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, status); + err("%s - failed submitting write urb, error %d", __func__, status); count = status; goto error; } else { @@ -1361,7 +1358,7 @@ static int ftdi_write (struct usb_serial_port *port, * really free it when it is finished with it */ usb_free_urb(urb); - dbg("%s write returning: %d", __FUNCTION__, count); + dbg("%s write returning: %d", __func__, count); return count; error: usb_free_urb(urb); @@ -1380,7 +1377,7 @@ error_no_buffer: static void ftdi_write_bulk_callback (struct urb *urb) { unsigned long flags; - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct ftdi_private *priv; int data_offset; /* will be 1 for the SIO and 0 otherwise */ unsigned long countback; @@ -1389,7 +1386,7 @@ static void ftdi_write_bulk_callback (struct urb *urb) /* free up the transfer buffer, as usb_free_urb() does not do this */ kfree (urb->transfer_buffer); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("nonzero write bulk status received: %d", status); @@ -1398,7 +1395,7 @@ static void ftdi_write_bulk_callback (struct urb *urb) priv = usb_get_serial_port_data(port); if (!priv) { - dbg("%s - bad port private data pointer - exiting", __FUNCTION__); + dbg("%s - bad port private data pointer - exiting", __func__); return; } /* account for transferred data */ @@ -1406,7 +1403,7 @@ static void ftdi_write_bulk_callback (struct urb *urb) data_offset = priv->write_offset; if (data_offset > 0) { /* Subtract the control bytes */ - countback -= (data_offset * ((countback + (PKTSZ - 1)) / PKTSZ)); + countback -= (data_offset * DIV_ROUND_UP(countback, PKTSZ)); } spin_lock_irqsave(&priv->tx_lock, flags); --priv->tx_outstanding_urbs; @@ -1423,7 +1420,7 @@ static int ftdi_write_room( struct usb_serial_port *port ) int room; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->tx_lock, flags); if (priv->tx_outstanding_urbs < URB_UPPER_LIMIT) { @@ -1447,13 +1444,13 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port) int buffered; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->tx_lock, flags); buffered = (int)priv->tx_outstanding_bytes; spin_unlock_irqrestore(&priv->tx_lock, flags); if (buffered < 0) { - err("%s outstanding tx bytes is negative!", __FUNCTION__); + err("%s outstanding tx bytes is negative!", __func__); buffered = 0; } return buffered; @@ -1463,7 +1460,7 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port) static void ftdi_read_bulk_callback (struct urb *urb) { /* ftdi_read_bulk_callback */ - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct tty_struct *tty; struct ftdi_private *priv; unsigned long countread; @@ -1471,30 +1468,30 @@ static void ftdi_read_bulk_callback (struct urb *urb) int status = urb->status; if (urb->number_of_packets > 0) { - err("%s transfer_buffer_length %d actual_length %d number of packets %d",__FUNCTION__, + err("%s transfer_buffer_length %d actual_length %d number of packets %d",__func__, urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets ); - err("%s transfer_flags %x ", __FUNCTION__,urb->transfer_flags ); + err("%s transfer_flags %x ", __func__,urb->transfer_flags ); } - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->open_count <= 0) return; tty = port->tty; if (!tty) { - dbg("%s - bad tty pointer - exiting",__FUNCTION__); + dbg("%s - bad tty pointer - exiting",__func__); return; } priv = usb_get_serial_port_data(port); if (!priv) { - dbg("%s - bad port private data pointer - exiting", __FUNCTION__); + dbg("%s - bad port private data pointer - exiting", __func__); return; } if (urb != port->read_urb) { - err("%s - Not my urb!", __FUNCTION__); + err("%s - Not my urb!", __func__); } if (status) { @@ -1506,7 +1503,7 @@ static void ftdi_read_bulk_callback (struct urb *urb) /* count data bytes, but not status bytes */ countread = urb->actual_length; - countread -= 2 * ((countread + (PKTSZ - 1)) / PKTSZ); + countread -= 2 * DIV_ROUND_UP(countread, PKTSZ); spin_lock_irqsave(&priv->rx_lock, flags); priv->rx_bytes += countread; spin_unlock_irqrestore(&priv->rx_lock, flags); @@ -1532,39 +1529,39 @@ static void ftdi_process_read (struct work_struct *work) int packet_offset; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->open_count <= 0) return; tty = port->tty; if (!tty) { - dbg("%s - bad tty pointer - exiting",__FUNCTION__); + dbg("%s - bad tty pointer - exiting",__func__); return; } priv = usb_get_serial_port_data(port); if (!priv) { - dbg("%s - bad port private data pointer - exiting", __FUNCTION__); + dbg("%s - bad port private data pointer - exiting", __func__); return; } urb = port->read_urb; if (!urb) { - dbg("%s - bad read_urb pointer - exiting", __FUNCTION__); + dbg("%s - bad read_urb pointer - exiting", __func__); return; } data = urb->transfer_buffer; if (priv->rx_processed) { - dbg("%s - already processed: %d bytes, %d remain", __FUNCTION__, + dbg("%s - already processed: %d bytes, %d remain", __func__, priv->rx_processed, urb->actual_length - priv->rx_processed); } else { /* The first two bytes of every read packet are status */ if (urb->actual_length > 2) { - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); } else { dbg("Status only: %03oo %03oo",data[0],data[1]); } @@ -1594,17 +1591,17 @@ static void ftdi_process_read (struct work_struct *work) length = min(PKTSZ, urb->actual_length-packet_offset)-2; if (length < 0) { - err("%s - bad packet length: %d", __FUNCTION__, length+2); + err("%s - bad packet length: %d", __func__, length+2); length = 0; } if (priv->rx_flags & THROTTLED) { - dbg("%s - throttled", __FUNCTION__); + dbg("%s - throttled", __func__); break; } if (tty_buffer_request_room(tty, length) < length) { /* break out & wait for throttling/unthrottling to happen */ - dbg("%s - receive room low", __FUNCTION__); + dbg("%s - receive room low", __func__); break; } @@ -1672,7 +1669,7 @@ static void ftdi_process_read (struct work_struct *work) /* not completely processed - record progress */ priv->rx_processed = packet_offset; dbg("%s - incomplete, %d bytes processed, %d remain", - __FUNCTION__, packet_offset, + __func__, packet_offset, urb->actual_length - packet_offset); /* check if we were throttled while processing */ spin_lock_irqsave(&priv->rx_lock, flags); @@ -1680,7 +1677,7 @@ static void ftdi_process_read (struct work_struct *work) priv->rx_flags |= ACTUALLY_THROTTLED; spin_unlock_irqrestore(&priv->rx_lock, flags); dbg("%s - deferring remainder until unthrottled", - __FUNCTION__); + __func__); return; } spin_unlock_irqrestore(&priv->rx_lock, flags); @@ -1689,7 +1686,7 @@ static void ftdi_process_read (struct work_struct *work) /* delay processing of remainder */ schedule_delayed_work(&priv->rx_work, 1); } else { - dbg("%s - port is closed", __FUNCTION__); + dbg("%s - port is closed", __func__); } return; } @@ -1707,7 +1704,7 @@ static void ftdi_process_read (struct work_struct *work) result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); + err("%s - failed resubmitting read urb, error %d", __func__, result); } return; @@ -1736,10 +1733,10 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) FTDI_SIO_SET_DATA_REQUEST_TYPE, urb_value , priv->interface, buf, 0, WDR_TIMEOUT) < 0) { - err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state); + err("%s FAILED to enable/disable break state (state was %d)", __func__,break_state); } - dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value); + dbg("%s break state is %d - urb is %d", __func__,break_state, urb_value); } @@ -1763,18 +1760,18 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old unsigned char vstop; unsigned char vstart; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Force baud rate if this device requires it, unless it is set to B0. */ if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { - dbg("%s: forcing baud rate for this device", __FUNCTION__); + dbg("%s: forcing baud rate for this device", __func__); tty_encode_baud_rate(port->tty, priv->force_baud, priv->force_baud); } /* Force RTS-CTS if this device requires it. */ if (priv->force_rtscts) { - dbg("%s: forcing rtscts for this device", __FUNCTION__); + dbg("%s: forcing rtscts for this device", __func__); termios->c_cflag |= CRTSCTS; } @@ -1818,7 +1815,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old FTDI_SIO_SET_DATA_REQUEST_TYPE, urb_value , priv->interface, buf, 0, WDR_SHORT_TIMEOUT) < 0) { - err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); + err("%s FAILED to set databits/stopbits/parity", __func__); } /* Now do the baudrate */ @@ -1829,14 +1826,14 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 0, priv->interface, buf, 0, WDR_TIMEOUT) < 0) { - err("%s error from disable flowcontrol urb", __FUNCTION__); + err("%s error from disable flowcontrol urb", __func__); } /* Drop RTS and DTR */ clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); } else { /* set the baudrate determined before */ if (change_speed(port)) { - err("%s urb failed to set baudrate", __FUNCTION__); + err("%s urb failed to set baudrate", __func__); } /* Ensure RTS and DTR are raised when baudrate changed from 0 */ if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) { @@ -1847,7 +1844,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old /* Set flow control */ /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ if (cflag & CRTSCTS) { - dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); + dbg("%s Setting to CRTSCTS flow control", __func__); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, @@ -1865,7 +1862,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old * if IXOFF is not set, the pre-xon/xoff code is executed. */ if (iflag & IXOFF) { - dbg("%s request to enable xonxoff iflag=%04x",__FUNCTION__,iflag); + dbg("%s request to enable xonxoff iflag=%04x",__func__,iflag); // Try to enable the XON/XOFF on the ftdi_sio // Set the vstart and vstop -- could have been done up above where // a lot of other dereferencing is done but that would be very @@ -1886,7 +1883,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old } else { /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ - dbg("%s Turning off hardware flow control", __FUNCTION__); + dbg("%s Turning off hardware flow control", __func__); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, @@ -1908,7 +1905,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) unsigned char buf[2]; int ret; - dbg("%s TIOCMGET", __FUNCTION__); + dbg("%s TIOCMGET", __func__); switch (priv->chip_type) { case SIO: /* Request the status from the device */ @@ -1918,7 +1915,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 0, 0, buf, 1, WDR_TIMEOUT)) < 0 ) { - err("%s Could not get modem status of device - err: %d", __FUNCTION__, + err("%s Could not get modem status of device - err: %d", __func__, ret); return(ret); } @@ -1935,7 +1932,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 0, priv->interface, buf, 2, WDR_TIMEOUT)) < 0 ) { - err("%s Could not get modem status of device - err: %d", __FUNCTION__, + err("%s Could not get modem status of device - err: %d", __func__, ret); return(ret); } @@ -1954,7 +1951,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) { - dbg("%s TIOCMSET", __FUNCTION__); + dbg("%s TIOCMSET", __func__); return update_mctrl(port, set, clear); } @@ -1963,7 +1960,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne { struct ftdi_private *priv = usb_get_serial_port_data(port); - dbg("%s cmd 0x%04x", __FUNCTION__, cmd); + dbg("%s cmd 0x%04x", __func__, cmd); /* Based on code from acm.c and others */ switch (cmd) { @@ -2022,7 +2019,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne /* This is not necessarily an error - turns out the higher layers will do * some ioctls itself (see comment above) */ - dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd); + dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); return(-ENOIOCTLCMD); } /* ftdi_ioctl */ @@ -2033,7 +2030,7 @@ static void ftdi_throttle (struct usb_serial_port *port) struct ftdi_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->rx_lock, flags); priv->rx_flags |= THROTTLED; @@ -2047,7 +2044,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port) int actually_throttled; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->rx_lock, flags); actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; @@ -2062,7 +2059,7 @@ static int __init ftdi_init (void) { int retval; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (vendor > 0 && product > 0) { /* Add user specified VID/PID to reserved element of table. */ int i; @@ -2091,7 +2088,7 @@ failed_sio_register: static void __exit ftdi_exit (void) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); usb_deregister (&ftdi_driver); usb_serial_deregister (&ftdi_sio_device); diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c index b5194dc7d3b..e8ba2cb5995 100644 --- a/drivers/usb/serial/funsoft.c +++ b/drivers/usb/serial/funsoft.c @@ -39,9 +39,6 @@ static struct usb_serial_driver funsoft_device = { }, .id_table = id_table, .usb_driver = &funsoft_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, }; diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index d74e43d6923..8ce5a56a48e 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -280,7 +280,7 @@ static void send_to_tty(struct usb_serial_port *port, if (tty && actual_length) { usb_serial_debug_data(debug, &port->dev, - __FUNCTION__, actual_length, data); + __func__, actual_length, data); tty_buffer_request_room(tty, actual_length); tty_insert_flip_string(tty, data, actual_length); @@ -355,7 +355,7 @@ static void pkt_clear(struct garmin_data * garmin_data_p) unsigned long flags; struct garmin_packet *result = NULL; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); spin_lock_irqsave(&garmin_data_p->lock, flags); while (!list_empty(&garmin_data_p->pktlist)) { @@ -379,7 +379,7 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id) __u8 *ptr = pkt; unsigned l = 0; - dbg("%s - pkt-id: 0x%X.", __FUNCTION__, 0xFF & pkt_id); + dbg("%s - pkt-id: 0x%X.", __func__, 0xFF & pkt_id); *ptr++ = DLE; *ptr++ = ACK; @@ -429,11 +429,11 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) int size = recpkt[1]; usb_serial_debug_data(debug, &garmin_data_p->port->dev, - __FUNCTION__, count-GSP_INITIAL_OFFSET, recpkt); + __func__, count-GSP_INITIAL_OFFSET, recpkt); if (size != (count-GSP_INITIAL_OFFSET-3)) { dbg("%s - invalid size, expected %d bytes, got %d", - __FUNCTION__, size, (count-GSP_INITIAL_OFFSET-3)); + __func__, size, (count-GSP_INITIAL_OFFSET-3)); return -EINVPKT; } @@ -443,7 +443,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) // sanity check, remove after test ... if ((__u8*)&(usbdata[3]) != recpkt) { dbg("%s - ptr mismatch %p - %p", - __FUNCTION__, &(usbdata[4]), recpkt); + __func__, &(usbdata[4]), recpkt); return -EINVPKT; } @@ -454,7 +454,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) if ((0xff & (cksum + *recpkt)) != 0) { dbg("%s - invalid checksum, expected %02x, got %02x", - __FUNCTION__, 0xff & -cksum, 0xff & *recpkt); + __func__, 0xff & -cksum, 0xff & *recpkt); return -EINVPKT; } @@ -519,7 +519,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p, spin_unlock_irqrestore(&garmin_data_p->lock, flags); dbg("%s - dle=%d skip=%d size=%d count=%d", - __FUNCTION__, dleSeen, skip, size, count); + __func__, dleSeen, skip, size, count); if (size == 0) { size = GSP_INITIAL_OFFSET; @@ -578,7 +578,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p, } if (size >= GPS_IN_BUFSIZ) { - dbg("%s - packet too large.", __FUNCTION__); + dbg("%s - packet too large.", __func__); skip = 1; size = GSP_INITIAL_OFFSET; dleSeen = 0; @@ -634,7 +634,7 @@ static int gsp_send(struct garmin_data * garmin_data_p, int i=0; int k; - dbg("%s - state %d - %d bytes.", __FUNCTION__, + dbg("%s - state %d - %d bytes.", __func__, garmin_data_p->state, count); k = garmin_data_p->outsize; @@ -658,13 +658,13 @@ static int gsp_send(struct garmin_data * garmin_data_p, return 0; } - dbg("%s - %d bytes in buffer, %d bytes in pkt.", __FUNCTION__, + dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i); /* garmin_data_p->outbuffer now contains a complete packet */ usb_serial_debug_data(debug, &garmin_data_p->port->dev, - __FUNCTION__, k, garmin_data_p->outbuffer); + __func__, k, garmin_data_p->outbuffer); garmin_data_p->outsize = 0; @@ -749,7 +749,7 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p) struct garmin_packet *pkt = NULL; while ((pkt = pkt_pop(garmin_data_p)) != NULL) { - dbg("%s - next pkt: %d", __FUNCTION__, pkt->seq); + dbg("%s - next pkt: %d", __func__, pkt->seq); if (gsp_send(garmin_data_p, pkt->data, pkt->size) > 0) { kfree(pkt); return; @@ -794,7 +794,7 @@ static int nat_receive(struct garmin_data * garmin_data_p, if (len >= GPS_IN_BUFSIZ) { /* seem to be an invalid packet, ignore rest of input */ dbg("%s - packet size too large: %d", - __FUNCTION__, len); + __func__, len); garmin_data_p->insize = 0; count = 0; result = -EINVPKT; @@ -873,11 +873,11 @@ static int process_resetdev_request(struct usb_serial_port *port) spin_unlock_irqrestore(&garmin_data_p->lock, flags); usb_kill_urb (port->interrupt_in_urb); - dbg("%s - usb_reset_device", __FUNCTION__ ); + dbg("%s - usb_reset_device", __func__ ); status = usb_reset_device(port->serial->dev); if (status) dbg("%s - usb_reset_device failed: %d", - __FUNCTION__, status); + __func__, status); return status; } @@ -926,18 +926,18 @@ static int garmin_init_session(struct usb_serial_port *port) if (status == 0) { usb_kill_urb (port->interrupt_in_urb); - dbg("%s - adding interrupt input", __FUNCTION__); + dbg("%s - adding interrupt input", __func__); port->interrupt_in_urb->dev = serial->dev; status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (status) dev_err(&serial->dev->dev, "%s - failed submitting interrupt urb," " error %d\n", - __FUNCTION__, status); + __func__, status); } if (status == 0) { - dbg("%s - starting session ...", __FUNCTION__); + dbg("%s - starting session ...", __func__); garmin_data_p->state = STATE_ACTIVE; status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, sizeof(GARMIN_START_SESSION_REQ), @@ -976,7 +976,7 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp) int status = 0; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * Force low_latency on so that our tty_push actually forces the data @@ -1013,7 +1013,7 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp) struct usb_serial *serial = port->serial; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); - dbg("%s - port %d - mode=%d state=%d flags=0x%X", __FUNCTION__, + dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, port->number, garmin_data_p->mode, garmin_data_p->state, garmin_data_p->flags); @@ -1046,13 +1046,13 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp) static void garmin_write_bulk_callback (struct urb *urb) { unsigned long flags; - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int status = urb->status; if (port) { struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer) && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) { @@ -1061,7 +1061,7 @@ static void garmin_write_bulk_callback (struct urb *urb) if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, urb->status); + __func__, urb->status); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= CLEAR_HALT_REQUIRED; spin_unlock_irqrestore(&garmin_data_p->lock, flags); @@ -1088,7 +1088,7 @@ static int garmin_write_bulk (struct usb_serial_port *port, unsigned char *buffer; int status; - dbg("%s - port %d, state %d", __FUNCTION__, port->number, + dbg("%s - port %d, state %d", __func__, port->number, garmin_data_p->state); spin_lock_irqsave(&garmin_data_p->lock, flags); @@ -1110,7 +1110,7 @@ static int garmin_write_bulk (struct usb_serial_port *port, memcpy (buffer, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); usb_fill_bulk_urb (urb, serial->dev, usb_sndbulkpipe (serial->dev, @@ -1134,7 +1134,7 @@ static int garmin_write_bulk (struct usb_serial_port *port, dev_err(&port->dev, "%s - usb_submit_urb(write bulk) " "failed with status = %d\n", - __FUNCTION__, status); + __func__, status); count = status; } @@ -1154,7 +1154,7 @@ static int garmin_write (struct usb_serial_port *port, struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buf); + usb_serial_debug_data(debug, &port->dev, __func__, count, buf); /* check for our private packets */ if (count >= GARMIN_PKTHDR_LENGTH) { @@ -1172,7 +1172,7 @@ static int garmin_write (struct usb_serial_port *port, && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) { dbg("%s - processing private request %d", - __FUNCTION__, pktid); + __func__, pktid); // drop all unfinished transfers garmin_clear(garmin_data_p); @@ -1184,7 +1184,7 @@ static int garmin_write (struct usb_serial_port *port, return -EINVPKT; debug = __le32_to_cpu(privpkt[3]); dbg("%s - debug level set to 0x%X", - __FUNCTION__, debug); + __func__, debug); break; case PRIV_PKTID_SET_MODE: @@ -1192,7 +1192,7 @@ static int garmin_write (struct usb_serial_port *port, return -EINVPKT; garmin_data_p->mode = __le32_to_cpu(privpkt[3]); dbg("%s - mode set to %d", - __FUNCTION__, garmin_data_p->mode); + __func__, garmin_data_p->mode); break; case PRIV_PKTID_INFO_REQ: @@ -1208,7 +1208,7 @@ static int garmin_write (struct usb_serial_port *port, return -EINVPKT; initial_mode = __le32_to_cpu(privpkt[3]); dbg("%s - initial_mode set to %d", - __FUNCTION__, + __func__, garmin_data_p->mode); break; } @@ -1255,7 +1255,7 @@ static void garmin_read_process(struct garmin_data * garmin_data_p, { if (garmin_data_p->flags & FLAGS_DROP_DATA) { /* abort-transfer cmd is actice */ - dbg("%s - pkt dropped", __FUNCTION__); + dbg("%s - pkt dropped", __func__); } else if (garmin_data_p->state != STATE_DISCONNECTED && garmin_data_p->state != STATE_RESET ) { @@ -1286,28 +1286,28 @@ static void garmin_read_process(struct garmin_data * garmin_data_p, static void garmin_read_bulk_callback (struct urb *urb) { unsigned long flags; - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct usb_serial *serial = port->serial; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; int retval; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); + dbg("%s - bad serial pointer, exiting", __func__); return; } if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } usb_serial_debug_data(debug, &port->dev, - __FUNCTION__, urb->actual_length, data); + __func__, urb->actual_length, data); garmin_read_process(garmin_data_p, data, urb->actual_length); @@ -1320,7 +1320,7 @@ static void garmin_read_bulk_callback (struct urb *urb) if (retval) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", - __FUNCTION__, retval); + __func__, retval); } else if (urb->actual_length > 0) { /* Continue trying to read until nothing more is received */ if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) { @@ -1328,10 +1328,10 @@ static void garmin_read_bulk_callback (struct urb *urb) if (retval) dev_err(&port->dev, "%s - failed resubmitting read urb, " - "error %d\n", __FUNCTION__, retval); + "error %d\n", __func__, retval); } } else { - dbg("%s - end of bulk data", __FUNCTION__); + dbg("%s - end of bulk data", __func__); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; spin_unlock_irqrestore(&garmin_data_p->lock, flags); @@ -1344,7 +1344,7 @@ static void garmin_read_int_callback (struct urb *urb) { unsigned long flags; int retval; - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct usb_serial *serial = port->serial; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; @@ -1359,22 +1359,22 @@ static void garmin_read_int_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, urb->transfer_buffer); if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { - dbg("%s - bulk data available.", __FUNCTION__); + dbg("%s - bulk data available.", __func__); if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { @@ -1389,7 +1389,7 @@ static void garmin_read_int_callback (struct urb *urb) if (retval) { dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", - __FUNCTION__, retval); + __func__, retval); } else { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE; @@ -1417,14 +1417,14 @@ static void garmin_read_int_callback (struct urb *urb) = __le32_to_cpup((__le32*)(data+GARMIN_PKTHDR_LENGTH)); dbg("%s - start-of-session reply seen - serial %u.", - __FUNCTION__, garmin_data_p->serial_num); + __func__, garmin_data_p->serial_num); } if (garmin_data_p->ignorePkts) { /* this reply belongs to a request generated by the driver, ignore it. */ dbg("%s - pkt ignored (%d)", - __FUNCTION__, garmin_data_p->ignorePkts); + __func__, garmin_data_p->ignorePkts); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->ignorePkts--; spin_unlock_irqrestore(&garmin_data_p->lock, flags); @@ -1437,7 +1437,7 @@ static void garmin_read_int_callback (struct urb *urb) if (retval) dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", - __FUNCTION__, retval); + __func__, retval); } @@ -1473,7 +1473,7 @@ static void garmin_throttle (struct usb_serial_port *port) unsigned long flags; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* set flag, data received will be put into a queue for later processing */ spin_lock_irqsave(&garmin_data_p->lock, flags); @@ -1488,7 +1488,7 @@ static void garmin_unthrottle (struct usb_serial_port *port) struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~FLAGS_THROTTLED; spin_unlock_irqrestore(&garmin_data_p->lock, flags); @@ -1503,7 +1503,7 @@ static void garmin_unthrottle (struct usb_serial_port *port) if (status) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", - __FUNCTION__, status); + __func__, status); } } @@ -1532,11 +1532,11 @@ static int garmin_attach (struct usb_serial *serial) struct usb_serial_port *port = serial->port[0]; struct garmin_data * garmin_data_p = NULL; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); 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__); + dev_err(&port->dev, "%s - Out of memory\n", __func__); return -ENOMEM; } init_timer(&garmin_data_p->timer); @@ -1561,7 +1561,7 @@ static void garmin_shutdown (struct usb_serial *serial) struct usb_serial_port *port = serial->port[0]; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); - dbg("%s", __FUNCTION__); + dbg("%s", __func__); usb_kill_urb (port->interrupt_in_urb); del_timer_sync(&garmin_data_p->timer); @@ -1579,9 +1579,6 @@ static struct usb_serial_driver garmin_device = { .description = "Garmin GPS usb/tty", .usb_driver = &garmin_driver, .id_table = id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = garmin_open, .close = garmin_close, diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 7cfce9dabb9..537f12a027c 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -62,9 +62,6 @@ struct usb_serial_driver usb_serial_generic_device = { }, .id_table = generic_device_ids, .usb_driver = &generic_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .shutdown = usb_serial_generic_shutdown, .throttle = usb_serial_generic_throttle, @@ -121,7 +118,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) int result = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* force low_latency on so that our tty_push actually forces the data through, otherwise it is scheduled, and with high data rates (like with OHCI) data @@ -148,7 +145,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); } return result; @@ -159,7 +156,7 @@ static void generic_cleanup (struct usb_serial_port *port) { struct usb_serial *serial = port->serial; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (serial->dev) { /* shutdown any bulk reads that might be going on */ @@ -197,7 +194,7 @@ int usb_serial_generic_resume(struct usb_serial *serial) void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); generic_cleanup (port); } @@ -207,10 +204,10 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * int result; unsigned char *data; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return (0); } @@ -220,7 +217,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * spin_lock_irqsave(&port->lock, flags); if (port->write_urb_busy) { spin_unlock_irqrestore(&port->lock, flags); - dbg("%s - already writing", __FUNCTION__); + dbg("%s - already writing", __func__); return 0; } port->write_urb_busy = 1; @@ -230,7 +227,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * memcpy (port->write_urb->transfer_buffer, buf, count); data = port->write_urb->transfer_buffer; - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, data); + usb_serial_debug_data(debug, &port->dev, __func__, count, data); /* set up our urb */ usb_fill_bulk_urb (port->write_urb, serial->dev, @@ -245,7 +242,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * port->write_urb_busy = 1; result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); /* don't have to grab the lock here, as we will retry if != 0 */ port->write_urb_busy = 0; } else @@ -263,15 +260,16 @@ int usb_serial_generic_write_room (struct usb_serial_port *port) struct usb_serial *serial = port->serial; int room = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); + /* FIXME: Locking */ if (serial->num_bulk_out) { if (!(port->write_urb_busy)) room = port->bulk_out_size; } - dbg("%s - returns %d", __FUNCTION__, room); - return (room); + dbg("%s - returns %d", __func__, room); + return room; } int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) @@ -279,14 +277,15 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) struct usb_serial *serial = port->serial; int chars = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); + /* FIXME: Locking */ if (serial->num_bulk_out) { if (port->write_urb_busy) chars = port->write_urb->transfer_buffer_length; } - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return (chars); } @@ -308,7 +307,7 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) usb_serial_generic_read_bulk_callback), port); result = usb_submit_urb(urb, mem_flags); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); } /* Push data to tty layer and resubmit the bulk read URB */ @@ -332,20 +331,20 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port) void usb_serial_generic_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; int status = urb->status; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (unlikely(status != 0)) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); /* Throttle the device if requested by tty */ spin_lock_irqsave(&port->lock, flags); @@ -360,18 +359,17 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); void usb_serial_generic_write_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); port->write_urb_busy = 0; if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_port_softint(port); } EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); @@ -380,7 +378,7 @@ void usb_serial_generic_throttle (struct usb_serial_port *port) { unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* Set the throttle request flag. It will be picked up * by usb_serial_generic_read_bulk_callback(). */ @@ -394,7 +392,7 @@ void usb_serial_generic_unthrottle (struct usb_serial_port *port) int was_throttled; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* Clear the throttle flags */ spin_lock_irqsave(&port->lock, flags); @@ -412,7 +410,7 @@ void usb_serial_generic_shutdown (struct usb_serial *serial) { int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index 6c6ebae741c..75b88b356eb 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c @@ -50,9 +50,6 @@ static struct usb_serial_driver hp49gp_device = { }, .id_table = id_table, .usb_driver = &hp49gp_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, }; diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 3428ccc28da..ce2e487f324 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -371,7 +371,7 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen) struct usb_string_descriptor StringDesc; struct usb_string_descriptor *pStringDesc; - dbg("%s - USB String ID = %d", __FUNCTION__, Id ); + dbg("%s - USB String ID = %d", __func__, Id ); if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) { return 0; @@ -391,7 +391,7 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen) unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2); kfree(pStringDesc); - dbg("%s - USB String %s", __FUNCTION__, string); + dbg("%s - USB String %s", __func__, string); return strlen(string); } @@ -407,7 +407,7 @@ static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_de struct usb_string_descriptor StringDesc; struct usb_string_descriptor *pStringDesc; - dbg("%s - USB String ID = %d", __FUNCTION__, Id ); + dbg("%s - USB String ID = %d", __func__, Id ); if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) { return 0; @@ -537,7 +537,7 @@ static int get_epic_descriptor(struct edgeport_serial *ep) sizeof(struct edge_compatibility_descriptor), 300); - dbg("%s result = %d", __FUNCTION__, result); + dbg("%s result = %d", __func__, result); if (result > 0) { ep->is_epic = 1; @@ -589,7 +589,7 @@ static int get_epic_descriptor(struct edgeport_serial *ep) *****************************************************************************/ static void edge_interrupt_callback (struct urb *urb) { - struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; + struct edgeport_serial *edge_serial = urb->context; struct edgeport_port *edge_port; struct usb_serial_port *port; unsigned char *data = urb->transfer_buffer; @@ -601,7 +601,7 @@ static void edge_interrupt_callback (struct urb *urb) int result; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); switch (status) { case 0: @@ -612,35 +612,35 @@ static void edge_interrupt_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } // process this interrupt-read even if there are no ports open if (length) { - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, length, data); + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data); if (length > 1) { bytes_avail = data[0] | (data[1] << 8); if (bytes_avail) { spin_lock(&edge_serial->es_lock); edge_serial->rxBytesAvail += bytes_avail; - dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __FUNCTION__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress); + dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __func__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress); if (edge_serial->rxBytesAvail > 0 && !edge_serial->read_in_progress) { - dbg("%s - posting a read", __FUNCTION__); + dbg("%s - posting a read", __func__); edge_serial->read_in_progress = true; /* we have pending bytes on the bulk in pipe, send a request */ edge_serial->read_urb->dev = edge_serial->serial->dev; result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); if (result) { - dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __FUNCTION__, result); + dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __func__, result); edge_serial->read_in_progress = false; } } @@ -659,7 +659,7 @@ static void edge_interrupt_callback (struct urb *urb) spin_lock(&edge_port->ep_lock); edge_port->txCredits += txCredits; spin_unlock(&edge_port->ep_lock); - dbg("%s - txcredits for port%d = %d", __FUNCTION__, portNumber, edge_port->txCredits); + dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits); /* tell the tty driver that something has changed */ if (edge_port->port->tty) @@ -677,7 +677,7 @@ static void edge_interrupt_callback (struct urb *urb) exit: result = usb_submit_urb (urb, GFP_ATOMIC); if (result) { - dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, result); + dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __func__, result); } } @@ -689,49 +689,49 @@ exit: *****************************************************************************/ static void edge_bulk_in_callback (struct urb *urb) { - struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; + struct edgeport_serial *edge_serial = urb->context; unsigned char *data = urb->transfer_buffer; int retval; __u16 raw_data_length; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); edge_serial->read_in_progress = false; return; } if (urb->actual_length == 0) { - dbg("%s - read bulk callback with no data", __FUNCTION__); + dbg("%s - read bulk callback with no data", __func__); edge_serial->read_in_progress = false; return; } raw_data_length = urb->actual_length; - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, raw_data_length, data); + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, raw_data_length, data); spin_lock(&edge_serial->es_lock); /* decrement our rxBytes available by the number that we just got */ edge_serial->rxBytesAvail -= raw_data_length; - dbg("%s - Received = %d, rxBytesAvail %d", __FUNCTION__, raw_data_length, edge_serial->rxBytesAvail); + dbg("%s - Received = %d, rxBytesAvail %d", __func__, raw_data_length, edge_serial->rxBytesAvail); process_rcvd_data (edge_serial, data, urb->actual_length); /* check to see if there's any more data for us to read */ if (edge_serial->rxBytesAvail > 0) { - dbg("%s - posting a read", __FUNCTION__); + dbg("%s - posting a read", __func__); edge_serial->read_urb->dev = edge_serial->serial->dev; retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); if (retval) { dev_err(&urb->dev->dev, "%s - usb_submit_urb(read bulk) failed, " - "retval = %d\n", __FUNCTION__, retval); + "retval = %d\n", __func__, retval); edge_serial->read_in_progress = false; } } else { @@ -749,15 +749,15 @@ static void edge_bulk_in_callback (struct urb *urb) *****************************************************************************/ static void edge_bulk_out_data_callback (struct urb *urb) { - struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; + struct edgeport_port *edge_port = urb->context; struct tty_struct *tty; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); } tty = edge_port->port->tty; @@ -782,14 +782,14 @@ static void edge_bulk_out_data_callback (struct urb *urb) *****************************************************************************/ static void edge_bulk_out_cmd_callback (struct urb *urb) { - struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; + struct edgeport_port *edge_port = urb->context; struct tty_struct *tty; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); atomic_dec(&CmdUrbs); - dbg("%s - FREE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs)); + dbg("%s - FREE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs)); /* clean up the transfer buffer */ @@ -799,7 +799,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) usb_free_urb (urb); if (status) { - dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, status); + dbg("%s - nonzero write bulk status received: %d", __func__, status); return; } @@ -833,7 +833,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) struct edgeport_serial *edge_serial; int response; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return -ENODEV; @@ -883,7 +883,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) * this interrupt will continue as long as the edgeport is connected */ response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL); if (response) { - dev_err(&port->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, response); + dev_err(&port->dev, "%s - Error %d submitting control urb\n", __func__, response); } } @@ -907,7 +907,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0); if (response < 0) { - dev_err(&port->dev, "%s - error sending open port command\n", __FUNCTION__); + dev_err(&port->dev, "%s - error sending open port command\n", __func__); edge_port->openPending = false; return -ENODEV; } @@ -917,7 +917,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) if (!edge_port->open) { /* open timed out */ - dbg("%s - open timedout", __FUNCTION__); + dbg("%s - open timedout", __func__); edge_port->openPending = false; return -ENODEV; } @@ -930,7 +930,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) edge_port->txfifo.fifo = kmalloc (edge_port->maxTxCredits, GFP_KERNEL); if (!edge_port->txfifo.fifo) { - dbg("%s - no memory", __FUNCTION__); + dbg("%s - no memory", __func__); edge_close (port, filp); return -ENOMEM; } @@ -940,14 +940,14 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) edge_port->write_in_progress = false; if (!edge_port->write_urb) { - dbg("%s - no memory", __FUNCTION__); + dbg("%s - no memory", __func__); edge_close (port, filp); return -ENOMEM; } - dbg("%s(%d) - Initialize TX fifo to %d bytes", __FUNCTION__, port->number, edge_port->maxTxCredits); + dbg("%s(%d) - Initialize TX fifo to %d bytes", __func__, port->number, edge_port->maxTxCredits); - dbg("%s exited", __FUNCTION__); + dbg("%s exited", __func__); return 0; } @@ -976,11 +976,11 @@ static void block_until_chase_response(struct edgeport_port *edge_port) // Did we get our Chase response if (!edge_port->chaseResponsePending) { - dbg("%s - Got Chase Response", __FUNCTION__); + dbg("%s - Got Chase Response", __func__); // did we get all of our credit back? if (edge_port->txCredits == edge_port->maxTxCredits ) { - dbg("%s - Got all credits", __FUNCTION__); + dbg("%s - Got all credits", __func__); return; } } @@ -995,12 +995,12 @@ static void block_until_chase_response(struct edgeport_port *edge_port) loop--; if (loop == 0) { edge_port->chaseResponsePending = false; - dbg("%s - Chase TIMEOUT", __FUNCTION__); + dbg("%s - Chase TIMEOUT", __func__); return; } } else { // Reset timeout value back to 10 seconds - dbg("%s - Last %d, Current %d", __FUNCTION__, lastCredits, edge_port->txCredits); + dbg("%s - Last %d, Current %d", __func__, lastCredits, edge_port->txCredits); loop = 10; } } @@ -1031,7 +1031,7 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) // Is the Edgeport Buffer empty? if (lastCount == 0) { - dbg("%s - TX Buffer Empty", __FUNCTION__); + dbg("%s - TX Buffer Empty", __func__); return; } @@ -1040,13 +1040,13 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) schedule_timeout(timeout); finish_wait(&edge_port->wait_chase, &wait); - dbg("%s wait", __FUNCTION__); + dbg("%s wait", __func__); if (lastCount == fifo->count) { // No activity.. count down. loop--; if (loop == 0) { - dbg("%s - TIMEOUT", __FUNCTION__); + dbg("%s - TIMEOUT", __func__); return; } } else { @@ -1067,7 +1067,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) struct edgeport_port *edge_port; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); edge_serial = usb_get_serial_data(port->serial); edge_port = usb_get_serial_port_data(port); @@ -1085,7 +1085,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) /* flush and chase */ edge_port->chaseResponsePending = true; - dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); + dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); if (status == 0) { // block until chase finished @@ -1099,7 +1099,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ((edge_serial->is_epic) && (edge_serial->epic_descriptor.Supports.IOSPClose))) { /* close the port */ - dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __FUNCTION__); + dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__); send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); } @@ -1119,7 +1119,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) kfree(edge_port->txfifo.fifo); edge_port->txfifo.fifo = NULL; - dbg("%s exited", __FUNCTION__); + dbg("%s exited", __func__); } /***************************************************************************** @@ -1139,7 +1139,7 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data, int secondhalf; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return -ENODEV; @@ -1152,12 +1152,12 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data, // calculate number of bytes to put in fifo copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count)); - dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", __FUNCTION__, + dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", __func__, port->number, count, edge_port->txCredits - fifo->count, copySize); /* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */ if (copySize == 0) { - dbg("%s - copySize = Zero", __FUNCTION__); + dbg("%s - copySize = Zero", __func__); goto finish_write; } @@ -1169,11 +1169,11 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data, bytesleft = fifo->size - fifo->head; firsthalf = min (bytesleft, copySize); - dbg("%s - copy %d bytes of %d into fifo ", __FUNCTION__, firsthalf, bytesleft); + dbg("%s - copy %d bytes of %d into fifo ", __func__, firsthalf, bytesleft); /* now copy our data */ memcpy(&fifo->fifo[fifo->head], data, firsthalf); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, firsthalf, &fifo->fifo[fifo->head]); + usb_serial_debug_data(debug, &port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]); // update the index and size fifo->head += firsthalf; @@ -1187,9 +1187,9 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data, secondhalf = copySize-firsthalf; if (secondhalf) { - dbg("%s - copy rest of data %d", __FUNCTION__, secondhalf); + dbg("%s - copy rest of data %d", __func__, secondhalf); memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, secondhalf, &fifo->fifo[fifo->head]); + usb_serial_debug_data(debug, &port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]); // update the index and size fifo->count += secondhalf; fifo->head += secondhalf; @@ -1201,7 +1201,7 @@ finish_write: send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port); - dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count); + dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, copySize, edge_port->txCredits, fifo->count); return copySize; } @@ -1232,14 +1232,14 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge int secondhalf; unsigned long flags; - dbg("%s(%d)", __FUNCTION__, edge_port->port->number); + dbg("%s(%d)", __func__, edge_port->port->number); spin_lock_irqsave(&edge_port->ep_lock, flags); if (edge_port->write_in_progress || !edge_port->open || (fifo->count == 0)) { - dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __FUNCTION__, edge_port->port->number, fifo->count, edge_port->write_in_progress); + dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __func__, edge_port->port->number, fifo->count, edge_port->write_in_progress); goto exit_send; } @@ -1251,7 +1251,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge // it's better to wait for more credits so we can do a larger // write. if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) { - dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __FUNCTION__, edge_port->port->number, fifo->count, edge_port->txCredits ); + dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __func__, edge_port->port->number, fifo->count, edge_port->txCredits ); goto exit_send; } @@ -1269,7 +1269,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge count = fifo->count; buffer = kmalloc (count+2, GFP_ATOMIC); if (buffer == NULL) { - dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __FUNCTION__); + dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __func__); edge_port->write_in_progress = false; goto exit_send; } @@ -1294,7 +1294,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge } if (count) - usb_serial_debug_data(debug, &edge_port->port->dev, __FUNCTION__, count, &buffer[2]); + usb_serial_debug_data(debug, &edge_port->port->dev, __func__, count, &buffer[2]); /* fill up the urb with all of our data and submit it */ usb_fill_bulk_urb (urb, edge_serial->serial->dev, @@ -1309,14 +1309,14 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { /* something went wrong */ - dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __FUNCTION__, status); + dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __func__, status); edge_port->write_in_progress = false; /* revert the credits as something bad happened. */ edge_port->txCredits += count; edge_port->icount.tx -= count; } - dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __FUNCTION__, count, edge_port->txCredits, fifo->count); + dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __func__, count, edge_port->txCredits, fifo->count); exit_send: spin_unlock_irqrestore(&edge_port->ep_lock, flags); @@ -1337,17 +1337,17 @@ static int edge_write_room (struct usb_serial_port *port) int room; unsigned long flags; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (edge_port == NULL) return -ENODEV; if (edge_port->closePending) return -ENODEV; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!edge_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return -EINVAL; } @@ -1356,7 +1356,7 @@ static int edge_write_room (struct usb_serial_port *port) room = edge_port->txCredits - edge_port->txfifo.count; spin_unlock_irqrestore(&edge_port->ep_lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -1376,7 +1376,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) int num_chars; unsigned long flags; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (edge_port == NULL) return -ENODEV; @@ -1384,7 +1384,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) return -ENODEV; if (!edge_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return -EINVAL; } @@ -1392,7 +1392,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count; spin_unlock_irqrestore(&edge_port->ep_lock, flags); if (num_chars) { - dbg("%s(port %d) - returns %d", __FUNCTION__, port->number, num_chars); + dbg("%s(port %d) - returns %d", __func__, port->number, num_chars); } return num_chars; @@ -1410,19 +1410,19 @@ static void edge_throttle (struct usb_serial_port *port) struct tty_struct *tty; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; if (!edge_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } tty = port->tty; if (!tty) { - dbg ("%s - no tty available", __FUNCTION__); + dbg ("%s - no tty available", __func__); return; } @@ -1459,19 +1459,19 @@ static void edge_unthrottle (struct usb_serial_port *port) struct tty_struct *tty; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; if (!edge_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } tty = port->tty; if (!tty) { - dbg ("%s - no tty available", __FUNCTION__); + dbg ("%s - no tty available", __func__); return; } @@ -1509,18 +1509,18 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old unsigned int cflag; cflag = tty->termios->c_cflag; - dbg("%s - clfag %08x iflag %08x", __FUNCTION__, + dbg("%s - clfag %08x iflag %08x", __func__, tty->termios->c_cflag, tty->termios->c_iflag); - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, + dbg("%s - old clfag %08x old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; if (!edge_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } @@ -1549,7 +1549,7 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va spin_lock_irqsave(&edge_port->ep_lock, flags); if (edge_port->maxTxCredits == edge_port->txCredits && edge_port->txfifo.count == 0) { - dbg("%s -- Empty", __FUNCTION__); + dbg("%s -- Empty", __func__); result = TIOCSER_TEMT; } spin_unlock_irqrestore(&edge_port->ep_lock, flags); @@ -1569,7 +1569,7 @@ static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int result = tty->read_cnt; - dbg("%s(%d) = %d", __FUNCTION__, edge_port->port->number, result); + dbg("%s(%d) = %d", __func__, edge_port->port->number, result); if (copy_to_user(value, &result, sizeof(int))) return -EFAULT; //return 0; @@ -1581,7 +1581,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int mcr; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); mcr = edge_port->shadowMCR; if (set & TIOCM_RTS) @@ -1612,7 +1612,7 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) unsigned int msr; unsigned int mcr; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); msr = edge_port->shadowMSR; mcr = edge_port->shadowMCR; @@ -1624,7 +1624,7 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ - dbg("%s -- %x", __FUNCTION__, result); + dbg("%s -- %x", __func__, result); return result; } @@ -1670,30 +1670,30 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned struct async_icount cprev; struct serial_icounter_struct icount; - dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { // return number of bytes available case TIOCINQ: - dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); + dbg("%s (%d) TIOCINQ", __func__, port->number); return get_number_bytes_avail(edge_port, (unsigned int __user *) arg); break; case TIOCSERGETLSR: - dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); + dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); return get_lsr_info(edge_port, (unsigned int __user *) arg); return 0; case TIOCGSERIAL: - dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); + dbg("%s (%d) TIOCGSERIAL", __func__, port->number); return get_serial_info(edge_port, (struct serial_struct __user *) arg); case TIOCSSERIAL: - dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); + dbg("%s (%d) TIOCSSERIAL", __func__, port->number); break; case TIOCMIWAIT: - dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = edge_port->icount; while (1) { prepare_to_wait(&edge_port->delta_msr_wait, &wait, TASK_INTERRUPTIBLE); @@ -1732,7 +1732,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned icount.brk = cnow.brk; icount.buf_overrun = cnow.buf_overrun; - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, port->number, icount.rx, icount.tx ); + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx ); if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) return -EFAULT; return 0; @@ -1758,7 +1758,7 @@ static void edge_break (struct usb_serial_port *port, int break_state) /* flush and chase */ edge_port->chaseResponsePending = true; - dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); + dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); if (status == 0) { // block until chase finished @@ -1772,14 +1772,14 @@ static void edge_break (struct usb_serial_port *port, int break_state) ((edge_serial->is_epic) && (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { if (break_state == -1) { - dbg("%s - Sending IOSP_CMD_SET_BREAK", __FUNCTION__); + dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__); status = send_iosp_ext_cmd (edge_port, IOSP_CMD_SET_BREAK, 0); } else { - dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __FUNCTION__); + dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__); status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CLEAR_BREAK, 0); } if (status) { - dbg("%s - error sending break set/clear command.", __FUNCTION__); + dbg("%s - error sending break set/clear command.", __func__); } } @@ -1799,14 +1799,14 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha __u16 lastBufferLength; __u16 rxLen; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); lastBufferLength = bufferLength + 1; while (bufferLength > 0) { /* failsafe incase we get a message that we don't understand */ if (lastBufferLength == bufferLength) { - dbg("%s - stuck in loop, exiting it.", __FUNCTION__); + dbg("%s - stuck in loop, exiting it.", __func__); break; } lastBufferLength = bufferLength; @@ -1828,7 +1828,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha ++buffer; --bufferLength; - dbg("%s - Hdr1=%02X Hdr2=%02X", __FUNCTION__, edge_serial->rxHeader1, edge_serial->rxHeader2); + dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, edge_serial->rxHeader1, edge_serial->rxHeader2); // Process depending on whether this header is // data or status @@ -1858,7 +1858,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1); edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, edge_serial->rxHeader2); - dbg("%s - Data for Port %u Len %u", __FUNCTION__, edge_serial->rxPort, edge_serial->rxBytesRemaining); + dbg("%s - Data for Port %u Len %u", __func__, edge_serial->rxPort, edge_serial->rxBytesRemaining); //ASSERT( DevExt->RxPort < DevExt->NumPorts ); //ASSERT( DevExt->RxBytesRemaining < IOSP_MAX_DATA_LENGTH ); @@ -1891,7 +1891,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha if (edge_port->open) { tty = edge_port->port->tty; if (tty) { - dbg("%s - Sending %d bytes to TTY for port %d", __FUNCTION__, rxLen, edge_serial->rxPort); + dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort); edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); } edge_port->icount.rx += rxLen; @@ -1930,17 +1930,17 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 port = edge_serial->serial->port[edge_serial->rxPort]; edge_port = usb_get_serial_port_data(port); if (edge_port == NULL) { - dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __FUNCTION__, edge_serial->rxPort); + dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __func__, edge_serial->rxPort); return; } - dbg("%s - port %d", __FUNCTION__, edge_serial->rxPort); + dbg("%s - port %d", __func__, edge_serial->rxPort); if (code == IOSP_EXT_STATUS) { switch (byte2) { case IOSP_EXT_STATUS_CHASE_RSP: // we want to do EXT status regardless of port open/closed - dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __FUNCTION__, edge_serial->rxPort, byte3 ); + dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __func__, edge_serial->rxPort, byte3 ); // Currently, the only EXT_STATUS is Chase, so process here instead of one more call // to one more subroutine. If/when more EXT_STATUS, there'll be more work to do. // Also, we currently clear flag and close the port regardless of content of above's Byte3. @@ -1951,7 +1951,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 return; case IOSP_EXT_STATUS_RX_CHECK_RSP: - dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __FUNCTION__, edge_serial->rxPort, byte3 ); + dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3 ); //Port->RxCheckRsp = true; return; } @@ -1960,7 +1960,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 if (code == IOSP_STATUS_OPEN_RSP) { edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); edge_port->maxTxCredits = edge_port->txCredits; - dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __FUNCTION__, edge_serial->rxPort, byte2, edge_port->txCredits); + dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits); handle_new_msr (edge_port, byte2); /* send the current line settings to the port so we are in sync with any further termios calls */ @@ -1984,23 +1984,23 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 switch (code) { // Not currently sent by Edgeport case IOSP_STATUS_LSR: - dbg("%s - Port %u LSR Status = %02x", __FUNCTION__, edge_serial->rxPort, byte2); + dbg("%s - Port %u LSR Status = %02x", __func__, edge_serial->rxPort, byte2); handle_new_lsr(edge_port, false, byte2, 0); break; case IOSP_STATUS_LSR_DATA: - dbg("%s - Port %u LSR Status = %02x, Data = %02x", __FUNCTION__, edge_serial->rxPort, byte2, byte3); + dbg("%s - Port %u LSR Status = %02x, Data = %02x", __func__, edge_serial->rxPort, byte2, byte3); // byte2 is LSR Register // byte3 is broken data byte handle_new_lsr(edge_port, true, byte2, byte3); break; // // case IOSP_EXT_4_STATUS: - // dbg("%s - Port %u LSR Status = %02x Data = %02x", __FUNCTION__, edge_serial->rxPort, byte2, byte3); + // dbg("%s - Port %u LSR Status = %02x Data = %02x", __func__, edge_serial->rxPort, byte2, byte3); // break; // case IOSP_STATUS_MSR: - dbg("%s - Port %u MSR Status = %02x", __FUNCTION__, edge_serial->rxPort, byte2); + dbg("%s - Port %u MSR Status = %02x", __func__, edge_serial->rxPort, byte2); // Process this new modem status and generate appropriate // events, etc, based on the new status. This routine @@ -2009,7 +2009,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 break; default: - dbg("%s - Unrecognized IOSP status code %u\n", __FUNCTION__, code); + dbg("%s - Unrecognized IOSP status code %u\n", __func__, code); break; } @@ -2029,7 +2029,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c cnt = tty_buffer_request_room(tty, length); if (cnt < length) { dev_err(dev, "%s - dropping data, %d bytes lost\n", - __FUNCTION__, length - cnt); + __func__, length - cnt); if(cnt == 0) break; } @@ -2050,7 +2050,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr) { struct async_icount *icount; - dbg("%s %02x", __FUNCTION__, newMsr); + dbg("%s %02x", __func__, newMsr); if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { icount = &edge_port->icount; @@ -2087,7 +2087,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l __u8 newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); struct async_icount *icount; - dbg("%s - %02x", __FUNCTION__, newLsr); + dbg("%s - %02x", __func__, newLsr); edge_port->shadowLSR = lsr; @@ -2136,11 +2136,11 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u __u16 current_length; unsigned char *transfer_buffer; - dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); + dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); transfer_buffer = kmalloc (64, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64); return -ENOMEM; } @@ -2152,7 +2152,7 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u } else { current_length = length; } -// dbg("%s - writing %x, %x, %d", __FUNCTION__, extAddr, addr, current_length); +// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length); memcpy (transfer_buffer, data, current_length); result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_RAM, 0x40, addr, extAddr, transfer_buffer, current_length, 300); @@ -2181,11 +2181,11 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1 __u16 current_length; unsigned char *transfer_buffer; -// dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); +// dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); transfer_buffer = kmalloc (64, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64); return -ENOMEM; } @@ -2197,7 +2197,7 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1 } else { current_length = length; } -// dbg("%s - writing %x, %x, %d", __FUNCTION__, extAddr, addr, current_length); +// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length); memcpy (transfer_buffer, data, current_length); result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_ROM, 0x40, addr, extAddr, transfer_buffer, current_length, 300); @@ -2226,11 +2226,11 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 __u16 current_length; unsigned char *transfer_buffer; - dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); + dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); transfer_buffer = kmalloc (64, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64); return -ENOMEM; } @@ -2242,7 +2242,7 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 } else { current_length = length; } -// dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, current_length); +// dbg("%s - %x, %x, %d", __func__, extAddr, addr, current_length); result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQUEST_ION_READ_ROM, 0xC0, addr, extAddr, transfer_buffer, current_length, 300); if (result < 0) @@ -2269,11 +2269,11 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u int length = 0; int status = 0; - dbg("%s - %d, %d", __FUNCTION__, command, param); + dbg("%s - %d, %d", __func__, command, param); buffer = kmalloc (10, GFP_ATOMIC); if (!buffer) { - dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 10); + dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 10); return -ENOMEM; } @@ -2304,7 +2304,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer struct urb *urb; int timeout; - usb_serial_debug_data(debug, &edge_port->port->dev, __FUNCTION__, length, buffer); + usb_serial_debug_data(debug, &edge_port->port->dev, __func__, length, buffer); /* Allocate our next urb */ urb = usb_alloc_urb (0, GFP_ATOMIC); @@ -2312,7 +2312,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer return -ENOMEM; atomic_inc(&CmdUrbs); - dbg("%s - ALLOCATE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs)); + dbg("%s - ALLOCATE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs)); usb_fill_bulk_urb (urb, edge_serial->serial->dev, usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint), @@ -2323,7 +2323,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer if (status) { /* something went wrong */ - dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status); + dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __func__, status); usb_kill_urb(urb); usb_free_urb(urb); atomic_dec(&CmdUrbs); @@ -2337,7 +2337,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer if (edge_port->commandPending) { /* command timed out */ - dbg("%s - command timed out", __FUNCTION__); + dbg("%s - command timed out", __func__); status = -EINVAL; } #endif @@ -2367,18 +2367,18 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa return 0; } - dbg("%s - port = %d, baud = %d", __FUNCTION__, edge_port->port->number, baudRate); + dbg("%s - port = %d, baud = %d", __func__, edge_port->port->number, baudRate); status = calc_baud_rate_divisor (baudRate, &divisor); if (status) { - dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __FUNCTION__); + dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __func__); return status; } // Alloc memory for the string of commands. cmdBuffer = kmalloc (0x100, GFP_ATOMIC); if (!cmdBuffer) { - dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 0x100); + dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100); return -ENOMEM; } currCmd = cmdBuffer; @@ -2414,7 +2414,7 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor) __u16 custom; - dbg("%s - %d", __FUNCTION__, baudrate); + dbg("%s - %d", __func__, baudrate); for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { if ( divisor_table[i].BaudRate == baudrate ) { @@ -2432,7 +2432,7 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor) *divisor = custom; - dbg("%s - Baud %d = %d\n", __FUNCTION__, baudrate, custom); + dbg("%s - Baud %d = %d\n", __func__, baudrate, custom); return 0; } @@ -2452,7 +2452,7 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r unsigned long cmdLen = 0; int status; - dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __FUNCTION__, regValue); + dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __func__, regValue); if (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && @@ -2513,29 +2513,29 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi __u8 txFlow; int status; - dbg("%s - port %d", __FUNCTION__, edge_port->port->number); + dbg("%s - port %d", __func__, edge_port->port->number); if (!edge_port->open && !edge_port->openPending) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } tty = edge_port->port->tty; if ((!tty) || (!tty->termios)) { - dbg("%s - no tty structures", __FUNCTION__); + dbg("%s - no tty structures", __func__); return; } cflag = tty->termios->c_cflag; switch (cflag & CSIZE) { - case CS5: lData = LCR_BITS_5; mask = 0x1f; dbg("%s - data bits = 5", __FUNCTION__); break; - case CS6: lData = LCR_BITS_6; mask = 0x3f; dbg("%s - data bits = 6", __FUNCTION__); break; - case CS7: lData = LCR_BITS_7; mask = 0x7f; dbg("%s - data bits = 7", __FUNCTION__); break; + case CS5: lData = LCR_BITS_5; mask = 0x1f; dbg("%s - data bits = 5", __func__); break; + case CS6: lData = LCR_BITS_6; mask = 0x3f; dbg("%s - data bits = 6", __func__); break; + case CS7: lData = LCR_BITS_7; mask = 0x7f; dbg("%s - data bits = 7", __func__); break; default: - case CS8: lData = LCR_BITS_8; dbg("%s - data bits = 8", __FUNCTION__); break; + case CS8: lData = LCR_BITS_8; dbg("%s - data bits = 8", __func__); break; } lParity = LCR_PAR_NONE; @@ -2543,28 +2543,28 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi if (cflag & CMSPAR) { if (cflag & PARODD) { lParity = LCR_PAR_MARK; - dbg("%s - parity = mark", __FUNCTION__); + dbg("%s - parity = mark", __func__); } else { lParity = LCR_PAR_SPACE; - dbg("%s - parity = space", __FUNCTION__); + dbg("%s - parity = space", __func__); } } else if (cflag & PARODD) { lParity = LCR_PAR_ODD; - dbg("%s - parity = odd", __FUNCTION__); + dbg("%s - parity = odd", __func__); } else { lParity = LCR_PAR_EVEN; - dbg("%s - parity = even", __FUNCTION__); + dbg("%s - parity = even", __func__); } } else { - dbg("%s - parity = none", __FUNCTION__); + dbg("%s - parity = none", __func__); } if (cflag & CSTOPB) { lStop = LCR_STOP_2; - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); } else { lStop = LCR_STOP_1; - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); } /* figure out the flow control settings */ @@ -2572,9 +2572,9 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi if (cflag & CRTSCTS) { rxFlow |= IOSP_RX_FLOW_RTS; txFlow |= IOSP_TX_FLOW_CTS; - dbg("%s - RTS/CTS is enabled", __FUNCTION__); + dbg("%s - RTS/CTS is enabled", __func__); } else { - dbg("%s - RTS/CTS is disabled", __FUNCTION__); + dbg("%s - RTS/CTS is disabled", __func__); } /* if we are implementing XON/XOFF, set the start and stop character in the device */ @@ -2592,17 +2592,17 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi /* if we are implementing INBOUND XON/XOFF */ if (I_IXOFF(tty)) { rxFlow |= IOSP_RX_FLOW_XON_XOFF; - dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __FUNCTION__, start_char, stop_char); + dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char); } else { - dbg("%s - INBOUND XON/XOFF is disabled", __FUNCTION__); + dbg("%s - INBOUND XON/XOFF is disabled", __func__); } /* if we are implementing OUTBOUND XON/XOFF */ if (I_IXON(tty)) { txFlow |= IOSP_TX_FLOW_XON_XOFF; - dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __FUNCTION__, start_char, stop_char); + dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char); } else { - dbg("%s - OUTBOUND XON/XOFF is disabled", __FUNCTION__); + dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); } } @@ -2645,7 +2645,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi baud = 9600; } - dbg("%s - baud rate = %d", __FUNCTION__, baud); + dbg("%s - baud rate = %d", __func__, baud); status = send_cmd_write_baud_rate (edge_port, baud); if (status == -1) { /* Speed change was not possible - put back the old speed */ @@ -2843,7 +2843,7 @@ static int edge_startup (struct usb_serial *serial) /* create our private serial structure */ edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); if (edge_serial == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); return -ENOMEM; } spin_lock_init(&edge_serial->es_lock); @@ -2885,19 +2885,19 @@ static int edge_startup (struct usb_serial *serial) serial->num_ports); } - dbg("%s - time 1 %ld", __FUNCTION__, jiffies); + dbg("%s - time 1 %ld", __func__, jiffies); /* If not an EPiC device */ if (!edge_serial->is_epic) { /* now load the application firmware into this device */ load_application_firmware (edge_serial); - dbg("%s - time 2 %ld", __FUNCTION__, jiffies); + dbg("%s - time 2 %ld", __func__, jiffies); /* Check current Edgeport EEPROM and update if necessary */ update_edgeport_E2PROM (edge_serial); - dbg("%s - time 3 %ld", __FUNCTION__, jiffies); + dbg("%s - time 3 %ld", __func__, jiffies); /* set the configuration to use #1 */ // dbg("set_configuration 1"); @@ -2911,7 +2911,7 @@ static int edge_startup (struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); if (edge_port == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); for (j = 0; j < i; ++j) { kfree (usb_get_serial_port_data(serial->port[j])); usb_set_serial_port_data(serial->port[j], NULL); @@ -3017,7 +3017,7 @@ static int edge_startup (struct usb_serial *serial) * continue as long as the edgeport is connected */ response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL); if (response) - err("%s - Error %d submitting control urb", __FUNCTION__, response); + err("%s - Error %d submitting control urb", __func__, response); } return response; } @@ -3032,7 +3032,7 @@ static void edge_shutdown (struct usb_serial *serial) struct edgeport_serial *edge_serial = usb_get_serial_data(serial); int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index 6d300877254..2ec85893f27 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h @@ -111,9 +111,6 @@ static struct usb_serial_driver edgeport_2port_device = { .description = "Edgeport 2 port adapter", .usb_driver = &io_driver, .id_table = edgeport_2port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 2, .open = edge_open, .close = edge_close, @@ -142,9 +139,6 @@ static struct usb_serial_driver edgeport_4port_device = { .description = "Edgeport 4 port adapter", .usb_driver = &io_driver, .id_table = edgeport_4port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 4, .open = edge_open, .close = edge_close, @@ -173,9 +167,6 @@ static struct usb_serial_driver edgeport_8port_device = { .description = "Edgeport 8 port adapter", .usb_driver = &io_driver, .id_table = edgeport_8port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 8, .open = edge_open, .close = edge_close, @@ -203,9 +194,6 @@ static struct usb_serial_driver epic_device = { }, .description = "EPiC device", .id_table = Epic_port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = edge_open, .close = edge_close, diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index e5ea5ef6335..05e4fa73073 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -290,7 +290,7 @@ static int TIReadVendorRequestSync (struct usb_device *dev, return status; if (status != size) { dbg ("%s - wanted to write %d, but only wrote %d", - __FUNCTION__, size, status); + __func__, size, status); return -ECOMM; } return 0; @@ -320,7 +320,7 @@ static int TISendVendorRequestSync (struct usb_device *dev, return status; if (status != size) { dbg ("%s - wanted to write %d, but only wrote %d", - __FUNCTION__, size, status); + __func__, size, status); return -ECOMM; } return 0; @@ -344,7 +344,7 @@ static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask) { int port_number = port->number - port->serial->minor; - dbg ("%s - port %d, mask %x", __FUNCTION__, port_number, mask); + dbg ("%s - port %d, mask %x", __func__, port_number, mask); return TIWriteCommandSync (port->serial->dev, UMPC_PURGE_PORT, @@ -369,7 +369,7 @@ static int TIReadDownloadMemory(struct usb_device *dev, int start_address, __u8 read_length; __be16 be_start_address; - dbg ("%s - @ %x for %d", __FUNCTION__, start_address, length); + dbg ("%s - @ %x for %d", __func__, start_address, length); /* Read in blocks of 64 bytes * (TI firmware can't handle more than 64 byte reads) @@ -381,7 +381,7 @@ static int TIReadDownloadMemory(struct usb_device *dev, int start_address, read_length = (__u8)length; if (read_length > 1) { - dbg ("%s - @ %x for %d", __FUNCTION__, + dbg ("%s - @ %x for %d", __func__, start_address, read_length); } be_start_address = cpu_to_be16 (start_address); @@ -393,12 +393,12 @@ static int TIReadDownloadMemory(struct usb_device *dev, int start_address, read_length); // TransferBufferLength if (status) { - dbg ("%s - ERROR %x", __FUNCTION__, status); + dbg ("%s - ERROR %x", __func__, status); return status; } if (read_length > 1) { - usb_serial_debug_data(debug, &dev->dev, __FUNCTION__, + usb_serial_debug_data(debug, &dev->dev, __func__, read_length, buffer); } @@ -434,13 +434,13 @@ static int TIReadBootMemory (struct edgeport_serial *serial, int start_address, &buffer[i], // TransferBuffer 0x01); // TransferBufferLength if (status) { - dbg ("%s - ERROR %x", __FUNCTION__, status); + dbg ("%s - ERROR %x", __func__, status); return status; } } - dbg ("%s - start_address = %x, length = %d", __FUNCTION__, start_address, length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, length, buffer); + dbg ("%s - start_address = %x, length = %d", __func__, start_address, length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer); serial->TiReadI2C = 1; @@ -472,8 +472,8 @@ static int TIWriteBootMemory (struct edgeport_serial *serial, int start_address, return status; } - dbg ("%s - start_sddr = %x, length = %d", __FUNCTION__, start_address, length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, length, buffer); + dbg ("%s - start_sddr = %x, length = %d", __func__, start_address, length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer); return status; } @@ -494,8 +494,8 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address if (write_length > length) write_length = length; - dbg ("%s - BytesInFirstPage Addr = %x, length = %d", __FUNCTION__, start_address, write_length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, write_length, buffer); + dbg ("%s - BytesInFirstPage Addr = %x, length = %d", __func__, start_address, write_length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer); /* Write first page */ be_start_address = cpu_to_be16 (start_address); @@ -506,7 +506,7 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address buffer, // TransferBuffer write_length); if (status) { - dbg ("%s - ERROR %d", __FUNCTION__, status); + dbg ("%s - ERROR %d", __func__, status); return status; } @@ -521,8 +521,8 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address else write_length = length; - dbg ("%s - Page Write Addr = %x, length = %d", __FUNCTION__, start_address, write_length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __FUNCTION__, write_length, buffer); + dbg ("%s - Page Write Addr = %x, length = %d", __func__, start_address, write_length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer); /* Write next page */ be_start_address = cpu_to_be16 (start_address); @@ -533,7 +533,7 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address buffer, // TransferBuffer write_length); // TransferBufferLength if (status) { - dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __FUNCTION__, status); + dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __func__, status); return status; } @@ -559,7 +559,7 @@ static int TIIsTxActive (struct edgeport_port *port) oedb = kmalloc (sizeof (* oedb), GFP_KERNEL); if (!oedb) { - dev_err (&port->port->dev, "%s - out of memory\n", __FUNCTION__); + dev_err (&port->port->dev, "%s - out of memory\n", __func__); return -ENOMEM; } @@ -579,7 +579,7 @@ static int TIIsTxActive (struct edgeport_port *port) if (status) goto exit_is_tx_active; - dbg ("%s - XByteCount 0x%X", __FUNCTION__, oedb->XByteCount); + dbg ("%s - XByteCount 0x%X", __func__, oedb->XByteCount); /* and the LSR */ status = TIReadRam (port->port->serial->dev, @@ -589,7 +589,7 @@ static int TIIsTxActive (struct edgeport_port *port) if (status) goto exit_is_tx_active; - dbg ("%s - LSR = 0x%X", __FUNCTION__, *lsr); + dbg ("%s - LSR = 0x%X", __func__, *lsr); /* If either buffer has data or we are transmitting then return TRUE */ if ((oedb->XByteCount & 0x80 ) != 0 ) @@ -600,7 +600,7 @@ static int TIIsTxActive (struct edgeport_port *port) /* We return Not Active if we get any kind of error */ exit_is_tx_active: - dbg ("%s - return %d", __FUNCTION__, bytes_left ); + dbg ("%s - return %d", __func__, bytes_left ); kfree(lsr); kfree(oedb); @@ -654,7 +654,7 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f /* (TIIsTxActive doesn't seem to wait for the last byte) */ if ((baud_rate=port->baud_rate) == 0) baud_rate = 50; - msleep(max(1,(10000+baud_rate-1)/baud_rate)); + msleep(max(1, DIV_ROUND_UP(10000, baud_rate))); } static int TIChooseConfiguration (struct usb_device *dev) @@ -664,11 +664,11 @@ static int TIChooseConfiguration (struct usb_device *dev) // we want. However, we just support one config at this point, // configuration # 1, which is Config Descriptor 0. - dbg ("%s - Number of Interfaces = %d", __FUNCTION__, dev->config->desc.bNumInterfaces); - dbg ("%s - MAX Power = %d", __FUNCTION__, dev->config->desc.bMaxPower*2); + dbg ("%s - Number of Interfaces = %d", __func__, dev->config->desc.bNumInterfaces); + dbg ("%s - MAX Power = %d", __func__, dev->config->desc.bMaxPower*2); if (dev->config->desc.bNumInterfaces != 1) { - dev_err (&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __FUNCTION__); + dev_err (&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__); return -ENODEV; } @@ -751,7 +751,7 @@ static int ValidChecksum(struct ti_i2c_desc *rom_desc, __u8 *buffer) cs = (__u8)(cs + buffer[i]); } if (cs != rom_desc->CheckSum) { - dbg ("%s - Mismatch %x - %x", __FUNCTION__, rom_desc->CheckSum, cs); + dbg ("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); return -EINVAL; } return 0; @@ -769,12 +769,12 @@ static int TiValidateI2cImage (struct edgeport_serial *serial) rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); if (!rom_desc) { - dev_err (dev, "%s - out of memory\n", __FUNCTION__); + dev_err (dev, "%s - out of memory\n", __func__); return -ENOMEM; } buffer = kmalloc (TI_MAX_I2C_SIZE, GFP_KERNEL); if (!buffer) { - dev_err (dev, "%s - out of memory when allocating buffer\n", __FUNCTION__); + dev_err (dev, "%s - out of memory when allocating buffer\n", __func__); kfree (rom_desc); return -ENOMEM; } @@ -785,7 +785,7 @@ static int TiValidateI2cImage (struct edgeport_serial *serial) goto ExitTiValidateI2cImage; if (*buffer != UMP5152 && *buffer != UMP3410) { - dev_err (dev, "%s - invalid buffer signature\n", __FUNCTION__); + dev_err (dev, "%s - invalid buffer signature\n", __func__); status = -ENODEV; goto ExitTiValidateI2cImage; } @@ -801,11 +801,11 @@ static int TiValidateI2cImage (struct edgeport_serial *serial) if ((start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size) > TI_MAX_I2C_SIZE) { status = -ENODEV; - dbg ("%s - structure too big, erroring out.", __FUNCTION__); + dbg ("%s - structure too big, erroring out.", __func__); break; } - dbg ("%s Type = 0x%x", __FUNCTION__, rom_desc->Type); + dbg ("%s Type = 0x%x", __func__, rom_desc->Type); // Skip type 2 record ttype = rom_desc->Type & 0x0f; @@ -845,13 +845,13 @@ static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer) rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); if (!rom_desc) { - dev_err (&serial->serial->dev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err (&serial->serial->dev->dev, "%s - out of memory\n", __func__); return -ENOMEM; } start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_ION, rom_desc); if (!start_address) { - dbg ("%s - Edge Descriptor not found in I2C", __FUNCTION__); + dbg ("%s - Edge Descriptor not found in I2C", __func__); status = -ENODEV; goto exit; } @@ -867,12 +867,12 @@ static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer) status = ValidChecksum(rom_desc, buffer); desc = (struct edge_ti_manuf_descriptor *)buffer; - dbg ( "%s - IonConfig 0x%x", __FUNCTION__, desc->IonConfig ); - dbg ( "%s - Version %d", __FUNCTION__, desc->Version ); - dbg ( "%s - Cpu/Board 0x%x", __FUNCTION__, desc->CpuRev_BoardRev ); - dbg ( "%s - NumPorts %d", __FUNCTION__, desc->NumPorts ); - dbg ( "%s - NumVirtualPorts %d", __FUNCTION__, desc->NumVirtualPorts ); - dbg ( "%s - TotalPorts %d", __FUNCTION__, desc->TotalPorts ); + dbg ( "%s - IonConfig 0x%x", __func__, desc->IonConfig ); + dbg ( "%s - Version %d", __func__, desc->Version ); + dbg ( "%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev ); + dbg ( "%s - NumPorts %d", __func__, desc->NumPorts ); + dbg ( "%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts ); + dbg ( "%s - TotalPorts %d", __func__, desc->TotalPorts ); exit: kfree (rom_desc); @@ -902,7 +902,7 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) buffer = kmalloc (buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (dev, "%s - out of memory\n", __FUNCTION__); + dev_err (dev, "%s - out of memory\n", __func__); return -ENOMEM; } @@ -955,11 +955,11 @@ static int TIGetI2cTypeInBootMode (struct edgeport_serial *serial) &data, // TransferBuffer 0x01); // TransferBufferLength if (status) - dbg ("%s - read 2 status error = %d", __FUNCTION__, status); + dbg ("%s - read 2 status error = %d", __func__, status); else - dbg ("%s - read 2 data = 0x%x", __FUNCTION__, data); + dbg ("%s - read 2 data = 0x%x", __func__, data); if ((!status) && (data == UMP5152 || data == UMP3410)) { - dbg ("%s - ROM_TYPE_II", __FUNCTION__); + dbg ("%s - ROM_TYPE_II", __func__); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; return 0; } @@ -972,16 +972,16 @@ static int TIGetI2cTypeInBootMode (struct edgeport_serial *serial) &data, // TransferBuffer 0x01); // TransferBufferLength if (status) - dbg ("%s - read 3 status error = %d", __FUNCTION__, status); + dbg ("%s - read 3 status error = %d", __func__, status); else - dbg ("%s - read 2 data = 0x%x", __FUNCTION__, data); + dbg ("%s - read 2 data = 0x%x", __func__, data); if ((!status) && (data == UMP5152 || data == UMP3410)) { - dbg ("%s - ROM_TYPE_III", __FUNCTION__); + dbg ("%s - ROM_TYPE_III", __func__); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; return 0; } - dbg ("%s - Unknown", __FUNCTION__); + dbg ("%s - Unknown", __func__); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; return -ENODEV; } @@ -1063,7 +1063,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) interface = &serial->serial->interface->cur_altsetting->desc; if (!interface) { - dev_err (dev, "%s - no interface set, error!\n", __FUNCTION__); + dev_err (dev, "%s - no interface set, error!\n", __func__); return -ENODEV; } @@ -1086,12 +1086,11 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { struct ti_i2c_desc *rom_desc; - dbg ("%s - <<<<<<<<<<<<<<<RUNNING IN DOWNLOAD MODE>>>>>>>>>>", __FUNCTION__); + dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); status = TiValidateI2cImage (serial); if (status) { - dbg ("%s - <<<<<<<<<<<<<<<DOWNLOAD MODE -- BAD I2C >>>>>>>>>>", - __FUNCTION__); + dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); return status; } @@ -1100,7 +1099,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) */ ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); if (!ti_manuf_desc) { - dev_err (dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (dev, "%s - out of memory.\n", __func__); return -ENOMEM; } status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); @@ -1111,7 +1110,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) // Check version number of ION descriptor if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { - dbg ( "%s - Wrong CPU Rev %d (Must be 2)", __FUNCTION__, + dbg ( "%s - Wrong CPU Rev %d (Must be 2)", __func__, TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); kfree (ti_manuf_desc); return -EINVAL; @@ -1119,7 +1118,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); if (!rom_desc) { - dev_err (dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (dev, "%s - out of memory.\n", __func__); kfree (ti_manuf_desc); return -ENOMEM; } @@ -1129,11 +1128,11 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) struct ti_i2c_firmware_rec *firmware_version; __u8 record; - dbg ("%s - Found Type FIRMWARE (Type 2) record", __FUNCTION__); + dbg ("%s - Found Type FIRMWARE (Type 2) record", __func__); firmware_version = kmalloc (sizeof (*firmware_version), GFP_KERNEL); if (!firmware_version) { - dev_err (dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (dev, "%s - out of memory.\n", __func__); kfree (rom_desc); kfree (ti_manuf_desc); return -ENOMEM; @@ -1159,7 +1158,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) (OperationalCodeImageVersion.MinorVersion); dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d", - __FUNCTION__, + __func__, firmware_version->Ver_Major, firmware_version->Ver_Minor, OperationalCodeImageVersion.MajorVersion, @@ -1168,7 +1167,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) // Check if we have an old version in the I2C and update if necessary if (download_cur_ver != download_new_ver) { dbg ("%s - Update I2C Download from %d.%d to %d.%d", - __FUNCTION__, + __func__, firmware_version->Ver_Major, firmware_version->Ver_Minor, OperationalCodeImageVersion.MajorVersion, @@ -1210,14 +1209,14 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) } if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { - dev_err (dev, "%s - error resetting device\n", __FUNCTION__); + dev_err (dev, "%s - error resetting device\n", __func__); kfree (firmware_version); kfree (rom_desc); kfree (ti_manuf_desc); return -ENODEV; } - dbg ("%s - HARDWARE RESET", __FUNCTION__); + dbg ("%s - HARDWARE RESET", __func__); // Reset UMP -- Back to BOOT MODE status = TISendVendorRequestSync (serial->serial->dev, @@ -1227,7 +1226,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) NULL, // TransferBuffer 0); // TransferBufferLength - dbg ( "%s - HARDWARE RESET return %d", __FUNCTION__, status); + dbg ( "%s - HARDWARE RESET return %d", __func__, status); /* return an error on purpose. */ kfree (firmware_version); @@ -1245,7 +1244,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) header = kmalloc (HEADER_SIZE, GFP_KERNEL); if (!header) { - dev_err (dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (dev, "%s - out of memory.\n", __func__); kfree (rom_desc); kfree (ti_manuf_desc); return -ENOMEM; @@ -1253,14 +1252,14 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) vheader = kmalloc (HEADER_SIZE, GFP_KERNEL); if (!vheader) { - dev_err (dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (dev, "%s - out of memory.\n", __func__); kfree (header); kfree (rom_desc); kfree (ti_manuf_desc); return -ENOMEM; } - dbg ("%s - Found Type BLANK FIRMWARE (Type F2) record", __FUNCTION__); + dbg ("%s - Found Type BLANK FIRMWARE (Type F2) record", __func__); // In order to update the I2C firmware we must change the type 2 record to type 0xF2. // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver @@ -1298,7 +1297,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) vheader); if (status) { - dbg ("%s - can't read header back", __FUNCTION__); + dbg ("%s - can't read header back", __func__); kfree (vheader); kfree (header); kfree (rom_desc); @@ -1306,7 +1305,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) return status; } if (memcmp(vheader, header, HEADER_SIZE)) { - dbg ("%s - write download record failed", __FUNCTION__); + dbg ("%s - write download record failed", __func__); kfree (vheader); kfree (header); kfree (rom_desc); @@ -1317,7 +1316,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) kfree (vheader); kfree (header); - dbg ("%s - Start firmware update", __FUNCTION__); + dbg ("%s - Start firmware update", __func__); // Tell firmware to copy download image into I2C status = TISendVendorRequestSync (serial->serial->dev, @@ -1327,9 +1326,9 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) NULL, // TransferBuffer 0); // TransferBufferLength - dbg ("%s - Update complete 0x%x", __FUNCTION__, status); + dbg ("%s - Update complete 0x%x", __func__, status); if (status) { - dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __FUNCTION__); + dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __func__); kfree (rom_desc); kfree (ti_manuf_desc); return status; @@ -1345,8 +1344,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) /********************************************************************/ /* Boot Mode */ /********************************************************************/ - dbg ("%s - <<<<<<<<<<<<<<<RUNNING IN BOOT MODE>>>>>>>>>>>>>>>", - __FUNCTION__); + dbg("%s - RUNNING IN BOOT MODE", __func__); // Configure the TI device so we can use the BULK pipes for download status = TIConfigureBootDevice (serial->serial->dev); @@ -1354,7 +1352,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) return status; if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) != USB_VENDOR_ID_ION) { - dbg ("%s - VID = 0x%x", __FUNCTION__, + dbg ("%s - VID = 0x%x", __func__, le16_to_cpu(serial->serial->dev->descriptor.idVendor)); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; goto StayInBootMode; @@ -1368,7 +1366,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) // Registry variable set? if (TIStayInBootMode) { - dbg ("%s - TIStayInBootMode", __FUNCTION__); + dbg ("%s - TIStayInBootMode", __func__); goto StayInBootMode; } @@ -1385,7 +1383,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) */ ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); if (!ti_manuf_desc) { - dev_err (dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (dev, "%s - out of memory.\n", __func__); return -ENOMEM; } status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); @@ -1396,7 +1394,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) // Check for version 2 if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { - dbg ("%s - Wrong CPU Rev %d (Must be 2)", __FUNCTION__, + dbg ("%s - Wrong CPU Rev %d (Must be 2)", __func__, TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); kfree (ti_manuf_desc); goto StayInBootMode; @@ -1420,7 +1418,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) buffer_size = (((1024 * 16) - 512) + sizeof(struct ti_i2c_image_header)); buffer = kmalloc (buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (dev, "%s - out of memory\n", __FUNCTION__); + dev_err (dev, "%s - out of memory\n", __func__); return -ENOMEM; } @@ -1440,20 +1438,20 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) header->CheckSum = cs; // Download the operational code - dbg ("%s - Downloading operational code image (TI UMP)", __FUNCTION__); + dbg ("%s - Downloading operational code image (TI UMP)", __func__); status = TIDownloadCodeImage (serial, buffer, buffer_size); kfree (buffer); if (status) { - dbg ("%s - Error downloading operational code image", __FUNCTION__); + dbg ("%s - Error downloading operational code image", __func__); return status; } // Device will reboot serial->product_info.TiMode = TI_MODE_TRANSITIONING; - dbg ("%s - Download successful -- Device rebooting...", __FUNCTION__); + dbg ("%s - Download successful -- Device rebooting...", __func__); /* return an error on purpose */ return -ENODEV; @@ -1461,7 +1459,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) StayInBootMode: // Eprom is invalid or blank stay in boot mode - dbg ("%s - <<<<<<<<<<<<<<<STAYING IN BOOT MODE>>>>>>>>>>>>", __FUNCTION__); + dbg("%s - STAYING IN BOOT MODE", __func__); serial->product_info.TiMode = TI_MODE_BOOT; return 0; @@ -1472,7 +1470,7 @@ static int TISetDtr (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); port->shadow_mcr |= MCR_DTR; return TIWriteCommandSync (port->port->serial->dev, @@ -1487,7 +1485,7 @@ static int TIClearDtr (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); port->shadow_mcr &= ~MCR_DTR; return TIWriteCommandSync (port->port->serial->dev, @@ -1502,7 +1500,7 @@ static int TISetRts (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); port->shadow_mcr |= MCR_RTS; return TIWriteCommandSync (port->port->serial->dev, @@ -1517,7 +1515,7 @@ static int TIClearRts (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); port->shadow_mcr &= ~MCR_RTS; return TIWriteCommandSync (port->port->serial->dev, @@ -1532,7 +1530,7 @@ static int TISetLoopBack (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); return TIWriteCommandSync (port->port->serial->dev, UMPC_SET_CLR_LOOPBACK, @@ -1546,7 +1544,7 @@ static int TIClearLoopBack (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); return TIWriteCommandSync (port->port->serial->dev, UMPC_SET_CLR_LOOPBACK, @@ -1560,7 +1558,7 @@ static int TISetBreak (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); return TIWriteCommandSync (port->port->serial->dev, UMPC_SET_CLR_BREAK, @@ -1574,7 +1572,7 @@ static int TIClearBreak (struct edgeport_port *port) { int port_number = port->port->number - port->port->serial->minor; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); return TIWriteCommandSync (port->port->serial->dev, UMPC_SET_CLR_BREAK, @@ -1588,7 +1586,7 @@ static int TIRestoreMCR (struct edgeport_port *port, __u8 mcr) { int status = 0; - dbg ("%s - %x", __FUNCTION__, mcr); + dbg ("%s - %x", __func__, mcr); if (mcr & MCR_DTR) status = TISetDtr (port); @@ -1642,7 +1640,7 @@ static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) struct async_icount *icount; struct tty_struct *tty; - dbg ("%s - %02x", __FUNCTION__, msr); + dbg ("%s - %02x", __func__, msr); if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { icount = &edge_port->icount; @@ -1681,7 +1679,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8 struct async_icount *icount; __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); - dbg ("%s - %02x", __FUNCTION__, new_lsr); + dbg ("%s - %02x", __func__, new_lsr); edge_port->shadow_lsr = lsr; @@ -1712,7 +1710,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8 static void edge_interrupt_callback (struct urb *urb) { - struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; + struct edgeport_serial *edge_serial = urb->context; struct usb_serial_port *port; struct edgeport_port *edge_port; unsigned char *data = urb->transfer_buffer; @@ -1724,7 +1722,7 @@ static void edge_interrupt_callback (struct urb *urb) __u8 msr; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); switch (status) { case 0: @@ -1735,34 +1733,34 @@ static void edge_interrupt_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dev_err(&urb->dev->dev, "%s - nonzero urb status received: " - "%d\n", __FUNCTION__, status); + "%d\n", __func__, status); goto exit; } if (!length) { - dbg ("%s - no data in urb", __FUNCTION__); + dbg ("%s - no data in urb", __func__); goto exit; } - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, length, data); + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data); if (length != 2) { - dbg ("%s - expecting packet of size 2, got %d", __FUNCTION__, length); + dbg ("%s - expecting packet of size 2, got %d", __func__, length); goto exit; } port_number = TIUMP_GET_PORT_FROM_CODE (data[0]); function = TIUMP_GET_FUNC_FROM_CODE (data[0]); dbg ("%s - port_number %d, function %d, info 0x%x", - __FUNCTION__, port_number, function, data[1]); + __func__, port_number, function, data[1]); port = edge_serial->serial->port[port_number]; edge_port = usb_get_serial_port_data(port); if (!edge_port) { - dbg ("%s - edge_port not found", __FUNCTION__); + dbg ("%s - edge_port not found", __func__); return; } switch (function) { @@ -1771,12 +1769,12 @@ static void edge_interrupt_callback (struct urb *urb) if (lsr & UMP_UART_LSR_DATA_MASK) { /* Save the LSR event for bulk read completion routine */ dbg ("%s - LSR Event Port %u LSR Status = %02x", - __FUNCTION__, port_number, lsr); + __func__, port_number, lsr); edge_port->lsr_event = 1; edge_port->lsr_mask = lsr; } else { dbg ("%s - ===== Port %d LSR Status = %02x ======", - __FUNCTION__, port_number, lsr); + __func__, port_number, lsr); handle_new_lsr (edge_port, 0, lsr, 0); } break; @@ -1785,13 +1783,13 @@ static void edge_interrupt_callback (struct urb *urb) /* Copy MSR from UMP */ msr = data[1]; dbg ("%s - ===== Port %u MSR Status = %02x ======\n", - __FUNCTION__, port_number, msr); + __func__, port_number, msr); handle_new_msr (edge_port, msr); break; default: dev_err (&urb->dev->dev, "%s - Unknown Interrupt code from UMP %x\n", - __FUNCTION__, data[1]); + __func__, data[1]); break; } @@ -1800,19 +1798,19 @@ exit: retval = usb_submit_urb (urb, GFP_ATOMIC); if (retval) dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", - __FUNCTION__, retval); + __func__, retval); } static void edge_bulk_in_callback (struct urb *urb) { - struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; + struct edgeport_port *edge_port = urb->context; unsigned char *data = urb->transfer_buffer; struct tty_struct *tty; int retval = 0; int port_number; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); switch (status) { case 0: @@ -1823,18 +1821,18 @@ static void edge_bulk_in_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dev_err (&urb->dev->dev,"%s - nonzero read bulk status received: %d\n", - __FUNCTION__, status); + __func__, status); } if (status == -EPIPE) goto exit; if (status) { - dev_err(&urb->dev->dev,"%s - stopping read!\n", __FUNCTION__); + dev_err(&urb->dev->dev,"%s - stopping read!\n", __func__); return; } @@ -1843,7 +1841,7 @@ static void edge_bulk_in_callback (struct urb *urb) if (edge_port->lsr_event) { edge_port->lsr_event = 0; dbg ("%s ===== Port %u LSR Status = %02x, Data = %02x ======", - __FUNCTION__, port_number, edge_port->lsr_mask, *data); + __func__, port_number, edge_port->lsr_mask, *data); handle_new_lsr (edge_port, 1, edge_port->lsr_mask, *data); /* Adjust buffer length/pointer */ --urb->actual_length; @@ -1852,10 +1850,10 @@ static void edge_bulk_in_callback (struct urb *urb) tty = edge_port->port->tty; if (tty && urb->actual_length) { - usb_serial_debug_data(debug, &edge_port->port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &edge_port->port->dev, __func__, urb->actual_length, data); if (edge_port->close_pending) { - dbg ("%s - close is pending, dropping data on the floor.", __FUNCTION__); + dbg ("%s - close is pending, dropping data on the floor.", __func__); } else { edge_tty_recv(&edge_port->port->dev, tty, data, urb->actual_length); } @@ -1874,7 +1872,7 @@ exit: spin_unlock(&edge_port->ep_lock); if (retval) dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", - __FUNCTION__, retval); + __func__, retval); } static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length) @@ -1885,7 +1883,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c cnt = tty_buffer_request_room(tty, length); if (cnt < length) { dev_err(dev, "%s - dropping data, %d bytes lost\n", - __FUNCTION__, length - cnt); + __func__, length - cnt); if(cnt == 0) break; } @@ -1899,11 +1897,11 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c static void edge_bulk_out_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status = urb->status; - dbg ("%s - port %d", __FUNCTION__, port->number); + dbg ("%s - port %d", __func__, port->number); edge_port->ep_write_urb_in_use = 0; @@ -1916,11 +1914,11 @@ static void edge_bulk_out_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dev_err(&urb->dev->dev, "%s - nonzero write bulk status " - "received: %d\n", __FUNCTION__, status); + "received: %d\n", __func__, status); } /* send any buffered data */ @@ -1938,13 +1936,12 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) u16 open_settings; u8 transaction_timeout; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return -ENODEV; - if (port->tty) - port->tty->low_latency = low_latency; + port->tty->low_latency = low_latency; port_number = port->number - port->serial->minor; switch (port_number) { @@ -1962,7 +1959,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) } dbg ("%s - port_number = %d, uart_base = %04x, dma_address = %04x", - __FUNCTION__, port_number, edge_port->uart_base, edge_port->dma_address); + __func__, port_number, edge_port->uart_base, edge_port->dma_address); dev = port->serial->dev; @@ -1973,7 +1970,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) status = TIClearLoopBack (edge_port); if (status) { dev_err(&port->dev,"%s - cannot send clear loopback command, %d\n", - __FUNCTION__, status); + __func__, status); return status; } @@ -1992,7 +1989,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) UMP_PIPE_TRANS_TIMEOUT_ENA | (transaction_timeout << 2)); - dbg ("%s - Sending UMPC_OPEN_PORT", __FUNCTION__); + dbg ("%s - Sending UMPC_OPEN_PORT", __func__); /* Tell TI to open and start the port */ status = TIWriteCommandSync (dev, @@ -2002,7 +1999,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) NULL, 0); if (status) { - dev_err(&port->dev,"%s - cannot send open command, %d\n", __FUNCTION__, status); + dev_err(&port->dev,"%s - cannot send open command, %d\n", __func__, status); return status; } @@ -2014,14 +2011,14 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) NULL, 0); if (status) { - dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __FUNCTION__, status); + dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __func__, status); return status; } /* Clear TX and RX buffers in UMP */ status = TIPurgeDataSync (port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); if (status) { - dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __FUNCTION__, status); + dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __func__, status); return status; } @@ -2033,7 +2030,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) &edge_port->shadow_msr, // TransferBuffer 1); // TransferBufferLength if (status) { - dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __FUNCTION__, status); + dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __func__, status); return status; } @@ -2050,7 +2047,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) /* we are the first port to be opened, let's post the interrupt urb */ urb = edge_serial->serial->port[0]->interrupt_in_urb; if (!urb) { - dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); + dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __func__); status = -EINVAL; goto release_es_lock; } @@ -2059,7 +2056,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) urb->dev = dev; status = usb_submit_urb (urb, GFP_KERNEL); if (status) { - dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); + dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __func__, status); goto release_es_lock; } } @@ -2074,7 +2071,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) /* start up our bulk read urb */ urb = port->read_urb; if (!urb) { - dev_err (&port->dev, "%s - no read urb present, exiting\n", __FUNCTION__); + dev_err (&port->dev, "%s - no read urb present, exiting\n", __func__); status = -EINVAL; goto unlink_int_urb; } @@ -2084,13 +2081,13 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) urb->dev = dev; status = usb_submit_urb (urb, GFP_KERNEL); if (status) { - dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status); + dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status); goto unlink_int_urb; } ++edge_serial->num_ports_open; - dbg("%s - exited", __FUNCTION__); + dbg("%s - exited", __func__); goto release_es_lock; @@ -2109,7 +2106,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) int port_number; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); edge_serial = usb_get_serial_data(port->serial); edge_port = usb_get_serial_port_data(port); @@ -2129,7 +2126,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) /* assuming we can still talk to the device, * send a close port command to it */ - dbg("%s - send umpc_close_port", __FUNCTION__); + dbg("%s - send umpc_close_port", __func__); port_number = port->number - port->serial->minor; status = TIWriteCommandSync (port->serial->dev, UMPC_CLOSE_PORT, @@ -2147,7 +2144,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) mutex_unlock(&edge_serial->es_lock); edge_port->close_pending = 0; - dbg("%s - exited", __FUNCTION__); + dbg("%s - exited", __func__); } static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) @@ -2155,10 +2152,10 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data, struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return 0; } @@ -2184,7 +2181,7 @@ static void edge_send(struct usb_serial_port *port) unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&edge_port->ep_lock, flags); @@ -2206,7 +2203,7 @@ static void edge_send(struct usb_serial_port *port) spin_unlock_irqrestore(&edge_port->ep_lock, flags); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); /* set up our urb */ usb_fill_bulk_urb (port->write_urb, port->serial->dev, @@ -2219,7 +2216,7 @@ static void edge_send(struct usb_serial_port *port) /* send the data out the bulk port */ result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); edge_port->ep_write_urb_in_use = 0; // TODO: reschedule edge_send } else { @@ -2240,7 +2237,7 @@ static int edge_write_room (struct usb_serial_port *port) int room = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return -ENODEV; @@ -2251,7 +2248,7 @@ static int edge_write_room (struct usb_serial_port *port) room = edge_buf_space_avail(edge_port->ep_out_buf); spin_unlock_irqrestore(&edge_port->ep_lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -2261,7 +2258,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) int chars = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return -ENODEV; @@ -2272,7 +2269,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) chars = edge_buf_data_avail(edge_port->ep_out_buf); spin_unlock_irqrestore(&edge_port->ep_lock, flags); - dbg ("%s - returns %d", __FUNCTION__, chars); + dbg ("%s - returns %d", __func__, chars); return chars; } @@ -2282,14 +2279,14 @@ static void edge_throttle (struct usb_serial_port *port) struct tty_struct *tty; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; tty = port->tty; if (!tty) { - dbg ("%s - no tty available", __FUNCTION__); + dbg ("%s - no tty available", __func__); return; } @@ -2298,7 +2295,7 @@ static void edge_throttle (struct usb_serial_port *port) unsigned char stop_char = STOP_CHAR(tty); status = edge_write (port, &stop_char, 1); if (status <= 0) { - dev_err(&port->dev, "%s - failed to write stop character, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status); } } @@ -2315,14 +2312,14 @@ static void edge_unthrottle (struct usb_serial_port *port) struct tty_struct *tty; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; tty = port->tty; if (!tty) { - dbg ("%s - no tty available", __FUNCTION__); + dbg ("%s - no tty available", __func__); return; } @@ -2331,7 +2328,7 @@ static void edge_unthrottle (struct usb_serial_port *port) unsigned char start_char = START_CHAR(tty); status = edge_write (port, &start_char, 1); if (status <= 0) { - dev_err(&port->dev, "%s - failed to write start character, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); } } @@ -2340,7 +2337,7 @@ static void edge_unthrottle (struct usb_serial_port *port) if (C_CRTSCTS(tty)) { status = restart_read(edge_port); if (status) - dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status); } } @@ -2390,13 +2387,13 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi int status; int port_number = edge_port->port->number - edge_port->port->serial->minor; - dbg("%s - port %d", __FUNCTION__, edge_port->port->number); + dbg("%s - port %d", __func__, edge_port->port->number); tty = edge_port->port->tty; config = kmalloc (sizeof (*config), GFP_KERNEL); if (!config) { - dev_err (&edge_port->port->dev, "%s - out of memory\n", __FUNCTION__); + dev_err (&edge_port->port->dev, "%s - out of memory\n", __func__); return; } @@ -2412,20 +2409,20 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi switch (cflag & CSIZE) { case CS5: config->bDataBits = UMP_UART_CHAR5BITS; - dbg ("%s - data bits = 5", __FUNCTION__); + dbg ("%s - data bits = 5", __func__); break; case CS6: config->bDataBits = UMP_UART_CHAR6BITS; - dbg ("%s - data bits = 6", __FUNCTION__); + dbg ("%s - data bits = 6", __func__); break; case CS7: config->bDataBits = UMP_UART_CHAR7BITS; - dbg ("%s - data bits = 7", __FUNCTION__); + dbg ("%s - data bits = 7", __func__); break; default: case CS8: config->bDataBits = UMP_UART_CHAR8BITS; - dbg ("%s - data bits = 8", __FUNCTION__); + dbg ("%s - data bits = 8", __func__); break; } @@ -2433,32 +2430,32 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi if (cflag & PARODD) { config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; config->bParity = UMP_UART_ODDPARITY; - dbg("%s - parity = odd", __FUNCTION__); + dbg("%s - parity = odd", __func__); } else { config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; config->bParity = UMP_UART_EVENPARITY; - dbg("%s - parity = even", __FUNCTION__); + dbg("%s - parity = even", __func__); } } else { config->bParity = UMP_UART_NOPARITY; - dbg("%s - parity = none", __FUNCTION__); + dbg("%s - parity = none", __func__); } if (cflag & CSTOPB) { config->bStopBits = UMP_UART_STOPBIT2; - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); } else { config->bStopBits = UMP_UART_STOPBIT1; - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); } /* figure out the flow control settings */ if (cflag & CRTSCTS) { config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; - dbg("%s - RTS/CTS is enabled", __FUNCTION__); + dbg("%s - RTS/CTS is enabled", __func__); } else { - dbg("%s - RTS/CTS is disabled", __FUNCTION__); + dbg("%s - RTS/CTS is disabled", __func__); tty->hw_stopped = 0; restart_read(edge_port); } @@ -2472,18 +2469,18 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi if (I_IXOFF(tty)) { config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", - __FUNCTION__, config->cXon, config->cXoff); + __func__, config->cXon, config->cXoff); } else { - dbg ("%s - INBOUND XON/XOFF is disabled", __FUNCTION__); + dbg ("%s - INBOUND XON/XOFF is disabled", __func__); } /* if we are implementing OUTBOUND XON/XOFF */ if (I_IXON(tty)) { config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", - __FUNCTION__, config->cXon, config->cXoff); + __func__, config->cXon, config->cXoff); } else { - dbg ("%s - OUTBOUND XON/XOFF is disabled", __FUNCTION__); + dbg ("%s - OUTBOUND XON/XOFF is disabled", __func__); } } @@ -2502,7 +2499,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi /* FIXME: Recompute actual baud from divisor here */ - dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate); + dbg ("%s - baud rate = %d, wBaudRate = %d", __func__, baud, config->wBaudRate); dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); dbg ("wFlags: 0x%x", config->wFlags); @@ -2525,7 +2522,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi sizeof(*config)); if (status) { dbg ("%s - error %d when trying to write config to device", - __FUNCTION__, status); + __func__, status); } kfree (config); @@ -2541,12 +2538,12 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old cflag = tty->termios->c_cflag; - dbg("%s - clfag %08x iflag %08x", __FUNCTION__, + dbg("%s - clfag %08x iflag %08x", __func__, tty->termios->c_cflag, tty->termios->c_iflag); - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, + dbg("%s - old clfag %08x old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; @@ -2561,9 +2558,11 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig { struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int mcr; + unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); + spin_lock_irqsave(&edge_port->ep_lock, flags); mcr = edge_port->shadow_mcr; if (set & TIOCM_RTS) mcr |= MCR_RTS; @@ -2580,6 +2579,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig mcr &= ~MCR_LOOPBACK; edge_port->shadow_mcr = mcr; + spin_unlock_irqrestore(&edge_port->ep_lock, flags); TIRestoreMCR (edge_port, mcr); @@ -2592,8 +2592,11 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) unsigned int result = 0; unsigned int msr; unsigned int mcr; + unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); + + spin_lock_irqsave(&edge_port->ep_lock, flags); msr = edge_port->shadow_msr; mcr = edge_port->shadow_mcr; @@ -2605,7 +2608,8 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ - dbg("%s -- %x", __FUNCTION__, result); + dbg("%s -- %x", __func__, result); + spin_unlock_irqrestore(&edge_port->ep_lock, flags); return result; } @@ -2644,30 +2648,30 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned struct async_icount cnow; struct async_icount cprev; - dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { case TIOCINQ: - dbg("%s - (%d) TIOCINQ", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCINQ", __func__, port->number); // return get_number_bytes_avail(edge_port, (unsigned int *) arg); break; case TIOCSERGETLSR: - dbg("%s - (%d) TIOCSERGETLSR", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCSERGETLSR", __func__, port->number); // return get_lsr_info(edge_port, (unsigned int *) arg); break; case TIOCGSERIAL: - dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); return get_serial_info(edge_port, (struct serial_struct __user *) arg); break; case TIOCSSERIAL: - dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); break; case TIOCMIWAIT: - dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); cprev = edge_port->icount; while (1) { interruptible_sleep_on(&edge_port->delta_msr_wait); @@ -2690,7 +2694,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned break; case TIOCGICOUNT: - dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, + dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, edge_port->icount.rx, edge_port->icount.tx); if (copy_to_user((void __user *)arg, &edge_port->icount, sizeof(edge_port->icount))) return -EFAULT; @@ -2705,7 +2709,7 @@ static void edge_break (struct usb_serial_port *port, int break_state) struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status; - dbg ("%s - state = %d", __FUNCTION__, break_state); + dbg ("%s - state = %d", __func__, break_state); /* chase the port close */ TIChasePort (edge_port, 0, 0); @@ -2717,7 +2721,7 @@ static void edge_break (struct usb_serial_port *port, int break_state) } if (status) { dbg ("%s - error %d sending break set/clear command.", - __FUNCTION__, status); + __func__, status); } } @@ -2734,7 +2738,7 @@ static int edge_startup (struct usb_serial *serial) /* create our private serial structure */ edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); if (edge_serial == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); return -ENOMEM; } mutex_init(&edge_serial->es_lock); @@ -2751,13 +2755,13 @@ static int edge_startup (struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); if (edge_port == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); goto cleanup; } 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) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); kfree(edge_port); goto cleanup; } @@ -2786,7 +2790,7 @@ static void edge_shutdown (struct usb_serial *serial) int i; struct edgeport_port *edge_port; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); for (i = 0; i < serial->num_ports; ++i) { edge_port = usb_get_serial_port_data(serial->port[i]); @@ -2818,12 +2822,12 @@ static ssize_t store_uart_mode(struct device *dev, struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int v = simple_strtoul(valbuf, NULL, 0); - dbg("%s: setting uart_mode = %d", __FUNCTION__, v); + dbg("%s: setting uart_mode = %d", __func__, v); if (v < 256) edge_port->bUartMode = v; else - dev_err(dev, "%s - uart_mode %d is invalid\n", __FUNCTION__, v); + dev_err(dev, "%s - uart_mode %d is invalid\n", __func__, v); return count; } @@ -3028,9 +3032,6 @@ static struct usb_serial_driver edgeport_1port_device = { .description = "Edgeport TI 1 port adapter", .usb_driver = &io_driver, .id_table = edgeport_1port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = edge_open, .close = edge_close, @@ -3060,9 +3061,6 @@ static struct usb_serial_driver edgeport_2port_device = { .description = "Edgeport TI 2 port adapter", .usb_driver = &io_driver, .id_table = edgeport_2port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 2, - .num_bulk_out = 2, .num_ports = 2, .open = edge_open, .close = edge_close, diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 9b38a08ac83..ea924dc4849 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -570,10 +570,7 @@ static struct usb_serial_driver ipaq_device = { .description = "PocketPC PDA", .usb_driver = &ipaq_driver, .id_table = ipaq_id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 1, - .num_bulk_out = 1, - .num_ports = 1, + .num_ports = 2, .open = ipaq_open, .close = ipaq_close, .attach = ipaq_startup, @@ -597,13 +594,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) int i, result = 0; int retries = connect_retries; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); bytes_in = 0; bytes_out = 0; priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); if (priv == NULL) { - err("%s - Out of memory", __FUNCTION__); + err("%s - Out of memory", __func__); return -ENOMEM; } usb_set_serial_port_data(port, priv); @@ -682,7 +679,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) } if (!retries && result) { - err("%s - failed doing control urb, error %d", __FUNCTION__, + err("%s - failed doing control urb, error %d", __func__, result); goto error; } @@ -695,7 +692,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { - err("%s - failed submitting read urb, error %d", __FUNCTION__, result); + err("%s - failed submitting read urb, error %d", __func__, result); goto error; } @@ -703,7 +700,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) enomem: result = -ENOMEM; - err("%s - Out of memory", __FUNCTION__); + err("%s - Out of memory", __func__); error: ipaq_destroy_lists(port); kfree(priv); @@ -715,7 +712,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) { struct ipaq_private *priv = usb_get_serial_port_data(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * shut down bulk read and write @@ -732,21 +729,21 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) static void ipaq_read_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); tty = port->tty; if (tty && urb->actual_length) { @@ -763,7 +760,7 @@ static void ipaq_read_bulk_callback(struct urb *urb) ipaq_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); + err("%s - failed resubmitting read urb, error %d", __func__, result); return; } @@ -774,7 +771,7 @@ static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, int bytes_sent = 0; int transfer_size; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); while (count > 0) { transfer_size = min(count, PACKET_SIZE); @@ -799,7 +796,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu unsigned long flags; if (priv->free_len <= 0) { - dbg("%s - we're stuffed", __FUNCTION__); + dbg("%s - we're stuffed", __func__); return -EAGAIN; } @@ -811,12 +808,12 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu } spin_unlock_irqrestore(&write_list_lock, flags); if (pkt == NULL) { - dbg("%s - we're stuffed", __FUNCTION__); + dbg("%s - we're stuffed", __func__); return -EAGAIN; } memcpy(pkt->data, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, pkt->data); + usb_serial_debug_data(debug, &port->dev, __func__, count, pkt->data); pkt->len = count; pkt->written = 0; @@ -829,7 +826,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu spin_unlock_irqrestore(&write_list_lock, flags); result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); } } else { spin_unlock_irqrestore(&write_list_lock, flags); @@ -872,17 +869,17 @@ static void ipaq_write_gather(struct usb_serial_port *port) static void ipaq_write_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct ipaq_private *priv = usb_get_serial_port_data(port); unsigned long flags; int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -892,7 +889,7 @@ static void ipaq_write_bulk_callback(struct urb *urb) spin_unlock_irqrestore(&write_list_lock, flags); result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); } } else { priv->active = 0; @@ -906,7 +903,7 @@ static int ipaq_write_room(struct usb_serial_port *port) { struct ipaq_private *priv = usb_get_serial_port_data(port); - dbg("%s - freelen %d", __FUNCTION__, priv->free_len); + dbg("%s - freelen %d", __func__, priv->free_len); return priv->free_len; } @@ -914,7 +911,7 @@ static int ipaq_chars_in_buffer(struct usb_serial_port *port) { struct ipaq_private *priv = usb_get_serial_port_data(port); - dbg("%s - queuelen %d", __FUNCTION__, priv->queue_len); + dbg("%s - queuelen %d", __func__, priv->queue_len); return priv->queue_len; } @@ -936,7 +933,7 @@ static void ipaq_destroy_lists(struct usb_serial_port *port) static int ipaq_startup(struct usb_serial *serial) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (serial->dev->actconfig->desc.bConfigurationValue != 1) { err("active config #%d != 1 ??", serial->dev->actconfig->desc.bConfigurationValue); @@ -947,7 +944,7 @@ static int ipaq_startup(struct usb_serial *serial) static void ipaq_shutdown(struct usb_serial *serial) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static int __init ipaq_init(void) diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index cbe5530f3db..bc85ca5c1c3 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -169,15 +169,15 @@ static void ipw_read_bulk_callback(struct urb *urb) int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); tty = port->tty; if (tty && urb->actual_length) { @@ -195,7 +195,7 @@ static void ipw_read_bulk_callback(struct urb *urb) ipw_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); return; } @@ -206,7 +206,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) u8 *buf_flow_init; int result; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL); if (!buf_flow_init) @@ -217,7 +217,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) /* --1: Tell the modem to initialize (we think) From sniffs this is always the * first thing that gets sent to the modem during opening of the device */ - dbg("%s: Sending SIO_INIT (we guess)",__FUNCTION__); + dbg("%s: Sending SIO_INIT (we guess)",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev,0), IPW_SIO_INIT, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, @@ -234,7 +234,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress)); /*--2: Start reading from the device */ - dbg("%s: setting up bulk read callback",__FUNCTION__); + dbg("%s: setting up bulk read callback",__func__); usb_fill_bulk_urb(port->read_urb, dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), port->bulk_in_buffer, @@ -242,10 +242,10 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) ipw_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result < 0) - dbg("%s - usb_submit_urb(read bulk) failed with status %d", __FUNCTION__, result); + dbg("%s - usb_submit_urb(read bulk) failed with status %d", __func__, result); /*--3: Tell the modem to open the floodgates on the rx bulk channel */ - dbg("%s:asking modem for RxRead (RXBULK_ON)",__FUNCTION__); + dbg("%s:asking modem for RxRead (RXBULK_ON)",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_RXCTL, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, @@ -258,7 +258,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)\n", result); /*--4: setup the initial flowcontrol */ - dbg("%s:setting init flowcontrol (%s)",__FUNCTION__,buf_flow_init); + dbg("%s:setting init flowcontrol (%s)",__func__,buf_flow_init); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_HANDFLOW, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, @@ -272,7 +272,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) /*--5: raise the dtr */ - dbg("%s:raising dtr",__FUNCTION__); + dbg("%s:raising dtr",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, @@ -285,7 +285,7 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) dev_err(&port->dev, "setting dtr failed (error = %d)\n", result); /*--6: raise the rts */ - dbg("%s:raising rts",__FUNCTION__); + dbg("%s:raising rts",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, @@ -307,12 +307,12 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp) int result; if (tty_hung_up_p(filp)) { - dbg("%s: tty_hung_up_p ...", __FUNCTION__); + dbg("%s: tty_hung_up_p ...", __func__); return; } /*--1: drop the dtr */ - dbg("%s:dropping dtr",__FUNCTION__); + dbg("%s:dropping dtr",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, @@ -325,7 +325,7 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp) dev_err(&port->dev, "dropping dtr failed (error = %d)\n", result); /*--2: drop the rts */ - dbg("%s:dropping rts",__FUNCTION__); + dbg("%s:dropping rts",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_PIN_CLRRTS, @@ -338,7 +338,7 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp) /*--3: purge */ - dbg("%s:sending purge",__FUNCTION__); + dbg("%s:sending purge",__func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 0x03, @@ -373,13 +373,13 @@ static void ipw_write_bulk_callback(struct urb *urb) struct usb_serial_port *port = urb->context; int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); port->write_urb_busy = 0; if (status) dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); usb_serial_port_softint(port); } @@ -389,18 +389,18 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int struct usb_device *dev = port->serial->dev; int ret; - dbg("%s: TOP: count=%d, in_interrupt=%ld", __FUNCTION__, + dbg("%s: TOP: count=%d, in_interrupt=%ld", __func__, count, in_interrupt() ); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return 0; } spin_lock_bh(&port->lock); if (port->write_urb_busy) { spin_unlock_bh(&port->lock); - dbg("%s - already writing", __FUNCTION__); + dbg("%s - already writing", __func__); return 0; } port->write_urb_busy = 1; @@ -409,7 +409,7 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count = min(count, port->bulk_out_size); memcpy(port->bulk_out_buffer, buf, count); - dbg("%s count now:%d", __FUNCTION__, count); + dbg("%s count now:%d", __func__, count); usb_fill_bulk_urb(port->write_urb, dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress), @@ -421,11 +421,11 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (ret != 0) { port->write_urb_busy = 0; - dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __FUNCTION__, ret); + dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __func__, ret); return ret; } - dbg("%s returning %d", __FUNCTION__, count); + dbg("%s returning %d", __func__, count); return count; } @@ -448,9 +448,6 @@ static struct usb_serial_driver ipw_device = { .description = "IPWireless converter", .usb_driver = &usb_ipw_driver, .id_table = usb_ipw_ids, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = ipw_open, .close = ipw_close, diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 6b803ab9854..004d57385a7 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -145,9 +145,6 @@ static struct usb_serial_driver ir_device = { .description = "IR Dongle", .usb_driver = &ir_driver, .id_table = id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .set_termios = ir_set_termios, .attach = ir_startup, @@ -198,16 +195,16 @@ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, ifnum, desc, sizeof(*desc), 1000); - dbg("%s - ret=%d", __FUNCTION__, ret); + dbg("%s - ret=%d", __func__, ret); if (ret < sizeof(*desc)) { dbg("%s - class descriptor read %s (%d)", - __FUNCTION__, + __func__, (ret<0) ? "failed" : "too short", ret); goto error; } if (desc->bDescriptorType != USB_DT_IRDA) { - dbg("%s - bad class descriptor type", __FUNCTION__); + dbg("%s - bad class descriptor type", __func__); goto error; } @@ -251,7 +248,7 @@ static int ir_startup (struct usb_serial *serial) } dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", - __FUNCTION__, + __func__, (irda_desc->wBaudRate & 0x0001) ? " 2400" : "", (irda_desc->wBaudRate & 0x0002) ? " 9600" : "", (irda_desc->wBaudRate & 0x0004) ? " 19200" : "", @@ -284,13 +281,13 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) char *buffer; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (buffer_size) { /* override the default buffer sizes */ buffer = kmalloc (buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (&port->dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (&port->dev, "%s - out of memory.\n", __func__); return -ENOMEM; } kfree (port->read_urb->transfer_buffer); @@ -299,7 +296,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) buffer = kmalloc (buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (&port->dev, "%s - out of memory.\n", __FUNCTION__); + dev_err (&port->dev, "%s - out of memory.\n", __func__); return -ENOMEM; } kfree (port->write_urb->transfer_buffer); @@ -319,14 +316,14 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); return result; } static void ir_close (struct usb_serial_port *port, struct file * filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* shutdown our bulk read */ usb_kill_urb(port->read_urb); @@ -338,10 +335,10 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int int result; int transfer_size; - dbg("%s - port = %d, count = %d", __FUNCTION__, port->number, count); + dbg("%s - port = %d, count = %d", __func__, port->number, count); if (!port->tty) { - dev_err (&port->dev, "%s - no tty???\n", __FUNCTION__); + dev_err (&port->dev, "%s - no tty???\n", __func__); return 0; } @@ -351,7 +348,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int spin_lock_bh(&port->lock); if (port->write_urb_busy) { spin_unlock_bh(&port->lock); - dbg("%s - already writing", __FUNCTION__); + dbg("%s - already writing", __func__); return 0; } port->write_urb_busy = 1; @@ -387,7 +384,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int result = usb_submit_urb (port->write_urb, GFP_ATOMIC); if (result) { port->write_urb_busy = 0; - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); } else result = transfer_size; @@ -396,22 +393,22 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int static void ir_write_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); port->write_urb_busy = 0; if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } usb_serial_debug_data ( debug, &port->dev, - __FUNCTION__, + __func__, urb->actual_length, urb->transfer_buffer); @@ -420,16 +417,16 @@ static void ir_write_bulk_callback (struct urb *urb) static void ir_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port closed.", __FUNCTION__); + dbg("%s - port closed.", __func__); return; } @@ -447,7 +444,7 @@ static void ir_read_bulk_callback (struct urb *urb) usb_serial_debug_data ( debug, &port->dev, - __FUNCTION__, + __func__, urb->actual_length, data); @@ -480,13 +477,13 @@ static void ir_read_bulk_callback (struct urb *urb) result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", - __FUNCTION__, result); + __func__, result); break ; default: dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, + __func__, status); break ; @@ -502,7 +499,7 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t speed_t baud; int ir_baud; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); baud = tty_get_baud_rate(port->tty); @@ -554,7 +551,7 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t result = usb_submit_urb (port->write_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); /* Only speed changes are supported */ tty_termios_copy_hw(port->tty->termios, old_termios); diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index fde188e23ce..8a217648b25 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -98,10 +98,10 @@ static int iuu_alloc_buf(struct iuu_private *priv) priv->writebuf = kzalloc(256, GFP_KERNEL); if (!priv->buf || !priv->dbgbuf || !priv->writebuf) { iuu_free_buf(priv); - dbg("%s problem allocation buffer", __FUNCTION__); + dbg("%s problem allocation buffer", __func__); return -ENOMEM; } - dbg("%s - Privates buffers allocation success", __FUNCTION__); + dbg("%s - Privates buffers allocation success", __func__); return 0; } @@ -109,7 +109,7 @@ static int iuu_startup(struct usb_serial *serial) { struct iuu_private *priv; priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); - dbg("%s- priv allocation success", __FUNCTION__); + dbg("%s- priv allocation success", __func__); if (!priv) return -ENOMEM; if (iuu_alloc_buf(priv)) { @@ -130,17 +130,17 @@ static void iuu_shutdown(struct usb_serial *serial) if (!port) return; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (priv) { iuu_free_buf(priv); - dbg("%s - I will free all", __FUNCTION__); + dbg("%s - I will free all", __func__); usb_set_serial_port_data(port, NULL); - dbg("%s - priv is not anymore in port structure", __FUNCTION__); + dbg("%s - priv is not anymore in port structure", __func__); kfree(priv); - dbg("%s priv is now kfree", __FUNCTION__); + dbg("%s priv is now kfree", __func__); } } @@ -148,20 +148,21 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear) { struct iuu_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; - tty = port->tty; + unsigned long flags; - dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __FUNCTION__, + /* FIXME: locking on tiomstatus */ + dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __func__, port->number, set, clear); + + spin_lock_irqsave(&priv->lock, flags); if (set & TIOCM_RTS) priv->tiostatus = TIOCM_RTS; if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) { - dbg("%s TIOCMSET RESET called !!!", __FUNCTION__); + dbg("%s TIOCMSET RESET called !!!", __func__); priv->reset = 1; - return 0; } - + spin_unlock_irqrestore(&priv->lock, flags); return 0; } @@ -173,17 +174,24 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) { struct iuu_private *priv = usb_get_serial_port_data(port); - return priv->tiostatus; + unsigned long flags; + int rc; + + spin_lock_irqsave(&priv->lock, flags); + rc = priv->tiostatus; + spin_unlock_irqrestore(&priv->lock, flags); + + return rc; } static void iuu_rxcmd(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int result; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (urb->status) { - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); /* error stop all */ return; } @@ -203,7 +211,7 @@ static int iuu_reset(struct usb_serial_port *port, u8 wt) struct iuu_private *priv = usb_get_serial_port_data(port); int result; char *buf_ptr = port->write_urb->transfer_buffer; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); /* Prepare the reset sequence */ @@ -232,19 +240,19 @@ static int iuu_reset(struct usb_serial_port *port, u8 wt) */ static void iuu_update_status_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct iuu_private *priv = usb_get_serial_port_data(port); u8 *st; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (urb->status) { - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); /* error stop all */ return; } st = urb->transfer_buffer; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (urb->actual_length == 1) { switch (st[0]) { case 0x1: @@ -262,11 +270,11 @@ static void iuu_update_status_callback(struct urb *urb) static void iuu_status_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int result; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), @@ -279,7 +287,7 @@ static int iuu_status(struct usb_serial_port *port) { int result; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1); usb_fill_bulk_urb(port->write_urb, port->serial->dev, @@ -298,7 +306,7 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) struct usb_serial *serial = port->serial; int actual = 0; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); /* send the data out the bulk port */ @@ -309,9 +317,9 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) count, &actual, HZ * 1); if (status != IUU_OPERATION_OK) { - dbg("%s - error = %2x", __FUNCTION__, status); + dbg("%s - error = %2x", __func__, status); } else { - dbg("%s - write OK !", __FUNCTION__); + dbg("%s - write OK !", __func__); } return status; } @@ -322,7 +330,7 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) struct usb_serial *serial = port->serial; int actual = 0; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); /* send the data out the bulk port */ @@ -333,9 +341,9 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) count, &actual, HZ * 1); if (status != IUU_OPERATION_OK) { - dbg("%s - error = %2x", __FUNCTION__, status); + dbg("%s - error = %2x", __func__, status); } else { - dbg("%s - read OK !", __FUNCTION__); + dbg("%s - read OK !", __func__); } return status; @@ -350,7 +358,7 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R, if (!buf) return -ENOMEM; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); buf[0] = IUU_SET_LED; buf[1] = R & 0xFF; @@ -363,9 +371,9 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R, status = bulk_immediate(port, buf, 8); kfree(buf); if (status != IUU_OPERATION_OK) - dbg("%s - led error status = %2x", __FUNCTION__, status); + dbg("%s - led error status = %2x", __func__, status); else - dbg("%s - led OK !", __FUNCTION__); + dbg("%s - led OK !", __func__); return IUU_OPERATION_OK; } @@ -384,7 +392,7 @@ static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1, static void iuu_led_activity_on(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int result; char *buf_ptr = port->write_urb->transfer_buffer; *buf_ptr++ = IUU_SET_LED; @@ -405,7 +413,7 @@ static void iuu_led_activity_on(struct urb *urb) static void iuu_led_activity_off(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int result; char *buf_ptr = port->write_urb->transfer_buffer; if (xmas == 1) { @@ -443,7 +451,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq) unsigned int P2 = 0; int frq = (int)dwFrq; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (frq == 0) { priv->buf[Count++] = IUU_UART_WRITE_I2C; @@ -453,7 +461,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq) status = bulk_immediate(port, (u8 *) priv->buf, Count); if (status != 0) { - dbg("%s - write error ", __FUNCTION__); + dbg("%s - write error ", __func__); return status; } } else if (frq == 3579000) { @@ -562,7 +570,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq) status = bulk_immediate(port, (u8 *) priv->buf, Count); if (status != IUU_OPERATION_OK) - dbg("%s - write error ", __FUNCTION__); + dbg("%s - write error ", __func__); return status; } @@ -573,7 +581,7 @@ static int iuu_uart_flush(struct usb_serial_port *port) u8 rxcmd = IUU_UART_RX; struct iuu_private *priv = usb_get_serial_port_data(port); - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0) return -EIO; @@ -581,50 +589,50 @@ static int iuu_uart_flush(struct usb_serial_port *port) for (i = 0; i < 2; i++) { status = bulk_immediate(port, &rxcmd, 1); if (status != IUU_OPERATION_OK) { - dbg("%s - uart_flush_write error", __FUNCTION__); + dbg("%s - uart_flush_write error", __func__); return status; } status = read_immediate(port, &priv->len, 1); if (status != IUU_OPERATION_OK) { - dbg("%s - uart_flush_read error", __FUNCTION__); + dbg("%s - uart_flush_read error", __func__); return status; } if (priv->len > 0) { - dbg("%s - uart_flush datalen is : %i ", __FUNCTION__, + dbg("%s - uart_flush datalen is : %i ", __func__, priv->len); status = read_immediate(port, priv->buf, priv->len); if (status != IUU_OPERATION_OK) { - dbg("%s - uart_flush_read error", __FUNCTION__); + dbg("%s - uart_flush_read error", __func__); return status; } } } - dbg("%s - uart_flush_read OK!", __FUNCTION__); + dbg("%s - uart_flush_read OK!", __func__); iuu_led(port, 0, 0xF000, 0, 0xFF); return status; } static void read_buf_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; struct tty_struct *tty; - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); if (urb->status) { - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); if (urb->status == -EPROTO) { /* reschedule needed */ } return; } - dbg("%s - %i chars to write", __FUNCTION__, urb->actual_length); + dbg("%s - %i chars to write", __func__, urb->actual_length); tty = port->tty; if (data == NULL) - dbg("%s - data is NULL !!!", __FUNCTION__); + dbg("%s - data is NULL !!!", __func__); if (tty && urb->actual_length && data) { tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); @@ -639,7 +647,7 @@ static int iuu_bulk_write(struct usb_serial_port *port) int result; int i; char *buf_ptr = port->write_urb->transfer_buffer; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); *buf_ptr++ = IUU_UART_ESC; *buf_ptr++ = IUU_UART_TX; @@ -652,7 +660,7 @@ static int iuu_bulk_write(struct usb_serial_port *port) sprintf(priv->dbgbuf + i*2 , "%02X", priv->writebuf[i]); priv->dbgbuf[priv->writelen+i*2] = 0; - dbg("%s - writing %i chars : %s", __FUNCTION__, + dbg("%s - writing %i chars : %s", __func__, priv->writelen, priv->dbgbuf); } usb_fill_bulk_urb(port->write_urb, port->serial->dev, @@ -671,7 +679,7 @@ static int iuu_bulk_write(struct usb_serial_port *port) static int iuu_read_buf(struct usb_serial_port *port, int len) { int result; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, @@ -684,7 +692,7 @@ static int iuu_read_buf(struct usb_serial_port *port, int len) static void iuu_uart_read_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct iuu_private *priv = usb_get_serial_port_data(port); unsigned int flags; int status; @@ -693,21 +701,21 @@ static void iuu_uart_read_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; priv->poll++; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (urb->status) { - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); /* error stop all */ return; } if (data == NULL) - dbg("%s - data is NULL !!!", __FUNCTION__); + dbg("%s - data is NULL !!!", __func__); if (urb->actual_length == 1 && data != NULL) len = (int) data[0]; if (urb->actual_length > 1) { - dbg("%s - urb->actual_length = %i", __FUNCTION__, + dbg("%s - urb->actual_length = %i", __func__, urb->actual_length); error = 1; return; @@ -716,7 +724,7 @@ static void iuu_uart_read_callback(struct urb *urb) if (len > 0 && error == 0) { dbg("%s - call read buf - len to read is %i ", - __FUNCTION__, len); + __func__, len); status = iuu_read_buf(port, len); return; } @@ -742,7 +750,7 @@ static void iuu_uart_read_callback(struct urb *urb) } spin_unlock_irqrestore(&priv->lock, flags); /* if nothing to write call again rxcmd */ - dbg("%s - rxcmd recall", __FUNCTION__); + dbg("%s - rxcmd recall", __func__); iuu_led_activity_off(urb); return; } @@ -752,7 +760,7 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, { struct iuu_private *priv = usb_get_serial_port_data(port); unsigned int flags; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); if (count > 256) return -ENOMEM; @@ -773,14 +781,14 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, static void read_rxcmd_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int result; - dbg("%s - enter", __FUNCTION__); + dbg("%s - enter", __func__); - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); if (urb->status) { - dbg("%s - urb->status = %d", __FUNCTION__, urb->status); + dbg("%s - urb->status = %d", __func__, urb->status); /* error stop all */ return; } @@ -791,7 +799,7 @@ static void read_rxcmd_callback(struct urb *urb) port->read_urb->transfer_buffer, 256, iuu_uart_read_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); - dbg("%s - submit result = %d", __FUNCTION__, result); + dbg("%s - submit result = %d", __func__, result); return; } @@ -812,13 +820,13 @@ static int iuu_uart_on(struct usb_serial_port *port) status = bulk_immediate(port, buf, 4); if (status != IUU_OPERATION_OK) { - dbg("%s - uart_on error", __FUNCTION__); + dbg("%s - uart_on error", __func__); goto uart_enable_failed; } /* iuu_reset() the card after iuu_uart_on() */ status = iuu_uart_flush(port); if (status != IUU_OPERATION_OK) - dbg("%s - uart_flush error", __FUNCTION__); + dbg("%s - uart_flush error", __func__); uart_enable_failed: kfree(buf); return status; @@ -836,7 +844,7 @@ static int iuu_uart_off(struct usb_serial_port *port) status = bulk_immediate(port, buf, 1); if (status != IUU_OPERATION_OK) - dbg("%s - uart_off error", __FUNCTION__); + dbg("%s - uart_off error", __func__); kfree(buf); return status; @@ -930,7 +938,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud, status = bulk_immediate(port, dataout, DataCount); if (status != IUU_OPERATION_OK) - dbg("%s - uart_off error", __FUNCTION__); + dbg("%s - uart_off error", __func__); kfree(dataout); return status; } @@ -952,7 +960,7 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp) if (!serial) return; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); iuu_uart_off(port); if (serial->dev) { @@ -969,7 +977,7 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp) } /* free writebuf */ /* shutdown our urbs */ - dbg("%s - shutting down urbs", __FUNCTION__); + dbg("%s - shutting down urbs", __func__); usb_kill_urb(port->write_urb); usb_kill_urb(port->read_urb); usb_kill_urb(port->interrupt_in_urb); @@ -990,7 +998,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) unsigned long flags; struct iuu_private *priv = usb_get_serial_port_data(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); usb_clear_halt(serial->dev, port->write_urb->pipe); usb_clear_halt(serial->dev, port->read_urb->pipe); @@ -1127,7 +1135,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) iuu_uart_flush(port); - dbg("%s - initialization done", __FUNCTION__); + dbg("%s - initialization done", __func__); memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); usb_fill_bulk_urb(port->write_urb, port->serial->dev, @@ -1139,11 +1147,11 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) if (result) { dev_err(&port->dev, "%s - failed submitting read urb," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); iuu_close(port, NULL); return -EPROTO; } else { - dbg("%s - rxcmd OK", __FUNCTION__); + dbg("%s - rxcmd OK", __func__); } return result; } @@ -1154,9 +1162,6 @@ static struct usb_serial_driver iuu_device = { .name = "iuu_phoenix", }, .id_table = id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = iuu_open, .close = iuu_close, diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index ea7bba69f4d..3df8a66c5c3 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -244,13 +244,13 @@ module_exit(keyspan_exit); static void keyspan_rx_throttle (struct usb_serial_port *port) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); } static void keyspan_rx_unthrottle (struct usb_serial_port *port) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); } @@ -258,7 +258,7 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state) { struct keyspan_port_private *p_priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); p_priv = usb_get_serial_port_data(port); @@ -280,7 +280,7 @@ static void keyspan_set_termios (struct usb_serial_port *port, unsigned int cflag; struct tty_struct *tty = port->tty; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; @@ -377,7 +377,7 @@ static int keyspan_write(struct usb_serial_port *port, } dbg("%s - for port %d (%d chars), flip=%d", - __FUNCTION__, port->number, count, p_priv->out_flip); + __func__, port->number, count, p_priv->out_flip); for (left = count; left > 0; left -= todo) { todo = left; @@ -389,11 +389,11 @@ static int keyspan_write(struct usb_serial_port *port, /* Check we have a valid urb/endpoint before we use it... */ if ((this_urb = p_priv->out_urbs[flip]) == NULL) { /* no bulk out, so return 0 bytes written */ - dbg("%s - no output urb :(", __FUNCTION__); + dbg("%s - no output urb :(", __func__); return count; } - dbg("%s - endpoint %d flip %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), flip); + dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip); if (this_urb->status == -EINPROGRESS) { if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ)) @@ -435,17 +435,17 @@ static void usa26_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); endpoint = usb_pipeendpoint(urb->pipe); if (status) { dbg("%s - nonzero status: %x on endpoint %d.", - __FUNCTION__, status, endpoint); + __func__, status, endpoint); return; } - port = (struct usb_serial_port *) urb->context; + port = urb->context; tty = port->tty; if (tty && urb->actual_length) { /* 0x80 bit is error flag */ @@ -459,7 +459,7 @@ static void usa26_indat_callback(struct urb *urb) } } else { /* some bytes had errors, every byte has status */ - dbg("%s - RX error!!!!", __FUNCTION__); + dbg("%s - RX error!!!!", __func__); for (i = 0; i + 1 < urb->actual_length; i += 2) { int stat = data[i], flag = 0; if (stat & RXERROR_OVERRUN) @@ -479,7 +479,7 @@ static void usa26_indat_callback(struct urb *urb) urb->dev = port->serial->dev; if (port->open_count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } return; } @@ -490,9 +490,9 @@ static void usa2x_outdat_callback(struct urb *urb) struct usb_serial_port *port; struct keyspan_port_private *p_priv; - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); - dbg ("%s - urb %d", __FUNCTION__, urb == p_priv->out_urbs[1]); + dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); if (port->open_count) usb_serial_port_softint(port); @@ -500,7 +500,7 @@ static void usa2x_outdat_callback(struct urb *urb) static void usa26_inack_callback(struct urb *urb) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } @@ -509,11 +509,11 @@ static void usa26_outcont_callback(struct urb *urb) struct usb_serial_port *port; struct keyspan_port_private *p_priv; - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __FUNCTION__); + dbg ("%s - sending setup", __func__); keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1); } } @@ -528,14 +528,14 @@ static void usa26_instat_callback(struct urb *urb) int old_dcd_state, err; int status = urb->status; - serial = (struct usb_serial *) urb->context; + serial = urb->context; if (status) { - dbg("%s - nonzero status: %x", __FUNCTION__, status); + dbg("%s - nonzero status: %x", __func__, status); return; } if (urb->actual_length != 9) { - dbg("%s - %d byte report??", __FUNCTION__, urb->actual_length); + dbg("%s - %d byte report??", __func__, urb->actual_length); goto exit; } @@ -543,7 +543,7 @@ static void usa26_instat_callback(struct urb *urb) #if 0 dbg("%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d", - __FUNCTION__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, msg->ri, msg->_txOff, + __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, msg->ri, msg->_txOff, msg->_txXoff, msg->rxEnabled, msg->controlResponse); #endif @@ -552,7 +552,7 @@ static void usa26_instat_callback(struct urb *urb) /* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->port); + dbg ("%s - Unexpected port number %d", __func__, msg->port); goto exit; } port = serial->port[msg->port]; @@ -576,14 +576,14 @@ static void usa26_instat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } exit: ; } static void usa26_glocont_callback(struct urb *urb) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } @@ -597,9 +597,9 @@ static void usa28_indat_callback(struct urb *urb) struct keyspan_port_private *p_priv; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); data = urb->transfer_buffer; @@ -609,11 +609,11 @@ static void usa28_indat_callback(struct urb *urb) do { if (status) { dbg("%s - nonzero status: %x on endpoint %d.", - __FUNCTION__, status, usb_pipeendpoint(urb->pipe)); + __func__, status, usb_pipeendpoint(urb->pipe)); return; } - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); data = urb->transfer_buffer; @@ -629,7 +629,7 @@ static void usa28_indat_callback(struct urb *urb) urb->dev = port->serial->dev; if (port->open_count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } p_priv->in_flip ^= 1; @@ -639,7 +639,7 @@ static void usa28_indat_callback(struct urb *urb) static void usa28_inack_callback(struct urb *urb) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } static void usa28_outcont_callback(struct urb *urb) @@ -647,11 +647,11 @@ static void usa28_outcont_callback(struct urb *urb) struct usb_serial_port *port; struct keyspan_port_private *p_priv; - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __FUNCTION__); + dbg ("%s - sending setup", __func__); keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1); } } @@ -667,19 +667,19 @@ static void usa28_instat_callback(struct urb *urb) int old_dcd_state; int status = urb->status; - serial = (struct usb_serial *) urb->context; + serial = urb->context; if (status) { - dbg("%s - nonzero status: %x", __FUNCTION__, status); + dbg("%s - nonzero status: %x", __func__, status); return; } if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) { - dbg("%s - bad length %d", __FUNCTION__, urb->actual_length); + dbg("%s - bad length %d", __func__, urb->actual_length); goto exit; } - /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __FUNCTION__ + /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11]);*/ @@ -689,7 +689,7 @@ static void usa28_instat_callback(struct urb *urb) /* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->port); + dbg ("%s - Unexpected port number %d", __func__, msg->port); goto exit; } port = serial->port[msg->port]; @@ -713,14 +713,14 @@ static void usa28_instat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } exit: ; } static void usa28_glocont_callback(struct urb *urb) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } @@ -731,15 +731,15 @@ static void usa49_glocont_callback(struct urb *urb) struct keyspan_port_private *p_priv; int i; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); - serial = (struct usb_serial *) urb->context; + serial = urb->context; for (i = 0; i < serial->num_ports; ++i) { port = serial->port[i]; p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __FUNCTION__); + dbg ("%s - sending setup", __func__); keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1); break; } @@ -759,21 +759,21 @@ static void usa49_instat_callback(struct urb *urb) int old_dcd_state; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); - serial = (struct usb_serial *) urb->context; + serial = urb->context; if (status) { - dbg("%s - nonzero status: %x", __FUNCTION__, status); + dbg("%s - nonzero status: %x", __func__, status); return; } if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) { - dbg("%s - bad length %d", __FUNCTION__, urb->actual_length); + dbg("%s - bad length %d", __func__, urb->actual_length); goto exit; } - /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __FUNCTION__, + /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]);*/ @@ -782,7 +782,7 @@ static void usa49_instat_callback(struct urb *urb) /* Check port number from message and retrieve private data */ if (msg->portNumber >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->portNumber); + dbg ("%s - Unexpected port number %d", __func__, msg->portNumber); goto exit; } port = serial->port[msg->portNumber]; @@ -807,14 +807,14 @@ static void usa49_instat_callback(struct urb *urb) urb->dev = serial->dev; if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } exit: ; } static void usa49_inack_callback(struct urb *urb) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } static void usa49_indat_callback(struct urb *urb) @@ -826,17 +826,17 @@ static void usa49_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); endpoint = usb_pipeendpoint(urb->pipe); if (status) { - dbg("%s - nonzero status: %x on endpoint %d.", __FUNCTION__, + dbg("%s - nonzero status: %x on endpoint %d.", __func__, status, endpoint); return; } - port = (struct usb_serial_port *) urb->context; + port = urb->context; tty = port->tty; if (tty && urb->actual_length) { /* 0x80 bit is error flag */ @@ -866,7 +866,7 @@ static void usa49_indat_callback(struct urb *urb) urb->dev = port->serial->dev; if (port->open_count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } } @@ -879,12 +879,12 @@ static void usa49wg_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); serial = urb->context; if (status) { - dbg("%s - nonzero status: %x", __FUNCTION__, status); + dbg("%s - nonzero status: %x", __func__, status); return; } @@ -898,7 +898,7 @@ static void usa49wg_indat_callback(struct urb *urb) /* Check port number from message*/ if (data[i] >= serial->num_ports) { dbg ("%s - Unexpected port number %d", - __FUNCTION__, data[i]); + __func__, data[i]); return; } port = serial->port[data[i++]]; @@ -944,13 +944,13 @@ static void usa49wg_indat_callback(struct urb *urb) err = usb_submit_urb(urb, GFP_ATOMIC); if (err != 0) - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } /* not used, usa-49 doesn't have per-port control endpoints */ static void usa49_outcont_callback(struct urb *urb) { - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); } static void usa90_indat_callback(struct urb *urb) @@ -963,17 +963,17 @@ static void usa90_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); endpoint = usb_pipeendpoint(urb->pipe); if (status) { dbg("%s - nonzero status: %x on endpoint %d.", - __FUNCTION__, status, endpoint); + __func__, status, endpoint); return; } - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); tty = port->tty; @@ -1000,7 +1000,7 @@ static void usa90_indat_callback(struct urb *urb) } else { /* some bytes had errors, every byte has status */ - dbg("%s - RX error!!!!", __FUNCTION__); + dbg("%s - RX error!!!!", __func__); for (i = 0; i + 1 < urb->actual_length; i += 2) { int stat = data[i], flag = 0; if (stat & RXERROR_OVERRUN) @@ -1021,7 +1021,7 @@ static void usa90_indat_callback(struct urb *urb) urb->dev = port->serial->dev; if (port->open_count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } return; } @@ -1037,14 +1037,14 @@ static void usa90_instat_callback(struct urb *urb) int old_dcd_state, err; int status = urb->status; - serial = (struct usb_serial *) urb->context; + serial = urb->context; if (status) { - dbg("%s - nonzero status: %x", __FUNCTION__, status); + dbg("%s - nonzero status: %x", __func__, status); return; } if (urb->actual_length < 14) { - dbg("%s - %d byte report??", __FUNCTION__, urb->actual_length); + dbg("%s - %d byte report??", __func__, urb->actual_length); goto exit; } @@ -1073,7 +1073,7 @@ static void usa90_instat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } exit: ; @@ -1084,11 +1084,11 @@ static void usa90_outcont_callback(struct urb *urb) struct usb_serial_port *port; struct keyspan_port_private *p_priv; - port = (struct usb_serial_port *) urb->context; + port = urb->context; p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __FUNCTION__); + dbg ("%s - sending setup", __func__); keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1); } } @@ -1105,17 +1105,17 @@ static void usa67_instat_callback(struct urb *urb) int old_dcd_state; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); serial = urb->context; if (status) { - dbg("%s - nonzero status: %x", __FUNCTION__, status); + dbg("%s - nonzero status: %x", __func__, status); return; } if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) { - dbg("%s - bad length %d", __FUNCTION__, urb->actual_length); + dbg("%s - bad length %d", __func__, urb->actual_length); return; } @@ -1125,7 +1125,7 @@ static void usa67_instat_callback(struct urb *urb) /* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __FUNCTION__, msg->port); + dbg ("%s - Unexpected port number %d", __func__, msg->port); return; } @@ -1149,7 +1149,7 @@ static void usa67_instat_callback(struct urb *urb) urb->dev = serial->dev; err = usb_submit_urb(urb, GFP_ATOMIC); if (err != 0) - dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err); + dbg("%s - resubmit read urb failed. (%d)", __func__, err); } static void usa67_glocont_callback(struct urb *urb) @@ -1159,7 +1159,7 @@ static void usa67_glocont_callback(struct urb *urb) struct keyspan_port_private *p_priv; int i; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); serial = urb->context; for (i = 0; i < serial->num_ports; ++i) { @@ -1167,7 +1167,7 @@ static void usa67_glocont_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __FUNCTION__); + dbg ("%s - sending setup", __func__); keyspan_usa67_send_setup(serial, port, p_priv->resend_cont - 1); break; @@ -1183,10 +1183,11 @@ static int keyspan_write_room (struct usb_serial_port *port) int data_len; struct urb *this_urb; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; + /* FIXME: locking */ if (d_details->msg_format == msg_usa90) data_len = 64; else @@ -1203,13 +1204,13 @@ static int keyspan_write_room (struct usb_serial_port *port) if (this_urb->status != -EINPROGRESS) return (data_len); } - return (0); + return 0; } static int keyspan_chars_in_buffer (struct usb_serial_port *port) { - return (0); + return 0; } @@ -1228,7 +1229,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; - dbg("%s - port%d.", __FUNCTION__, port->number); + dbg("%s - port%d.", __func__, port->number); /* Set some sane defaults */ p_priv->rts_state = 1; @@ -1253,7 +1254,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) usb_clear_halt(urb->dev, urb->pipe); if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) { - dbg("%s - submit urb %d failed (%d)", __FUNCTION__, i, err); + dbg("%s - submit urb %d failed (%d)", __func__, i, err); } } @@ -1289,7 +1290,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) //mdelay(100); //keyspan_set_termios(port, NULL); - return (0); + return 0; } static inline void stop_urb(struct urb *urb) @@ -1305,7 +1306,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) struct keyspan_serial_private *s_priv; struct keyspan_port_private *p_priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -1320,7 +1321,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) } /*while (p_priv->outcont_urb->status == -EINPROGRESS) { - dbg("%s - urb in progress", __FUNCTION__); + dbg("%s - urb in progress", __func__); }*/ p_priv->out_flip = 0; @@ -1484,10 +1485,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, if (endpoint == -1) return NULL; /* endpoint not needed */ - dbg ("%s - alloc for endpoint %d.", __FUNCTION__, endpoint); + dbg ("%s - alloc for endpoint %d.", __func__, endpoint); urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ if (urb == NULL) { - dbg ("%s - alloc for endpoint %d failed.", __FUNCTION__, endpoint); + dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint); return NULL; } @@ -1588,7 +1589,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) struct callbacks *cback; int endp; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); s_priv = usb_get_serial_data(serial); d_details = s_priv->device_details; @@ -1662,7 +1663,7 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, div, /* divisor */ cnt; /* inverse of divisor (programmed into 8051) */ - dbg ("%s - %d.", __FUNCTION__, baud_rate); + dbg ("%s - %d.", __func__, baud_rate); /* prevent divide by zero... */ if( (b16 = (baud_rate * 16L)) == 0) { @@ -1695,7 +1696,7 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, *rate_hi = (u8) ((cnt >> 8) & 0xff); } if (rate_low && rate_hi) { - dbg ("%s - %d %02x %02x.", __FUNCTION__, baud_rate, *rate_hi, *rate_low); + dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); } return (KEYSPAN_BAUD_RATE_OK); @@ -1708,7 +1709,7 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u32 b16, /* baud rate times 16 (actual rate used internally) */ div; /* divisor */ - dbg ("%s - %d.", __FUNCTION__, baud_rate); + dbg ("%s - %d.", __func__, baud_rate); /* prevent divide by zero... */ if( (b16 = (baud_rate * 16L)) == 0) @@ -1731,7 +1732,7 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, *rate_hi = (u8) ((div >> 8) & 0xff); if (rate_low && rate_hi) - dbg ("%s - %d %02x %02x.", __FUNCTION__, baud_rate, *rate_hi, *rate_low); + dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); return (KEYSPAN_BAUD_RATE_OK); } @@ -1748,7 +1749,7 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 best_prescaler; int i; - dbg ("%s - %d.", __FUNCTION__, baud_rate); + dbg ("%s - %d.", __func__, baud_rate); /* prevent divide by zero */ if( (b16 = baud_rate * 16L) == 0) { @@ -1796,7 +1797,7 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, } if (prescaler) { *prescaler = best_prescaler; - /* dbg("%s - %d %d", __FUNCTION__, *prescaler, div); */ + /* dbg("%s - %d %d", __func__, *prescaler, div); */ } return (KEYSPAN_BAUD_RATE_OK); } @@ -1809,7 +1810,7 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, div, /* divisor */ cnt; /* inverse of divisor (programmed into 8051) */ - dbg ("%s - %d.", __FUNCTION__, baud_rate); + dbg ("%s - %d.", __func__, baud_rate); /* prevent divide by zero */ if ((b16 = baud_rate * 16L) == 0) @@ -1848,7 +1849,7 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, if (rate_hi) { *rate_hi = (u8) ((cnt >> 8) & 0xff); } - dbg ("%s - %d OK.", __FUNCTION__, baud_rate); + dbg ("%s - %d OK.", __func__, baud_rate); return (KEYSPAN_BAUD_RATE_OK); } @@ -1864,7 +1865,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, struct urb *this_urb; int device_port, err; - dbg ("%s reset=%d", __FUNCTION__, reset_port); + dbg ("%s reset=%d", __func__, reset_port); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -1874,11 +1875,11 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, outcont_urb = d_details->outcont_endpoints[port->number]; this_urb = p_priv->outcont_urb; - dbg("%s - endpoint %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe)); + dbg("%s - endpoint %d", __func__, usb_pipeendpoint(this_urb->pipe)); /* Make sure we have an urb then send the message */ if (this_urb == NULL) { - dbg("%s - oops no urb.", __FUNCTION__); + dbg("%s - oops no urb.", __func__); return -1; } @@ -1887,7 +1888,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - /* dbg ("%s - already writing", __FUNCTION__); */ + /* dbg ("%s - already writing", __func__); */ mdelay(5); return(-1); } @@ -1901,7 +1902,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, + dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, p_priv->baud); msg.baudLo = 0; msg.baudHi = 125; /* Values for 9600 baud */ @@ -1996,17 +1997,17 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, this_urb->dev = serial->dev; if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { - dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err); + dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); } #if 0 else { - dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __FUNCTION__ + dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ outcont_urb, this_urb->transfer_buffer_length, usb_pipeendpoint(this_urb->pipe)); } #endif - return (0); + return 0; } static int keyspan_usa28_send_setup(struct usb_serial *serial, @@ -2020,7 +2021,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, struct urb *this_urb; int device_port, err; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -2029,7 +2030,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, /* only do something if we have a bulk out endpoint */ if ((this_urb = p_priv->outcont_urb) == NULL) { - dbg("%s - oops no urb.", __FUNCTION__); + dbg("%s - oops no urb.", __func__); return -1; } @@ -2038,7 +2039,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - dbg ("%s already writing", __FUNCTION__); + dbg ("%s already writing", __func__); mdelay(5); return(-1); } @@ -2048,7 +2049,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, msg.setBaudRate = 1; if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate requested %d.", __FUNCTION__, p_priv->baud); + dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud); msg.baudLo = 0xff; msg.baudHi = 0xb2; /* Values for 9600 baud */ } @@ -2122,16 +2123,16 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, this_urb->dev = serial->dev; if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { - dbg("%s - usb_submit_urb(setup) failed", __FUNCTION__); + dbg("%s - usb_submit_urb(setup) failed", __func__); } #if 0 else { - dbg("%s - usb_submit_urb(setup) OK %d bytes", __FUNCTION__, + dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, this_urb->transfer_buffer_length); } #endif - return (0); + return 0; } static int keyspan_usa49_send_setup(struct usb_serial *serial, @@ -2146,7 +2147,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, struct urb *this_urb; int err, device_port; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -2157,11 +2158,11 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, /* Work out which port within the device is being setup */ device_port = port->number - port->serial->minor; - dbg("%s - endpoint %d port %d (%d)",__FUNCTION__, usb_pipeendpoint(this_urb->pipe), port->number, device_port); + dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port); /* Make sure we have an urb then send the message */ if (this_urb == NULL) { - dbg("%s - oops no urb for port %d.", __FUNCTION__, port->number); + dbg("%s - oops no urb for port %d.", __func__, port->number); return -1; } @@ -2171,7 +2172,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - /* dbg ("%s - already writing", __FUNCTION__); */ + /* dbg ("%s - already writing", __func__); */ mdelay(5); return(-1); } @@ -2188,7 +2189,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, + dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, p_priv->baud); msg.baudLo = 0; msg.baudHi = 125; /* Values for 9600 baud */ @@ -2307,17 +2308,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, this_urb->dev = serial->dev; } if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { - dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err); + dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); } #if 0 else { - dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __FUNCTION__, + dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, outcont_urb, this_urb->transfer_buffer_length, usb_pipeendpoint(this_urb->pipe)); } #endif - return (0); + return 0; } static int keyspan_usa90_send_setup(struct usb_serial *serial, @@ -2332,7 +2333,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, int err; u8 prescaler; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -2340,7 +2341,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, /* only do something if we have a bulk out endpoint */ if ((this_urb = p_priv->outcont_urb) == NULL) { - dbg("%s - oops no urb.", __FUNCTION__); + dbg("%s - oops no urb.", __func__); return -1; } @@ -2349,7 +2350,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - dbg ("%s already writing", __FUNCTION__); + dbg ("%s already writing", __func__); mdelay(5); return(-1); } @@ -2363,7 +2364,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, + dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, p_priv->baud); p_priv->baud = 9600; d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, @@ -2453,9 +2454,9 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, this_urb->dev = serial->dev; if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { - dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err); + dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); } - return (0); + return 0; } static int keyspan_usa67_send_setup(struct usb_serial *serial, @@ -2469,7 +2470,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, struct urb *this_urb; int err, device_port; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -2482,7 +2483,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, /* Make sure we have an urb then send the message */ if (this_urb == NULL) { - dbg("%s - oops no urb for port %d.", __FUNCTION__, + dbg("%s - oops no urb for port %d.", __func__, port->number); return -1; } @@ -2492,7 +2493,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - /* dbg ("%s - already writing", __FUNCTION__); */ + /* dbg ("%s - already writing", __func__); */ mdelay(5); return(-1); } @@ -2508,7 +2509,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__, + dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, p_priv->baud); msg.baudLo = 0; msg.baudHi = 125; /* Values for 9600 baud */ @@ -2601,9 +2602,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, err = usb_submit_urb(this_urb, GFP_ATOMIC); if (err != 0) - dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, + dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); - return (0); + return 0; } static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) @@ -2612,7 +2613,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) struct keyspan_serial_private *s_priv; const struct keyspan_device_details *d_details; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); s_priv = usb_get_serial_data(serial); d_details = s_priv->device_details; @@ -2647,20 +2648,20 @@ static int keyspan_startup (struct usb_serial *serial) struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct)) break; if (d_details == NULL) { - dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __FUNCTION__, le16_to_cpu(serial->dev->descriptor.idProduct)); + dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); return 1; } /* Setup private data for serial driver */ s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); if (!s_priv) { - dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__); + dbg("%s - kmalloc for keyspan_serial_private failed.", __func__); return -ENOMEM; } @@ -2672,7 +2673,7 @@ static int keyspan_startup (struct usb_serial *serial) port = serial->port[i]; p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); if (!p_priv) { - dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i); + dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); return (1); } p_priv->device_details = d_details; @@ -2685,18 +2686,18 @@ static int keyspan_startup (struct usb_serial *serial) s_priv->instat_urb->dev = serial->dev; err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); if (err != 0) - dbg("%s - submit instat urb failed %d", __FUNCTION__, + dbg("%s - submit instat urb failed %d", __func__, err); } if (s_priv->indat_urb != NULL) { s_priv->indat_urb->dev = serial->dev; err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); if (err != 0) - dbg("%s - submit indat urb failed %d", __FUNCTION__, + dbg("%s - submit indat urb failed %d", __func__, err); } - return (0); + return 0; } static void keyspan_shutdown (struct usb_serial *serial) @@ -2706,7 +2707,7 @@ static void keyspan_shutdown (struct usb_serial *serial) struct keyspan_serial_private *s_priv; struct keyspan_port_private *p_priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index 74ce8bca3e6..8d6ed0293bf 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h @@ -636,10 +636,6 @@ static struct usb_serial_driver keyspan_pre_device = { }, .description = "Keyspan - (without firmware)", .id_table = keyspan_pre_ids, - .num_interrupt_in = NUM_DONT_CARE, - .num_interrupt_out = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .attach = keyspan_fake_startup, }; @@ -651,10 +647,6 @@ static struct usb_serial_driver keyspan_1port_device = { }, .description = "Keyspan 1 port adapter", .id_table = keyspan_1port_ids, - .num_interrupt_in = NUM_DONT_CARE, - .num_interrupt_out = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .open = keyspan_open, .close = keyspan_close, @@ -679,10 +671,6 @@ static struct usb_serial_driver keyspan_2port_device = { }, .description = "Keyspan 2 port adapter", .id_table = keyspan_2port_ids, - .num_interrupt_in = NUM_DONT_CARE, - .num_interrupt_out = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 2, .open = keyspan_open, .close = keyspan_close, @@ -707,10 +695,6 @@ static struct usb_serial_driver keyspan_4port_device = { }, .description = "Keyspan 4 port adapter", .id_table = keyspan_4port_ids, - .num_interrupt_in = NUM_DONT_CARE, - .num_interrupt_out = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 4, .open = keyspan_open, .close = keyspan_close, diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index b1fa5a376e9..ff54203944c 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -208,13 +208,13 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) 2000); if (result < 0) dbg("%s - error %d from usb_control_msg", - __FUNCTION__, result); + __func__, result); } static void keyspan_pda_rx_interrupt (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct tty_struct *tty = port->tty; unsigned char *data = urb->transfer_buffer; int i; @@ -232,11 +232,11 @@ static void keyspan_pda_rx_interrupt (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } @@ -274,7 +274,7 @@ exit: retval = usb_submit_urb (urb, GFP_ATOMIC); if (retval) err ("%s - usb_submit_urb failed with result %d", - __FUNCTION__, retval); + __func__, retval); } @@ -358,7 +358,7 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state value, 0, NULL, 0, 2000); if (result < 0) dbg("%s - error %d from usb_control_msg", - __FUNCTION__, result); + __func__, result); /* there is something funky about this.. the TCSBRK that 'cu' performs ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4 seconds apart, but it feels like the break sent isn't as long as it @@ -608,7 +608,7 @@ exit: static void keyspan_pda_write_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct keyspan_pda_private *priv; port->write_urb_busy = 0; @@ -636,14 +636,19 @@ static int keyspan_pda_write_room (struct usb_serial_port *port) static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) { struct keyspan_pda_private *priv; + unsigned long flags; + int ret = 0; priv = usb_get_serial_port_data(port); /* when throttled, return at least WAKEUP_CHARS to tell select() (via n_tty.c:normal_poll() ) that we're not writeable. */ + + spin_lock_irqsave(&port->lock, flags); if (port->write_urb_busy || priv->tx_throttled) - return 256; - return 0; + ret = 256; + spin_unlock_irqrestore(&port->lock, flags); + return ret; } @@ -665,11 +670,11 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) 1, 2000); if (rc < 0) { - dbg("%s - roomquery failed", __FUNCTION__); + dbg("%s - roomquery failed", __func__); goto error; } if (rc == 0) { - dbg("%s - roomquery returned 0 bytes", __FUNCTION__); + dbg("%s - roomquery returned 0 bytes", __func__); rc = -EIO; goto error; } @@ -688,7 +693,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) port->interrupt_in_urb->dev = serial->dev; rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (rc) { - dbg("%s - usb_submit_urb(read int) failed", __FUNCTION__); + dbg("%s - usb_submit_urb(read int) failed", __func__); goto error; } @@ -732,7 +737,7 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial) record = &xircom_pgs_firmware[0]; #endif if (record == NULL) { - err("%s: unknown vendor, aborting.", __FUNCTION__); + err("%s: unknown vendor, aborting.", __func__); return -ENODEV; } @@ -779,7 +784,7 @@ static int keyspan_pda_startup (struct usb_serial *serial) static void keyspan_pda_shutdown (struct usb_serial *serial) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); kfree(usb_get_serial_port_data(serial->port[0])); } @@ -793,9 +798,6 @@ static struct usb_serial_driver keyspan_pda_fake_device = { .description = "Keyspan PDA - (prerenumeration)", .usb_driver = &keyspan_pda_driver, .id_table = id_table_fake, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .attach = keyspan_pda_fake_startup, }; @@ -810,9 +812,6 @@ static struct usb_serial_driver xircom_pgs_fake_device = { .description = "Xircom / Entregra PGS - (prerenumeration)", .usb_driver = &keyspan_pda_driver, .id_table = id_table_fake_xircom, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .attach = keyspan_pda_fake_startup, }; @@ -826,9 +825,6 @@ static struct usb_serial_driver keyspan_pda_device = { .description = "Keyspan PDA", .usb_driver = &keyspan_pda_driver, .id_table = id_table_std, - .num_interrupt_in = 1, - .num_bulk_in = 0, - .num_bulk_out = 1, .num_ports = 1, .open = keyspan_pda_open, .close = keyspan_pda_close, diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 55736df7d2f..b395ac75988 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -126,9 +126,6 @@ static struct usb_serial_driver kl5kusb105d_device = { .description = "KL5KUSB105D / PalmConnect", .usb_driver = &kl5kusb105d_driver, .id_table = id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = klsi_105_open, .close = klsi_105_close, @@ -194,7 +191,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, if (rc < 0) err("Change port settings failed (error = %d)", rc); info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", - __FUNCTION__, + __func__, settings->pktlen, settings->baudrate, settings->databits, settings->unknown1, settings->unknown2); @@ -225,7 +222,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1}; __u16 status; - info("%s - sending SIO Poll request", __FUNCTION__); + info("%s - sending SIO Poll request", __func__); rc = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_POLL, @@ -240,7 +237,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, else { status = le16_to_cpu(*(u16 *)status_buf); - info("%s - read status %x %x", __FUNCTION__, + info("%s - read status %x %x", __func__, status_buf[0], status_buf[1]); *line_state_p = klsi_105_status2linestate(status); @@ -268,7 +265,7 @@ static int klsi_105_startup (struct usb_serial *serial) priv = kmalloc(sizeof(struct klsi_105_private), GFP_KERNEL); if (!priv) { - dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__); + dbg("%skmalloc for klsi_105_private failed.", __func__); i--; goto err_cleanup; } @@ -298,7 +295,7 @@ static int klsi_105_startup (struct usb_serial *serial) urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (!urb->transfer_buffer) { - err("%s - out of memory for urb buffers.", __FUNCTION__); + err("%s - out of memory for urb buffers.", __func__); goto err_cleanup; } } @@ -328,7 +325,7 @@ static void klsi_105_shutdown (struct usb_serial *serial) { int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { @@ -373,7 +370,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) struct klsi_105_port_settings cfg; unsigned long flags; - dbg("%s port %d", __FUNCTION__, port->number); + dbg("%s port %d", __func__, port->number); /* force low_latency on so that our tty_push actually forces * the data through @@ -419,7 +416,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) rc = usb_submit_urb(port->read_urb, GFP_KERNEL); if (rc) { - err("%s - failed submitting read urb, error %d", __FUNCTION__, rc); + err("%s - failed submitting read urb, error %d", __func__, rc); retval = rc; goto exit; } @@ -437,14 +434,14 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) err("Enabling read failed (error = %d)", rc); retval = rc; } else - dbg("%s - enabled reading", __FUNCTION__); + dbg("%s - enabled reading", __func__); rc = klsi_105_get_line_state(port, &line_state); if (rc >= 0) { spin_lock_irqsave (&priv->lock, flags); priv->line_state = line_state; spin_unlock_irqrestore (&priv->lock, flags); - dbg("%s - read line state 0x%lx", __FUNCTION__, line_state); + dbg("%s - read line state 0x%lx", __func__, line_state); retval = 0; } else retval = rc; @@ -459,7 +456,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) struct klsi_105_private *priv = usb_get_serial_port_data(port); int rc; - dbg("%s port %d", __FUNCTION__, port->number); + dbg("%s port %d", __func__, port->number); mutex_lock(&port->serial->disc_mutex); if (!port->serial->disconnected) { @@ -502,7 +499,7 @@ static int klsi_105_write (struct usb_serial_port *port, int result, size; int bytes_sent=0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); while (count > 0) { /* try to find a free urb (write 0 bytes if none) */ @@ -514,21 +511,21 @@ static int klsi_105_write (struct usb_serial_port *port, for (i=0; i<NUM_URBS; i++) { if (priv->write_urb_pool[i]->status != -EINPROGRESS) { urb = priv->write_urb_pool[i]; - dbg("%s - using pool URB %d", __FUNCTION__, i); + dbg("%s - using pool URB %d", __func__, i); break; } } spin_unlock_irqrestore (&priv->lock, flags); if (urb==NULL) { - dbg("%s - no more free urbs", __FUNCTION__); + dbg("%s - no more free urbs", __func__); goto exit; } if (urb->transfer_buffer == NULL) { urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); if (urb->transfer_buffer == NULL) { - err("%s - no more kernel memory...", __FUNCTION__); + err("%s - no more kernel memory...", __func__); goto exit; } } @@ -554,7 +551,7 @@ static int klsi_105_write (struct usb_serial_port *port, /* send the data out the bulk port */ result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); goto exit; } buf += size; @@ -570,13 +567,13 @@ exit: static void klsi_105_write_bulk_callback ( struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { - dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, + dbg("%s - nonzero write bulk status received: %d", __func__, status); return; } @@ -603,7 +600,7 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port) spin_unlock_irqrestore (&priv->lock, flags); - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return (chars); } @@ -623,7 +620,7 @@ static int klsi_105_write_room (struct usb_serial_port *port) spin_unlock_irqrestore (&priv->lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return (room); } @@ -631,18 +628,18 @@ static int klsi_105_write_room (struct usb_serial_port *port) static void klsi_105_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct klsi_105_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int rc; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* The urb might have been killed. */ if (status) { - dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, + dbg("%s - nonzero read bulk status received: %d", __func__, status); return; } @@ -652,12 +649,12 @@ static void klsi_105_read_bulk_callback (struct urb *urb) */ if (urb->actual_length == 0) { /* empty urbs seem to happen, we ignore them */ - /* dbg("%s - emtpy URB", __FUNCTION__); */ + /* dbg("%s - emtpy URB", __func__); */ ; } else if (urb->actual_length <= 2) { - dbg("%s - size %d URB not understood", __FUNCTION__, + dbg("%s - size %d URB not understood", __func__, urb->actual_length); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); } else { int bytes_sent = ((__u8 *) data)[0] + @@ -669,12 +666,12 @@ static void klsi_105_read_bulk_callback (struct urb *urb) * intermixed tty_flip_buffer_push()s * FIXME */ - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); if (bytes_sent + 2 > urb->actual_length) { dbg("%s - trying to read more data than available" - " (%d vs. %d)", __FUNCTION__, + " (%d vs. %d)", __func__, bytes_sent+2, urb->actual_length); /* cap at implied limit */ bytes_sent = urb->actual_length - 2; @@ -697,7 +694,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) port); rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (rc) - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, rc); + err("%s - failed resubmitting read urb, error %d", __func__, rc); } /* klsi_105_read_bulk_callback */ @@ -705,12 +702,14 @@ static void klsi_105_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { struct klsi_105_private *priv = usb_get_serial_port_data(port); - unsigned int iflag = port->tty->termios->c_iflag; + struct tty_struct *tty = port->tty; + unsigned int iflag = tty->termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag; - unsigned int cflag = port->tty->termios->c_cflag; + unsigned int cflag = tty->termios->c_cflag; unsigned int old_cflag = old_termios->c_cflag; struct klsi_105_port_settings cfg; unsigned long flags; + speed_t baud; /* lock while we are modifying the settings */ spin_lock_irqsave (&priv->lock, flags); @@ -718,10 +717,12 @@ static void klsi_105_set_termios (struct usb_serial_port *port, /* * Update baud rate */ + baud = tty_get_baud_rate(tty); + if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { /* reassert DTR and (maybe) RTS on transition from B0 */ if( (old_cflag & CBAUD) == B0 ) { - dbg("%s: baud was B0", __FUNCTION__); + dbg("%s: baud was B0", __func__); #if 0 priv->control_state |= TIOCM_DTR; /* don't set RTS if using hardware flow control */ @@ -731,8 +732,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, mct_u232_set_modem_ctrl(serial, priv->control_state); #endif } - - switch(tty_get_baud_rate(port->tty)) { + } + switch(baud) { case 0: /* handled below */ break; case 1200: @@ -760,35 +761,36 @@ static void klsi_105_set_termios (struct usb_serial_port *port, priv->cfg.baudrate = kl5kusb105a_sio_b115200; break; default: - err("KLSI USB->Serial converter:" + dbg("KLSI USB->Serial converter:" " unsupported baudrate request, using default" " of 9600"); priv->cfg.baudrate = kl5kusb105a_sio_b9600; + baud = 9600; break; - } - if ((cflag & CBAUD) == B0 ) { - dbg("%s: baud is B0", __FUNCTION__); - /* Drop RTS and DTR */ - /* maybe this should be simulated by sending read - * disable and read enable messages? - */ - ; + } + if ((cflag & CBAUD) == B0 ) { + dbg("%s: baud is B0", __func__); + /* Drop RTS and DTR */ + /* maybe this should be simulated by sending read + * disable and read enable messages? + */ + ; #if 0 - priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); - mct_u232_set_modem_ctrl(serial, priv->control_state); + priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); + mct_u232_set_modem_ctrl(serial, priv->control_state); #endif - } } + tty_encode_baud_rate(tty, baud, baud); if ((cflag & CSIZE) != (old_cflag & CSIZE)) { /* set the number of data bits */ switch (cflag & CSIZE) { case CS5: - dbg("%s - 5 bits/byte not supported", __FUNCTION__); + dbg("%s - 5 bits/byte not supported", __func__); spin_unlock_irqrestore (&priv->lock, flags); return ; case CS6: - dbg("%s - 6 bits/byte not supported", __FUNCTION__); + dbg("%s - 6 bits/byte not supported", __func__); spin_unlock_irqrestore (&priv->lock, flags); return ; case CS7: @@ -810,6 +812,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { + /* Not currently supported */ + tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); #if 0 priv->last_lcr = 0; @@ -837,6 +841,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, || (iflag & IXON) != (old_iflag & IXON) || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { + /* Not currently supported */ + tty->termios->c_cflag &= ~CRTSCTS; /* Drop DTR/RTS if no flow control otherwise assert */ #if 0 if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) @@ -862,7 +868,7 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) struct mct_u232_private *priv = (struct mct_u232_private *)port->private; unsigned char lcr = priv->last_lcr; - dbg("%sstate=%d", __FUNCTION__, break_state); + dbg("%sstate=%d", __func__, break_state); if (break_state) lcr |= MCT_U232_SET_BREAK; @@ -877,7 +883,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) unsigned long flags; int rc; unsigned long line_state; - dbg("%s - request, just guessing", __FUNCTION__); + dbg("%s - request, just guessing", __func__); rc = klsi_105_get_line_state(port, &line_state); if (rc < 0) { @@ -889,7 +895,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) spin_lock_irqsave (&priv->lock, flags); priv->line_state = line_state; spin_unlock_irqrestore (&priv->lock, flags); - dbg("%s - read line state 0x%lx", __FUNCTION__, line_state); + dbg("%s - read line state 0x%lx", __func__, line_state); return (int)line_state; } @@ -898,7 +904,7 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, { int retval = -EINVAL; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* if this ever gets implemented, it should be done something like this: struct usb_serial *serial = port->serial; @@ -924,7 +930,7 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, static void klsi_105_throttle (struct usb_serial_port *port) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); } @@ -932,12 +938,12 @@ static void klsi_105_unthrottle (struct usb_serial_port *port) { int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed submitting read urb, error %d", __FUNCTION__, + err("%s - failed submitting read urb, error %d", __func__, result); } diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 17b3baead4a..693f00da7c0 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -113,10 +113,6 @@ static struct usb_serial_driver kobil_device = { .description = "KOBIL USB smart card terminal", .usb_driver = &kobil_driver, .id_table = id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_interrupt_out = NUM_DONT_CARE, - .num_bulk_in = 0, - .num_bulk_out = 0, .num_ports = 1, .attach = kobil_startup, .shutdown = kobil_shutdown, @@ -139,7 +135,6 @@ struct kobil_private { int filled; // index of the last char in buf int cur_pos; // index of the next char to send in buf __u16 device_type; - int line_state; }; @@ -161,7 +156,6 @@ static int kobil_startup (struct usb_serial *serial) priv->filled = 0; priv->cur_pos = 0; priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); - priv->line_state = 0; switch (priv->device_type){ case KOBIL_ADAPTER_B_PRODUCT_ID: @@ -189,11 +183,11 @@ static int kobil_startup (struct usb_serial *serial) for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { endpoint = &altsetting->endpoint[i]; if (usb_endpoint_is_int_out(&endpoint->desc)) { - dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); + dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; } if (usb_endpoint_is_int_in(&endpoint->desc)) { - dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); + dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; } } @@ -204,7 +198,7 @@ static int kobil_startup (struct usb_serial *serial) static void kobil_shutdown (struct usb_serial *serial) { int i; - dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); + dbg("%s - port %d", __func__, serial->port[0]->number); for (i=0; i < serial->num_ports; ++i) { while (serial->port[i]->open_count > 0) { @@ -224,9 +218,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) int transfer_buffer_length = 8; int write_urb_transfer_buffer_length = 8; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); priv = usb_get_serial_port_data(port); - priv->line_state = 0; // someone sets the dev to 0 if the close method has been called port->interrupt_in_urb->dev = port->serial->dev; @@ -252,10 +245,10 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) // allocate write_urb if (!port->write_urb) { - dbg("%s - port %d Allocating port->write_urb", __FUNCTION__, port->number); + dbg("%s - port %d Allocating port->write_urb", __func__, port->number); port->write_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port->write_urb) { - dbg("%s - port %d usb_alloc_urb failed", __FUNCTION__, port->number); + dbg("%s - port %d usb_alloc_urb failed", __func__, port->number); kfree(transfer_buffer); return -ENOMEM; } @@ -281,7 +274,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) transfer_buffer_length, KOBIL_TIMEOUT ); - dbg("%s - port %d Send get_HW_version URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result); dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); // get firmware version @@ -295,7 +288,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) transfer_buffer_length, KOBIL_TIMEOUT ); - dbg("%s - port %d Send get_FW_version URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result); dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { @@ -310,7 +303,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) 0, KOBIL_TIMEOUT ); - dbg("%s - port %d Send set_baudrate URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result); // reset all queues result = usb_control_msg( port->serial->dev, @@ -323,13 +316,13 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) 0, KOBIL_TIMEOUT ); - dbg("%s - port %d Send reset_all_queues URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result); } if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { // start reading (Adapter B 'cause PNP string) result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); - dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); } kfree(transfer_buffer); @@ -339,7 +332,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) static void kobil_close (struct usb_serial_port *port, struct file *filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->write_urb) { usb_kill_urb(port->write_urb); @@ -359,11 +352,11 @@ static void kobil_read_int_callback(struct urb *urb) int status = urb->status; // char *dbg_data; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - port %d Read int status not zero: %d", - __FUNCTION__, port->number, status); + __func__, port->number, status); return; } @@ -393,7 +386,7 @@ static void kobil_read_int_callback(struct urb *urb) port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); - dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); } @@ -411,21 +404,21 @@ static int kobil_write (struct usb_serial_port *port, struct kobil_private * priv; if (count == 0) { - dbg("%s - port %d write request of 0 bytes", __FUNCTION__, port->number); + dbg("%s - port %d write request of 0 bytes", __func__, port->number); return 0; } priv = usb_get_serial_port_data(port); if (count > (KOBIL_BUF_LENGTH - priv->filled)) { - dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number); + dbg("%s - port %d Error: write request bigger than buffer size", __func__, port->number); return -ENOMEM; } // Copy data to buffer memcpy (priv->buf + priv->filled, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled); + usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); priv->filled = priv->filled + count; @@ -457,7 +450,7 @@ static int kobil_write (struct usb_serial_port *port, priv->cur_pos = priv->cur_pos + length; result = usb_submit_urb( port->write_urb, GFP_NOIO ); - dbg("%s - port %d Send write URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result); todo = priv->filled - priv->cur_pos; if (todo > 0) { @@ -478,7 +471,7 @@ static int kobil_write (struct usb_serial_port *port, port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); - dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); } } return count; @@ -487,7 +480,7 @@ static int kobil_write (struct usb_serial_port *port, static int kobil_write_room (struct usb_serial_port *port) { - //dbg("%s - port %d", __FUNCTION__, port->number); + //dbg("%s - port %d", __func__, port->number); return 8; } @@ -522,16 +515,13 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) KOBIL_TIMEOUT); dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", - __FUNCTION__, port->number, result, transfer_buffer[0]); - - if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) { - priv->line_state |= TIOCM_DSR; - } else { - priv->line_state &= ~TIOCM_DSR; - } + __func__, port->number, result, transfer_buffer[0]); + result = 0; + if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) + result = TIOCM_DSR; kfree(transfer_buffer); - return priv->line_state; + return result; } static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, @@ -544,6 +534,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, unsigned char *transfer_buffer; int transfer_buffer_length = 8; + /* FIXME: locking ? */ priv = usb_get_serial_port_data(port); if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { // This device doesn't support ioctl calls @@ -567,9 +558,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { if (dtr != 0) - dbg("%s - port %d Setting DTR", __FUNCTION__, port->number); + dbg("%s - port %d Setting DTR", __func__, port->number); else - dbg("%s - port %d Clearing DTR", __FUNCTION__, port->number); + dbg("%s - port %d Clearing DTR", __func__, port->number); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), SUSBCRequest_SetStatusLinesOrQueues, @@ -581,9 +572,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, KOBIL_TIMEOUT); } else { if (rts != 0) - dbg("%s - port %d Setting RTS", __FUNCTION__, port->number); + dbg("%s - port %d Setting RTS", __func__, port->number); else - dbg("%s - port %d Clearing RTS", __FUNCTION__, port->number); + dbg("%s - port %d Clearing RTS", __func__, port->number); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), SUSBCRequest_SetStatusLinesOrQueues, @@ -594,7 +585,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, 0, KOBIL_TIMEOUT); } - dbg("%s - port %d Send set_status_line URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result); kfree(transfer_buffer); return (result < 0) ? result : 0; } @@ -687,7 +678,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne KOBIL_TIMEOUT ); - dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); kfree(transfer_buffer); return (result < 0) ? -EFAULT : 0; default: diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index fc1cea4aba1..5fc2cef30e3 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -143,9 +143,6 @@ static struct usb_serial_driver mct_u232_device = { .description = "MCT U232", .usb_driver = &mct_u232_driver, .id_table = id_table_combined, - .num_interrupt_in = 2, - .num_bulk_in = 0, - .num_bulk_out = 1, .num_ports = 1, .open = mct_u232_open, .close = mct_u232_close, @@ -402,7 +399,7 @@ static void mct_u232_shutdown (struct usb_serial *serial) struct mct_u232_private *priv; int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i=0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ @@ -424,7 +421,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) unsigned char last_lcr; unsigned char last_msr; - dbg("%s port %d", __FUNCTION__, port->number); + dbg("%s port %d", __func__, port->number); /* Compensate for a hardware bug: although the Sitecom U232-P25 * device reports a maximum output packet size of 32 bytes, @@ -489,7 +486,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp) unsigned int c_cflag; unsigned int control_state; struct mct_u232_private *priv = usb_get_serial_port_data(port); - dbg("%s port %d", __FUNCTION__, port->number); + dbg("%s port %d", __func__, port->number); if (port->tty) { c_cflag = port->tty->termios->c_cflag; @@ -517,7 +514,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp) static void mct_u232_read_int_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct mct_u232_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; struct tty_struct *tty; @@ -535,21 +532,21 @@ static void mct_u232_read_int_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); + dbg("%s - bad serial pointer, exiting", __func__); return; } - dbg("%s - port %d", __FUNCTION__, port->number); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + dbg("%s - port %d", __func__, port->number); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); /* * Work-a-round: handle the 'usual' bulk-in pipe here @@ -606,7 +603,7 @@ exit: retval = usb_submit_urb (urb, GFP_ATOMIC); if (retval) err ("%s - usb_submit_urb failed with result %d", - __FUNCTION__, retval); + __func__, retval); } /* mct_u232_read_int_callback */ static void mct_u232_set_termios (struct usb_serial_port *port, @@ -636,7 +633,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, /* reassert DTR and RTS on transition from B0 */ if ((old_cflag & CBAUD) == B0) { - dbg("%s: baud was B0", __FUNCTION__); + dbg("%s: baud was B0", __func__); control_state |= TIOCM_DTR | TIOCM_RTS; mct_u232_set_modem_ctrl(serial, control_state); } @@ -644,7 +641,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty)); if ((cflag & CBAUD) == B0 ) { - dbg("%s: baud is B0", __FUNCTION__); + dbg("%s: baud is B0", __func__); /* Drop RTS and DTR */ control_state &= ~(TIOCM_DTR | TIOCM_RTS); mct_u232_set_modem_ctrl(serial, control_state); @@ -699,7 +696,7 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) unsigned char lcr; unsigned long flags; - dbg("%sstate=%d", __FUNCTION__, break_state); + dbg("%sstate=%d", __func__, break_state); spin_lock_irqsave(&priv->lock, flags); lcr = priv->last_lcr; @@ -718,7 +715,7 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file) unsigned int control_state; unsigned long flags; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); control_state = priv->control_state; @@ -735,7 +732,7 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int control_state; unsigned long flags; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); control_state = priv->control_state; @@ -757,7 +754,7 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) { - dbg("%scmd=0x%x", __FUNCTION__, cmd); + dbg("%scmd=0x%x", __func__, cmd); /* Based on code from acm.c and others */ switch (cmd) { @@ -772,7 +769,7 @@ static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, return 0; default: - dbg("%s: arg not supported - 0x%04x", __FUNCTION__,cmd); + dbg("%s: arg not supported - 0x%04x", __func__,cmd); return(-ENOIOCTLCMD); break; } @@ -787,7 +784,7 @@ static void mct_u232_throttle (struct usb_serial_port *port) struct tty_struct *tty; tty = port->tty; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->rx_flags |= THROTTLED; @@ -809,7 +806,7 @@ static void mct_u232_unthrottle (struct usb_serial_port *port) unsigned int control_state; struct tty_struct *tty; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); tty = port->tty; spin_lock_irqsave(&priv->lock, flags); diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 40f3a018880..50f1fe26333 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -118,11 +118,11 @@ static void mos7720_interrupt_callback(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, + dbg("%s - urb shutting down with status: %d", __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", __FUNCTION__, + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } @@ -183,7 +183,7 @@ exit: if (result) dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", - __FUNCTION__, result); + __func__, result); return; } @@ -214,7 +214,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) port = mos7720_port->port; - dbg("Entering...%s", __FUNCTION__); + dbg("Entering...%s", __func__); data = urb->transfer_buffer; @@ -362,7 +362,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (!urb->transfer_buffer) { - err("%s-out of memory for urb buffers.", __FUNCTION__); + err("%s-out of memory for urb buffers.", __func__); usb_free_urb(mos7720_port->write_urb_pool[j]); mos7720_port->write_urb_pool[j] = NULL; continue; @@ -479,7 +479,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) if (response) dev_err(&port->dev, "%s - Error %d submitting control urb\n", - __FUNCTION__, response); + __func__, response); } /* set up our bulk in urb */ @@ -492,7 +492,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) response = usb_submit_urb(port->read_urb, GFP_KERNEL); if (response) dev_err(&port->dev, - "%s - Error %d submitting read urb\n", __FUNCTION__, response); + "%s - Error %d submitting read urb\n", __func__, response); /* initialize our icount structure */ memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); @@ -521,11 +521,11 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port) int chars = 0; struct moschip_port *mos7720_port; - dbg("%s:entering ...........", __FUNCTION__); + dbg("%s:entering ...........", __func__); mos7720_port = usb_get_serial_port_data(port); if (mos7720_port == NULL) { - dbg("%s:leaving ...........", __FUNCTION__); + dbg("%s:leaving ...........", __func__); return -ENODEV; } @@ -533,7 +533,7 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port) if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) chars += URB_TRANSFER_BUFFER_SIZE; } - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } @@ -585,7 +585,7 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp) mutex_unlock(&serial->disc_mutex); mos7720_port->open = 0; - dbg("Leaving %s", __FUNCTION__); + dbg("Leaving %s", __func__); } static void mos7720_break(struct usb_serial_port *port, int break_state) @@ -594,7 +594,7 @@ static void mos7720_break(struct usb_serial_port *port, int break_state) struct usb_serial *serial; struct moschip_port *mos7720_port; - dbg("Entering %s", __FUNCTION__); + dbg("Entering %s", __func__); serial = port->serial; @@ -627,20 +627,21 @@ static int mos7720_write_room(struct usb_serial_port *port) int room = 0; int i; - dbg("%s:entering ...........", __FUNCTION__); + dbg("%s:entering ...........", __func__); mos7720_port = usb_get_serial_port_data(port); if (mos7720_port == NULL) { - dbg("%s:leaving ...........", __FUNCTION__); + dbg("%s:leaving ...........", __func__); return -ENODEV; } + /* FIXME: Locking */ for (i = 0; i < NUM_URBS; ++i) { if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) room += URB_TRANSFER_BUFFER_SIZE; } - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -657,7 +658,7 @@ static int mos7720_write(struct usb_serial_port *port, struct urb *urb; const unsigned char *current_position = data; - dbg("%s:entering ...........", __FUNCTION__); + dbg("%s:entering ...........", __func__); serial = port->serial; @@ -679,7 +680,7 @@ static int mos7720_write(struct usb_serial_port *port, } if (urb == NULL) { - dbg("%s - no more free urbs", __FUNCTION__); + dbg("%s - no more free urbs", __func__); goto exit; } @@ -687,14 +688,14 @@ static int mos7720_write(struct usb_serial_port *port, urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (urb->transfer_buffer == NULL) { - err("%s no more kernel memory...", __FUNCTION__); + err("%s no more kernel memory...", __func__); goto exit; } } transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); memcpy(urb->transfer_buffer, current_position, transfer_size); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, + usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer); /* fill urb with data and submit */ @@ -708,7 +709,7 @@ static int mos7720_write(struct usb_serial_port *port, status = usb_submit_urb(urb,GFP_ATOMIC); if (status) { err("%s - usb_submit_urb(write bulk) failed with status = %d", - __FUNCTION__, status); + __func__, status); bytes_sent = status; goto exit; } @@ -724,7 +725,7 @@ static void mos7720_throttle(struct usb_serial_port *port) struct tty_struct *tty; int status; - dbg("%s- port %d\n", __FUNCTION__, port->number); + dbg("%s- port %d\n", __func__, port->number); mos7720_port = usb_get_serial_port_data(port); @@ -736,11 +737,11 @@ static void mos7720_throttle(struct usb_serial_port *port) return; } - dbg("%s: Entering ..........", __FUNCTION__); + dbg("%s: Entering ..........", __func__); tty = port->tty; if (!tty) { - dbg("%s - no tty available", __FUNCTION__); + dbg("%s - no tty available", __func__); return; } @@ -773,15 +774,15 @@ static void mos7720_unthrottle(struct usb_serial_port *port) return; if (!mos7720_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } - dbg("%s: Entering ..........", __FUNCTION__); + dbg("%s: Entering ..........", __func__); tty = port->tty; if (!tty) { - dbg("%s - no tty available", __FUNCTION__); + dbg("%s - no tty available", __func__); return; } @@ -922,7 +923,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) __u16 round; - dbg("%s - %d", __FUNCTION__, baudrate); + dbg("%s - %d", __func__, baudrate); for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { if (divisor_table[i].baudrate == baudrate) { @@ -973,15 +974,15 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, port = mos7720_port->port; serial = port->serial; - dbg("%s: Entering ..........", __FUNCTION__); + dbg("%s: Entering ..........", __func__); number = port->number - port->serial->minor; - dbg("%s - port = %d, baud = %d", __FUNCTION__, port->number, baudrate); + dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); /* Calculate the Divisor */ status = calc_baud_rate_divisor(baudrate, &divisor); if (status) { - err("%s - bad baud rate", __FUNCTION__); + err("%s - bad baud rate", __func__); return status; } @@ -1034,16 +1035,16 @@ static void change_port_settings(struct moschip_port *mos7720_port, serial = port->serial; port_number = port->number - port->serial->minor; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!mos7720_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } tty = mos7720_port->port->tty; - dbg("%s: Entering ..........", __FUNCTION__); + dbg("%s: Entering ..........", __func__); lData = UART_LCR_WLEN8; lStop = 0x00; /* 1 stop bit */ @@ -1078,14 +1079,14 @@ static void change_port_settings(struct moschip_port *mos7720_port, if (cflag & PARENB) { if (cflag & PARODD) { lParity = UART_LCR_PARITY; - dbg("%s - parity = odd", __FUNCTION__); + dbg("%s - parity = odd", __func__); } else { lParity = (UART_LCR_EPAR | UART_LCR_PARITY); - dbg("%s - parity = even", __FUNCTION__); + dbg("%s - parity = even", __func__); } } else { - dbg("%s - parity = none", __FUNCTION__); + dbg("%s - parity = none", __func__); } if (cflag & CMSPAR) @@ -1094,10 +1095,10 @@ static void change_port_settings(struct moschip_port *mos7720_port, /* Change the Stop bit */ if (cflag & CSTOPB) { lStop = UART_LCR_STOP; - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); } else { lStop = 0x00; - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); } #define LCR_BITS_MASK 0x03 /* Mask for bits/char field */ @@ -1171,7 +1172,7 @@ static void change_port_settings(struct moschip_port *mos7720_port, return; } - dbg("%s - baud rate = %d", __FUNCTION__, baud); + dbg("%s - baud rate = %d", __func__, baud); status = send_cmd_write_baud_rate(mos7720_port, baud); /* FIXME: needs to write actual resulting baud back not just blindly do so */ @@ -1217,7 +1218,7 @@ static void mos7720_set_termios(struct usb_serial_port *port, if (!mos7720_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } @@ -1225,15 +1226,15 @@ static void mos7720_set_termios(struct usb_serial_port *port, cflag = tty->termios->c_cflag; - dbg("%s - cflag %08x iflag %08x", __FUNCTION__, + dbg("%s - cflag %08x iflag %08x", __func__, tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); - dbg("%s - old cflag %08x old iflag %08x", __FUNCTION__, + dbg("%s - old cflag %08x old iflag %08x", __func__, old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* change the port settings to the new ones specified */ change_port_settings(mos7720_port, old_termios); @@ -1271,7 +1272,7 @@ static int get_lsr_info(struct moschip_port *mos7720_port, count = mos7720_chars_in_buffer(mos7720_port->port); if (count == 0) { - dbg("%s -- Empty", __FUNCTION__); + dbg("%s -- Empty", __func__); result = TIOCSER_TEMT; } @@ -1296,7 +1297,7 @@ static int get_number_bytes_avail(struct moschip_port *mos7720_port, result = tty->read_cnt; - dbg("%s(%d) = %d", __FUNCTION__, mos7720_port->port->number, result); + dbg("%s(%d) = %d", __func__, mos7720_port->port->number, result); if (copy_to_user(value, &result, sizeof(int))) return -EFAULT; @@ -1374,7 +1375,7 @@ static int get_modem_info(struct moschip_port *mos7720_port, | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ - dbg("%s -- %x", __FUNCTION__, result); + dbg("%s -- %x", __func__, result); if (copy_to_user(value, &result, sizeof(int))) return -EFAULT; @@ -1418,45 +1419,45 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, if (mos7720_port == NULL) return -ENODEV; - dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { case TIOCINQ: /* return number of bytes available */ - dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); + dbg("%s (%d) TIOCINQ", __func__, port->number); return get_number_bytes_avail(mos7720_port, (unsigned int __user *)arg); break; case TIOCSERGETLSR: - dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); + dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); return get_lsr_info(mos7720_port, (unsigned int __user *)arg); return 0; case TIOCMBIS: case TIOCMBIC: case TIOCMSET: - dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, + dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, port->number); return set_modem_info(mos7720_port, cmd, (unsigned int __user *)arg); case TIOCMGET: - dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); + dbg("%s (%d) TIOCMGET", __func__, port->number); return get_modem_info(mos7720_port, (unsigned int __user *)arg); case TIOCGSERIAL: - dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); + dbg("%s (%d) TIOCGSERIAL", __func__, port->number); return get_serial_info(mos7720_port, (struct serial_struct __user *)arg); case TIOCSSERIAL: - dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); + dbg("%s (%d) TIOCSSERIAL", __func__, port->number); break; case TIOCMIWAIT: - dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = mos7720_port->icount; while (1) { if (signal_pending(current)) @@ -1490,7 +1491,7 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, icount.brk = cnow.brk; icount.buf_overrun = cnow.buf_overrun; - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx ); if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) return -EFAULT; @@ -1508,7 +1509,7 @@ static int mos7720_startup(struct usb_serial *serial) int i; char data; - dbg("%s: Entering ..........", __FUNCTION__); + dbg("%s: Entering ..........", __func__); if (!serial) { dbg("Invalid Handler"); @@ -1520,7 +1521,7 @@ static int mos7720_startup(struct usb_serial *serial) /* create our private serial structure */ mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); if (mos7720_serial == NULL) { - err("%s - Out of memory", __FUNCTION__); + err("%s - Out of memory", __func__); return -ENOMEM; } @@ -1533,7 +1534,7 @@ static int mos7720_startup(struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); if (mos7720_port == NULL) { - err("%s - Out of memory", __FUNCTION__); + err("%s - Out of memory", __func__); usb_set_serial_data(serial, NULL); kfree(mos7720_serial); return -ENOMEM; @@ -1596,9 +1597,6 @@ static struct usb_serial_driver moschip7720_2port_driver = { .description = "Moschip 2 port adapter", .usb_driver = &usb_driver, .id_table = moschip_port_id_table, - .num_interrupt_in = 1, - .num_bulk_in = 2, - .num_bulk_out = 2, .num_ports = 2, .open = mos7720_open, .close = mos7720_close, @@ -1620,7 +1618,7 @@ static int __init moschip7720_init(void) { int retval; - dbg("%s: Entering ..........", __FUNCTION__); + dbg("%s: Entering ..........", __func__); /* Register with the usb serial */ retval = usb_serial_register(&moschip7720_2port_driver); diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index aeeb9cb2099..6bcb82d3911 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -403,7 +403,7 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr) { struct async_icount *icount; - dbg("%s - %02x", __FUNCTION__, new_lsr); + dbg("%s - %02x", __func__, new_lsr); if (new_lsr & SERIAL_LSR_BI) { // @@ -449,7 +449,7 @@ static void mos7840_control_callback(struct urb *urb) int result = 0; int status = urb->status; - mos7840_port = (struct moschip_port *)urb->context; + mos7840_port = urb->context; switch (status) { case 0: @@ -459,21 +459,21 @@ static void mos7840_control_callback(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, + dbg("%s - urb shutting down with status: %d", __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", __FUNCTION__, + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } - dbg("%s urb buffer size is %d\n", __FUNCTION__, urb->actual_length); - dbg("%s mos7840_port->MsrLsr is %d port %d\n", __FUNCTION__, + dbg("%s urb buffer size is %d\n", __func__, urb->actual_length); + dbg("%s mos7840_port->MsrLsr is %d port %d\n", __func__, mos7840_port->MsrLsr, mos7840_port->port_num); data = urb->transfer_buffer; regval = (__u8) data[0]; - dbg("%s data is %x\n", __FUNCTION__, regval); + dbg("%s data is %x\n", __func__, regval); if (mos7840_port->MsrLsr == 0) mos7840_handle_new_msr(mos7840_port, regval); else if (mos7840_port->MsrLsr == 1) @@ -487,7 +487,7 @@ exit: if (result) { dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", - __FUNCTION__, result); + __func__, result); } } @@ -542,11 +542,11 @@ static void mos7840_interrupt_callback(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, + dbg("%s - urb shutting down with status: %d", __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", __FUNCTION__, + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } @@ -554,7 +554,7 @@ static void mos7840_interrupt_callback(struct urb *urb) length = urb->actual_length; data = urb->transfer_buffer; - serial = (struct usb_serial *)urb->context; + serial = urb->context; /* Moschip get 5 bytes * Byte 1 IIR Port 1 (port.number is 0) @@ -614,7 +614,7 @@ exit: if (result) { dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", - __FUNCTION__, result); + __func__, result); } } @@ -685,19 +685,19 @@ static void mos7840_bulk_in_callback(struct urb *urb) return; } - mos7840_port = (struct moschip_port *)urb->context; + mos7840_port = urb->context; if (!mos7840_port) { dbg("%s", "NULL mos7840_port pointer \n"); return; } port = (struct usb_serial_port *)mos7840_port->port; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } - serial = mos7840_get_usb_serial(port, __FUNCTION__); + serial = mos7840_get_usb_serial(port, __func__); if (!serial) { dbg("%s\n", "Bad serial pointer "); return; @@ -752,7 +752,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) int status = urb->status; int i; - mos7840_port = (struct moschip_port *)urb->context; + mos7840_port = urb->context; spin_lock(&mos7840_port->pool_lock); for (i = 0; i < NUM_URBS; i++) { if (urb == mos7840_port->write_urb_pool[i]) { @@ -767,7 +767,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) return; } - if (mos7840_port_paranoia_check(mos7840_port->port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } @@ -815,14 +815,14 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp) struct moschip_port *mos7840_port; struct moschip_port *port0; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return -ENODEV; } serial = port->serial; - if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { + if (mos7840_serial_paranoia_check(serial, __func__)) { dbg("%s", "Serial Paranoia failed \n"); return -ENODEV; } @@ -851,7 +851,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp) if (!urb->transfer_buffer) { usb_free_urb(urb); mos7840_port->write_urb_pool[j] = NULL; - err("%s-out of memory for urb buffers.", __FUNCTION__); + err("%s-out of memory for urb buffers.", __func__); continue; } } @@ -1039,7 +1039,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp) GFP_KERNEL); if (response) { err("%s - Error %d submitting interrupt urb", - __FUNCTION__, response); + __func__, response); } } @@ -1072,7 +1072,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp) port->bulk_in_endpointAddress); response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); if (response) { - err("%s - Error %d submitting control urb", __FUNCTION__, + err("%s - Error %d submitting control urb", __func__, response); } @@ -1116,7 +1116,7 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port) dbg("%s \n", " mos7840_chars_in_buffer:entering ..........."); - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } @@ -1134,7 +1134,7 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port) } } spin_unlock_irqrestore(&mos7840_port->pool_lock,flags); - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } @@ -1171,7 +1171,7 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) /* No activity.. count down section */ wait--; if (wait == 0) { - dbg("%s - TIMEOUT", __FUNCTION__); + dbg("%s - TIMEOUT", __func__); return; } else { /* Reset timeout value back to seconds */ @@ -1195,12 +1195,12 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp) dbg("%s\n", "mos7840_close:entering..."); - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } - serial = mos7840_get_usb_serial(port, __FUNCTION__); + serial = mos7840_get_usb_serial(port, __func__); if (!serial) { dbg("%s", "Serial Paranoia failed \n"); return; @@ -1314,7 +1314,7 @@ static void mos7840_block_until_chase_response(struct moschip_port /* No activity.. count down section */ wait--; if (wait == 0) { - dbg("%s - TIMEOUT", __FUNCTION__); + dbg("%s - TIMEOUT", __func__); return; } else { /* Reset timeout value back to seconds */ @@ -1337,12 +1337,12 @@ static void mos7840_break(struct usb_serial_port *port, int break_state) dbg("%s \n", "Entering ..........."); dbg("mos7840_break: Start\n"); - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } - serial = mos7840_get_usb_serial(port, __FUNCTION__); + serial = mos7840_get_usb_serial(port, __func__); if (!serial) { dbg("%s", "Serial Paranoia failed \n"); return; @@ -1392,7 +1392,7 @@ static int mos7840_write_room(struct usb_serial_port *port) dbg("%s \n", " mos7840_write_room:entering ..........."); - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); dbg("%s \n", " mos7840_write_room:leaving ..........."); return -1; @@ -1413,7 +1413,7 @@ static int mos7840_write_room(struct usb_serial_port *port) spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -1480,13 +1480,13 @@ static int mos7840_write(struct usb_serial_port *port, status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); #endif - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return -1; } serial = port->serial; - if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { + if (mos7840_serial_paranoia_check(serial, __func__)) { dbg("%s", "Serial Paranoia failed \n"); return -1; } @@ -1512,7 +1512,7 @@ static int mos7840_write(struct usb_serial_port *port, spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); if (urb == NULL) { - dbg("%s - no more free urbs", __FUNCTION__); + dbg("%s - no more free urbs", __func__); goto exit; } @@ -1521,7 +1521,7 @@ static int mos7840_write(struct usb_serial_port *port, kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (urb->transfer_buffer == NULL) { - err("%s no more kernel memory...", __FUNCTION__); + err("%s no more kernel memory...", __func__); goto exit; } } @@ -1547,7 +1547,7 @@ static int mos7840_write(struct usb_serial_port *port, if (status) { mos7840_port->busy[i] = 0; err("%s - usb_submit_urb(write bulk) failed with status = %d", - __FUNCTION__, status); + __func__, status); bytes_sent = status; goto exit; } @@ -1573,7 +1573,7 @@ static void mos7840_throttle(struct usb_serial_port *port) struct tty_struct *tty; int status; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } @@ -1594,7 +1594,7 @@ static void mos7840_throttle(struct usb_serial_port *port) tty = port->tty; if (!tty) { - dbg("%s - no tty available", __FUNCTION__); + dbg("%s - no tty available", __func__); return; } @@ -1634,7 +1634,7 @@ static void mos7840_unthrottle(struct usb_serial_port *port) int status; struct moschip_port *mos7840_port = mos7840_get_port_private(port); - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } @@ -1643,7 +1643,7 @@ static void mos7840_unthrottle(struct usb_serial_port *port) return; if (!mos7840_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } @@ -1651,7 +1651,7 @@ static void mos7840_unthrottle(struct usb_serial_port *port) tty = port->tty; if (!tty) { - dbg("%s - no tty available", __FUNCTION__); + dbg("%s - no tty available", __func__); return; } @@ -1688,7 +1688,7 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file) int status = 0; mos7840_port = mos7840_get_port_private(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (mos7840_port == NULL) return -ENODEV; @@ -1703,7 +1703,7 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file) | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); - dbg("%s - 0x%04X", __FUNCTION__, result); + dbg("%s - 0x%04X", __func__, result); return result; } @@ -1715,13 +1715,14 @@ static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file, unsigned int mcr; unsigned int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) return -ENODEV; + /* FIXME: What locks the port registers ? */ mcr = mos7840_port->shadowMCR; if (clear & TIOCM_RTS) mcr &= ~MCR_RTS; @@ -1758,7 +1759,7 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, __u16 * clk_sel_val) { - dbg("%s - %d", __FUNCTION__, baudRate); + dbg("%s - %d", __func__, baudRate); if (baudRate <= 115200) { *divisor = 115200 / baudRate; @@ -1841,12 +1842,12 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, return -1; port = (struct usb_serial_port *)mos7840_port->port; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } - if (mos7840_serial_paranoia_check(port->serial, __FUNCTION__)) { + if (mos7840_serial_paranoia_check(port->serial, __func__)) { dbg("%s", "Invalid Serial \n"); return -1; } @@ -1855,7 +1856,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, number = mos7840_port->port->number - mos7840_port->port->serial->minor; - dbg("%s - port = %d, baud = %d", __FUNCTION__, + dbg("%s - port = %d, baud = %d", __func__, mos7840_port->port->number, baudRate); //reset clk_uart_sel in spregOffset if (baudRate > 115200) { @@ -1915,7 +1916,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, /* Calculate the Divisor */ if (status) { - err("%s - bad baud rate", __FUNCTION__); + err("%s - bad baud rate", __func__); dbg("%s\n", "bad baud rate"); return status; } @@ -1969,22 +1970,22 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, port = (struct usb_serial_port *)mos7840_port->port; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } - if (mos7840_serial_paranoia_check(port->serial, __FUNCTION__)) { + if (mos7840_serial_paranoia_check(port->serial, __func__)) { dbg("%s", "Invalid Serial \n"); return; } serial = port->serial; - dbg("%s - port %d", __FUNCTION__, mos7840_port->port->number); + dbg("%s - port %d", __func__, mos7840_port->port->number); if (!mos7840_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } @@ -2023,14 +2024,14 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, if (cflag & PARENB) { if (cflag & PARODD) { lParity = LCR_PAR_ODD; - dbg("%s - parity = odd", __FUNCTION__); + dbg("%s - parity = odd", __func__); } else { lParity = LCR_PAR_EVEN; - dbg("%s - parity = even", __FUNCTION__); + dbg("%s - parity = even", __func__); } } else { - dbg("%s - parity = none", __FUNCTION__); + dbg("%s - parity = none", __func__); } if (cflag & CMSPAR) { @@ -2040,10 +2041,10 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, /* Change the Stop bit */ if (cflag & CSTOPB) { lStop = LCR_STOP_2; - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); } else { lStop = LCR_STOP_1; - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); } /* Update the LCR with the correct value */ @@ -2100,7 +2101,7 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, baud = 9600; } - dbg("%s - baud rate = %d", __FUNCTION__, baud); + dbg("%s - baud rate = %d", __func__, baud); status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); /* Enable Interrupts */ @@ -2140,14 +2141,14 @@ static void mos7840_set_termios(struct usb_serial_port *port, struct moschip_port *mos7840_port; struct tty_struct *tty; dbg("mos7840_set_termios: START\n"); - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } serial = port->serial; - if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { + if (mos7840_serial_paranoia_check(serial, __func__)) { dbg("%s", "Invalid Serial \n"); return; } @@ -2160,7 +2161,7 @@ static void mos7840_set_termios(struct usb_serial_port *port, tty = port->tty; if (!mos7840_port->open) { - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); return; } @@ -2168,11 +2169,11 @@ static void mos7840_set_termios(struct usb_serial_port *port, cflag = tty->termios->c_cflag; - dbg("%s - clfag %08x iflag %08x", __FUNCTION__, + dbg("%s - clfag %08x iflag %08x", __func__, tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, + dbg("%s - old clfag %08x old iflag %08x", __func__, old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* change the port settings to the new ones specified */ @@ -2213,7 +2214,7 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, count = mos7840_chars_in_buffer(mos7840_port->port); if (count == 0) { - dbg("%s -- Empty", __FUNCTION__); + dbg("%s -- Empty", __func__); result = TIOCSER_TEMT; } @@ -2240,7 +2241,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port, return -1; port = (struct usb_serial_port *)mos7840_port->port; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } @@ -2314,7 +2315,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port, |((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ |((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ - dbg("%s -- %x", __FUNCTION__, result); + dbg("%s -- %x", __func__, result); if (copy_to_user(value, &result, sizeof(int))) return -EFAULT; @@ -2371,7 +2372,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, struct serial_icounter_struct icount; int mosret = 0; - if (mos7840_port_paranoia_check(port, __FUNCTION__)) { + if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } @@ -2383,39 +2384,39 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, tty = mos7840_port->port->tty; - dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { /* return number of bytes available */ case TIOCSERGETLSR: - dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); + dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); return mos7840_get_lsr_info(mos7840_port, argp); return 0; case TIOCMBIS: case TIOCMBIC: case TIOCMSET: - dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, + dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, port->number); mosret = mos7840_set_modem_info(mos7840_port, cmd, argp); return mosret; case TIOCMGET: - dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); + dbg("%s (%d) TIOCMGET", __func__, port->number); return mos7840_get_modem_info(mos7840_port, argp); case TIOCGSERIAL: - dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); + dbg("%s (%d) TIOCGSERIAL", __func__, port->number); return mos7840_get_serial_info(mos7840_port, argp); case TIOCSSERIAL: - dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); + dbg("%s (%d) TIOCSSERIAL", __func__, port->number); break; case TIOCMIWAIT: - dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = mos7840_port->icount; while (1) { //interruptible_sleep_on(&mos7840_port->delta_msr_wait); @@ -2458,7 +2459,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, icount.brk = cnow.brk; icount.buf_overrun = cnow.buf_overrun; - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx); if (copy_to_user(argp, &icount, sizeof(icount))) return -EFAULT; @@ -2521,7 +2522,7 @@ static int mos7840_startup(struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); if (mos7840_port == NULL) { - err("%s - Out of memory", __FUNCTION__); + err("%s - Out of memory", __func__); status = -ENOMEM; i--; /* don't follow NULL pointer cleaning up */ goto error; @@ -2799,12 +2800,7 @@ static struct usb_serial_driver moschip7840_4port_device = { .description = DRIVER_DESC, .usb_driver = &io_driver, .id_table = moschip_port_id_table, - .num_interrupt_in = 1, //NUM_DONT_CARE,//1, -#ifdef check - .num_bulk_in = 4, - .num_bulk_out = 4, .num_ports = 4, -#endif .open = mos7840_open, .close = mos7840_close, .write = mos7840_write, diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index 7f337c9aeb5..43c8894353b 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c @@ -6,6 +6,10 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. + * + * TODO: + * Add termios method that uses copy_hw but also kills all echo + * flags as the navman is rx only so cannot echo. */ #include <linux/kernel.h> @@ -49,15 +53,15 @@ static void navman_read_int_callback(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); tty = port->tty; @@ -72,29 +76,29 @@ exit: if (result) dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", - __FUNCTION__, result); + __func__, result); } static int navman_open(struct usb_serial_port *port, struct file *filp) { int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->interrupt_in_urb) { - dbg("%s - adding interrupt input for treo", __FUNCTION__); + dbg("%s - adding interrupt input for treo", __func__); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result) dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", - __FUNCTION__, result); + __func__, result); } return result; } static void navman_close(struct usb_serial_port *port, struct file *filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->interrupt_in_urb); } @@ -102,16 +106,12 @@ static void navman_close(struct usb_serial_port *port, struct file *filp) static int navman_write(struct usb_serial_port *port, const unsigned char *buf, int count) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * This device can't write any data, only read from the device - * so we just silently eat all data sent to us and say it was - * successfully sent. - * Evil, I know, but do you have a better idea? */ - - return count; + return -EOPNOTSUPP; } static struct usb_serial_driver navman_device = { @@ -121,9 +121,6 @@ static struct usb_serial_driver navman_device = { }, .id_table = id_table, .usb_driver = &navman_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .open = navman_open, .close = navman_close, diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index ee94d9616d8..7b7422f4947 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -95,9 +95,6 @@ static struct usb_serial_driver zyxel_omninet_device = { .description = "ZyXEL - omni.net lcd plus usb", .usb_driver = &omninet_driver, .id_table = id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 2, .num_ports = 1, .attach = omninet_attach, .open = omninet_open, @@ -153,7 +150,7 @@ static int omninet_attach (struct usb_serial *serial) od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); if( !od ) { - err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); + err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct omninet_data)); return -ENOMEM; } usb_set_serial_port_data(port, od); @@ -166,7 +163,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) struct usb_serial_port *wport; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); wport = serial->port[1]; wport->tty = port->tty; @@ -178,7 +175,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) omninet_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { - err("%s - failed submitting read urb, error %d", __FUNCTION__, result); + err("%s - failed submitting read urb, error %d", __func__, result); } return result; @@ -186,7 +183,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) static void omninet_close (struct usb_serial_port *port, struct file * filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); } @@ -197,18 +194,18 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) static void omninet_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; struct omninet_header *header = (struct omninet_header *) &data[0]; int status = urb->status; int i; int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -236,7 +233,7 @@ static void omninet_read_bulk_callback (struct urb *urb) omninet_read_bulk_callback, port); result = usb_submit_urb(urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); + err("%s - failed resubmitting read urb, error %d", __func__, result); return; } @@ -251,17 +248,17 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return (0); } spin_lock_bh(&wport->lock); if (wport->write_urb_busy) { spin_unlock_bh(&wport->lock); - dbg("%s - already writing", __FUNCTION__); + dbg("%s - already writing", __func__); return 0; } wport->write_urb_busy = 1; @@ -271,7 +268,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, wport->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, wport->write_urb->transfer_buffer); header->oh_seq = od->od_outseq++; header->oh_len = count; @@ -285,7 +282,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); if (result) { wport->write_urb_busy = 0; - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); } else result = count; @@ -298,12 +295,13 @@ static int omninet_write_room (struct usb_serial_port *port) struct usb_serial *serial = port->serial; struct usb_serial_port *wport = serial->port[1]; - int room = 0; // Default: no room + int room = 0; /* Default: no room */ + /* FIXME: no consistent locking for write_urb_busy */ if (wport->write_urb_busy) room = wport->bulk_out_size - OMNINET_HEADERLEN; - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return (room); } @@ -311,15 +309,15 @@ static int omninet_write_room (struct usb_serial_port *port) static void omninet_write_bulk_callback (struct urb *urb) { /* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */ - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; int status = urb->status; - dbg("%s - port %0x\n", __FUNCTION__, port->number); + dbg("%s - port %0x\n", __func__, port->number); port->write_urb_busy = 0; if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -331,7 +329,7 @@ static void omninet_shutdown (struct usb_serial *serial) { struct usb_serial_port *wport = serial->port[1]; struct usb_serial_port *port = serial->port[0]; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); usb_kill_urb(wport->write_urb); kfree(usb_get_serial_port_data(port)); diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index d101025a4c6..e4be2d442b1 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -28,7 +28,7 @@ device features. */ -#define DRIVER_VERSION "v0.7.1" +#define DRIVER_VERSION "v0.7.2" #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" #define DRIVER_DESC "USB Driver for GSM modems" @@ -325,9 +325,6 @@ static struct usb_serial_driver option_1port_device = { .description = "GSM modem (1-port)", .usb_driver = &option_driver, .id_table = option_ids, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .open = option_open, .close = option_close, @@ -411,24 +408,24 @@ module_exit(option_exit); static void option_rx_throttle(struct usb_serial_port *port) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static void option_rx_unthrottle(struct usb_serial_port *port) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static void option_break_ctl(struct usb_serial_port *port, int break_state) { /* Unfortunately, I don't know how to send a break */ - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static void option_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Doesn't support option setting */ tty_termios_copy_hw(port->tty->termios, old_termios); option_send_setup(port); @@ -458,6 +455,7 @@ static int option_tiocmset(struct usb_serial_port *port, struct file *file, portdata = usb_get_serial_port_data(port); + /* FIXME: what locks portdata fields ? */ if (set & TIOCM_RTS) portdata->rts_state = 1; if (set & TIOCM_DTR) @@ -488,7 +486,7 @@ static int option_write(struct usb_serial_port *port, portdata = usb_get_serial_port_data(port); - dbg("%s: write (%d chars)", __FUNCTION__, count); + dbg("%s: write (%d chars)", __func__, count); i = 0; left = count; @@ -509,7 +507,7 @@ static int option_write(struct usb_serial_port *port, dbg("usb_write %p failed (err=%d)", this_urb, this_urb->status); - dbg("%s: endpoint %d buf %d", __FUNCTION__, + dbg("%s: endpoint %d buf %d", __func__, usb_pipeendpoint(this_urb->pipe), i); /* send the data */ @@ -531,7 +529,7 @@ static int option_write(struct usb_serial_port *port, } count -= left; - dbg("%s: wrote (did %d)", __FUNCTION__, count); + dbg("%s: wrote (did %d)", __func__, count); return count; } @@ -544,14 +542,14 @@ static void option_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg("%s: %p", __FUNCTION__, urb); + dbg("%s: %p", __func__, urb); endpoint = usb_pipeendpoint(urb->pipe); - port = (struct usb_serial_port *) urb->context; + port = urb->context; if (status) { dbg("%s: nonzero status: %d on endpoint %02x.", - __FUNCTION__, status, endpoint); + __func__, status, endpoint); } else { tty = port->tty; if (urb->actual_length) { @@ -559,7 +557,7 @@ static void option_indat_callback(struct urb *urb) tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } else { - dbg("%s: empty read urb received", __FUNCTION__); + dbg("%s: empty read urb received", __func__); } /* Resubmit urb so we continue receiving */ @@ -567,7 +565,7 @@ static void option_indat_callback(struct urb *urb) err = usb_submit_urb(urb, GFP_ATOMIC); if (err) printk(KERN_ERR "%s: resubmit read urb failed. " - "(%d)", __FUNCTION__, err); + "(%d)", __func__, err); } } return; @@ -579,9 +577,9 @@ static void option_outdat_callback(struct urb *urb) struct option_port_private *portdata; int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); - port = (struct usb_serial_port *) urb->context; + port = urb->context; usb_serial_port_softint(port); @@ -599,19 +597,19 @@ static void option_instat_callback(struct urb *urb) { int err; int status = urb->status; - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct option_port_private *portdata = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; - dbg("%s", __FUNCTION__); - dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); + dbg("%s", __func__); + dbg("%s: urb %p port %p has data %p", __func__,urb,port,portdata); if (status == 0) { struct usb_ctrlrequest *req_pkt = (struct usb_ctrlrequest *)urb->transfer_buffer; if (!req_pkt) { - dbg("%s: NULL req_pkt\n", __FUNCTION__); + dbg("%s: NULL req_pkt\n", __func__); return; } if ((req_pkt->bRequestType == 0xA1) && @@ -621,7 +619,7 @@ static void option_instat_callback(struct urb *urb) urb->transfer_buffer + sizeof(struct usb_ctrlrequest)); - dbg("%s: signal x%x", __FUNCTION__, signals); + dbg("%s: signal x%x", __func__, signals); old_dcd_state = portdata->dcd_state; portdata->cts_state = 1; @@ -633,11 +631,11 @@ static void option_instat_callback(struct urb *urb) old_dcd_state && !portdata->dcd_state) tty_hangup(port->tty); } else { - dbg("%s: type %x req %x", __FUNCTION__, + dbg("%s: type %x req %x", __func__, req_pkt->bRequestType,req_pkt->bRequest); } } else - dbg("%s: error %d", __FUNCTION__, status); + dbg("%s: error %d", __func__, status); /* Resubmit urb so we continue receiving IRQ data */ if (status != -ESHUTDOWN) { @@ -645,7 +643,7 @@ static void option_instat_callback(struct urb *urb) err = usb_submit_urb(urb, GFP_ATOMIC); if (err) dbg("%s: resubmit intr urb failed. (%d)", - __FUNCTION__, err); + __func__, err); } } @@ -658,13 +656,14 @@ static int option_write_room(struct usb_serial_port *port) portdata = usb_get_serial_port_data(port); + for (i=0; i < N_OUT_URB; i++) { this_urb = portdata->out_urbs[i]; if (this_urb && !test_bit(i, &portdata->out_busy)) data_len += OUT_BUFLEN; } - dbg("%s: %d", __FUNCTION__, data_len); + dbg("%s: %d", __func__, data_len); return data_len; } @@ -679,10 +678,12 @@ static int option_chars_in_buffer(struct usb_serial_port *port) for (i=0; i < N_OUT_URB; i++) { this_urb = portdata->out_urbs[i]; + /* FIXME: This locking is insufficient as this_urb may + go unused during the test */ if (this_urb && test_bit(i, &portdata->out_busy)) data_len += this_urb->transfer_buffer_length; } - dbg("%s: %d", __FUNCTION__, data_len); + dbg("%s: %d", __func__, data_len); return data_len; } @@ -695,7 +696,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp) portdata = usb_get_serial_port_data(port); - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Set some sane defaults */ portdata->rts_state = 1; @@ -707,7 +708,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp) if (! urb) continue; if (urb->dev != serial->dev) { - dbg("%s: dev %p != %p", __FUNCTION__, + dbg("%s: dev %p != %p", __func__, urb->dev, serial->dev); continue; } @@ -721,7 +722,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp) err = usb_submit_urb(urb, GFP_KERNEL); if (err) { dbg("%s: submit urb %d failed (%d) %d", - __FUNCTION__, i, err, + __func__, i, err, urb->transfer_buffer_length); } } @@ -749,7 +750,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp) struct usb_serial *serial = port->serial; struct option_port_private *portdata; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); portdata = usb_get_serial_port_data(port); portdata->rts_state = 0; @@ -782,7 +783,7 @@ static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint, urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ if (urb == NULL) { - dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint); + dbg("%s: alloc for endpoint %d failed.", __func__, endpoint); return NULL; } @@ -801,7 +802,7 @@ static void option_setup_urbs(struct usb_serial *serial) struct usb_serial_port *port; struct option_port_private *portdata; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; @@ -823,15 +824,18 @@ static void option_setup_urbs(struct usb_serial *serial) } } + +/** send RTS/DTR state to the port. + * + * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN + * CDC. +*/ static int option_send_setup(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct option_port_private *portdata; - - dbg("%s", __FUNCTION__); - - if (port->number != 0) - return 0; + int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; + dbg("%s", __func__); portdata = usb_get_serial_port_data(port); @@ -844,7 +848,7 @@ static int option_send_setup(struct usb_serial_port *port) return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); + 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT); } return 0; @@ -857,7 +861,7 @@ static int option_startup(struct usb_serial *serial) struct option_port_private *portdata; u8 *buffer; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { @@ -865,7 +869,7 @@ static int option_startup(struct usb_serial *serial) portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); if (!portdata) { dbg("%s: kmalloc for option_port_private (%d) failed!.", - __FUNCTION__, i); + __func__, i); return (1); } @@ -890,7 +894,7 @@ static int option_startup(struct usb_serial *serial) err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (err) dbg("%s: submit irq_in urb failed %d", - __FUNCTION__, err); + __func__, err); } option_setup_urbs(serial); @@ -914,7 +918,7 @@ static void option_shutdown(struct usb_serial *serial) struct usb_serial_port *port; struct option_port_private *portdata; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Stop reading/writing urbs */ for (i = 0; i < serial->num_ports; ++i) { diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index a3847d6c946..d92bb6501c8 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c @@ -179,9 +179,6 @@ static struct usb_serial_driver oti6858_device = { .name = "oti6858", }, .id_table = id_table, - .num_interrupt_in = 1, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = oti6858_open, .close = oti6858_close, @@ -238,10 +235,10 @@ static void setup_line(struct work_struct *work) unsigned long flags; int result; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); if ((new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { - dev_err(&port->dev, "%s(): out of memory!\n", __FUNCTION__); + dev_err(&port->dev, "%s(): out of memory!\n", __func__); /* we will try again */ schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); return; @@ -256,7 +253,7 @@ static void setup_line(struct work_struct *work) 100); if (result != OTI6858_CTRL_PKT_SIZE) { - dev_err(&port->dev, "%s(): error reading status\n", __FUNCTION__); + dev_err(&port->dev, "%s(): error reading status\n", __func__); kfree(new_setup); /* we will try again */ schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); @@ -289,12 +286,12 @@ static void setup_line(struct work_struct *work) priv->setup_done = 1; spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s(): submitting interrupt urb", __FUNCTION__); + dbg("%s(): submitting interrupt urb", __func__); port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result != 0) { dev_err(&port->dev, "%s(): usb_submit_urb() failed" - " with error %d\n", __FUNCTION__, result); + " with error %d\n", __func__, result); } } @@ -306,7 +303,7 @@ void send_data(struct work_struct *work) unsigned long flags; unsigned char allow; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); if (priv->flags.write_urb_in_use) { @@ -334,12 +331,12 @@ void send_data(struct work_struct *work) if (count == 0) { priv->flags.write_urb_in_use = 0; - dbg("%s(): submitting interrupt urb", __FUNCTION__); + dbg("%s(): submitting interrupt urb", __func__); port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result != 0) { dev_err(&port->dev, "%s(): usb_submit_urb() failed" - " with error %d\n", __FUNCTION__, result); + " with error %d\n", __func__, result); } return; } @@ -353,7 +350,7 @@ void send_data(struct work_struct *work) result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result != 0) { dev_err(&port->dev, "%s(): usb_submit_urb() failed" - " with error %d\n", __FUNCTION__, result); + " with error %d\n", __func__, result); priv->flags.write_urb_in_use = 0; } @@ -404,7 +401,7 @@ static int oti6858_write(struct usb_serial_port *port, struct oti6858_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s(port = %d, count = %d)", __FUNCTION__, port->number, count); + dbg("%s(port = %d, count = %d)", __func__, port->number, count); if (!count) return count; @@ -422,7 +419,7 @@ static int oti6858_write_room(struct usb_serial_port *port) int room = 0; unsigned long flags; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); room = oti6858_buf_space_avail(priv->buf); @@ -437,7 +434,7 @@ static int oti6858_chars_in_buffer(struct usb_serial_port *port) int chars = 0; unsigned long flags; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); chars = oti6858_buf_data_avail(priv->buf); @@ -456,10 +453,10 @@ static void oti6858_set_termios(struct usb_serial_port *port, u16 divisor; int br; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); if (!port->tty || !port->tty->termios) { - dbg("%s(): no tty structures", __FUNCTION__); + dbg("%s(): no tty structures", __func__); return; } @@ -575,7 +572,7 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp) unsigned long flags; int result; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); usb_clear_halt(serial->dev, port->write_urb->pipe); usb_clear_halt(serial->dev, port->read_urb->pipe); @@ -584,7 +581,7 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp) return 0; if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { - dev_err(&port->dev, "%s(): out of memory!\n", __FUNCTION__); + dev_err(&port->dev, "%s(): out of memory!\n", __func__); return -ENOMEM; } @@ -613,12 +610,12 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp) spin_unlock_irqrestore(&priv->lock, flags); kfree(buf); - dbg("%s(): submitting interrupt urb", __FUNCTION__); + dbg("%s(): submitting interrupt urb", __func__); port->interrupt_in_urb->dev = serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result != 0) { dev_err(&port->dev, "%s(): usb_submit_urb() failed" - " with error %d\n", __FUNCTION__, result); + " with error %d\n", __func__, result); oti6858_close(port, NULL); return -EPROTO; } @@ -637,14 +634,14 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) long timeout; wait_queue_t wait; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); /* wait for data to drain from the buffer */ spin_lock_irqsave(&priv->lock, flags); timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */ init_waitqueue_entry(&wait, current); add_wait_queue(&port->tty->write_wait, &wait); - dbg("%s(): entering wait loop", __FUNCTION__); + dbg("%s(): entering wait loop", __func__); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (oti6858_buf_data_avail(priv->buf) == 0 @@ -657,7 +654,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) } set_current_state(TASK_RUNNING); remove_wait_queue(&port->tty->write_wait, &wait); - dbg("%s(): after wait loop", __FUNCTION__); + dbg("%s(): after wait loop", __func__); /* clear out any remaining data in the buffer */ oti6858_buf_clear(priv->buf); @@ -678,7 +675,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) */ timeout = 2*HZ; schedule_timeout_interruptible(timeout); - dbg("%s(): after schedule_timeout_interruptible()", __FUNCTION__); + dbg("%s(): after schedule_timeout_interruptible()", __func__); /* cancel scheduled setup */ cancel_delayed_work(&priv->delayed_setup_work); @@ -686,7 +683,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) flush_scheduled_work(); /* shutdown our urbs */ - dbg("%s(): shutting down urbs", __FUNCTION__); + dbg("%s(): shutting down urbs", __func__); usb_kill_urb(port->write_urb); usb_kill_urb(port->read_urb); usb_kill_urb(port->interrupt_in_urb); @@ -709,7 +706,7 @@ static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file, u8 control; dbg("%s(port = %d, set = 0x%08x, clear = 0x%08x)", - __FUNCTION__, port->number, set, clear); + __func__, port->number, set, clear); if (!usb_get_intfdata(port->serial->interface)) return -ENODEV; @@ -741,7 +738,7 @@ static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file) unsigned pin_state; unsigned result = 0; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); if (!usb_get_intfdata(port->serial->interface)) return -ENODEV; @@ -764,7 +761,7 @@ static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file) if ((pin_state & PIN_DCD) != 0) result |= TIOCM_CD; - dbg("%s() = 0x%08x", __FUNCTION__, result); + dbg("%s() = 0x%08x", __func__, result); return result; } @@ -811,13 +808,9 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, unsigned int x; dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)", - __FUNCTION__, port->number, cmd, arg); + __func__, port->number, cmd, arg); switch (cmd) { - case TCFLSH: - /* FIXME */ - return 0; - case TIOCMBIS: if (copy_from_user(&x, user_arg, sizeof(x))) return -EFAULT; @@ -829,11 +822,11 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, return oti6858_tiocmset(port, NULL, 0, x); case TIOCMIWAIT: - dbg("%s(): TIOCMIWAIT", __FUNCTION__); + dbg("%s(): TIOCMIWAIT", __func__); return wait_modem_info(port, arg); default: - dbg("%s(): 0x%04x not supported", __FUNCTION__, cmd); + dbg("%s(): 0x%04x not supported", __func__, cmd); break; } @@ -844,10 +837,10 @@ static void oti6858_break_ctl(struct usb_serial_port *port, int break_state) { int state; - dbg("%s(port = %d)", __FUNCTION__, port->number); + dbg("%s(port = %d)", __func__, port->number); state = (break_state == 0) ? 0 : 1; - dbg("%s(): turning break %s", __FUNCTION__, state ? "on" : "off"); + dbg("%s(): turning break %s", __func__, state ? "on" : "off"); /* FIXME */ /* @@ -855,7 +848,7 @@ static void oti6858_break_ctl(struct usb_serial_port *port, int break_state) BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 0, NULL, 0, 100); if (result != 0) - dbg("%s(): error sending break", __FUNCTION__); + dbg("%s(): error sending break", __func__); */ } @@ -864,7 +857,7 @@ static void oti6858_shutdown(struct usb_serial *serial) struct oti6858_private *priv; int i; - dbg("%s()", __FUNCTION__); + dbg("%s()", __func__); for (i = 0; i < serial->num_ports; ++i) { priv = usb_get_serial_port_data(serial->port[i]); @@ -878,13 +871,13 @@ static void oti6858_shutdown(struct usb_serial *serial) static void oti6858_read_int_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct oti6858_private *priv = usb_get_serial_port_data(port); int transient = 0, can_recv = 0, resubmit = 1; int status = urb->status; dbg("%s(port = %d, status = %d)", - __FUNCTION__, port->number, status); + __func__, port->number, status); switch (status) { case 0: @@ -895,11 +888,11 @@ static void oti6858_read_int_callback(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s(): urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s(): nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); break; } @@ -916,7 +909,7 @@ static void oti6858_read_int_callback(struct urb *urb) priv->setup_done = 0; resubmit = 0; dbg("%s(): scheduling setup_line()", - __FUNCTION__); + __func__); schedule_delayed_work(&priv->delayed_setup_work, 0); } } @@ -931,7 +924,7 @@ static void oti6858_read_int_callback(struct urb *urb) priv->setup_done = 0; resubmit = 0; dbg("%s(): scheduling setup_line()", - __FUNCTION__); + __func__); schedule_delayed_work(&priv->delayed_setup_work, 0); } } @@ -960,7 +953,7 @@ static void oti6858_read_int_callback(struct urb *urb) if (result != 0) { priv->flags.read_urb_in_use = 0; dev_err(&port->dev, "%s(): usb_submit_urb() failed," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); } else { resubmit = 0; } @@ -979,20 +972,20 @@ static void oti6858_read_int_callback(struct urb *urb) if (resubmit) { int result; -// dbg("%s(): submitting interrupt urb", __FUNCTION__); +// dbg("%s(): submitting interrupt urb", __func__); urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result != 0) { dev_err(&urb->dev->dev, "%s(): usb_submit_urb() failed with" - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); } } } static void oti6858_read_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct oti6858_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -1001,7 +994,7 @@ static void oti6858_read_bulk_callback(struct urb *urb) int result; dbg("%s(port = %d, status = %d)", - __FUNCTION__, port->number, status); + __func__, port->number, status); spin_lock_irqsave(&priv->lock, flags); priv->flags.read_urb_in_use = 0; @@ -1009,20 +1002,20 @@ static void oti6858_read_bulk_callback(struct urb *urb) if (status != 0) { if (!port->open_count) { - dbg("%s(): port is closed, exiting", __FUNCTION__); + dbg("%s(): port is closed, exiting", __func__); return; } /* if (status == -EPROTO) { // PL2303 mysteriously fails with -EPROTO reschedule the read - dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__); + dbg("%s - caught -EPROTO, resubmitting the urb", __func__); result = usb_submit_urb(urb, GFP_ATOMIC); if (result) - dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); return; } */ - dbg("%s(): unable to handle the error, exiting", __FUNCTION__); + dbg("%s(): unable to handle the error, exiting", __func__); return; } @@ -1038,20 +1031,20 @@ static void oti6858_read_bulk_callback(struct urb *urb) result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result != 0) { dev_err(&port->dev, "%s(): usb_submit_urb() failed," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); } } } static void oti6858_write_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct oti6858_private *priv = usb_get_serial_port_data(port); int status = urb->status; int result; dbg("%s(port = %d, status = %d)", - __FUNCTION__, port->number, status); + __func__, port->number, status); switch (status) { case 0: @@ -1062,21 +1055,21 @@ static void oti6858_write_bulk_callback(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s(): urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); priv->flags.write_urb_in_use = 0; return; default: /* error in the urb, so we have to resubmit it */ dbg("%s(): nonzero write bulk status received: %d", - __FUNCTION__, status); - dbg("%s(): overflow in write", __FUNCTION__); + __func__, status); + dbg("%s(): overflow in write", __func__); port->write_urb->transfer_buffer_length = 1; port->write_urb->dev = port->serial->dev; result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { dev_err(&port->dev, "%s(): usb_submit_urb() failed," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); } else { return; } @@ -1086,11 +1079,11 @@ static void oti6858_write_bulk_callback(struct urb *urb) // schedule the interrupt urb if we are still open */ port->interrupt_in_urb->dev = port->serial->dev; - dbg("%s(): submitting interrupt urb", __FUNCTION__); + dbg("%s(): submitting interrupt urb", __func__); result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result != 0) { dev_err(&port->dev, "%s(): failed submitting int urb," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); } } diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 2af778555bd..c605fb68f80 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -410,7 +410,7 @@ static int set_control_lines(struct usb_device *dev, u8 value) retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, value, 0, NULL, 0, 100); - dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval); + dbg("%s - value = %d, retval = %d", __func__, value, retval); return retval; } @@ -420,7 +420,7 @@ static void pl2303_send(struct usb_serial_port *port) struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); @@ -441,7 +441,7 @@ static void pl2303_send(struct usb_serial_port *port) spin_unlock_irqrestore(&priv->lock, flags); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, + usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); port->write_urb->transfer_buffer_length = count; @@ -449,7 +449,7 @@ static void pl2303_send(struct usb_serial_port *port) result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { dev_err(&port->dev, "%s - failed submitting write urb," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); priv->write_urb_in_use = 0; // TODO: reschedule pl2303_send } @@ -463,7 +463,7 @@ static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf, struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count); + dbg("%s - port %d, %d bytes", __func__, port->number, count); if (!count) return count; @@ -483,13 +483,13 @@ static int pl2303_write_room(struct usb_serial_port *port) int room = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); room = pl2303_buf_space_avail(priv->buf); spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -499,13 +499,13 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port) int chars = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); chars = pl2303_buf_data_avail(priv->buf); spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } @@ -521,7 +521,7 @@ static void pl2303_set_termios(struct usb_serial_port *port, int i; u8 control; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { @@ -545,7 +545,9 @@ static void pl2303_set_termios(struct usb_serial_port *port, buf = kzalloc(7, GFP_KERNEL); if (!buf) { - dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); + dev_err(&port->dev, "%s - out of memory.\n", __func__); + /* Report back no change occurred */ + *port->tty->termios = *old_termios; return; } @@ -563,11 +565,11 @@ static void pl2303_set_termios(struct usb_serial_port *port, default: case CS8: buf[6] = 8; break; } - dbg("%s - data bits = %d", __FUNCTION__, buf[6]); + dbg("%s - data bits = %d", __func__, buf[6]); } baud = tty_get_baud_rate(port->tty);; - dbg("%s - baud = %d", __FUNCTION__, baud); + dbg("%s - baud = %d", __func__, baud); if (baud) { buf[0] = baud & 0xff; buf[1] = (baud >> 8) & 0xff; @@ -580,10 +582,10 @@ static void pl2303_set_termios(struct usb_serial_port *port, /* For reference buf[4]=2 is 2 stop bits */ if (cflag & CSTOPB) { buf[4] = 2; - dbg("%s - stop bits = 2", __FUNCTION__); + dbg("%s - stop bits = 2", __func__); } else { buf[4] = 0; - dbg("%s - stop bits = 1", __FUNCTION__); + dbg("%s - stop bits = 1", __func__); } if (cflag & PARENB) { @@ -594,14 +596,14 @@ static void pl2303_set_termios(struct usb_serial_port *port, /* For reference buf[5]=4 is space parity */ if (cflag & PARODD) { buf[5] = 1; - dbg("%s - parity = odd", __FUNCTION__); + dbg("%s - parity = odd", __func__); } else { buf[5] = 2; - dbg("%s - parity = even", __FUNCTION__); + dbg("%s - parity = even", __func__); } } else { buf[5] = 0; - dbg("%s - parity = none", __FUNCTION__); + dbg("%s - parity = none", __func__); } i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), @@ -657,7 +659,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) long timeout; wait_queue_t wait; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* wait for data to drain from the buffer */ spin_lock_irqsave(&priv->lock, flags); @@ -695,7 +697,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) schedule_timeout_interruptible(timeout); /* shutdown our urbs */ - dbg("%s - shutting down urbs", __FUNCTION__); + dbg("%s - shutting down urbs", __func__); usb_kill_urb(port->write_urb); usb_kill_urb(port->read_urb); usb_kill_urb(port->interrupt_in_urb); @@ -719,7 +721,7 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) struct pl2303_private *priv = usb_get_serial_port_data(port); int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (priv->type != HX) { usb_clear_halt(serial->dev, port->write_urb->pipe); @@ -737,22 +739,22 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) //FIXME: need to assert RTS and DTR if CRTSCTS off - dbg("%s - submitting read urb", __FUNCTION__); + dbg("%s - submitting read urb", __func__); port->read_urb->dev = serial->dev; result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { dev_err(&port->dev, "%s - failed submitting read urb," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); pl2303_close(port, NULL); return -EPROTO; } - dbg("%s - submitting interrupt urb", __FUNCTION__); + dbg("%s - submitting interrupt urb", __func__); port->interrupt_in_urb->dev = serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result) { dev_err(&port->dev, "%s - failed submitting interrupt urb," - " error %d\n", __FUNCTION__, result); + " error %d\n", __func__, result); pl2303_close(port, NULL); return -EPROTO; } @@ -792,7 +794,7 @@ static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file) unsigned int status; unsigned int result; - dbg("%s (%d)", __FUNCTION__, port->number); + dbg("%s (%d)", __func__, port->number); if (!usb_get_intfdata(port->serial->interface)) return -ENODEV; @@ -809,7 +811,7 @@ static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file) | ((status & UART_RING) ? TIOCM_RI : 0) | ((status & UART_DCD) ? TIOCM_CD : 0); - dbg("%s - result = %x", __FUNCTION__, result); + dbg("%s - result = %x", __func__, result); return result; } @@ -853,15 +855,15 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) static int pl2303_ioctl(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) { - dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd); + dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); switch (cmd) { case TIOCMIWAIT: - dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number); + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); return wait_modem_info(port, arg); default: - dbg("%s not supported = 0x%04x", __FUNCTION__, cmd); + dbg("%s not supported = 0x%04x", __func__, cmd); break; } @@ -874,19 +876,19 @@ static void pl2303_break_ctl(struct usb_serial_port *port, int break_state) u16 state; int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (break_state == 0) state = BREAK_OFF; else state = BREAK_ON; - dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on"); + dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on"); result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 0, NULL, 0, 100); if (result) - dbg("%s - error sending break = %d", __FUNCTION__, result); + dbg("%s - error sending break = %d", __func__, result); } static void pl2303_shutdown(struct usb_serial *serial) @@ -894,7 +896,7 @@ static void pl2303_shutdown(struct usb_serial *serial) int i; struct pl2303_private *priv; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i = 0; i < serial->num_ports; ++i) { priv = usb_get_serial_port_data(serial->port[i]); @@ -943,13 +945,13 @@ static void pl2303_update_line_status(struct usb_serial_port *port, static void pl2303_read_int_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; unsigned int actual_length = urb->actual_length; int status = urb->status; int retval; - dbg("%s (%d)", __FUNCTION__, port->number); + dbg("%s (%d)", __func__, port->number); switch (status) { case 0: @@ -959,16 +961,16 @@ static void pl2303_read_int_callback(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, + dbg("%s - urb shutting down with status: %d", __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", __FUNCTION__, + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, urb->transfer_buffer); pl2303_update_line_status(port, data, actual_length); @@ -978,12 +980,12 @@ exit: if (retval) dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", - __FUNCTION__, retval); + __func__, retval); } static void pl2303_read_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct pl2303_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -994,32 +996,32 @@ static void pl2303_read_bulk_callback(struct urb *urb) u8 line_status; char tty_flag; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { - dbg("%s - urb status = %d", __FUNCTION__, status); + dbg("%s - urb status = %d", __func__, status); if (!port->open_count) { - dbg("%s - port is closed, exiting.", __FUNCTION__); + dbg("%s - port is closed, exiting.", __func__); return; } if (status == -EPROTO) { /* PL2303 mysteriously fails with -EPROTO reschedule * the read */ dbg("%s - caught -EPROTO, resubmitting the urb", - __FUNCTION__); + __func__); urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed" " resubmitting read urb, error %d\n", - __FUNCTION__, result); + __func__, result); return; } - dbg("%s - unable to handle the error, exiting.", __FUNCTION__); + dbg("%s - unable to handle the error, exiting.", __func__); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); /* get tty_flag from status */ @@ -1039,7 +1041,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) tty_flag = TTY_PARITY; else if (line_status & UART_FRAME_ERROR) tty_flag = TTY_FRAME; - dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); + dbg("%s - tty_flag = %d", __func__, tty_flag); tty = port->tty; if (tty && urb->actual_length) { @@ -1058,7 +1060,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) result = usb_submit_urb(urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting" - " read urb, error %d\n", __FUNCTION__, result); + " read urb, error %d\n", __func__, result); } return; @@ -1066,12 +1068,12 @@ static void pl2303_read_bulk_callback(struct urb *urb) static void pl2303_write_bulk_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct pl2303_private *priv = usb_get_serial_port_data(port); int result; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); switch (status) { case 0: @@ -1081,21 +1083,21 @@ static void pl2303_write_bulk_callback(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", __FUNCTION__, + dbg("%s - urb shutting down with status: %d", __func__, status); priv->write_urb_in_use = 0; return; default: /* error in the urb, so we have to resubmit it */ - dbg("%s - Overflow in write", __FUNCTION__); - dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, + dbg("%s - Overflow in write", __func__); + dbg("%s - nonzero write bulk status received: %d", __func__, status); port->write_urb->transfer_buffer_length = 1; port->write_urb->dev = port->serial->dev; result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting write" - " urb, error %d\n", __FUNCTION__, result); + " urb, error %d\n", __func__, result); else return; } @@ -1114,9 +1116,6 @@ static struct usb_serial_driver pl2303_device = { }, .id_table = id_table, .usb_driver = &pl2303_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = pl2303_open, .close = pl2303_close, diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 4e6dcc199be..94bddf06ea4 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -195,18 +195,17 @@ static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs) static void safe_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; unsigned char length = urb->actual_length; - int i; int result; int status = urb->status; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -227,28 +226,20 @@ static void safe_read_bulk_callback (struct urb *urb) if (safe) { __u16 fcs; if (!(fcs = fcs_compute10 (data, length, CRC10_INITFCS))) { - int actual_length = data[length - 2] >> 2; - if (actual_length <= (length - 2)) { - - info ("%s - actual: %d", __FUNCTION__, actual_length); - - for (i = 0; i < actual_length; i++) { - tty_insert_flip_char (port->tty, data[i], 0); - } + info ("%s - actual: %d", __func__, actual_length); + tty_insert_flip_string(port->tty, data, actual_length); tty_flip_buffer_push (port->tty); } else { - err ("%s - inconsistent lengths %d:%d", __FUNCTION__, + err ("%s - inconsistent lengths %d:%d", __func__, actual_length, length); } } else { - err ("%s - bad CRC %x", __FUNCTION__, fcs); + err ("%s - bad CRC %x", __func__, fcs); } } else { - for (i = 0; i < length; i++) { - tty_insert_flip_char (port->tty, data[i], 0); - } + tty_insert_flip_string(port->tty, data, length); tty_flip_buffer_push (port->tty); } @@ -259,7 +250,8 @@ static void safe_read_bulk_callback (struct urb *urb) safe_read_bulk_callback, port); if ((result = usb_submit_urb (urb, GFP_ATOMIC))) { - err ("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); + err ("%s - failed resubmitting read urb, error %d", __func__, result); + /* FIXME: Need a mechanism to retry later if this happens */ } } @@ -274,25 +266,25 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i count); if (!port->write_urb) { - dbg ("%s - write urb NULL", __FUNCTION__); - return (0); + dbg ("%s - write urb NULL", __func__); + return 0; } dbg ("safe_write write_urb: %d transfer_buffer_length", port->write_urb->transfer_buffer_length); if (!port->write_urb->transfer_buffer_length) { - dbg ("%s - write urb transfer_buffer_length zero", __FUNCTION__); - return (0); + dbg ("%s - write urb transfer_buffer_length zero", __func__); + return 0; } if (count == 0) { - dbg ("%s - write request of 0 bytes", __FUNCTION__); - return (0); + dbg ("%s - write request of 0 bytes", __func__); + return 0; } spin_lock_bh(&port->lock); if (port->write_urb_busy) { spin_unlock_bh(&port->lock); - dbg("%s - already writing", __FUNCTION__); + dbg("%s - already writing", __func__); return 0; } port->write_urb_busy = 1; @@ -332,7 +324,7 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i port->write_urb->transfer_buffer_length = count; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); #ifdef ECHO_TX { int i; @@ -349,28 +341,31 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i port->write_urb->dev = port->serial->dev; if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) { port->write_urb_busy = 0; - err ("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err ("%s - failed submitting write urb, error %d", __func__, result); return 0; } - dbg ("%s urb: %p submitted", __FUNCTION__, port->write_urb); + dbg ("%s urb: %p submitted", __func__, port->write_urb); return (count); } static int safe_write_room (struct usb_serial_port *port) { - int room = 0; // Default: no room + int room = 0; /* Default: no room */ + unsigned long flags; - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); + spin_lock_irqsave(&port->lock, flags); if (port->write_urb_busy) room = port->bulk_out_size - (safe ? 2 : 0); + spin_unlock_irqrestore(&port->lock, flags); if (room) { dbg ("safe_write_room returns %d", room); } - return (room); + return room; } static int safe_startup (struct usb_serial *serial) @@ -394,9 +389,6 @@ static struct usb_serial_driver safe_device = { }, .id_table = id_table, .usb_driver = &safe_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .write = safe_write, .write_room = safe_write_room, diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index ed678811e6a..29074c1ba22 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -1,7 +1,7 @@ /* USB Driver for Sierra Wireless - Copyright (C) 2006, 2007, 2008 Kevin Lloyd <linux@sierrawireless.com> + Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com> IMPORTANT DISCLAIMER: This driver is not commercially supported by Sierra Wireless. Use at your own risk. @@ -14,8 +14,8 @@ Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> */ -#define DRIVER_VERSION "v.1.2.8" -#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" +#define DRIVER_VERSION "v.1.2.9c" +#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" #include <linux/kernel.h> @@ -31,7 +31,6 @@ #define SWIMS_USB_REQUEST_SetPower 0x00 #define SWIMS_USB_REQUEST_SetNmea 0x07 #define SWIMS_USB_REQUEST_SetMode 0x0B -#define SWIMS_USB_REQUEST_TYPE_VSC_SET 0x40 #define SWIMS_SET_MODE_Modem 0x0001 /* per port private data */ @@ -55,7 +54,7 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) dev_dbg(&udev->dev, "%s", "SET POWER STATE\n"); result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), SWIMS_USB_REQUEST_SetPower, /* __u8 request */ - SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ + USB_TYPE_VENDOR, /* __u8 request type */ swiState, /* __u16 value */ 0, /* __u16 index */ NULL, /* void *data */ @@ -70,7 +69,7 @@ static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n"); result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), SWIMS_USB_REQUEST_SetMode, /* __u8 request */ - SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ + USB_TYPE_VENDOR, /* __u8 request type */ eSWocMode, /* __u16 value */ 0x0000, /* __u16 index */ NULL, /* void *data */ @@ -85,7 +84,7 @@ static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n"); result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ - SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ + USB_TYPE_VENDOR, /* __u8 request type */ enable, /* __u16 value */ 0x0000, /* __u16 index */ NULL, /* void *data */ @@ -109,6 +108,26 @@ static int sierra_calc_num_ports(struct usb_serial *serial) return result; } +static int sierra_calc_interface(struct usb_serial *serial) +{ + int interface; + struct usb_interface *p_interface; + struct usb_host_interface *p_host_interface; + + /* Get the interface structure pointer from the serial struct */ + p_interface = serial->interface; + + /* Get a pointer to the host interface structure */ + p_host_interface = p_interface->cur_altsetting; + + /* read the interface descriptor for this active altsetting + * to find out the interface number we are on + */ + interface = p_host_interface->desc.bInterfaceNumber; + + return interface; +} + static int sierra_probe(struct usb_serial *serial, const struct usb_device_id *id) { @@ -124,6 +143,22 @@ static int sierra_probe(struct usb_serial *serial, ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; udev = serial->dev; + /* Figure out the interface number from the serial structure */ + ifnum = sierra_calc_interface(serial); + + /* + * If this interface supports more than 1 alternate + * select the 2nd one + */ + if (serial->interface->num_altsetting == 2) { + dev_dbg(&udev->dev, + "Selecting alt setting for interface %d\n", + ifnum); + + /* We know the alternate setting is 1 for the MC8785 */ + usb_set_interface(udev, ifnum, 1); + } + /* Check if in installer mode */ if (truinstall && id->driver_info == DEVICE_INSTALLER) { dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n"); @@ -156,7 +191,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ - { USB_DEVICE(0x1199, 0x0023) }, /* Sierra Wireless AirCard */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, /* Sierra Wireless C597 */ { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ @@ -164,15 +199,20 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */ { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */ + { USB_DEVICE(0x03f0, 0x1e1d) }, /* HP hs2300 a.k.a MC8775 */ { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ + { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ + { USB_DEVICE(0x1199, 0x683B), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless MC8785 Composite*/ { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */ { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ + { USB_DEVICE(0x1199, 0x6859), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */ + { USB_DEVICE(0x1199, 0x685A), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */ { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */ { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */ @@ -216,7 +256,7 @@ static int sierra_send_setup(struct usb_serial_port *port) struct sierra_port_private *portdata; __u16 interface = 0; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); portdata = usb_get_serial_port_data(port); @@ -246,24 +286,24 @@ static int sierra_send_setup(struct usb_serial_port *port) static void sierra_rx_throttle(struct usb_serial_port *port) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static void sierra_rx_unthrottle(struct usb_serial_port *port) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static void sierra_break_ctl(struct usb_serial_port *port, int break_state) { /* Unfortunately, I don't know how to send a break */ - dbg("%s", __FUNCTION__); + dbg("%s", __func__); } static void sierra_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); tty_termios_copy_hw(port->tty->termios, old_termios); sierra_send_setup(port); } @@ -317,14 +357,14 @@ static void sierra_outdat_callback(struct urb *urb) int status = urb->status; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* free up the transfer buffer, as usb_free_urb() does not do this */ kfree(urb->transfer_buffer); if (status) dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); spin_lock_irqsave(&portdata->lock, flags); --portdata->outstanding_urbs; @@ -346,12 +386,12 @@ static int sierra_write(struct usb_serial_port *port, portdata = usb_get_serial_port_data(port); - dbg("%s: write (%d chars)", __FUNCTION__, count); + dbg("%s: write (%d chars)", __func__, count); spin_lock_irqsave(&portdata->lock, flags); if (portdata->outstanding_urbs > N_OUT_URB) { spin_unlock_irqrestore(&portdata->lock, flags); - dbg("%s - write limit hit\n", __FUNCTION__); + dbg("%s - write limit hit\n", __func__); return 0; } portdata->outstanding_urbs++; @@ -373,7 +413,7 @@ static int sierra_write(struct usb_serial_port *port, memcpy(buffer, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, @@ -384,7 +424,7 @@ static int sierra_write(struct usb_serial_port *port, status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " - "with status = %d\n", __FUNCTION__, status); + "with status = %d\n", __func__, status); count = status; goto error; } @@ -414,14 +454,14 @@ static void sierra_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg("%s: %p", __FUNCTION__, urb); + dbg("%s: %p", __func__, urb); endpoint = usb_pipeendpoint(urb->pipe); - port = (struct usb_serial_port *) urb->context; + port = urb->context; if (status) { dbg("%s: nonzero status: %d on endpoint %02x.", - __FUNCTION__, status, endpoint); + __func__, status, endpoint); } else { tty = port->tty; if (urb->actual_length) { @@ -429,7 +469,7 @@ static void sierra_indat_callback(struct urb *urb) tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } else { - dbg("%s: empty read urb received", __FUNCTION__); + dbg("%s: empty read urb received", __func__); } /* Resubmit urb so we continue receiving */ @@ -447,19 +487,19 @@ static void sierra_instat_callback(struct urb *urb) { int err; int status = urb->status; - struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct usb_serial_port *port = urb->context; struct sierra_port_private *portdata = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; - dbg("%s", __FUNCTION__); - dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); + dbg("%s", __func__); + dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); if (status == 0) { struct usb_ctrlrequest *req_pkt = (struct usb_ctrlrequest *)urb->transfer_buffer; if (!req_pkt) { - dbg("%s: NULL req_pkt\n", __FUNCTION__); + dbg("%s: NULL req_pkt\n", __func__); return; } if ((req_pkt->bRequestType == 0xA1) && @@ -469,7 +509,7 @@ static void sierra_instat_callback(struct urb *urb) urb->transfer_buffer + sizeof(struct usb_ctrlrequest)); - dbg("%s: signal x%x", __FUNCTION__, signals); + dbg("%s: signal x%x", __func__, signals); old_dcd_state = portdata->dcd_state; portdata->cts_state = 1; @@ -481,11 +521,11 @@ static void sierra_instat_callback(struct urb *urb) old_dcd_state && !portdata->dcd_state) tty_hangup(port->tty); } else { - dbg("%s: type %x req %x", __FUNCTION__, - req_pkt->bRequestType,req_pkt->bRequest); + dbg("%s: type %x req %x", __func__, + req_pkt->bRequestType, req_pkt->bRequest); } } else - dbg("%s: error %d", __FUNCTION__, status); + dbg("%s: error %d", __func__, status); /* Resubmit urb so we continue receiving IRQ data */ if (status != -ESHUTDOWN) { @@ -493,7 +533,7 @@ static void sierra_instat_callback(struct urb *urb) err = usb_submit_urb(urb, GFP_ATOMIC); if (err) dbg("%s: resubmit intr urb failed. (%d)", - __FUNCTION__, err); + __func__, err); } } @@ -502,14 +542,14 @@ static int sierra_write_room(struct usb_serial_port *port) struct sierra_port_private *portdata = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* try to give a good number back based on if we have any free urbs at * this point in time */ spin_lock_irqsave(&portdata->lock, flags); if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { spin_unlock_irqrestore(&portdata->lock, flags); - dbg("%s - write limit hit\n", __FUNCTION__); + dbg("%s - write limit hit\n", __func__); return 0; } spin_unlock_irqrestore(&portdata->lock, flags); @@ -519,13 +559,15 @@ static int sierra_write_room(struct usb_serial_port *port) static int sierra_chars_in_buffer(struct usb_serial_port *port) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * We can't really account for how much data we * have sent out, but hasn't made it through to the * device as we can't see the backend here, so just * tell the tty layer that everything is flushed. + * + * FIXME: should walk the outstanding urbs info */ return 0; } @@ -540,7 +582,7 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp) portdata = usb_get_serial_port_data(port); - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Set some sane defaults */ portdata->rts_state = 1; @@ -552,7 +594,7 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp) if (!urb) continue; if (urb->dev != serial->dev) { - dbg("%s: dev %p != %p", __FUNCTION__, + dbg("%s: dev %p != %p", __func__, urb->dev, serial->dev); continue; } @@ -590,7 +632,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp) struct usb_serial *serial = port->serial; struct sierra_port_private *portdata; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); portdata = usb_get_serial_port_data(port); portdata->rts_state = 0; @@ -620,7 +662,7 @@ static int sierra_startup(struct usb_serial *serial) int i; int j; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* Set Device mode to D0 */ sierra_set_power_state(serial->dev, 0x0000); @@ -635,7 +677,7 @@ static int sierra_startup(struct usb_serial *serial) portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); if (!portdata) { dbg("%s: kmalloc for sierra_port_private (%d) failed!.", - __FUNCTION__, i); + __func__, i); return -ENOMEM; } spin_lock_init(&portdata->lock); @@ -656,7 +698,7 @@ static int sierra_startup(struct usb_serial *serial) urb = usb_alloc_urb(0, GFP_KERNEL); if (urb == NULL) { dbg("%s: alloc for in port failed.", - __FUNCTION__); + __func__); continue; } /* Fill URB using supplied data. */ @@ -678,7 +720,7 @@ static void sierra_shutdown(struct usb_serial *serial) struct usb_serial_port *port; struct sierra_port_private *portdata; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i = 0; i < serial->num_ports; ++i) { port = serial->port[i]; @@ -706,9 +748,6 @@ static struct usb_serial_driver sierra_device = { .description = "Sierra USB modem", .id_table = id_table, .usb_driver = &sierra_driver, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .calc_num_ports = sierra_calc_num_ports, .probe = sierra_probe, .open = sierra_open, diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c new file mode 100644 index 00000000000..2282d620186 --- /dev/null +++ b/drivers/usb/serial/spcp8x5.c @@ -0,0 +1,1072 @@ +/* + * spcp8x5 USB to serial adaptor driver + * + * Copyright (C) 2006 Linxb (xubin.lin@worldplus.com.cn) + * Copyright (C) 2006 S1 Corp. + * + * Original driver for 2.6.10 pl2303 driver by + * Greg Kroah-Hartman (greg@kroah.com) + * Changes for 2.6.20 by Harald Klein <hari@vt100.at> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * + */ +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/tty.h> +#include <linux/tty_driver.h> +#include <linux/tty_flip.h> +#include <linux/module.h> +#include <linux/spinlock.h> +#include <linux/usb.h> +#include <linux/usb/serial.h> + + +/* Version Information */ +#define DRIVER_VERSION "v0.04" +#define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" + +static int debug; + +#define SPCP8x5_007_VID 0x04FC +#define SPCP8x5_007_PID 0x0201 +#define SPCP8x5_008_VID 0x04fc +#define SPCP8x5_008_PID 0x0235 +#define SPCP8x5_PHILIPS_VID 0x0471 +#define SPCP8x5_PHILIPS_PID 0x081e +#define SPCP8x5_INTERMATIC_VID 0x04FC +#define SPCP8x5_INTERMATIC_PID 0x0204 +#define SPCP8x5_835_VID 0x04fc +#define SPCP8x5_835_PID 0x0231 + +static struct usb_device_id id_table [] = { + { USB_DEVICE(SPCP8x5_PHILIPS_VID , SPCP8x5_PHILIPS_PID)}, + { USB_DEVICE(SPCP8x5_INTERMATIC_VID, SPCP8x5_INTERMATIC_PID)}, + { USB_DEVICE(SPCP8x5_835_VID, SPCP8x5_835_PID)}, + { USB_DEVICE(SPCP8x5_008_VID, SPCP8x5_008_PID)}, + { USB_DEVICE(SPCP8x5_007_VID, SPCP8x5_007_PID)}, + { } /* Terminating entry */ +}; +MODULE_DEVICE_TABLE(usb, id_table); + +struct spcp8x5_usb_ctrl_arg { + u8 type; + u8 cmd; + u8 cmd_type; + u16 value; + u16 index; + u16 length; +}; + +/* wait 30s before close */ +#define SPCP8x5_CLOSING_WAIT (30*HZ) + +#define SPCP8x5_BUF_SIZE 1024 + + +/* spcp8x5 spec register define */ +#define MCR_CONTROL_LINE_RTS 0x02 +#define MCR_CONTROL_LINE_DTR 0x01 +#define MCR_DTR 0x01 +#define MCR_RTS 0x02 + +#define MSR_STATUS_LINE_DCD 0x80 +#define MSR_STATUS_LINE_RI 0x40 +#define MSR_STATUS_LINE_DSR 0x20 +#define MSR_STATUS_LINE_CTS 0x10 + +/* verdor command here , we should define myself */ +#define SET_DEFAULT 0x40 +#define SET_DEFAULT_TYPE 0x20 + +#define SET_UART_FORMAT 0x40 +#define SET_UART_FORMAT_TYPE 0x21 +#define SET_UART_FORMAT_SIZE_5 0x00 +#define SET_UART_FORMAT_SIZE_6 0x01 +#define SET_UART_FORMAT_SIZE_7 0x02 +#define SET_UART_FORMAT_SIZE_8 0x03 +#define SET_UART_FORMAT_STOP_1 0x00 +#define SET_UART_FORMAT_STOP_2 0x04 +#define SET_UART_FORMAT_PAR_NONE 0x00 +#define SET_UART_FORMAT_PAR_ODD 0x10 +#define SET_UART_FORMAT_PAR_EVEN 0x30 +#define SET_UART_FORMAT_PAR_MASK 0xD0 +#define SET_UART_FORMAT_PAR_SPACE 0x90 + +#define GET_UART_STATUS_TYPE 0xc0 +#define GET_UART_STATUS 0x22 +#define GET_UART_STATUS_MSR 0x06 + +#define SET_UART_STATUS 0x40 +#define SET_UART_STATUS_TYPE 0x23 +#define SET_UART_STATUS_MCR 0x0004 +#define SET_UART_STATUS_MCR_DTR 0x01 +#define SET_UART_STATUS_MCR_RTS 0x02 +#define SET_UART_STATUS_MCR_LOOP 0x10 + +#define SET_WORKING_MODE 0x40 +#define SET_WORKING_MODE_TYPE 0x24 +#define SET_WORKING_MODE_U2C 0x00 +#define SET_WORKING_MODE_RS485 0x01 +#define SET_WORKING_MODE_PDMA 0x02 +#define SET_WORKING_MODE_SPP 0x03 + +#define SET_FLOWCTL_CHAR 0x40 +#define SET_FLOWCTL_CHAR_TYPE 0x25 + +#define GET_VERSION 0xc0 +#define GET_VERSION_TYPE 0x26 + +#define SET_REGISTER 0x40 +#define SET_REGISTER_TYPE 0x27 + +#define GET_REGISTER 0xc0 +#define GET_REGISTER_TYPE 0x28 + +#define SET_RAM 0x40 +#define SET_RAM_TYPE 0x31 + +#define GET_RAM 0xc0 +#define GET_RAM_TYPE 0x32 + +/* how come ??? */ +#define UART_STATE 0x08 +#define UART_STATE_TRANSIENT_MASK 0x74 +#define UART_DCD 0x01 +#define UART_DSR 0x02 +#define UART_BREAK_ERROR 0x04 +#define UART_RING 0x08 +#define UART_FRAME_ERROR 0x10 +#define UART_PARITY_ERROR 0x20 +#define UART_OVERRUN_ERROR 0x40 +#define UART_CTS 0x80 + +enum spcp8x5_type { + SPCP825_007_TYPE, + SPCP825_008_TYPE, + SPCP825_PHILIP_TYPE, + SPCP825_INTERMATIC_TYPE, + SPCP835_TYPE, +}; + +/* 1st in 1st out buffer 4 driver */ +struct ringbuf { + unsigned int buf_size; + char *buf_buf; + char *buf_get; + char *buf_put; +}; + +/* alloc the ring buf and alloc the buffer itself */ +static inline struct ringbuf *alloc_ringbuf(unsigned int size) +{ + struct ringbuf *pb; + + if (size == 0) + return NULL; + + pb = kmalloc(sizeof(*pb), GFP_KERNEL); + if (pb == NULL) + return NULL; + + pb->buf_buf = kmalloc(size, GFP_KERNEL); + if (pb->buf_buf == NULL) { + kfree(pb); + return NULL; + } + + pb->buf_size = size; + pb->buf_get = pb->buf_put = pb->buf_buf; + + return pb; +} + +/* free the ring buf and the buffer itself */ +static inline void free_ringbuf(struct ringbuf *pb) +{ + if (pb != NULL) { + kfree(pb->buf_buf); + kfree(pb); + } +} + +/* clear pipo , juest repoint the pointer here */ +static inline void clear_ringbuf(struct ringbuf *pb) +{ + if (pb != NULL) + pb->buf_get = pb->buf_put; +} + +/* get the number of data in the pipo */ +static inline unsigned int ringbuf_avail_data(struct ringbuf *pb) +{ + if (pb == NULL) + return 0; + return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); +} + +/* get the number of space in the pipo */ +static inline unsigned int ringbuf_avail_space(struct ringbuf *pb) +{ + if (pb == NULL) + return 0; + return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size); +} + +/* put count data into pipo */ +static unsigned int put_ringbuf(struct ringbuf *pb, const char *buf, + unsigned int count) +{ + unsigned int len; + + if (pb == NULL) + return 0; + + len = ringbuf_avail_space(pb); + if (count > len) + count = len; + + if (count == 0) + return 0; + + len = pb->buf_buf + pb->buf_size - pb->buf_put; + if (count > len) { + memcpy(pb->buf_put, buf, len); + memcpy(pb->buf_buf, buf+len, count - len); + pb->buf_put = pb->buf_buf + count - len; + } else { + memcpy(pb->buf_put, buf, count); + if (count < len) + pb->buf_put += count; + else /* count == len */ + pb->buf_put = pb->buf_buf; + } + return count; +} + +/* get count data from pipo */ +static unsigned int get_ringbuf(struct ringbuf *pb, char *buf, + unsigned int count) +{ + unsigned int len; + + if (pb == NULL || buf == NULL) + return 0; + + len = ringbuf_avail_data(pb); + if (count > len) + count = len; + + if (count == 0) + return 0; + + len = pb->buf_buf + pb->buf_size - pb->buf_get; + if (count > len) { + memcpy(buf, pb->buf_get, len); + memcpy(buf+len, pb->buf_buf, count - len); + pb->buf_get = pb->buf_buf + count - len; + } else { + memcpy(buf, pb->buf_get, count); + if (count < len) + pb->buf_get += count; + else /* count == len */ + pb->buf_get = pb->buf_buf; + } + + return count; +} + +static struct usb_driver spcp8x5_driver = { + .name = "spcp8x5", + .probe = usb_serial_probe, + .disconnect = usb_serial_disconnect, + .id_table = id_table, + .no_dynamic_id = 1, +}; + + +struct spcp8x5_private { + spinlock_t lock; + struct ringbuf *buf; + int write_urb_in_use; + enum spcp8x5_type type; + wait_queue_head_t delta_msr_wait; + u8 line_control; + u8 line_status; + u8 termios_initialized; +}; + +/* desc : when device plug in,this function would be called. + * thanks to usb_serial subsystem,then do almost every things for us. And what + * we should do just alloc the buffer */ +static int spcp8x5_startup(struct usb_serial *serial) +{ + struct spcp8x5_private *priv; + int i; + enum spcp8x5_type type = SPCP825_007_TYPE; + + if (serial->dev->descriptor.idProduct == 0x0201) + type = SPCP825_007_TYPE; + else if (serial->dev->descriptor.idProduct == 0x0231) + type = SPCP835_TYPE; + else if (serial->dev->descriptor.idProduct == 0x0235) + type = SPCP825_008_TYPE; + else if (serial->dev->descriptor.idProduct == 0x0204) + type = SPCP825_INTERMATIC_TYPE; + else if (serial->dev->descriptor.idProduct == 0x0471 && + serial->dev->descriptor.idVendor == 0x081e) + type = SPCP825_PHILIP_TYPE; + dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type); + + for (i = 0; i < serial->num_ports; ++i) { + priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL); + if (!priv) + goto cleanup; + + spin_lock_init(&priv->lock); + priv->buf = alloc_ringbuf(SPCP8x5_BUF_SIZE); + if (priv->buf == NULL) + goto cleanup2; + + init_waitqueue_head(&priv->delta_msr_wait); + priv->type = type; + usb_set_serial_port_data(serial->port[i] , priv); + + } + + return 0; + +cleanup2: + kfree(priv); +cleanup: + for (--i; i >= 0; --i) { + priv = usb_get_serial_port_data(serial->port[i]); + free_ringbuf(priv->buf); + kfree(priv); + usb_set_serial_port_data(serial->port[i] , NULL); + } + return -ENOMEM; +} + +/* call when the device plug out. free all the memory alloced by probe */ +static void spcp8x5_shutdown(struct usb_serial *serial) +{ + int i; + struct spcp8x5_private *priv; + + for (i = 0; i < serial->num_ports; i++) { + priv = usb_get_serial_port_data(serial->port[i]); + if (priv) { + free_ringbuf(priv->buf); + kfree(priv); + usb_set_serial_port_data(serial->port[i] , NULL); + } + } +} + +/* set the modem control line of the device. + * NOTE spcp825-007 not supported this */ +static int spcp8x5_set_ctrlLine(struct usb_device *dev, u8 value, + enum spcp8x5_type type) +{ + int retval; + u8 mcr = 0 ; + + if (type == SPCP825_007_TYPE) + return -EPERM; + + mcr = (unsigned short)value; + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + SET_UART_STATUS_TYPE, SET_UART_STATUS, + mcr, 0x04, NULL, 0, 100); + if (retval != 0) + dev_dbg(&dev->dev, "usb_control_msg return %#x\n", retval); + return retval; +} + +/* get the modem status register of the device + * NOTE spcp825-007 not supported this */ +static int spcp8x5_get_msr(struct usb_device *dev, u8 *status, + enum spcp8x5_type type) +{ + u8 *status_buffer; + int ret; + + /* I return Permited not support here but seem inval device + * is more fix */ + if (type == SPCP825_007_TYPE) + return -EPERM; + if (status == NULL) + return -EINVAL; + + status_buffer = kmalloc(1, GFP_KERNEL); + if (!status_buffer) + return -ENOMEM; + status_buffer[0] = status[0]; + + ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), + GET_UART_STATUS, GET_UART_STATUS_TYPE, + 0, GET_UART_STATUS_MSR, status_buffer, 1, 100); + if (ret < 0) + dev_dbg(&dev->dev, "Get MSR = 0x%p failed (error = %d)", + status_buffer, ret); + + dev_dbg(&dev->dev, "0xc0:0x22:0:6 %d - 0x%p ", ret, status_buffer); + status[0] = status_buffer[0]; + kfree(status_buffer); + + return ret; +} + +/* select the work mode. + * NOTE this function not supported by spcp825-007 */ +static void spcp8x5_set_workMode(struct usb_device *dev, u16 value, + u16 index, enum spcp8x5_type type) +{ + int ret; + + /* I return Permited not support here but seem inval device + * is more fix */ + if (type == SPCP825_007_TYPE) + return; + + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + SET_WORKING_MODE_TYPE, SET_WORKING_MODE, + value, index, NULL, 0, 100); + dev_dbg(&dev->dev, "value = %#x , index = %#x\n", value, index); + if (ret < 0) + dev_dbg(&dev->dev, + "RTSCTS usb_control_msg(enable flowctrl) = %d\n", ret); +} + +/* close the serial port. We should wait for data sending to device 1st and + * then kill all urb. */ +static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + unsigned int c_cflag; + int bps; + long timeout; + wait_queue_t wait; + int result; + + dbg("%s - port %d", __func__, port->number); + + /* wait for data to drain from the buffer */ + spin_lock_irqsave(&priv->lock, flags); + timeout = SPCP8x5_CLOSING_WAIT; + init_waitqueue_entry(&wait, current); + add_wait_queue(&port->tty->write_wait, &wait); + for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + if (ringbuf_avail_data(priv->buf) == 0 || + timeout == 0 || signal_pending(current)) + break; + spin_unlock_irqrestore(&priv->lock, flags); + timeout = schedule_timeout(timeout); + spin_lock_irqsave(&priv->lock, flags); + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&port->tty->write_wait, &wait); + + /* clear out any remaining data in the buffer */ + clear_ringbuf(priv->buf); + spin_unlock_irqrestore(&priv->lock, flags); + + /* wait for characters to drain from the device (this is long enough + * for the entire all byte spcp8x5 hardware buffer to drain with no + * flow control for data rates of 1200 bps or more, for lower rates we + * should really know how much data is in the buffer to compute a delay + * that is not unnecessarily long) */ + bps = tty_get_baud_rate(port->tty); + if (bps > 1200) + timeout = max((HZ*2560) / bps, HZ/10); + else + timeout = 2*HZ; + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(timeout); + + /* clear control lines */ + if (port->tty) { + c_cflag = port->tty->termios->c_cflag; + if (c_cflag & HUPCL) { + spin_lock_irqsave(&priv->lock, flags); + priv->line_control = 0; + spin_unlock_irqrestore(&priv->lock, flags); + spcp8x5_set_ctrlLine(port->serial->dev, 0 , priv->type); + } + } + + /* kill urb */ + if (port->write_urb != NULL) { + result = usb_unlink_urb(port->write_urb); + if (result) + dev_dbg(&port->dev, + "usb_unlink_urb(write_urb) = %d\n", result); + } + result = usb_unlink_urb(port->read_urb); + if (result) + dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result); +} + +/* set the serial param for transfer. we should check if we really need to + * transfer. then if be set flow contorl we should do this too. */ +static void spcp8x5_set_termios(struct usb_serial_port *port, + struct ktermios *old_termios) +{ + struct usb_serial *serial = port->serial; + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + unsigned int cflag = port->tty->termios->c_cflag; + unsigned int old_cflag = old_termios->c_cflag; + unsigned short uartdata; + unsigned char buf[2] = {0, 0}; + int baud; + int i; + u8 control; + + if ((!port->tty) || (!port->tty->termios)) + return; + + /* for the 1st time call this function */ + spin_lock_irqsave(&priv->lock, flags); + if (!priv->termios_initialized) { + *(port->tty->termios) = tty_std_termios; + port->tty->termios->c_cflag = B115200 | CS8 | CREAD | + HUPCL | CLOCAL; + priv->termios_initialized = 1; + } + spin_unlock_irqrestore(&priv->lock, flags); + + /* check that they really want us to change something */ + if (!tty_termios_hw_change(port->tty->termios, old_termios)) + return; + + /* set DTR/RTS active */ + spin_lock_irqsave(&priv->lock, flags); + control = priv->line_control; + if ((old_cflag & CBAUD) == B0) { + priv->line_control |= MCR_DTR; + if (!(old_cflag & CRTSCTS)) + priv->line_control |= MCR_RTS; + } + if (control != priv->line_control) { + control = priv->line_control; + spin_unlock_irqrestore(&priv->lock, flags); + spcp8x5_set_ctrlLine(serial->dev, control , priv->type); + } else { + spin_unlock_irqrestore(&priv->lock, flags); + } + + /* Set Baud Rate */ + baud = tty_get_baud_rate(port->tty);; + switch (baud) { + case 300: buf[0] = 0x00; break; + case 600: buf[0] = 0x01; break; + case 1200: buf[0] = 0x02; break; + case 2400: buf[0] = 0x03; break; + case 4800: buf[0] = 0x04; break; + case 9600: buf[0] = 0x05; break; + case 19200: buf[0] = 0x07; break; + case 38400: buf[0] = 0x09; break; + case 57600: buf[0] = 0x0a; break; + case 115200: buf[0] = 0x0b; break; + case 230400: buf[0] = 0x0c; break; + case 460800: buf[0] = 0x0d; break; + case 921600: buf[0] = 0x0e; break; +/* case 1200000: buf[0] = 0x0f; break; */ +/* case 2400000: buf[0] = 0x10; break; */ + case 3000000: buf[0] = 0x11; break; +/* case 6000000: buf[0] = 0x12; break; */ + case 0: + case 1000000: + buf[0] = 0x0b; break; + default: + err("spcp825 driver does not support the baudrate " + "requested, using default of 9600."); + } + + /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ + if (cflag & CSIZE) { + switch (cflag & CSIZE) { + case CS5: + buf[1] |= SET_UART_FORMAT_SIZE_5; + break; + case CS6: + buf[1] |= SET_UART_FORMAT_SIZE_6; + break; + case CS7: + buf[1] |= SET_UART_FORMAT_SIZE_7; + break; + default: + case CS8: + buf[1] |= SET_UART_FORMAT_SIZE_8; + break; + } + } + + /* Set Stop bit2 : 0:1bit 1:2bit */ + buf[1] |= (cflag & CSTOPB) ? SET_UART_FORMAT_STOP_2 : + SET_UART_FORMAT_STOP_1; + + /* Set Parity bit3-4 01:Odd 11:Even */ + if (cflag & PARENB) { + buf[1] |= (cflag & PARODD) ? + SET_UART_FORMAT_PAR_ODD : SET_UART_FORMAT_PAR_EVEN ; + } else + buf[1] |= SET_UART_FORMAT_PAR_NONE; + + uartdata = buf[0] | buf[1]<<8; + + i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + SET_UART_FORMAT_TYPE, SET_UART_FORMAT, + uartdata, 0, NULL, 0, 100); + if (i < 0) + err("Set UART format %#x failed (error = %d)", uartdata, i); + dbg("0x21:0x40:0:0 %d\n", i); + + if (cflag & CRTSCTS) { + /* enable hardware flow control */ + spcp8x5_set_workMode(serial->dev, 0x000a, + SET_WORKING_MODE_U2C, priv->type); + } + return; +} + +/* open the serial port. do some usb system call. set termios and get the line + * status of the device. then submit the read urb */ +static int spcp8x5_open(struct usb_serial_port *port, struct file *filp) +{ + struct ktermios tmp_termios; + struct usb_serial *serial = port->serial; + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + int ret; + unsigned long flags; + u8 status = 0x30; + /* status 0x30 means DSR and CTS = 1 other CDC RI and delta = 0 */ + + dbg("%s - port %d", __func__, port->number); + + usb_clear_halt(serial->dev, port->write_urb->pipe); + usb_clear_halt(serial->dev, port->read_urb->pipe); + + ret = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + 0x09, 0x00, + 0x01, 0x00, NULL, 0x00, 100); + if (ret) + return ret; + + spin_lock_irqsave(&priv->lock, flags); + if (port->tty->termios->c_cflag & CBAUD) + priv->line_control = MCR_DTR | MCR_RTS; + else + priv->line_control = 0; + spin_unlock_irqrestore(&priv->lock, flags); + + spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type); + + /* Setup termios */ + if (port->tty) + spcp8x5_set_termios(port, &tmp_termios); + + spcp8x5_get_msr(serial->dev, &status, priv->type); + + /* may be we should update uart status here but now we did not do */ + spin_lock_irqsave(&priv->lock, flags); + priv->line_status = status & 0xf0 ; + spin_unlock_irqrestore(&priv->lock, flags); + + /* FIXME: need to assert RTS and DTR if CRTSCTS off */ + + dbg("%s - submitting read urb", __func__); + port->read_urb->dev = serial->dev; + ret = usb_submit_urb(port->read_urb, GFP_KERNEL); + if (ret) { + spcp8x5_close(port, NULL); + return -EPROTO; + } + return 0; +} + +/* bulk read call back function. check the status of the urb. if transfer + * failed return. then update the status and the tty send data to tty subsys. + * submit urb again. + */ +static void spcp8x5_read_bulk_callback(struct urb *urb) +{ + struct usb_serial_port *port = urb->context; + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + struct tty_struct *tty; + unsigned char *data = urb->transfer_buffer; + unsigned long flags; + int i; + int result; + u8 status = 0; + char tty_flag; + + dev_dbg(&port->dev, "start, urb->status = %d, " + "urb->actual_length = %d\n,", urb->status, urb->actual_length); + + /* check the urb status */ + if (urb->status) { + if (!port->open_count) + return; + if (urb->status == -EPROTO) { + /* spcp8x5 mysteriously fails with -EPROTO */ + /* reschedule the read */ + urb->status = 0; + urb->dev = port->serial->dev; + result = usb_submit_urb(urb , GFP_ATOMIC); + if (result) + dev_dbg(&port->dev, + "failed submitting read urb %d\n", + result); + return; + } + dev_dbg(&port->dev, "unable to handle the error, exiting.\n"); + return; + } + + /* get tty_flag from status */ + tty_flag = TTY_NORMAL; + + spin_lock_irqsave(&priv->lock, flags); + status = priv->line_status; + priv->line_status &= ~UART_STATE_TRANSIENT_MASK; + spin_unlock_irqrestore(&priv->lock, flags); + /* wake up the wait for termios */ + wake_up_interruptible(&priv->delta_msr_wait); + + /* break takes precedence over parity, which takes precedence over + * framing errors */ + if (status & UART_BREAK_ERROR) + tty_flag = TTY_BREAK; + else if (status & UART_PARITY_ERROR) + tty_flag = TTY_PARITY; + else if (status & UART_FRAME_ERROR) + tty_flag = TTY_FRAME; + dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag); + + tty = port->tty; + if (tty && urb->actual_length) { + tty_buffer_request_room(tty, urb->actual_length + 1); + /* overrun is special, not associated with a char */ + if (status & UART_OVERRUN_ERROR) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); + for (i = 0; i < urb->actual_length; ++i) + tty_insert_flip_char(tty, data[i], tty_flag); + tty_flip_buffer_push(tty); + } + + /* Schedule the next read _if_ we are still open */ + if (port->open_count) { + urb->dev = port->serial->dev; + result = usb_submit_urb(urb , GFP_ATOMIC); + if (result) + dev_dbg(&port->dev, "failed submitting read urb %d\n", + result); + } + + return; +} + +/* get data from ring buffer and then write to usb bus */ +static void spcp8x5_send(struct usb_serial_port *port) +{ + int count, result; + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + + if (priv->write_urb_in_use) { + dev_dbg(&port->dev, "write urb still used\n"); + spin_unlock_irqrestore(&priv->lock, flags); + return; + } + + /* send the 1st urb for writting */ + memset(port->write_urb->transfer_buffer , 0x00 , port->bulk_out_size); + count = get_ringbuf(priv->buf, port->write_urb->transfer_buffer, + port->bulk_out_size); + + if (count == 0) { + spin_unlock_irqrestore(&priv->lock, flags); + return; + } + + /* update the urb status */ + priv->write_urb_in_use = 1; + + spin_unlock_irqrestore(&priv->lock, flags); + + port->write_urb->transfer_buffer_length = count; + port->write_urb->dev = port->serial->dev; + + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); + if (result) { + dev_dbg(&port->dev, "failed submitting write urb, error %d\n", + result); + priv->write_urb_in_use = 0; + /* TODO: reschedule spcp8x5_send */ + } + + + schedule_work(&port->work); +} + +/* this is the call back function for write urb. NOTE we should not sleep in + * this routine. check the urb return code and then submit the write urb again + * to hold the write loop */ +static void spcp8x5_write_bulk_callback(struct urb *urb) +{ + struct usb_serial_port *port = urb->context; + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + int result; + + switch (urb->status) { + case 0: + /* success */ + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + /* this urb is terminated, clean up */ + dev_dbg(&port->dev, "urb shutting down with status: %d\n", + urb->status); + priv->write_urb_in_use = 0; + return; + default: + /* error in the urb, so we have to resubmit it */ + dbg("%s - Overflow in write", __func__); + dbg("%s - nonzero write bulk status received: %d", + __func__, urb->status); + port->write_urb->transfer_buffer_length = 1; + port->write_urb->dev = port->serial->dev; + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); + if (result) + dev_dbg(&port->dev, + "failed resubmitting write urb %d\n", result); + else + return; + } + + priv->write_urb_in_use = 0; + + /* send any buffered data */ + spcp8x5_send(port); +} + +/* write data to ring buffer. and then start the write transfer */ +static int spcp8x5_write(struct usb_serial_port *port, + const unsigned char *buf, int count) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + + dev_dbg(&port->dev, "%d bytes\n", count); + + if (!count) + return count; + + spin_lock_irqsave(&priv->lock, flags); + count = put_ringbuf(priv->buf, buf, count); + spin_unlock_irqrestore(&priv->lock, flags); + + spcp8x5_send(port); + + return count; +} + +static int spcp8x5_wait_modem_info(struct usb_serial_port *port, + unsigned int arg) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + unsigned int prevstatus; + unsigned int status; + unsigned int changed; + + spin_lock_irqsave(&priv->lock, flags); + prevstatus = priv->line_status; + spin_unlock_irqrestore(&priv->lock, flags); + + while (1) { + /* wake up in bulk read */ + interruptible_sleep_on(&priv->delta_msr_wait); + + /* see if a signal did it */ + if (signal_pending(current)) + return -ERESTARTSYS; + + spin_lock_irqsave(&priv->lock, flags); + status = priv->line_status; + spin_unlock_irqrestore(&priv->lock, flags); + + changed = prevstatus^status; + + if (((arg & TIOCM_RNG) && (changed & MSR_STATUS_LINE_RI)) || + ((arg & TIOCM_DSR) && (changed & MSR_STATUS_LINE_DSR)) || + ((arg & TIOCM_CD) && (changed & MSR_STATUS_LINE_DCD)) || + ((arg & TIOCM_CTS) && (changed & MSR_STATUS_LINE_CTS))) + return 0; + + prevstatus = status; + } + /* NOTREACHED */ + return 0; +} + +static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file, + unsigned int cmd, unsigned long arg) +{ + dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); + + switch (cmd) { + case TIOCMIWAIT: + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); + return spcp8x5_wait_modem_info(port, arg); + + default: + dbg("%s not supported = 0x%04x", __func__, cmd); + break; + } + + return -ENOIOCTLCMD; +} + +static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file, + unsigned int set, unsigned int clear) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + u8 control; + + spin_lock_irqsave(&priv->lock, flags); + if (set & TIOCM_RTS) + priv->line_control |= MCR_RTS; + if (set & TIOCM_DTR) + priv->line_control |= MCR_DTR; + if (clear & TIOCM_RTS) + priv->line_control &= ~MCR_RTS; + if (clear & TIOCM_DTR) + priv->line_control &= ~MCR_DTR; + control = priv->line_control; + spin_unlock_irqrestore(&priv->lock, flags); + + return spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type); +} + +static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + unsigned int mcr; + unsigned int status; + unsigned int result; + + spin_lock_irqsave(&priv->lock, flags); + mcr = priv->line_control; + status = priv->line_status; + spin_unlock_irqrestore(&priv->lock, flags); + + result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) + | ((mcr & MCR_RTS) ? TIOCM_RTS : 0) + | ((status & MSR_STATUS_LINE_CTS) ? TIOCM_CTS : 0) + | ((status & MSR_STATUS_LINE_DSR) ? TIOCM_DSR : 0) + | ((status & MSR_STATUS_LINE_RI) ? TIOCM_RI : 0) + | ((status & MSR_STATUS_LINE_DCD) ? TIOCM_CD : 0); + + return result; +} + +/* get the avail space room in ring buffer */ +static int spcp8x5_write_room(struct usb_serial_port *port) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + int room = 0; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + room = ringbuf_avail_space(priv->buf); + spin_unlock_irqrestore(&priv->lock, flags); + + return room; +} + +/* get the number of avail data in write ring buffer */ +static int spcp8x5_chars_in_buffer(struct usb_serial_port *port) +{ + struct spcp8x5_private *priv = usb_get_serial_port_data(port); + int chars = 0; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + chars = ringbuf_avail_data(priv->buf); + spin_unlock_irqrestore(&priv->lock, flags); + + return chars; +} + +/* All of the device info needed for the spcp8x5 SIO serial converter */ +static struct usb_serial_driver spcp8x5_device = { + .driver = { + .owner = THIS_MODULE, + .name = "SPCP8x5", + }, + .id_table = id_table, + .num_ports = 1, + .open = spcp8x5_open, + .close = spcp8x5_close, + .write = spcp8x5_write, + .set_termios = spcp8x5_set_termios, + .ioctl = spcp8x5_ioctl, + .tiocmget = spcp8x5_tiocmget, + .tiocmset = spcp8x5_tiocmset, + .write_room = spcp8x5_write_room, + .read_bulk_callback = spcp8x5_read_bulk_callback, + .write_bulk_callback = spcp8x5_write_bulk_callback, + .chars_in_buffer = spcp8x5_chars_in_buffer, + .attach = spcp8x5_startup, + .shutdown = spcp8x5_shutdown, +}; + +static int __init spcp8x5_init(void) +{ + int retval; + retval = usb_serial_register(&spcp8x5_device); + if (retval) + goto failed_usb_serial_register; + retval = usb_register(&spcp8x5_driver); + if (retval) + goto failed_usb_register; + info(DRIVER_DESC " " DRIVER_VERSION); + return 0; +failed_usb_register: + usb_serial_deregister(&spcp8x5_device); +failed_usb_serial_register: + return retval; +} + +static void __exit spcp8x5_exit(void) +{ + usb_deregister(&spcp8x5_driver); + usb_serial_deregister(&spcp8x5_device); +} + +module_init(spcp8x5_init); +module_exit(spcp8x5_exit); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL"); + +module_param(debug, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "Debug enabled or not"); diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 3a377667733..a1c8aef0141 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -264,9 +264,6 @@ static struct usb_serial_driver ti_1port_device = { .description = "TI USB 3410 1 port adapter", .usb_driver = &ti_usb_driver, .id_table = ti_id_table_3410, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = 1, .num_ports = 1, .attach = ti_startup, .shutdown = ti_shutdown, @@ -295,9 +292,6 @@ static struct usb_serial_driver ti_2port_device = { .description = "TI USB 5052 2 port adapter", .usb_driver = &ti_usb_driver, .id_table = ti_id_table_5052, - .num_interrupt_in = 1, - .num_bulk_in = 2, - .num_bulk_out = 2, .num_ports = 2, .attach = ti_startup, .shutdown = ti_shutdown, @@ -414,14 +408,14 @@ static int ti_startup(struct usb_serial *serial) dbg("%s - product 0x%4X, num configurations %d, configuration value %d", - __FUNCTION__, le16_to_cpu(dev->descriptor.idProduct), + __func__, le16_to_cpu(dev->descriptor.idProduct), dev->descriptor.bNumConfigurations, dev->actconfig->desc.bConfigurationValue); /* create device structure */ tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL); if (tdev == NULL) { - dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&dev->dev, "%s - out of memory\n", __func__); return -ENOMEM; } mutex_init(&tdev->td_open_close_lock); @@ -431,7 +425,7 @@ static int ti_startup(struct usb_serial *serial) /* determine device type */ if (usb_match_id(serial->interface, ti_id_table_3410)) tdev->td_is_3410 = 1; - dbg("%s - device type is %s", __FUNCTION__, tdev->td_is_3410 ? "3410" : "5052"); + dbg("%s - device type is %s", __func__, tdev->td_is_3410 ? "3410" : "5052"); /* if we have only 1 configuration, download firmware */ if (dev->descriptor.bNumConfigurations == 1) { @@ -465,7 +459,7 @@ static int ti_startup(struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL); if (tport == NULL) { - dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&dev->dev, "%s - out of memory\n", __func__); status = -ENOMEM; goto free_tports; } @@ -477,7 +471,7 @@ static int ti_startup(struct usb_serial *serial) init_waitqueue_head(&tport->tp_write_wait); tport->tp_write_buf = ti_buf_alloc(); if (tport->tp_write_buf == NULL) { - dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&dev->dev, "%s - out of memory\n", __func__); kfree(tport); status = -ENOMEM; goto free_tports; @@ -510,7 +504,7 @@ static void ti_shutdown(struct usb_serial *serial) struct ti_device *tdev = usb_get_serial_data(serial); struct ti_port *tport; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i=0; i < serial->num_ports; ++i) { tport = usb_get_serial_port_data(serial->port[i]); @@ -538,7 +532,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) TI_PIPE_TIMEOUT_ENABLE | (TI_TRANSFER_TIMEOUT << 2)); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return -ENODEV; @@ -563,10 +557,10 @@ static int ti_open(struct usb_serial_port *port, struct file *file) /* start interrupt urb the first time a port is opened on this device */ if (tdev->td_open_port_count == 0) { - dbg("%s - start interrupt in urb", __FUNCTION__); + dbg("%s - start interrupt in urb", __func__); urb = tdev->td_serial->port[0]->interrupt_in_urb; if (!urb) { - dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__); + dev_err(&port->dev, "%s - no interrupt urb\n", __func__); status = -EINVAL; goto release_lock; } @@ -575,40 +569,40 @@ static int ti_open(struct usb_serial_port *port, struct file *file) urb->dev = dev; status = usb_submit_urb(urb, GFP_KERNEL); if (status) { - dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status); goto release_lock; } } ti_set_termios(port, port->tty->termios); - dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); + dbg("%s - sending TI_OPEN_PORT", __func__); status = ti_command_out_sync(tdev, TI_OPEN_PORT, (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send open command, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot send open command, %d\n", __func__, status); goto unlink_int_urb; } - dbg("%s - sending TI_START_PORT", __FUNCTION__); + dbg("%s - sending TI_START_PORT", __func__); status = ti_command_out_sync(tdev, TI_START_PORT, (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send start command, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot send start command, %d\n", __func__, status); goto unlink_int_urb; } - dbg("%s - sending TI_PURGE_PORT", __FUNCTION__); + dbg("%s - sending TI_PURGE_PORT", __func__); status = ti_command_out_sync(tdev, TI_PURGE_PORT, (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __func__, status); goto unlink_int_urb; } status = ti_command_out_sync(tdev, TI_PURGE_PORT, (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __func__, status); goto unlink_int_urb; } @@ -619,27 +613,27 @@ static int ti_open(struct usb_serial_port *port, struct file *file) ti_set_termios(port, port->tty->termios); - dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); + dbg("%s - sending TI_OPEN_PORT (2)", __func__); status = ti_command_out_sync(tdev, TI_OPEN_PORT, (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __func__, status); goto unlink_int_urb; } - dbg("%s - sending TI_START_PORT (2)", __FUNCTION__); + dbg("%s - sending TI_START_PORT (2)", __func__); status = ti_command_out_sync(tdev, TI_START_PORT, (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __func__, status); goto unlink_int_urb; } /* start read urb */ - dbg("%s - start read urb", __FUNCTION__); + dbg("%s - start read urb", __func__); urb = port->read_urb; if (!urb) { - dev_err(&port->dev, "%s - no read urb\n", __FUNCTION__); + dev_err(&port->dev, "%s - no read urb\n", __func__); status = -EINVAL; goto unlink_int_urb; } @@ -649,7 +643,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) urb->dev = dev; status = usb_submit_urb(urb, GFP_KERNEL); if (status) { - dev_err(&port->dev, "%s - submit read urb failed, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - submit read urb failed, %d\n", __func__, status); goto unlink_int_urb; } @@ -663,7 +657,7 @@ unlink_int_urb: usb_kill_urb(port->serial->port[0]->interrupt_in_urb); release_lock: mutex_unlock(&tdev->td_open_close_lock); - dbg("%s - exit %d", __FUNCTION__, status); + dbg("%s - exit %d", __func__, status); return status; } @@ -676,7 +670,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file) int status; int do_unlock; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); tdev = usb_get_serial_data(port->serial); tport = usb_get_serial_port_data(port); @@ -693,11 +687,11 @@ static void ti_close(struct usb_serial_port *port, struct file *file) port_number = port->number - port->serial->minor; - dbg("%s - sending TI_CLOSE_PORT", __FUNCTION__); + dbg("%s - sending TI_CLOSE_PORT", __func__); status = ti_command_out_sync(tdev, TI_CLOSE_PORT, (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); if (status) - dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __func__, status); /* if mutex_lock is interrupted, continue anyway */ do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); @@ -710,7 +704,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file) if (do_unlock) mutex_unlock(&tdev->td_open_close_lock); - dbg("%s - exit", __FUNCTION__); + dbg("%s - exit", __func__); } @@ -720,10 +714,10 @@ static int ti_write(struct usb_serial_port *port, const unsigned char *data, struct ti_port *tport = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return 0; } @@ -746,7 +740,7 @@ static int ti_write_room(struct usb_serial_port *port) int room = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return -ENODEV; @@ -755,7 +749,7 @@ static int ti_write_room(struct usb_serial_port *port) room = ti_buf_space_avail(tport->tp_write_buf); spin_unlock_irqrestore(&tport->tp_lock, flags); - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return room; } @@ -766,7 +760,7 @@ static int ti_chars_in_buffer(struct usb_serial_port *port) int chars = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return -ENODEV; @@ -775,7 +769,7 @@ static int ti_chars_in_buffer(struct usb_serial_port *port) chars = ti_buf_data_avail(tport->tp_write_buf); spin_unlock_irqrestore(&tport->tp_lock, flags); - dbg("%s - returns %d", __FUNCTION__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } @@ -785,14 +779,14 @@ static void ti_throttle(struct usb_serial_port *port) struct ti_port *tport = usb_get_serial_port_data(port); struct tty_struct *tty; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return; tty = port->tty; if (!tty) { - dbg("%s - no tty", __FUNCTION__); + dbg("%s - no tty", __func__); return; } @@ -808,21 +802,21 @@ static void ti_unthrottle(struct usb_serial_port *port) struct tty_struct *tty; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return; tty = port->tty; if (!tty) { - dbg("%s - no tty", __FUNCTION__); + dbg("%s - no tty", __func__); return; } if (I_IXOFF(tty) || C_CRTSCTS(tty)) { status = ti_restart_read(tport, tty); if (status) - dev_err(&port->dev, "%s - cannot restart read, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - cannot restart read, %d\n", __func__, status); } } @@ -834,24 +828,24 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file, struct async_icount cnow; struct async_icount cprev; - dbg("%s - port %d, cmd = 0x%04X", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd = 0x%04X", __func__, port->number, cmd); if (tport == NULL) return -ENODEV; switch (cmd) { case TIOCGSERIAL: - dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); return ti_get_serial_info(tport, (struct serial_struct __user *)arg); break; case TIOCSSERIAL: - dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); return ti_set_serial_info(tport, (struct serial_struct __user *)arg); break; case TIOCMIWAIT: - dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->number); + dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); cprev = tport->tp_icount; while (1) { interruptible_sleep_on(&tport->tp_msr_wait); @@ -872,7 +866,7 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file, break; case TIOCGICOUNT: - dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); + dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount))) return -EFAULT; return 0; @@ -894,20 +888,20 @@ static void ti_set_termios(struct usb_serial_port *port, int port_number = port->number - port->serial->minor; unsigned int mcr; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); cflag = tty->termios->c_cflag; iflag = tty->termios->c_iflag; - dbg("%s - cflag %08x, iflag %08x", __FUNCTION__, cflag, iflag); - dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); + dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); + dbg("%s - old clfag %08x, old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); if (tport == NULL) return; config = kmalloc(sizeof(*config), GFP_KERNEL); if (!config) { - dev_err(&port->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&port->dev, "%s - out of memory\n", __func__); return; } @@ -991,7 +985,7 @@ static void ti_set_termios(struct usb_serial_port *port, tty_encode_baud_rate(tty, baud, baud); dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", - __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); + __func__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); cpu_to_be16s(&config->wBaudRate); cpu_to_be16s(&config->wFlags); @@ -1000,7 +994,7 @@ static void ti_set_termios(struct usb_serial_port *port, (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, sizeof(*config)); if (status) - dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __FUNCTION__, port_number, status); + dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __func__, port_number, status); /* SET_CONFIG asserts RTS and DTR, reset them correctly */ mcr = tport->tp_shadow_mcr; @@ -1009,7 +1003,7 @@ static void ti_set_termios(struct usb_serial_port *port, mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); status = ti_set_mcr(tport, mcr); if (status) - dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __FUNCTION__, port_number, status); + dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __func__, port_number, status); kfree(config); } @@ -1021,14 +1015,17 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file) unsigned int result; unsigned int msr; unsigned int mcr; + unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return -ENODEV; + spin_lock_irqsave(&tport->tp_lock, flags); msr = tport->tp_msr; mcr = tport->tp_shadow_mcr; + spin_unlock_irqrestore(&tport->tp_lock, flags); result = ((mcr & TI_MCR_DTR) ? TIOCM_DTR : 0) | ((mcr & TI_MCR_RTS) ? TIOCM_RTS : 0) @@ -1038,7 +1035,7 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file) | ((msr & TI_MSR_RI) ? TIOCM_RI : 0) | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0); - dbg("%s - 0x%04X", __FUNCTION__, result); + dbg("%s - 0x%04X", __func__, result); return result; } @@ -1049,12 +1046,14 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file, { struct ti_port *tport = usb_get_serial_port_data(port); unsigned int mcr; + unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (tport == NULL) return -ENODEV; + spin_lock_irqsave(&tport->tp_lock, flags); mcr = tport->tp_shadow_mcr; if (set & TIOCM_RTS) @@ -1070,6 +1069,7 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file, mcr &= ~TI_MCR_DTR; if (clear & TIOCM_LOOP) mcr &= ~TI_MCR_LOOP; + spin_unlock_irqrestore(&tport->tp_lock, flags); return ti_set_mcr(tport, mcr); } @@ -1080,7 +1080,7 @@ static void ti_break(struct usb_serial_port *port, int break_state) struct ti_port *tport = usb_get_serial_port_data(port); int status; - dbg("%s - state = %d", __FUNCTION__, break_state); + dbg("%s - state = %d", __func__, break_state); if (tport == NULL) return; @@ -1092,13 +1092,13 @@ static void ti_break(struct usb_serial_port *port, int break_state) TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); if (status) - dbg("%s - error setting break, %d", __FUNCTION__, status); + dbg("%s - error setting break, %d", __func__, status); } static void ti_interrupt_callback(struct urb *urb) { - struct ti_device *tdev = (struct ti_device *)urb->context; + struct ti_device *tdev = urb->context; struct usb_serial_port *port; struct usb_serial *serial = tdev->td_serial; struct ti_port *tport; @@ -1111,7 +1111,7 @@ static void ti_interrupt_callback(struct urb *urb) int retval; __u8 msr; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); switch (status) { case 0: @@ -1119,33 +1119,33 @@ static void ti_interrupt_callback(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - dbg("%s - urb shutting down, %d", __FUNCTION__, status); + dbg("%s - urb shutting down, %d", __func__, status); tdev->td_urb_error = 1; return; default: dev_err(dev, "%s - nonzero urb status, %d\n", - __FUNCTION__, status); + __func__, status); tdev->td_urb_error = 1; goto exit; } if (length != 2) { - dbg("%s - bad packet size, %d", __FUNCTION__, length); + dbg("%s - bad packet size, %d", __func__, length); goto exit; } if (data[0] == TI_CODE_HARDWARE_ERROR) { - dev_err(dev, "%s - hardware error, %d\n", __FUNCTION__, data[1]); + dev_err(dev, "%s - hardware error, %d\n", __func__, data[1]); goto exit; } port_number = TI_GET_PORT_FROM_CODE(data[0]); function = TI_GET_FUNC_FROM_CODE(data[0]); - dbg("%s - port_number %d, function %d, data 0x%02X", __FUNCTION__, port_number, function, data[1]); + dbg("%s - port_number %d, function %d, data 0x%02X", __func__, port_number, function, data[1]); if (port_number >= serial->num_ports) { - dev_err(dev, "%s - bad port number, %d\n", __FUNCTION__, port_number); + dev_err(dev, "%s - bad port number, %d\n", __func__, port_number); goto exit; } @@ -1157,17 +1157,17 @@ static void ti_interrupt_callback(struct urb *urb) switch (function) { case TI_CODE_DATA_ERROR: - dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __FUNCTION__, port_number, data[1]); + dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __func__, port_number, data[1]); break; case TI_CODE_MODEM_STATUS: msr = data[1]; - dbg("%s - port %d, msr 0x%02X", __FUNCTION__, port_number, msr); + dbg("%s - port %d, msr 0x%02X", __func__, port_number, msr); ti_handle_new_msr(tport, msr); break; default: - dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __FUNCTION__, data[1]); + dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __func__, data[1]); break; } @@ -1175,19 +1175,19 @@ exit: retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) dev_err(dev, "%s - resubmit interrupt urb failed, %d\n", - __FUNCTION__, retval); + __func__, retval); } static void ti_bulk_in_callback(struct urb *urb) { - struct ti_port *tport = (struct ti_port *)urb->context; + struct ti_port *tport = urb->context; struct usb_serial_port *port = tport->tp_port; struct device *dev = &urb->dev->dev; int status = urb->status; int retval = 0; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); switch (status) { case 0: @@ -1195,13 +1195,13 @@ static void ti_bulk_in_callback(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - dbg("%s - urb shutting down, %d", __FUNCTION__, status); + dbg("%s - urb shutting down, %d", __func__, status); tport->tp_tdev->td_urb_error = 1; wake_up_interruptible(&tport->tp_write_wait); return; default: dev_err(dev, "%s - nonzero urb status, %d\n", - __FUNCTION__, status ); + __func__, status ); tport->tp_tdev->td_urb_error = 1; wake_up_interruptible(&tport->tp_write_wait); } @@ -1210,16 +1210,16 @@ static void ti_bulk_in_callback(struct urb *urb) goto exit; if (status) { - dev_err(dev, "%s - stopping read!\n", __FUNCTION__); + dev_err(dev, "%s - stopping read!\n", __func__); return; } if (port->tty && urb->actual_length) { - usb_serial_debug_data(debug, dev, __FUNCTION__, + usb_serial_debug_data(debug, dev, __func__, urb->actual_length, urb->transfer_buffer); if (!tport->tp_is_open) - dbg("%s - port closed, dropping data", __FUNCTION__); + dbg("%s - port closed, dropping data", __func__); else ti_recv(&urb->dev->dev, port->tty, urb->transfer_buffer, urb->actual_length); @@ -1241,18 +1241,18 @@ exit: spin_unlock(&tport->tp_lock); if (retval) dev_err(dev, "%s - resubmit read urb failed, %d\n", - __FUNCTION__, retval); + __func__, retval); } static void ti_bulk_out_callback(struct urb *urb) { - struct ti_port *tport = (struct ti_port *)urb->context; + struct ti_port *tport = urb->context; struct usb_serial_port *port = tport->tp_port; struct device *dev = &urb->dev->dev; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); tport->tp_write_urb_in_use = 0; @@ -1262,13 +1262,13 @@ static void ti_bulk_out_callback(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - dbg("%s - urb shutting down, %d", __FUNCTION__, status); + dbg("%s - urb shutting down, %d", __func__, status); tport->tp_tdev->td_urb_error = 1; wake_up_interruptible(&tport->tp_write_wait); return; default: dev_err(dev, "%s - nonzero urb status, %d\n", - __FUNCTION__, status); + __func__, status); tport->tp_tdev->td_urb_error = 1; wake_up_interruptible(&tport->tp_write_wait); } @@ -1286,7 +1286,7 @@ static void ti_recv(struct device *dev, struct tty_struct *tty, do { cnt = tty_buffer_request_room(tty, length); if (cnt < length) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", __FUNCTION__, length - cnt); + dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); if(cnt == 0) break; } @@ -1307,7 +1307,7 @@ static void ti_send(struct ti_port *tport) unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&tport->tp_lock, flags); @@ -1329,7 +1329,7 @@ static void ti_send(struct ti_port *tport) spin_unlock_irqrestore(&tport->tp_lock, flags); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_sndbulkpipe(port->serial->dev, @@ -1339,7 +1339,7 @@ static void ti_send(struct ti_port *tport) result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - submit write urb failed, %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - submit write urb failed, %d\n", __func__, result); tport->tp_write_urb_in_use = 0; /* TODO: reschedule ti_send */ } else { @@ -1357,14 +1357,17 @@ static void ti_send(struct ti_port *tport) static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) { + unsigned long flags; int status; status = ti_write_byte(tport->tp_tdev, tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); + spin_lock_irqsave(&tport->tp_lock, flags); if (!status) tport->tp_shadow_mcr = mcr; + spin_unlock_irqrestore(&tport->tp_lock, flags); return status; } @@ -1378,23 +1381,23 @@ static int ti_get_lsr(struct ti_port *tport) int port_number = port->number - port->serial->minor; struct ti_port_status *data; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); size = sizeof(struct ti_port_status); data = kmalloc(size, GFP_KERNEL); if (!data) { - dev_err(&port->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&port->dev, "%s - out of memory\n", __func__); return -ENOMEM; } status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS, (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size); if (status) { - dev_err(&port->dev, "%s - get port status command failed, %d\n", __FUNCTION__, status); + dev_err(&port->dev, "%s - get port status command failed, %d\n", __func__, status); goto free_data; } - dbg("%s - lsr 0x%02X", __FUNCTION__, data->bLSR); + dbg("%s - lsr 0x%02X", __func__, data->bLSR); tport->tp_lsr = data->bLSR; @@ -1455,7 +1458,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) struct tty_struct *tty; unsigned long flags; - dbg("%s - msr 0x%02X", __FUNCTION__, msr); + dbg("%s - msr 0x%02X", __func__, msr); if (msr & TI_MSR_DELTA_MASK) { spin_lock_irqsave(&tport->tp_lock, flags); @@ -1493,7 +1496,7 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush) struct usb_serial_port *port = tport->tp_port; wait_queue_t wait; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irq(&tport->tp_lock); @@ -1625,12 +1628,12 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, struct ti_write_data_bytes *data; struct device *dev = &tdev->td_serial->dev->dev; - dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __FUNCTION__, addr, mask, byte); + dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __func__, addr, mask, byte); size = sizeof(struct ti_write_data_bytes) + 2; data = kmalloc(size, GFP_KERNEL); if (!data) { - dev_err(dev, "%s - out of memory\n", __FUNCTION__); + dev_err(dev, "%s - out of memory\n", __func__); return -ENOMEM; } @@ -1646,7 +1649,7 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, (__u8 *)data, size); if (status < 0) - dev_err(dev, "%s - failed, %d\n", __FUNCTION__, status); + dev_err(dev, "%s - failed, %d\n", __func__, status); kfree(data); @@ -1673,7 +1676,7 @@ static int ti_download_firmware(struct ti_device *tdev, buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) { - dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&dev->dev, "%s - out of memory\n", __func__); return -ENOMEM; } @@ -1687,7 +1690,7 @@ static int ti_download_firmware(struct ti_device *tdev, header->wLength = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_firmware_header))); header->bCheckSum = cs; - dbg("%s - downloading firmware", __FUNCTION__); + dbg("%s - downloading firmware", __func__); for (pos = 0; pos < buffer_size; pos += done) { len = min(buffer_size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); status = usb_bulk_msg(dev, pipe, buffer+pos, len, &done, 1000); @@ -1698,11 +1701,11 @@ static int ti_download_firmware(struct ti_device *tdev, kfree(buffer); if (status) { - dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __FUNCTION__, status); + dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); return status; } - dbg("%s - download successful", __FUNCTION__); + dbg("%s - download successful", __func__); return 0; } diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 2138ba8aeb6..a9934a3f984 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -81,7 +81,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po unsigned int i, j; int good_spot; - dbg("%s %d", __FUNCTION__, num_ports); + dbg("%s %d", __func__, num_ports); *minor = 0; mutex_lock(&table_lock); @@ -101,7 +101,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po *minor = i; j = 0; - dbg("%s - minor base = %d", __FUNCTION__, *minor); + dbg("%s - minor base = %d", __func__, *minor); for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) { serial_table[i] = serial; serial->port[j++]->number = i; @@ -117,7 +117,7 @@ static void return_serial(struct usb_serial *serial) { int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (serial == NULL) return; @@ -135,7 +135,7 @@ static void destroy_serial(struct kref *kref) serial = to_usb_serial(kref); - dbg("%s - %s", __FUNCTION__, serial->type->description); + dbg("%s - %s", __func__, serial->type->description); serial->type->shutdown(serial); @@ -187,7 +187,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) unsigned int portNumber; int retval; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* get the serial object associated with this tty pointer */ serial = usb_serial_get_by_index(tty->index); @@ -259,7 +259,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) if (!port) return; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); mutex_lock(&port->mutex); @@ -299,11 +299,11 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) goto exit; - dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); + dbg("%s - port %d, %d byte(s)", __func__, port->number, count); if (!port->open_count) { retval = -EINVAL; - dbg("%s - port not opened", __FUNCTION__); + dbg("%s - port not opened", __func__); goto exit; } @@ -322,10 +322,10 @@ static int serial_write_room (struct tty_struct *tty) if (!port) goto exit; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); goto exit; } @@ -344,10 +344,10 @@ static int serial_chars_in_buffer (struct tty_struct *tty) if (!port) goto exit; - dbg("%s = port %d", __FUNCTION__, port->number); + dbg("%s = port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); goto exit; } @@ -365,10 +365,10 @@ static void serial_throttle (struct tty_struct * tty) if (!port) return; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg ("%s - port not open", __FUNCTION__); + dbg ("%s - port not open", __func__); return; } @@ -384,10 +384,10 @@ static void serial_unthrottle (struct tty_struct * tty) if (!port) return; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); return; } @@ -401,13 +401,15 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in struct usb_serial_port *port = tty->driver_data; int retval = -ENODEV; + lock_kernel(); if (!port) goto exit; - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); + /* Caution - port->open_count is BKL protected */ if (!port->open_count) { - dbg ("%s - port not open", __FUNCTION__); + dbg ("%s - port not open", __func__); goto exit; } @@ -416,8 +418,8 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in retval = port->serial->type->ioctl(port, file, cmd, arg); else retval = -ENOIOCTLCMD; - exit: + unlock_kernel(); return retval; } @@ -428,10 +430,10 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) if (!port) return; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); return; } @@ -446,19 +448,24 @@ static void serial_break (struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; - if (!port) + lock_kernel(); + if (!port) { + unlock_kernel(); return; + } - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); + unlock_kernel(); return; } /* pass on to the driver specific version of this function if it is available */ if (port->serial->type->break_ctl) port->serial->type->break_ctl(port, break_state); + unlock_kernel(); } static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) @@ -469,7 +476,7 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int off_t begin = 0; char tmp[40]; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); length += sprintf (page, "usbserinfo:1.0 driver:2.0\n"); for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { serial = usb_serial_get_by_index(i); @@ -515,10 +522,10 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) if (!port) return -ENODEV; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); return -ENODEV; } @@ -536,10 +543,10 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, if (!port) return -ENODEV; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->open_count) { - dbg("%s - port not open", __FUNCTION__); + dbg("%s - port not open", __func__); return -ENODEV; } @@ -565,7 +572,7 @@ static void usb_serial_port_work(struct work_struct *work) container_of(work, struct usb_serial_port, work); struct tty_struct *tty; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port) return; @@ -581,7 +588,7 @@ static void port_release(struct device *dev) { struct usb_serial_port *port = to_usb_serial_port(dev); - dbg ("%s - %s", __FUNCTION__, dev->bus_id); + dbg ("%s - %s", __func__, dev->bus_id); port_free(port); } @@ -627,7 +634,7 @@ static struct usb_serial * create_serial (struct usb_device *dev, serial = kzalloc(sizeof(*serial), GFP_KERNEL); if (!serial) { - dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&dev->dev, "%s - out of memory\n", __func__); return NULL; } serial->dev = usb_get_dev(dev); @@ -722,7 +729,7 @@ int usb_serial_probe(struct usb_interface *interface, serial = create_serial (dev, interface, type); if (!serial) { unlock_kernel(); - dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__); + dev_err(&interface->dev, "%s - out of memory\n", __func__); return -ENOMEM; } @@ -854,22 +861,6 @@ int usb_serial_probe(struct usb_interface *interface, serial->num_interrupt_in = num_interrupt_in; serial->num_interrupt_out = num_interrupt_out; -#if 0 - /* check that the device meets the driver's requirements */ - if ((type->num_interrupt_in != NUM_DONT_CARE && - type->num_interrupt_in != num_interrupt_in) - || (type->num_interrupt_out != NUM_DONT_CARE && - type->num_interrupt_out != num_interrupt_out) - || (type->num_bulk_in != NUM_DONT_CARE && - type->num_bulk_in != num_bulk_in) - || (type->num_bulk_out != NUM_DONT_CARE && - type->num_bulk_out != num_bulk_out)) { - dbg("wrong number of endpoints"); - kfree(serial); - return -EIO; - } -#endif - /* found all that we need */ dev_info(&interface->dev, "%s converter detected\n", type->description); @@ -883,7 +874,7 @@ int usb_serial_probe(struct usb_interface *interface, serial->num_port_pointers = max_endpoints; unlock_kernel(); - dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints); + dbg("%s - setting up %d port structures for this device", __func__, max_endpoints); for (i = 0; i < max_endpoints; ++i) { port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); if (!port) @@ -1031,7 +1022,7 @@ int usb_serial_probe(struct usb_interface *interface, port->dev.release = &port_release; snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); - dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id); + dbg ("%s - registering %s", __func__, port->dev.bus_id); retval = device_register(&port->dev); if (retval) dev_err(&port->dev, "Error registering port device, " @@ -1090,7 +1081,7 @@ void usb_serial_disconnect(struct usb_interface *interface) struct usb_serial_port *port; usb_serial_console_disconnect(serial); - dbg ("%s", __FUNCTION__); + dbg ("%s", __func__); mutex_lock(&serial->disc_mutex); usb_set_intfdata (interface, NULL); @@ -1174,7 +1165,7 @@ static int __init usb_serial_init(void) result = bus_register(&usb_serial_bus_type); if (result) { - err("%s - registering bus driver failed", __FUNCTION__); + err("%s - registering bus driver failed", __func__); goto exit_bus; } @@ -1188,24 +1179,26 @@ static int __init usb_serial_init(void) usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; usb_serial_tty_driver->init_termios = tty_std_termios; usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + usb_serial_tty_driver->init_termios.c_ispeed = 9600; + usb_serial_tty_driver->init_termios.c_ospeed = 9600; tty_set_operations(usb_serial_tty_driver, &serial_ops); result = tty_register_driver(usb_serial_tty_driver); if (result) { - err("%s - tty_register_driver failed", __FUNCTION__); + err("%s - tty_register_driver failed", __func__); goto exit_reg_driver; } /* register the USB driver */ result = usb_register(&usb_serial_driver); if (result < 0) { - err("%s - usb_register failed", __FUNCTION__); + err("%s - usb_register failed", __func__); goto exit_tty; } /* register the generic driver, if we should */ result = usb_serial_generic_register(debug); if (result < 0) { - err("%s - registering generic driver failed", __FUNCTION__); + err("%s - registering generic driver failed", __func__); goto exit_generic; } @@ -1223,7 +1216,7 @@ exit_reg_driver: bus_unregister(&usb_serial_bus_type); exit_bus: - err ("%s - returning with error %d", __FUNCTION__, result); + err ("%s - returning with error %d", __func__, result); put_tty_driver(usb_serial_tty_driver); return result; } diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index 257a5e43687..f9fc926b56d 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c @@ -35,9 +35,6 @@ static struct usb_serial_driver debug_device = { .name = "debug", }, .id_table = id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, }; diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index c2b01f7c319..5fc20122145 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -189,9 +189,6 @@ static struct usb_serial_driver handspring_device = { .description = "Handspring Visor / Palm OS", .usb_driver = &visor_driver, .id_table = id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 2, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 2, .open = visor_open, .close = visor_close, @@ -219,9 +216,6 @@ static struct usb_serial_driver clie_5_device = { .description = "Sony Clie 5.0", .usb_driver = &visor_driver, .id_table = clie_id_5_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 2, - .num_bulk_out = 2, .num_ports = 2, .open = visor_open, .close = visor_close, @@ -249,9 +243,6 @@ static struct usb_serial_driver clie_3_5_device = { .description = "Sony Clie 3.5", .usb_driver = &visor_driver, .id_table = clie_id_3_5_table, - .num_interrupt_in = 0, - .num_bulk_in = 1, - .num_bulk_out = 1, .num_ports = 1, .open = visor_open, .close = visor_close, @@ -290,7 +281,7 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) unsigned long flags; int result = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (!port->read_urb) { /* this is needed for some brain dead Sony devices */ @@ -322,16 +313,16 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", - __FUNCTION__, result); + __func__, result); goto exit; } if (port->interrupt_in_urb) { - dbg("%s - adding interrupt input for treo", __FUNCTION__); + dbg("%s - adding interrupt input for treo", __func__); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result) dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", - __FUNCTION__, result); + __func__, result); } exit: return result; @@ -343,7 +334,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) struct visor_private *priv = usb_get_serial_port_data(port); unsigned char *transfer_buffer; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* shutdown our urbs */ usb_kill_urb(port->read_urb); @@ -379,12 +370,12 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf, unsigned long flags; int status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); if (priv->outstanding_urbs > URB_UPPER_LIMIT) { spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - write limit hit\n", __FUNCTION__); + dbg("%s - write limit hit\n", __func__); return 0; } priv->outstanding_urbs++; @@ -406,7 +397,7 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf, memcpy (buffer, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); usb_fill_bulk_urb (urb, serial->dev, usb_sndbulkpipe (serial->dev, @@ -418,7 +409,7 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf, status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", - __FUNCTION__, status); + __func__, status); count = status; goto error; } else { @@ -449,7 +440,7 @@ static int visor_write_room (struct usb_serial_port *port) struct visor_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * We really can take anything the user throws at us @@ -460,7 +451,7 @@ static int visor_write_room (struct usb_serial_port *port) spin_lock_irqsave(&priv->lock, flags); if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - write limit hit\n", __FUNCTION__); + dbg("%s - write limit hit\n", __func__); return 0; } spin_unlock_irqrestore(&priv->lock, flags); @@ -471,13 +462,15 @@ static int visor_write_room (struct usb_serial_port *port) static int visor_chars_in_buffer (struct usb_serial_port *port) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); /* * We can't really account for how much data we * have sent out, but hasn't made it through to the * device, so just tell the tty layer that everything * is flushed. + * + * FIXME: Should walk outstanding_urbs */ return 0; } @@ -485,7 +478,7 @@ static int visor_chars_in_buffer (struct usb_serial_port *port) static void visor_write_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct visor_private *priv = usb_get_serial_port_data(port); int status = urb->status; unsigned long flags; @@ -493,11 +486,11 @@ static void visor_write_bulk_callback (struct urb *urb) /* free up the transfer buffer, as usb_free_urb() does not do this */ kfree (urb->transfer_buffer); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); spin_lock_irqsave(&priv->lock, flags); --priv->outstanding_urbs; @@ -509,7 +502,7 @@ static void visor_write_bulk_callback (struct urb *urb) static void visor_read_bulk_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct visor_private *priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -517,15 +510,15 @@ static void visor_read_bulk_callback (struct urb *urb) int result; int available_room; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); tty = port->tty; if (tty && urb->actual_length) { @@ -551,7 +544,7 @@ static void visor_read_bulk_callback (struct urb *urb) visor_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); } else { priv->actually_throttled = 1; } @@ -560,7 +553,7 @@ static void visor_read_bulk_callback (struct urb *urb) static void visor_read_int_callback (struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; int status = urb->status; int result; @@ -573,11 +566,11 @@ static void visor_read_int_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, status); + __func__, status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, status); + __func__, status); goto exit; } @@ -588,14 +581,14 @@ static void visor_read_int_callback (struct urb *urb) * Rumor has it this endpoint is used to notify when data * is ready to be read from the bulk ones. */ - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, urb->transfer_buffer); exit: result = usb_submit_urb (urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", - __FUNCTION__, result); + __func__, result); } static void visor_throttle (struct usb_serial_port *port) @@ -603,7 +596,7 @@ static void visor_throttle (struct usb_serial_port *port) struct visor_private *priv = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->throttled = 1; spin_unlock_irqrestore(&priv->lock, flags); @@ -616,7 +609,7 @@ static void visor_unthrottle (struct usb_serial_port *port) unsigned long flags; int result; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->throttled = 0; priv->actually_throttled = 0; @@ -625,7 +618,7 @@ static void visor_unthrottle (struct usb_serial_port *port) port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); + dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); } static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id) @@ -638,11 +631,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i int i; int num_ports = 0; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); if (!transfer_buffer) { - dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__, + dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__, sizeof(*connection_info)); return -ENOMEM; } @@ -655,7 +648,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i sizeof(*connection_info), 300); if (retval < 0) { dev_err(dev, "%s - error %d getting connection information\n", - __FUNCTION__, retval); + __func__, retval); goto exit; } @@ -715,7 +708,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i 0x02, 300); if (retval < 0) dev_err(dev, "%s - error %d getting bytes available request\n", - __FUNCTION__, retval); + __func__, retval); retval = 0; exit: @@ -731,11 +724,11 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i unsigned char *transfer_buffer; int retval; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); if (!transfer_buffer) { - dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__, + dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__, sizeof(*connection_info)); return -ENOMEM; } @@ -747,9 +740,9 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i sizeof (*connection_info), 300); if (retval < 0) dev_err(dev, "%s - error %d getting connection info\n", - __FUNCTION__, retval); + __func__, retval); else - usb_serial_debug_data(debug, &serial->dev->dev, __FUNCTION__, + usb_serial_debug_data(debug, &serial->dev->dev, __func__, retval, transfer_buffer); kfree (transfer_buffer); @@ -762,7 +755,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *i int retval = 0; int (*startup) (struct usb_serial *serial, const struct usb_device_id *id); - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (serial->dev->actconfig->desc.bConfigurationValue != 1) { err("active config #%d != 1 ??", @@ -816,7 +809,7 @@ static int clie_3_5_startup (struct usb_serial *serial) int result; u8 data; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* * Note that PEG-300 series devices expect the following two calls. @@ -827,11 +820,11 @@ static int clie_3_5_startup (struct usb_serial *serial) USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 0, 0, &data, 1, 3000); if (result < 0) { - dev_err(dev, "%s: get config number failed: %d\n", __FUNCTION__, result); + dev_err(dev, "%s: get config number failed: %d\n", __func__, result); return result; } if (result != 1) { - dev_err(dev, "%s: get config number bad return length: %d\n", __FUNCTION__, result); + dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result); return -EIO; } @@ -841,11 +834,11 @@ static int clie_3_5_startup (struct usb_serial *serial) USB_DIR_IN | USB_RECIP_INTERFACE, 0, 0, &data, 1, 3000); if (result < 0) { - dev_err(dev, "%s: get interface number failed: %d\n", __FUNCTION__, result); + dev_err(dev, "%s: get interface number failed: %d\n", __func__, result); return result; } if (result != 1) { - dev_err(dev, "%s: get interface number bad return length: %d\n", __FUNCTION__, result); + dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result); return -EIO; } @@ -863,7 +856,7 @@ static int treo_attach (struct usb_serial *serial) (serial->num_interrupt_in == 0)) goto generic_startup; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* * It appears that Treos and Kyoceras want to use the @@ -894,7 +887,7 @@ generic_startup: static int clie_5_attach (struct usb_serial *serial) { - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* TH55 registers 2 ports. Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 @@ -918,7 +911,7 @@ static void visor_shutdown (struct usb_serial *serial) struct visor_private *priv; int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); for (i = 0; i < serial->num_ports; i++) { priv = usb_get_serial_port_data(serial->port[i]); @@ -931,7 +924,7 @@ static void visor_shutdown (struct usb_serial *serial) static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) { - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); return -ENOIOCTLCMD; } diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 38726ef3132..e96bf8663ff 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -164,9 +164,6 @@ static struct usb_serial_driver whiteheat_fake_device = { .description = "Connect Tech - WhiteHEAT - (prerenumeration)", .usb_driver = &whiteheat_driver, .id_table = id_table_prerenumeration, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .probe = whiteheat_firmware_download, .attach = whiteheat_firmware_attach, @@ -180,9 +177,6 @@ static struct usb_serial_driver whiteheat_device = { .description = "Connect Tech - WhiteHEAT", .usb_driver = &whiteheat_driver, .id_table = id_table_std, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = NUM_DONT_CARE, - .num_bulk_out = NUM_DONT_CARE, .num_ports = 4, .attach = whiteheat_attach, .shutdown = whiteheat_shutdown, @@ -225,7 +219,7 @@ struct whiteheat_urb_wrap { struct whiteheat_private { spinlock_t lock; __u8 flags; - __u8 mcr; + __u8 mcr; /* FIXME: no locking on mcr */ struct list_head rx_urbs_free; struct list_head rx_urbs_submitted; struct list_head rx_urb_q; @@ -288,7 +282,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct int response; const struct whiteheat_hex_record *record; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); response = ezusb_set_reset (serial, 1); @@ -298,7 +292,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct (unsigned char *)record->data, record->data_size, 0xa0); if (response < 0) { err("%s - ezusb_writememory failed for loader (%d %04X %p %d)", - __FUNCTION__, response, record->address, record->data, record->data_size); + __func__, response, record->address, record->data, record->data_size); break; } ++record; @@ -315,7 +309,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct (unsigned char *)record->data, record->data_size, 0xa3); if (response < 0) { err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", - __FUNCTION__, response, record->address, record->data, record->data_size); + __func__, response, record->address, record->data, record->data_size); break; } ++record; @@ -329,7 +323,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct (unsigned char *)record->data, record->data_size, 0xa0); if (response < 0) { err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", - __FUNCTION__, response, record->address, record->data, record->data_size); + __func__, response, record->address, record->data, record->data_size); break; } ++record; @@ -567,7 +561,7 @@ static void whiteheat_shutdown (struct usb_serial *serial) struct list_head *tmp2; int i; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); /* free up our private data for our command port */ command_port = serial->port[COMMAND_PORT]; @@ -604,7 +598,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) int retval = 0; struct ktermios old_term; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); retval = start_command_port(port->serial); if (retval) @@ -637,14 +631,14 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) /* Start reading from the device */ retval = start_port_read(port); if (retval) { - err("%s - failed submitting read urb, error %d", __FUNCTION__, retval); + err("%s - failed submitting read urb, error %d", __func__, retval); firm_close(port); stop_command_port(port->serial); goto exit; } exit: - dbg("%s - exit, retval = %d", __FUNCTION__, retval); + dbg("%s - exit, retval = %d", __func__, retval); return retval; } @@ -657,7 +651,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) struct list_head *tmp; struct list_head *tmp2; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); mutex_lock(&port->serial->disc_mutex); /* filp is NULL when called from usb_serial_disconnect */ @@ -732,10 +726,10 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu unsigned long flags; struct list_head *tmp; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (count == 0) { - dbg("%s - write request of 0 bytes", __FUNCTION__); + dbg("%s - write request of 0 bytes", __func__); return (0); } @@ -754,13 +748,13 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count; memcpy (urb->transfer_buffer, buf + sent, bytes); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, bytes, urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, bytes, urb->transfer_buffer); urb->dev = serial->dev; urb->transfer_buffer_length = bytes; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, result); + err("%s - failed submitting write urb, error %d", __func__, result); sent = result; spin_lock_irqsave(&info->lock, flags); list_add(tmp, &info->tx_urbs_free); @@ -786,7 +780,7 @@ static int whiteheat_write_room(struct usb_serial_port *port) int room = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&info->lock, flags); list_for_each(tmp, &info->tx_urbs_free) @@ -794,7 +788,7 @@ static int whiteheat_write_room(struct usb_serial_port *port) spin_unlock_irqrestore(&info->lock, flags); room *= port->bulk_out_size; - dbg("%s - returns %d", __FUNCTION__, room); + dbg("%s - returns %d", __func__, room); return (room); } @@ -804,7 +798,7 @@ static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file) struct whiteheat_private *info = usb_get_serial_port_data(port); unsigned int modem_signals = 0; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); firm_get_dtr_rts(port); if (info->mcr & UART_MCR_DTR) @@ -821,7 +815,7 @@ static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file, { struct whiteheat_private *info = usb_get_serial_port_data(port); - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (set & TIOCM_RTS) info->mcr |= UART_MCR_RTS; @@ -844,7 +838,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un struct serial_struct serstruct; void __user *user_arg = (void __user *)arg; - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); + dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); switch (cmd) { case TIOCGSERIAL: @@ -886,7 +880,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) { - dbg("%s -port %d", __FUNCTION__, port->number); + dbg("%s -port %d", __func__, port->number); firm_setup_port(port); } @@ -904,7 +898,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port) int chars = 0; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&info->lock, flags); list_for_each(tmp, &info->tx_urbs_submitted) { @@ -913,7 +907,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port) } spin_unlock_irqrestore(&info->lock, flags); - dbg ("%s - returns %d", __FUNCTION__, chars); + dbg ("%s - returns %d", __func__, chars); return chars; } @@ -923,7 +917,7 @@ static void whiteheat_throttle (struct usb_serial_port *port) struct whiteheat_private *info = usb_get_serial_port_data(port); unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&info->lock, flags); info->flags |= THROTTLED; @@ -939,7 +933,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port) int actually_throttled; unsigned long flags; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&info->lock, flags); actually_throttled = info->flags & ACTUALLY_THROTTLED; @@ -960,7 +954,7 @@ static void command_port_write_callback(struct urb *urb) { int status = urb->status; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); if (status) { dbg("nonzero urb status: %d", status); @@ -971,28 +965,28 @@ static void command_port_write_callback(struct urb *urb) static void command_port_read_callback(struct urb *urb) { - struct usb_serial_port *command_port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *command_port = urb->context; struct whiteheat_command_private *command_info; int status = urb->status; unsigned char *data = urb->transfer_buffer; int result; - dbg("%s", __FUNCTION__); + dbg("%s", __func__); command_info = usb_get_serial_port_data(command_port); if (!command_info) { - dbg ("%s - command_info is NULL, exiting.", __FUNCTION__); + dbg ("%s - command_info is NULL, exiting.", __func__); return; } if (status) { - dbg("%s - nonzero urb status: %d", __FUNCTION__, status); + dbg("%s - nonzero urb status: %d", __func__, status); if (status != -ENOENT) command_info->command_finished = WHITEHEAT_CMD_FAILURE; wake_up(&command_info->wait_command); return; } - usb_serial_debug_data(debug, &command_port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &command_port->dev, __func__, urb->actual_length, data); if (data[0] == WHITEHEAT_CMD_COMPLETE) { command_info->command_finished = WHITEHEAT_CMD_COMPLETE; @@ -1002,38 +996,38 @@ static void command_port_read_callback(struct urb *urb) wake_up(&command_info->wait_command); } else if (data[0] == WHITEHEAT_EVENT) { /* These are unsolicited reports from the firmware, hence no waiting command to wakeup */ - dbg("%s - event received", __FUNCTION__); + dbg("%s - event received", __func__); } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1); command_info->command_finished = WHITEHEAT_CMD_COMPLETE; wake_up(&command_info->wait_command); } else { - dbg("%s - bad reply from firmware", __FUNCTION__); + dbg("%s - bad reply from firmware", __func__); } /* Continue trying to always read */ command_port->read_urb->dev = command_port->serial->dev; result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); if (result) - dbg("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); + dbg("%s - failed resubmitting read urb, error %d", __func__, result); } static void whiteheat_read_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct whiteheat_urb_wrap *wrap; unsigned char *data = urb->transfer_buffer; struct whiteheat_private *info = usb_get_serial_port_data(port); int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock(&info->lock); wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); if (!wrap) { spin_unlock(&info->lock); - err("%s - Not my urb!", __FUNCTION__); + err("%s - Not my urb!", __func__); return; } list_del(&wrap->list); @@ -1041,14 +1035,14 @@ static void whiteheat_read_callback(struct urb *urb) if (status) { dbg("%s - nonzero read bulk status received: %d", - __FUNCTION__, status); + __func__, status); spin_lock(&info->lock); list_add(&wrap->list, &info->rx_urbs_free); spin_unlock(&info->lock); return; } - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); spin_lock(&info->lock); list_add_tail(&wrap->list, &info->rx_urb_q); @@ -1065,18 +1059,18 @@ static void whiteheat_read_callback(struct urb *urb) static void whiteheat_write_callback(struct urb *urb) { - struct usb_serial_port *port = (struct usb_serial_port *)urb->context; + struct usb_serial_port *port = urb->context; struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; int status = urb->status; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); spin_lock(&info->lock); wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); if (!wrap) { spin_unlock(&info->lock); - err("%s - Not my urb!", __FUNCTION__); + err("%s - Not my urb!", __func__); return; } list_move(&wrap->list, &info->tx_urbs_free); @@ -1084,7 +1078,7 @@ static void whiteheat_write_callback(struct urb *urb) if (status) { dbg("%s - nonzero write bulk status received: %d", - __FUNCTION__, status); + __func__, status); return; } @@ -1104,7 +1098,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d int retval = 0; int t; - dbg("%s - command %d", __FUNCTION__, command); + dbg("%s - command %d", __func__, command); command_port = port->serial->port[COMMAND_PORT]; command_info = usb_get_serial_port_data(command_port); @@ -1118,7 +1112,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d command_port->write_urb->dev = port->serial->dev; retval = usb_submit_urb (command_port->write_urb, GFP_NOIO); if (retval) { - dbg("%s - submit urb failed", __FUNCTION__); + dbg("%s - submit urb failed", __func__); goto exit; } @@ -1129,19 +1123,19 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d usb_kill_urb(command_port->write_urb); if (command_info->command_finished == false) { - dbg("%s - command timed out.", __FUNCTION__); + dbg("%s - command timed out.", __func__); retval = -ETIMEDOUT; goto exit; } if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { - dbg("%s - command failed.", __FUNCTION__); + dbg("%s - command failed.", __func__); retval = -EIO; goto exit; } if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { - dbg("%s - command completed.", __FUNCTION__); + dbg("%s - command completed.", __func__); switch (command) { case WHITEHEAT_GET_DTR_RTS: info = usb_get_serial_port_data(port); @@ -1186,7 +1180,7 @@ static int firm_setup_port(struct usb_serial_port *port) { default: case CS8: port_settings.bits = 8; break; } - dbg("%s - data bits = %d", __FUNCTION__, port_settings.bits); + dbg("%s - data bits = %d", __func__, port_settings.bits); /* determine the parity */ if (cflag & PARENB) @@ -1202,21 +1196,21 @@ static int firm_setup_port(struct usb_serial_port *port) { port_settings.parity = WHITEHEAT_PAR_EVEN; else port_settings.parity = WHITEHEAT_PAR_NONE; - dbg("%s - parity = %c", __FUNCTION__, port_settings.parity); + dbg("%s - parity = %c", __func__, port_settings.parity); /* figure out the stop bits requested */ if (cflag & CSTOPB) port_settings.stop = 2; else port_settings.stop = 1; - dbg("%s - stop bits = %d", __FUNCTION__, port_settings.stop); + dbg("%s - stop bits = %d", __func__, port_settings.stop); /* figure out the flow control settings */ if (cflag & CRTSCTS) port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS); else port_settings.hflow = WHITEHEAT_HFLOW_NONE; - dbg("%s - hardware flow control = %s %s %s %s", __FUNCTION__, + dbg("%s - hardware flow control = %s %s %s %s", __func__, (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "", (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", @@ -1227,15 +1221,15 @@ static int firm_setup_port(struct usb_serial_port *port) { port_settings.sflow = WHITEHEAT_SFLOW_RXTX; else port_settings.sflow = WHITEHEAT_SFLOW_NONE; - dbg("%s - software flow control = %c", __FUNCTION__, port_settings.sflow); + dbg("%s - software flow control = %c", __func__, port_settings.sflow); port_settings.xon = START_CHAR(port->tty); port_settings.xoff = STOP_CHAR(port->tty); - dbg("%s - XON = %2x, XOFF = %2x", __FUNCTION__, port_settings.xon, port_settings.xoff); + dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff); /* get the baud rate wanted */ port_settings.baud = tty_get_baud_rate(port->tty); - dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); + dbg("%s - baud rate = %d", __func__, port_settings.baud); /* fixme: should set validated settings */ tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); @@ -1318,7 +1312,7 @@ static int start_command_port(struct usb_serial *serial) command_port->read_urb->dev = serial->dev; retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); if (retval) { - err("%s - failed submitting read urb, error %d", __FUNCTION__, retval); + err("%s - failed submitting read urb, error %d", __func__, retval); goto exit; } } @@ -1454,7 +1448,7 @@ static void rx_data_softint(struct work_struct *work) urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); + err("%s - failed resubmitting read urb, error %d", __func__, result); spin_lock_irqsave(&info->lock, flags); list_add(tmp, &info->rx_urbs_free); continue; diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index 7e53333be01..0f6d234d699 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig @@ -32,8 +32,8 @@ config USB_STORAGE_DEBUG verbose debugging messages. config USB_STORAGE_DATAFAB - bool "Datafab Compact Flash Reader support (EXPERIMENTAL)" - depends on USB_STORAGE && EXPERIMENTAL + bool "Datafab Compact Flash Reader support" + depends on USB_STORAGE help Support for certain Datafab CompactFlash readers. Datafab has a web page at <http://www.datafabusa.com/>. @@ -69,8 +69,8 @@ config USB_STORAGE_DPCM There is a web page at <http://www.ziocorp.com/products/>. config USB_STORAGE_USBAT - bool "USBAT/USBAT02-based storage support (EXPERIMENTAL)" - depends on USB_STORAGE && EXPERIMENTAL + bool "USBAT/USBAT02-based storage support" + depends on USB_STORAGE help Say Y here to include additional code to support storage devices based on the SCM/Shuttle USBAT/USBAT02 processors. @@ -90,30 +90,30 @@ config USB_STORAGE_USBAT - Sandisk ImageMate SDDR-05b config USB_STORAGE_SDDR09 - bool "SanDisk SDDR-09 (and other SmartMedia) support (EXPERIMENTAL)" - depends on USB_STORAGE && EXPERIMENTAL + bool "SanDisk SDDR-09 (and other SmartMedia) support" + depends on USB_STORAGE help Say Y here to include additional code to support the Sandisk SDDR-09 SmartMedia reader in the USB Mass Storage driver. Also works for the Microtech Zio! SmartMedia reader. config USB_STORAGE_SDDR55 - bool "SanDisk SDDR-55 SmartMedia support (EXPERIMENTAL)" - depends on USB_STORAGE && EXPERIMENTAL + bool "SanDisk SDDR-55 SmartMedia support" + depends on USB_STORAGE help Say Y here to include additional code to support the Sandisk SDDR-55 SmartMedia reader in the USB Mass Storage driver. config USB_STORAGE_JUMPSHOT - bool "Lexar Jumpshot Compact Flash Reader (EXPERIMENTAL)" - depends on USB_STORAGE && EXPERIMENTAL + bool "Lexar Jumpshot Compact Flash Reader" + depends on USB_STORAGE help Say Y here to include additional code to support the Lexar Jumpshot USB CompactFlash reader. config USB_STORAGE_ALAUDA - bool "Olympus MAUSB-10/Fuji DPC-R1 support (EXPERIMENTAL)" - depends on USB_STORAGE && EXPERIMENTAL + bool "Olympus MAUSB-10/Fuji DPC-R1 support" + depends on USB_STORAGE help Say Y here to include additional code to support the Olympus MAUSB-10 and Fujifilm DPC-R1 USB Card reader/writer devices. @@ -122,8 +122,8 @@ config USB_STORAGE_ALAUDA XD and SmartMedia cards. config USB_STORAGE_ONETOUCH - bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" - depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL && !PM + bool "Support OneTouch Button on Maxtor Hard Drives" + depends on USB_STORAGE && INPUT_EVDEV help Say Y here to include additional code to support the Maxtor OneTouch USB hard drive's onetouch button. @@ -145,6 +145,17 @@ config USB_STORAGE_KARMA on the resulting scsi device node returns the Karma to normal operation. +config USB_STORAGE_CYPRESS_ATACB + bool "SAT emulation on Cypress USB/ATA Bridge with ATACB" + depends on USB_STORAGE + ---help--- + Say Y here if you want to use SAT (ata pass through) on devices based + on the Cypress USB/ATA bridge supporting ATACB. This will allow you + to use tools to tune and monitor your drive (like hdparm or smartctl). + + If you say no here your device will still work with the standard usb + mass storage class. + config USB_LIBUSUAL bool "The shared table of common (or usual) storage devices" depends on USB diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index 023969b4385..4c596c766c5 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -21,6 +21,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o +usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ initializers.o $(usb-storage-obj-y) diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c new file mode 100644 index 00000000000..d88824b3511 --- /dev/null +++ b/drivers/usb/storage/cypress_atacb.c @@ -0,0 +1,200 @@ +/* + * Support for emulating SAT (ata pass through) on devices based + * on the Cypress USB/ATA bridge supporting ATACB. + * + * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <scsi/scsi.h> +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_eh.h> +#include <linux/ata.h> + +#include "usb.h" +#include "protocol.h" +#include "scsiglue.h" +#include "debug.h" + +/* + * ATACB is a protocol used on cypress usb<->ata bridge to + * send raw ATA command over mass storage + * There is a ATACB2 protocol that support LBA48 on newer chip. + * More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf + * datasheet from cypress.com. + */ +void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) +{ + unsigned char save_cmnd[MAX_COMMAND_SIZE]; + + if (likely(srb->cmnd[0] != ATA_16 && srb->cmnd[0] != ATA_12)) { + usb_stor_transparent_scsi_command(srb, us); + return; + } + + memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd)); + memset(srb->cmnd, 0, sizeof(srb->cmnd)); + + /* check if we support the command */ + if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */ + goto invalid_fld; + /* check protocol */ + switch((save_cmnd[1] >> 1) & 0xf) { + case 3: /*no DATA */ + case 4: /* PIO in */ + case 5: /* PIO out */ + break; + default: + goto invalid_fld; + } + + /* first build the ATACB command */ + srb->cmd_len = 16; + + srb->cmnd[0] = 0x24; /* bVSCBSignature : vendor-specific command + this value can change, but most(all ?) manufacturers + keep the cypress default : 0x24 */ + srb->cmnd[1] = 0x24; /* bVSCBSubCommand : 0x24 for ATACB */ + + srb->cmnd[3] = 0xff - 1; /* features, sector count, lba low, lba med + lba high, device, command are valid */ + srb->cmnd[4] = 1; /* TransferBlockCount : 512 */ + + if (save_cmnd[0] == ATA_16) { + srb->cmnd[ 6] = save_cmnd[ 4]; /* features */ + srb->cmnd[ 7] = save_cmnd[ 6]; /* sector count */ + srb->cmnd[ 8] = save_cmnd[ 8]; /* lba low */ + srb->cmnd[ 9] = save_cmnd[10]; /* lba med */ + srb->cmnd[10] = save_cmnd[12]; /* lba high */ + srb->cmnd[11] = save_cmnd[13]; /* device */ + srb->cmnd[12] = save_cmnd[14]; /* command */ + + if (save_cmnd[1] & 0x01) {/* extended bit set for LBA48 */ + /* this could be supported by atacb2 */ + if (save_cmnd[3] || save_cmnd[5] || save_cmnd[7] || save_cmnd[9] + || save_cmnd[11]) + goto invalid_fld; + } + } + else { /* ATA12 */ + srb->cmnd[ 6] = save_cmnd[3]; /* features */ + srb->cmnd[ 7] = save_cmnd[4]; /* sector count */ + srb->cmnd[ 8] = save_cmnd[5]; /* lba low */ + srb->cmnd[ 9] = save_cmnd[6]; /* lba med */ + srb->cmnd[10] = save_cmnd[7]; /* lba high */ + srb->cmnd[11] = save_cmnd[8]; /* device */ + srb->cmnd[12] = save_cmnd[9]; /* command */ + + } + /* Filter SET_FEATURES - XFER MODE command */ + if ((srb->cmnd[12] == ATA_CMD_SET_FEATURES) + && (srb->cmnd[6] == SETFEATURES_XFER)) + goto invalid_fld; + + if (srb->cmnd[12] == ATA_CMD_ID_ATA || srb->cmnd[12] == ATA_CMD_ID_ATAPI) + srb->cmnd[2] |= (1<<7); /* set IdentifyPacketDevice for these cmds */ + + + usb_stor_transparent_scsi_command(srb, us); + + /* if the device doesn't support ATACB + */ + if (srb->result == SAM_STAT_CHECK_CONDITION && + memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB, + sizeof(usb_stor_sense_invalidCDB)) == 0) { + US_DEBUGP("cypress atacb not supported ???\n"); + goto end; + } + + /* if ck_cond flags is set, and there wasn't critical error, + * build the special sense + */ + if ((srb->result != (DID_ERROR << 16) && + srb->result != (DID_ABORT << 16)) && + save_cmnd[2] & 0x20) { + struct scsi_eh_save ses; + unsigned char regs[8]; + unsigned char *sb = srb->sense_buffer; + unsigned char *desc = sb + 8; + int tmp_result; + + /* build the command for + * reading the ATA registers */ + scsi_eh_prep_cmnd(srb, &ses, NULL, 0, 0); + srb->sdb.length = sizeof(regs); + sg_init_one(&ses.sense_sgl, regs, srb->sdb.length); + srb->sdb.table.sgl = &ses.sense_sgl; + srb->sc_data_direction = DMA_FROM_DEVICE; + srb->sdb.table.nents = 1; + /* we use the same command as before, but we set + * the read taskfile bit, for not executing atacb command, + * but reading register selected in srb->cmnd[4] + */ + srb->cmnd[2] = 1; + + usb_stor_transparent_scsi_command(srb, us); + tmp_result = srb->result; + scsi_eh_restore_cmnd(srb, &ses); + /* we fail to get registers, report invalid command */ + if (tmp_result != SAM_STAT_GOOD) + goto invalid_fld; + + /* build the sense */ + memset(sb, 0, SCSI_SENSE_BUFFERSIZE); + + /* set sk, asc for a good command */ + sb[1] = RECOVERED_ERROR; + sb[2] = 0; /* ATA PASS THROUGH INFORMATION AVAILABLE */ + sb[3] = 0x1D; + + /* XXX we should generate sk, asc, ascq from status and error + * regs + * (see 11.1 Error translation ATA device error to SCSI error map) + * and ata_to_sense_error from libata. + */ + + /* Sense data is current and format is descriptor. */ + sb[0] = 0x72; + desc[0] = 0x09; /* ATA_RETURN_DESCRIPTOR */ + + /* set length of additional sense data */ + sb[7] = 14; + desc[1] = 12; + + /* Copy registers into sense buffer. */ + desc[ 2] = 0x00; + desc[ 3] = regs[1]; /* features */ + desc[ 5] = regs[2]; /* sector count */ + desc[ 7] = regs[3]; /* lba low */ + desc[ 9] = regs[4]; /* lba med */ + desc[11] = regs[5]; /* lba high */ + desc[12] = regs[6]; /* device */ + desc[13] = regs[7]; /* command */ + + srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + } + goto end; +invalid_fld: + srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + + memcpy(srb->sense_buffer, + usb_stor_sense_invalidCDB, + sizeof(usb_stor_sense_invalidCDB)); +end: + memcpy(srb->cmnd, save_cmnd, sizeof(save_cmnd)); + if (srb->cmnd[0] == ATA_12) + srb->cmd_len = 12; +} diff --git a/drivers/usb/storage/cypress_atacb.h b/drivers/usb/storage/cypress_atacb.h new file mode 100644 index 00000000000..fbada898d56 --- /dev/null +++ b/drivers/usb/storage/cypress_atacb.h @@ -0,0 +1,25 @@ +/* + * Support for emulating SAT (ata pass through) on devices based + * on the Cypress USB/ATA bridge supporting ATACB. + * + * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _CYPRESS_ATACB_H_ +#define _CYPRESS_ATACB_H_ +extern void cypress_atacb_passthrough(struct scsi_cmnd*, struct us_data*); +#endif diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index 55b952084f0..a28d49122e7 100644 --- a/drivers/usb/storage/libusual.c +++ b/drivers/usb/storage/libusual.c @@ -9,6 +9,7 @@ #include <linux/usb_usual.h> #include <linux/vmalloc.h> #include <linux/kthread.h> +#include <linux/mutex.h> /* */ @@ -30,7 +31,7 @@ static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS); #define BIAS_NAME_SIZE (sizeof("usb-storage")) static const char *bias_names[3] = { "none", "usb-storage", "ub" }; -static struct semaphore usu_init_notify; +static DEFINE_MUTEX(usu_probe_mutex); static DECLARE_COMPLETION(usu_end_notify); static atomic_t total_threads = ATOMIC_INIT(0); @@ -178,10 +179,7 @@ static int usu_probe_thread(void *arg) int rc; unsigned long flags; - /* A completion does not work here because it's counted. */ - down(&usu_init_notify); - up(&usu_init_notify); - + mutex_lock(&usu_probe_mutex); rc = request_module(bias_names[type]); spin_lock_irqsave(&usu_lock, flags); if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { @@ -194,6 +192,7 @@ static int usu_probe_thread(void *arg) } st->fls &= ~USU_MOD_FL_THREAD; spin_unlock_irqrestore(&usu_lock, flags); + mutex_unlock(&usu_probe_mutex); complete_and_exit(&usu_end_notify, 0); } @@ -204,10 +203,9 @@ static int __init usb_usual_init(void) { int rc; - sema_init(&usu_init_notify, 0); - + mutex_lock(&usu_probe_mutex); rc = usb_register(&usu_driver); - up(&usu_init_notify); + mutex_unlock(&usu_probe_mutex); return rc; } diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 8c1e2954f3b..3fcde9f0fa5 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -73,6 +73,7 @@ static const char* host_info(struct Scsi_Host *host) static int slave_alloc (struct scsi_device *sdev) { struct us_data *us = host_to_us(sdev->host); + struct usb_host_endpoint *bulk_in_ep; /* * Set the INQUIRY transfer length to 36. We don't use any of @@ -84,12 +85,13 @@ static int slave_alloc (struct scsi_device *sdev) /* Scatter-gather buffers (all but the last) must have a length * divisible by the bulk maxpacket size. Otherwise a data packet * would end up being short, causing a premature end to the data - * transfer. Since high-speed bulk pipes have a maxpacket size - * of 512, we'll use that as the scsi device queue's DMA alignment - * mask. Guaranteeing proper alignment of the first buffer will - * have the desired effect because, except at the beginning and - * the end, scatter-gather buffers follow page boundaries. */ - blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); + * transfer. We'll use the maxpacket value of the bulk-IN pipe + * to set the SCSI device queue's DMA alignment mask. + */ + bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)]; + blk_queue_update_dma_alignment(sdev->request_queue, + le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1); + /* wMaxPacketSize must be a power of 2 */ /* * The UFI spec treates the Peripheral Qualifier bits in an @@ -132,7 +134,7 @@ static int slave_configure(struct scsi_device *sdev) /* Disk-type devices use MODE SENSE(6) if the protocol * (SubClass) is Transparent SCSI, otherwise they use * MODE SENSE(10). */ - if (us->subclass != US_SC_SCSI) + if (us->subclass != US_SC_SCSI && us->subclass != US_SC_CYP_ATACB) sdev->use_10_for_ms = 1; /* Many disks only accept MODE SENSE transfer lengths of @@ -226,12 +228,12 @@ static int queuecommand(struct scsi_cmnd *srb, { struct us_data *us = host_to_us(srb->device->host); - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); /* check for state-transition errors */ if (us->srb != NULL) { printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n", - __FUNCTION__, us->srb); + __func__, us->srb); return SCSI_MLQUEUE_HOST_BUSY; } @@ -260,7 +262,7 @@ static int command_abort(struct scsi_cmnd *srb) { struct us_data *us = host_to_us(srb->device->host); - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING * bits are protected by the host lock. */ @@ -297,7 +299,7 @@ static int device_reset(struct scsi_cmnd *srb) struct us_data *us = host_to_us(srb->device->host); int result; - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); /* lock the device pointers and do the reset */ mutex_lock(&(us->dev_mutex)); @@ -313,7 +315,7 @@ static int bus_reset(struct scsi_cmnd *srb) struct us_data *us = host_to_us(srb->device->host); int result; - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); result = usb_stor_port_reset(us); return result < 0 ? FAILED : SUCCESS; } diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index bdd4334bed5..6610d2dd1e7 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -110,7 +110,7 @@ */ static void usb_stor_blocking_completion(struct urb *urb) { - struct completion *urb_done_ptr = (struct completion *)urb->context; + struct completion *urb_done_ptr = urb->context; complete(urb_done_ptr); } @@ -198,7 +198,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe, int status; US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", - __FUNCTION__, request, requesttype, + __func__, request, requesttype, value, index, size); /* fill in the devrequest structure */ @@ -250,7 +250,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe) usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0); - US_DEBUGP("%s: result = %d\n", __FUNCTION__, result); + US_DEBUGP("%s: result = %d\n", __func__, result); return result; } @@ -332,7 +332,7 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe, int result; US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", - __FUNCTION__, request, requesttype, + __func__, request, requesttype, value, index, size); /* fill in the devrequest structure */ @@ -366,7 +366,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf, unsigned int pipe = us->recv_intr_pipe; unsigned int maxp; - US_DEBUGP("%s: xfer %u bytes\n", __FUNCTION__, length); + US_DEBUGP("%s: xfer %u bytes\n", __func__, length); /* calculate the max packet size */ maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); @@ -393,7 +393,7 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe, { int result; - US_DEBUGP("%s: xfer %u bytes\n", __FUNCTION__, length); + US_DEBUGP("%s: xfer %u bytes\n", __func__, length); /* fill and submit the URB */ usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, @@ -424,7 +424,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, return USB_STOR_XFER_ERROR; /* initialize the scatter-gather request block */ - US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, + US_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__, length, num_sg); result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, sg, num_sg, length, GFP_NOIO); @@ -603,7 +603,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE); /* FIXME: we must do the protocol translation here */ - if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI) + if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI || + us->subclass == US_SC_CYP_ATACB) srb->cmd_len = 6; else srb->cmd_len = 12; @@ -700,7 +701,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) /* Stop the current URB transfer */ void usb_stor_stop_transport(struct us_data *us) { - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); /* If the state machine is blocked waiting for an URB, * let's wake it up. The test_and_clear_bit() call @@ -1134,7 +1135,7 @@ static int usb_stor_reset_common(struct us_data *us, int usb_stor_CB_reset(struct us_data *us) { - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE); us->iobuf[0] = SEND_DIAGNOSTIC; @@ -1149,7 +1150,7 @@ int usb_stor_CB_reset(struct us_data *us) */ int usb_stor_Bulk_reset(struct us_data *us) { - US_DEBUGP("%s called\n", __FUNCTION__); + US_DEBUGP("%s called\n", __func__); return usb_stor_reset_common(us, US_BULK_RESET_REQUEST, USB_TYPE_CLASS | USB_RECIP_INTERFACE, diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 91252075e6e..732bf52a775 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -1719,6 +1719,14 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_CAPACITY_HEURISTICS), +#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB +UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, + "Cypress", + "Cypress AT2LP", + US_SC_CYP_ATACB, US_PR_BULK, NULL, + 0), +#endif + /* Control/Bulk transport for all SubClass values */ USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index ac6114eea0c..a856effad3b 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -101,6 +101,9 @@ #ifdef CONFIG_USB_STORAGE_KARMA #include "karma.h" #endif +#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB +#include "cypress_atacb.h" +#endif /* Some informational data */ MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); @@ -187,7 +190,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message) /* Wait until no command is running */ mutex_lock(&us->dev_mutex); - US_DEBUGP("%s\n", __FUNCTION__); + US_DEBUGP("%s\n", __func__); if (us->suspend_resume_hook) (us->suspend_resume_hook)(us, US_SUSPEND); @@ -204,7 +207,7 @@ static int storage_resume(struct usb_interface *iface) mutex_lock(&us->dev_mutex); - US_DEBUGP("%s\n", __FUNCTION__); + US_DEBUGP("%s\n", __func__); if (us->suspend_resume_hook) (us->suspend_resume_hook)(us, US_RESUME); @@ -216,7 +219,7 @@ static int storage_reset_resume(struct usb_interface *iface) { struct us_data *us = usb_get_intfdata(iface); - US_DEBUGP("%s\n", __FUNCTION__); + US_DEBUGP("%s\n", __func__); /* Report the reset to the SCSI core */ usb_stor_report_bus_reset(us); @@ -237,7 +240,7 @@ static int storage_pre_reset(struct usb_interface *iface) { struct us_data *us = usb_get_intfdata(iface); - US_DEBUGP("%s\n", __FUNCTION__); + US_DEBUGP("%s\n", __func__); /* Make sure no command runs during the reset */ mutex_lock(&us->dev_mutex); @@ -248,7 +251,7 @@ static int storage_post_reset(struct usb_interface *iface) { struct us_data *us = usb_get_intfdata(iface); - US_DEBUGP("%s\n", __FUNCTION__); + US_DEBUGP("%s\n", __func__); /* Report the reset to the SCSI core */ usb_stor_report_bus_reset(us); @@ -434,7 +437,7 @@ SkipForAbort: /* Associate our private data with the USB device */ static int associate_dev(struct us_data *us, struct usb_interface *intf) { - US_DEBUGP("-- %s\n", __FUNCTION__); + US_DEBUGP("-- %s\n", __func__); /* Fill in the device-related fields */ us->pusb_dev = interface_to_usbdev(intf); @@ -708,6 +711,13 @@ static int get_protocol(struct us_data *us) break; #endif +#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB + case US_SC_CYP_ATACB: + us->protocol_name = "Transparent SCSI with Cypress ATACB"; + us->proto_handler = cypress_atacb_passthrough; + break; +#endif + default: return -EIO; } @@ -806,7 +816,7 @@ static int usb_stor_acquire_resources(struct us_data *us) /* Release all our dynamic resources */ static void usb_stor_release_resources(struct us_data *us) { - US_DEBUGP("-- %s\n", __FUNCTION__); + US_DEBUGP("-- %s\n", __func__); /* Tell the control thread to exit. The SCSI host must * already have been removed so it won't try to queue @@ -832,7 +842,7 @@ static void usb_stor_release_resources(struct us_data *us) /* Dissociate from the USB device */ static void dissociate_dev(struct us_data *us) { - US_DEBUGP("-- %s\n", __FUNCTION__); + US_DEBUGP("-- %s\n", __func__); kfree(us->sensebuf); diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index c815a40e167..be76084c8d7 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -88,7 +88,7 @@ static int skel_open(struct inode *inode, struct file *file) interface = usb_find_interface(&skel_driver, subminor); if (!interface) { err ("%s - error, can't find device for minor %d", - __FUNCTION__, subminor); + __func__, subminor); retval = -ENODEV; goto exit; } @@ -212,7 +212,7 @@ static void skel_write_bulk_callback(struct urb *urb) { struct usb_skel *dev; - dev = (struct usb_skel *)urb->context; + dev = urb->context; /* sync/async unlink faults aren't errors */ if (urb->status) { @@ -220,7 +220,7 @@ static void skel_write_bulk_callback(struct urb *urb) urb->status == -ECONNRESET || urb->status == -ESHUTDOWN)) err("%s - nonzero write bulk status received: %d", - __FUNCTION__, urb->status); + __func__, urb->status); spin_lock(&dev->err_lock); dev->errors = urb->status; @@ -301,7 +301,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou retval = usb_submit_urb(urb, GFP_KERNEL); mutex_unlock(&dev->io_mutex); if (retval) { - err("%s - failed submitting write urb, error %d", __FUNCTION__, retval); + err("%s - failed submitting write urb, error %d", __func__, retval); goto error_unanchor; } |