diff options
Diffstat (limited to 'drivers/usb/core')
| -rw-r--r-- | drivers/usb/core/devio.c | 19 | ||||
| -rw-r--r-- | drivers/usb/core/driver.c | 1 | ||||
| -rw-r--r-- | drivers/usb/core/endpoint.c | 2 | ||||
| -rw-r--r-- | drivers/usb/core/hcd.c | 26 | ||||
| -rw-r--r-- | drivers/usb/core/hub.c | 72 | ||||
| -rw-r--r-- | drivers/usb/core/otg_whitelist.h | 2 | ||||
| -rw-r--r-- | drivers/usb/core/sysfs.c | 31 | ||||
| -rw-r--r-- | drivers/usb/core/usb.h | 1 | 
8 files changed, 103 insertions, 51 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 986abde07683..38ae877c46e3 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -103,7 +103,7 @@ MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic");  #define snoop(dev, format, arg...)				\  	do {							\  		if (usbfs_snoop)				\ -			dev_info(dev , format , ## arg);	\ +			dev_info(dev, format, ## arg);		\  	} while (0)  enum snoop_when { @@ -1082,7 +1082,8 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg)  	ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb));  	if (ret)  		return ret; -	if (!(tbuf = kmalloc(len1, GFP_KERNEL))) { +	tbuf = kmalloc(len1, GFP_KERNEL); +	if (!tbuf) {  		ret = -ENOMEM;  		goto done;  	} @@ -1224,7 +1225,8 @@ static int proc_setintf(struct usb_dev_state *ps, void __user *arg)  	if (copy_from_user(&setintf, arg, sizeof(setintf)))  		return -EFAULT; -	if ((ret = checkintf(ps, setintf.interface))) +	ret = checkintf(ps, setintf.interface); +	if (ret)  		return ret;  	destroy_async_on_interface(ps, setintf.interface); @@ -1319,7 +1321,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb  	is_in = (uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0;  	u = 0; -	switch(uurb->type) { +	switch (uurb->type) {  	case USBDEVFS_URB_TYPE_CONTROL:  		if (!usb_endpoint_xfer_control(&ep->desc))  			return -EINVAL; @@ -1393,7 +1395,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb  		number_of_packets = uurb->number_of_packets;  		isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *  				   number_of_packets; -		if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) +		isopkt = kmalloc(isofrmlen, GFP_KERNEL); +		if (!isopkt)  			return -ENOMEM;  		if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {  			ret = -EFAULT; @@ -1904,7 +1907,8 @@ static int proc_releaseinterface(struct usb_dev_state *ps, void __user *arg)  	if (get_user(ifnum, (unsigned int __user *)arg))  		return -EFAULT; -	if ((ret = releaseintf(ps, ifnum)) < 0) +	ret = releaseintf(ps, ifnum); +	if (ret < 0)  		return ret;  	destroy_async_on_interface (ps, ifnum);  	return 0; @@ -1919,7 +1923,8 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl)  	struct usb_driver       *driver = NULL;  	/* alloc buffer */ -	if ((size = _IOC_SIZE(ctl->ioctl_code)) > 0) { +	size = _IOC_SIZE(ctl->ioctl_code); +	if (size > 0) {  		buf = kmalloc(size, GFP_KERNEL);  		if (buf == NULL)  			return -ENOMEM; diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 818369afff63..6b5063e7943f 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -160,6 +160,7 @@ static ssize_t remove_id_store(struct device_driver *driver, const char *buf,  	spin_lock(&usb_driver->dynids.lock);  	list_for_each_entry_safe(dynid, n, &usb_driver->dynids.list, node) {  		struct usb_device_id *id = &dynid->id; +  		if ((id->idVendor == idVendor) &&  		    (id->idProduct == idProduct)) {  			list_del(&dynid->node); diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 39a24021fe4d..101983b7e8d2 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c @@ -51,7 +51,7 @@ static ssize_t wMaxPacketSize_show(struct device *dev,  {  	struct ep_device *ep = to_ep_device(dev);  	return sprintf(buf, "%04x\n", -		        usb_endpoint_maxp(ep->desc) & 0x07ff); +			usb_endpoint_maxp(ep->desc) & 0x07ff);  }  static DEVICE_ATTR_RO(wMaxPacketSize); diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index be5b2074f906..4d64e5c499e1 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1022,9 +1022,12 @@ static int register_root_hub(struct usb_hcd *hcd)  				dev_name(&usb_dev->dev), retval);  		return (retval < 0) ? retval : -EMSGSIZE;  	} -	if (usb_dev->speed == USB_SPEED_SUPER) { + +	if (le16_to_cpu(usb_dev->descriptor.bcdUSB) >= 0x0201) {  		retval = usb_get_bos_descriptor(usb_dev); -		if (retval < 0) { +		if (!retval) { +			usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev); +		} else if (usb_dev->speed == USB_SPEED_SUPER) {  			mutex_unlock(&usb_bus_list_lock);  			dev_dbg(parent_dev, "can't read %s bos descriptor %d\n",  					dev_name(&usb_dev->dev), retval); @@ -2683,12 +2686,14 @@ int usb_add_hcd(struct usb_hcd *hcd,  	 * bottom up so that hcds can customize the root hubs before hub_wq  	 * starts talking to them.  (Note, bus id is assigned early too.)  	 */ -	if ((retval = hcd_buffer_create(hcd)) != 0) { +	retval = hcd_buffer_create(hcd); +	if (retval != 0) {  		dev_dbg(hcd->self.controller, "pool alloc failed\n");  		goto err_create_buf;  	} -	if ((retval = usb_register_bus(&hcd->self)) < 0) +	retval = usb_register_bus(&hcd->self); +	if (retval < 0)  		goto err_register_bus;  	rhdev = usb_alloc_dev(NULL, &hcd->self, 0); @@ -2734,9 +2739,13 @@ int usb_add_hcd(struct usb_hcd *hcd,  	/* "reset" is misnamed; its role is now one-time init. the controller  	 * should already have been reset (and boot firmware kicked off etc).  	 */ -	if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { -		dev_err(hcd->self.controller, "can't setup: %d\n", retval); -		goto err_hcd_driver_setup; +	if (hcd->driver->reset) { +		retval = hcd->driver->reset(hcd); +		if (retval < 0) { +			dev_err(hcd->self.controller, "can't setup: %d\n", +					retval); +			goto err_hcd_driver_setup; +		}  	}  	hcd->rh_pollable = 1; @@ -2766,7 +2775,8 @@ int usb_add_hcd(struct usb_hcd *hcd,  	}  	/* starting here, usbcore will pay attention to this root hub */ -	if ((retval = register_root_hub(hcd)) != 0) +	retval = register_root_hub(hcd); +	if (retval != 0)  		goto err_register_root_hub;  	retval = sysfs_create_group(&rhdev->dev.kobj, &usb_bus_attr_group); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 43cb2f2e3b43..431839bd291f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -50,8 +50,8 @@ DEFINE_MUTEX(usb_port_peer_mutex);  /* cycle leds on hubs that aren't blinking for attention */  static bool blinkenlights = 0; -module_param (blinkenlights, bool, S_IRUGO); -MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); +module_param(blinkenlights, bool, S_IRUGO); +MODULE_PARM_DESC(blinkenlights, "true to cycle leds on hubs");  /*   * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about @@ -122,7 +122,7 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)  	return usb_get_intfdata(hdev->actconfig->interface[0]);  } -static int usb_device_supports_lpm(struct usb_device *udev) +int usb_device_supports_lpm(struct usb_device *udev)  {  	/* USB 2.1 (and greater) devices indicate LPM support through  	 * their USB 2.0 Extended Capabilities BOS descriptor. @@ -439,7 +439,7 @@ static void set_port_led(struct usb_hub *hub, int port1, int selector)  #define	LED_CYCLE_PERIOD	((2*HZ)/3) -static void led_work (struct work_struct *work) +static void led_work(struct work_struct *work)  {  	struct usb_hub		*hub =  		container_of(work, struct usb_hub, leds.work); @@ -646,7 +646,7 @@ static void hub_irq(struct urb *urb)  	default:		/* presumably an error */  		/* Cause a hub reset after 10 consecutive errors */ -		dev_dbg (hub->intfdev, "transfer --> %d\n", status); +		dev_dbg(hub->intfdev, "transfer --> %d\n", status);  		if ((++hub->nerrors < 10) || hub->error)  			goto resubmit;  		hub->error = status; @@ -671,14 +671,14 @@ resubmit:  	if (hub->quiescing)  		return; -	if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0 -			&& status != -ENODEV && status != -EPERM) -		dev_err (hub->intfdev, "resubmit --> %d\n", status); +	status = usb_submit_urb(hub->urb, GFP_ATOMIC); +	if (status != 0 && status != -ENODEV && status != -EPERM) +		dev_err(hub->intfdev, "resubmit --> %d\n", status);  }  /* USB 2.0 spec Section 11.24.2.3 */  static inline int -hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt) +hub_clear_tt_buffer(struct usb_device *hdev, u16 devinfo, u16 tt)  {  	/* Need to clear both directions for control ep */  	if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) == @@ -706,7 +706,7 @@ static void hub_tt_work(struct work_struct *work)  		container_of(work, struct usb_hub, tt.clear_work);  	unsigned long		flags; -	spin_lock_irqsave (&hub->tt.lock, flags); +	spin_lock_irqsave(&hub->tt.lock, flags);  	while (!list_empty(&hub->tt.clear_list)) {  		struct list_head	*next;  		struct usb_tt_clear	*clear; @@ -715,14 +715,14 @@ static void hub_tt_work(struct work_struct *work)  		int			status;  		next = hub->tt.clear_list.next; -		clear = list_entry (next, struct usb_tt_clear, clear_list); -		list_del (&clear->clear_list); +		clear = list_entry(next, struct usb_tt_clear, clear_list); +		list_del(&clear->clear_list);  		/* drop lock so HCD can concurrently report other TT errors */ -		spin_unlock_irqrestore (&hub->tt.lock, flags); -		status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); +		spin_unlock_irqrestore(&hub->tt.lock, flags); +		status = hub_clear_tt_buffer(hdev, clear->devinfo, clear->tt);  		if (status && status != -ENODEV) -			dev_err (&hdev->dev, +			dev_err(&hdev->dev,  				"clear tt %d (%04x) error %d\n",  				clear->tt, clear->devinfo, status); @@ -734,7 +734,7 @@ static void hub_tt_work(struct work_struct *work)  		kfree(clear);  		spin_lock_irqsave(&hub->tt.lock, flags);  	} -	spin_unlock_irqrestore (&hub->tt.lock, flags); +	spin_unlock_irqrestore(&hub->tt.lock, flags);  }  /** @@ -797,7 +797,7 @@ int usb_hub_clear_tt_buffer(struct urb *urb)  	 */  	clear = kmalloc(sizeof *clear, GFP_ATOMIC);  	if (clear == NULL) { -		dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); +		dev_err(&udev->dev, "can't save CLEAR_TT_BUFFER state\n");  		/* FIXME recover somehow ... RESET_TT? */  		return -ENOMEM;  	} @@ -806,10 +806,10 @@ int usb_hub_clear_tt_buffer(struct urb *urb)  	clear->tt = tt->multi ? udev->ttport : 1;  	clear->devinfo = usb_pipeendpoint (pipe);  	clear->devinfo |= udev->devnum << 4; -	clear->devinfo |= usb_pipecontrol (pipe) +	clear->devinfo |= usb_pipecontrol(pipe)  			? (USB_ENDPOINT_XFER_CONTROL << 11)  			: (USB_ENDPOINT_XFER_BULK << 11); -	if (usb_pipein (pipe)) +	if (usb_pipein(pipe))  		clear->devinfo |= 1 << 15;  	/* info for completion callback */ @@ -817,10 +817,10 @@ int usb_hub_clear_tt_buffer(struct urb *urb)  	clear->ep = urb->ep;  	/* tell keventd to clear state for this TT */ -	spin_lock_irqsave (&tt->lock, flags); -	list_add_tail (&clear->clear_list, &tt->clear_list); +	spin_lock_irqsave(&tt->lock, flags); +	list_add_tail(&clear->clear_list, &tt->clear_list);  	schedule_work(&tt->clear_work); -	spin_unlock_irqrestore (&tt->lock, flags); +	spin_unlock_irqrestore(&tt->lock, flags);  	return 0;  }  EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffer); @@ -1442,8 +1442,8 @@ static int hub_configure(struct usb_hub *hub,  		break;  	} -	spin_lock_init (&hub->tt.lock); -	INIT_LIST_HEAD (&hub->tt.clear_list); +	spin_lock_init(&hub->tt.lock); +	INIT_LIST_HEAD(&hub->tt.clear_list);  	INIT_WORK(&hub->tt.clear_work, hub_tt_work);  	switch (hdev->descriptor.bDeviceProtocol) {  	case USB_HUB_PR_FS: @@ -1632,7 +1632,7 @@ static int hub_configure(struct usb_hub *hub,  	return 0;  fail: -	dev_err (hub_dev, "config failed, %s (err %d)\n", +	dev_err(hub_dev, "config failed, %s (err %d)\n",  			message, ret);  	/* hub_disconnect() frees urb and descriptor */  	return ret; @@ -1775,7 +1775,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)  	if ((desc->desc.bInterfaceSubClass != 0) &&  	    (desc->desc.bInterfaceSubClass != 1)) {  descriptor_error: -		dev_err (&intf->dev, "bad descriptor, ignoring hub\n"); +		dev_err(&intf->dev, "bad descriptor, ignoring hub\n");  		return -EIO;  	} @@ -1790,11 +1790,11 @@ descriptor_error:  		goto descriptor_error;  	/* We found a hub */ -	dev_info (&intf->dev, "USB hub found\n"); +	dev_info(&intf->dev, "USB hub found\n");  	hub = kzalloc(sizeof(*hub), GFP_KERNEL);  	if (!hub) { -		dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n"); +		dev_dbg(&intf->dev, "couldn't kmalloc hub struct\n");  		return -ENOMEM;  	} @@ -1807,7 +1807,7 @@ descriptor_error:  	usb_get_intf(intf);  	usb_get_dev(hdev); -	usb_set_intfdata (intf, hub); +	usb_set_intfdata(intf, hub);  	intf->needs_remote_wakeup = 1;  	pm_suspend_ignore_children(&intf->dev, true); @@ -1820,14 +1820,14 @@ descriptor_error:  	if (hub_configure(hub, endpoint) >= 0)  		return 0; -	hub_disconnect (intf); +	hub_disconnect(intf);  	return -ENODEV;  }  static int  hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data)  { -	struct usb_device *hdev = interface_to_usbdev (intf); +	struct usb_device *hdev = interface_to_usbdev(intf);  	struct usb_hub *hub = usb_hub_to_struct_hub(hdev);  	/* assert ifno == 0 (part of hub spec) */ @@ -2143,7 +2143,7 @@ void usb_disconnect(struct usb_device **pdev)  	 * cleaning up all state associated with the current configuration  	 * so that the hardware is now fully quiesced.  	 */ -	dev_dbg (&udev->dev, "unregistering device\n"); +	dev_dbg(&udev->dev, "unregistering device\n");  	usb_disable_device(udev, 0);  	usb_hcd_synchronize_unlinks(udev); @@ -2242,7 +2242,7 @@ static int usb_enumerate_device_otg(struct usb_device *udev)  		struct usb_bus			*bus = udev->bus;  		/* descriptor may appear anywhere in config */ -		if (__usb_get_extra_descriptor (udev->rawdescriptors[0], +		if (__usb_get_extra_descriptor(udev->rawdescriptors[0],  					le16_to_cpu(udev->config[0].desc.wTotalLength),  					USB_DT_OTG, (void **) &desc) == 0) {  			if (desc->bmAttributes & USB_OTG_HNP) { @@ -3526,7 +3526,7 @@ static int check_ports_changed(struct usb_hub *hub)  static int hub_suspend(struct usb_interface *intf, pm_message_t msg)  { -	struct usb_hub		*hub = usb_get_intfdata (intf); +	struct usb_hub		*hub = usb_get_intfdata(intf);  	struct usb_device	*hdev = hub->hdev;  	unsigned		port1;  	int			status; @@ -3950,6 +3950,8 @@ int usb_disable_lpm(struct usb_device *udev)  	if (usb_disable_link_state(hcd, udev, USB3_LPM_U2))  		goto enable_lpm; +	udev->usb3_lpm_enabled = 0; +  	return 0;  enable_lpm: @@ -4007,6 +4009,8 @@ void usb_enable_lpm(struct usb_device *udev)  	usb_enable_link_state(hcd, udev, USB3_LPM_U1);  	usb_enable_link_state(hcd, udev, USB3_LPM_U2); + +	udev->usb3_lpm_enabled = 1;  }  EXPORT_SYMBOL_GPL(usb_enable_lpm); diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h index a6315abe7b7c..a95b0c989c21 100644 --- a/drivers/usb/core/otg_whitelist.h +++ b/drivers/usb/core/otg_whitelist.h @@ -16,7 +16,7 @@   * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!   */ -static struct usb_device_id whitelist_table [] = { +static struct usb_device_id whitelist_table[] = {  /* hubs are optional in OTG, but very handy ... */  { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), }, diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index d26973844a4d..cfc68c11c3f5 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -531,6 +531,25 @@ static ssize_t usb2_lpm_besl_store(struct device *dev,  }  static DEVICE_ATTR_RW(usb2_lpm_besl); +static ssize_t usb3_hardware_lpm_show(struct device *dev, +				      struct device_attribute *attr, char *buf) +{ +	struct usb_device *udev = to_usb_device(dev); +	const char *p; + +	usb_lock_device(udev); + +	if (udev->usb3_lpm_enabled) +		p = "enabled"; +	else +		p = "disabled"; + +	usb_unlock_device(udev); + +	return sprintf(buf, "%s\n", p); +} +static DEVICE_ATTR_RO(usb3_hardware_lpm); +  static struct attribute *usb2_hardware_lpm_attr[] = {  	&dev_attr_usb2_hardware_lpm.attr,  	&dev_attr_usb2_lpm_l1_timeout.attr, @@ -542,6 +561,15 @@ static struct attribute_group usb2_hardware_lpm_attr_group = {  	.attrs	= usb2_hardware_lpm_attr,  }; +static struct attribute *usb3_hardware_lpm_attr[] = { +	&dev_attr_usb3_hardware_lpm.attr, +	NULL, +}; +static struct attribute_group usb3_hardware_lpm_attr_group = { +	.name	= power_group_name, +	.attrs	= usb3_hardware_lpm_attr, +}; +  static struct attribute *power_attrs[] = {  	&dev_attr_autosuspend.attr,  	&dev_attr_level.attr, @@ -564,6 +592,9 @@ static int add_power_attributes(struct device *dev)  		if (udev->usb2_hw_lpm_capable == 1)  			rc = sysfs_merge_group(&dev->kobj,  					&usb2_hardware_lpm_attr_group); +		if (udev->lpm_capable == 1) +			rc = sysfs_merge_group(&dev->kobj, +					&usb3_hardware_lpm_attr_group);  	}  	return rc; diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 7eb1e26798e5..457255a3306a 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -65,6 +65,7 @@ extern int  usb_hub_init(void);  extern void usb_hub_cleanup(void);  extern int usb_major_init(void);  extern void usb_major_cleanup(void); +extern int usb_device_supports_lpm(struct usb_device *udev);  #ifdef	CONFIG_PM  |