aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2013-03-27 16:14:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-28 14:05:52 -0400
commite9e88fb7bca9f527ccdf4166a240a9023ba6ee73 (patch)
treed331f018b3a10f2328257c2c48668648b0938f60
parentb13379758f17e66d60f1f288bf917762c54ebd2f (diff)
USB: avoid error messages when a device is disconnected
This patch (as1673) reduces the amount of log spew from the hub driver by removing a bunch of error messages in the case where the device in question is already known to have been disconnected. Since the disconnect event itself appears in the log, there's no need for other error messages. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Jenya Y <jy.gerstmaier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/generic.c2
-rw-r--r--drivers/usb/core/hub.c65
2 files changed, 37 insertions, 30 deletions
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 271e761f563e..acbfeb0a0119 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -169,7 +169,7 @@ static int generic_probe(struct usb_device *udev)
169 c = usb_choose_configuration(udev); 169 c = usb_choose_configuration(udev);
170 if (c >= 0) { 170 if (c >= 0) {
171 err = usb_set_configuration(udev, c); 171 err = usb_set_configuration(udev, c);
172 if (err) { 172 if (err && err != -ENODEV) {
173 dev_err(&udev->dev, "can't set config #%d, error %d\n", 173 dev_err(&udev->dev, "can't set config #%d, error %d\n",
174 c, err); 174 c, err);
175 /* This need not be fatal. The user can try to 175 /* This need not be fatal. The user can try to
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 781546269d26..669da9ef714d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -555,8 +555,9 @@ static int hub_port_status(struct usb_hub *hub, int port1,
555 mutex_lock(&hub->status_mutex); 555 mutex_lock(&hub->status_mutex);
556 ret = get_port_status(hub->hdev, port1, &hub->status->port); 556 ret = get_port_status(hub->hdev, port1, &hub->status->port);
557 if (ret < 4) { 557 if (ret < 4) {
558 dev_err(hub->intfdev, 558 if (ret != -ENODEV)
559 "%s failed (err = %d)\n", __func__, ret); 559 dev_err(hub->intfdev,
560 "%s failed (err = %d)\n", __func__, ret);
560 if (ret >= 0) 561 if (ret >= 0)
561 ret = -EIO; 562 ret = -EIO;
562 } else { 563 } else {
@@ -699,7 +700,7 @@ static void hub_tt_work(struct work_struct *work)
699 /* drop lock so HCD can concurrently report other TT errors */ 700 /* drop lock so HCD can concurrently report other TT errors */
700 spin_unlock_irqrestore (&hub->tt.lock, flags); 701 spin_unlock_irqrestore (&hub->tt.lock, flags);
701 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); 702 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt);
702 if (status) 703 if (status && status != -ENODEV)
703 dev_err (&hdev->dev, 704 dev_err (&hdev->dev,
704 "clear tt %d (%04x) error %d\n", 705 "clear tt %d (%04x) error %d\n",
705 clear->tt, clear->devinfo, status); 706 clear->tt, clear->devinfo, status);
@@ -837,10 +838,11 @@ static int hub_hub_status(struct usb_hub *hub,
837 838
838 mutex_lock(&hub->status_mutex); 839 mutex_lock(&hub->status_mutex);
839 ret = get_hub_status(hub->hdev, &hub->status->hub); 840 ret = get_hub_status(hub->hdev, &hub->status->hub);
840 if (ret < 0) 841 if (ret < 0) {
841 dev_err (hub->intfdev, 842 if (ret != -ENODEV)
842 "%s failed (err = %d)\n", __func__, ret); 843 dev_err(hub->intfdev,
843 else { 844 "%s failed (err = %d)\n", __func__, ret);
845 } else {
844 *status = le16_to_cpu(hub->status->hub.wHubStatus); 846 *status = le16_to_cpu(hub->status->hub.wHubStatus);
845 *change = le16_to_cpu(hub->status->hub.wHubChange); 847 *change = le16_to_cpu(hub->status->hub.wHubChange);
846 ret = 0; 848 ret = 0;
@@ -877,11 +879,8 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
877 return -EINVAL; 879 return -EINVAL;
878 880
879 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); 881 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
880 if (ret) { 882 if (ret)
881 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
882 port1, ret);
883 return ret; 883 return ret;
884 }
885 884
886 /* Wait for the link to enter the disabled state. */ 885 /* Wait for the link to enter the disabled state. */
887 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { 886 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
@@ -918,7 +917,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
918 ret = usb_clear_port_feature(hdev, port1, 917 ret = usb_clear_port_feature(hdev, port1,
919 USB_PORT_FEAT_ENABLE); 918 USB_PORT_FEAT_ENABLE);
920 } 919 }
921 if (ret) 920 if (ret && ret != -ENODEV)
922 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", 921 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
923 port1, ret); 922 port1, ret);
924 return ret; 923 return ret;
@@ -2196,8 +2195,9 @@ static int usb_enumerate_device(struct usb_device *udev)
2196 if (udev->config == NULL) { 2195 if (udev->config == NULL) {
2197 err = usb_get_configuration(udev); 2196 err = usb_get_configuration(udev);
2198 if (err < 0) { 2197 if (err < 0) {
2199 dev_err(&udev->dev, "can't read configurations, error %d\n", 2198 if (err != -ENODEV)
2200 err); 2199 dev_err(&udev->dev, "can't read configurations, error %d\n",
2200 err);
2201 return err; 2201 return err;
2202 } 2202 }
2203 } 2203 }
@@ -2644,14 +2644,16 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2644 status = set_port_feature(hub->hdev, port1, (warm ? 2644 status = set_port_feature(hub->hdev, port1, (warm ?
2645 USB_PORT_FEAT_BH_PORT_RESET : 2645 USB_PORT_FEAT_BH_PORT_RESET :
2646 USB_PORT_FEAT_RESET)); 2646 USB_PORT_FEAT_RESET));
2647 if (status) { 2647 if (status == -ENODEV) {
2648 ; /* The hub is gone */
2649 } else if (status) {
2648 dev_err(hub->intfdev, 2650 dev_err(hub->intfdev,
2649 "cannot %sreset port %d (err = %d)\n", 2651 "cannot %sreset port %d (err = %d)\n",
2650 warm ? "warm " : "", port1, status); 2652 warm ? "warm " : "", port1, status);
2651 } else { 2653 } else {
2652 status = hub_port_wait_reset(hub, port1, udev, delay, 2654 status = hub_port_wait_reset(hub, port1, udev, delay,
2653 warm); 2655 warm);
2654 if (status && status != -ENOTCONN) 2656 if (status && status != -ENOTCONN && status != -ENODEV)
2655 dev_dbg(hub->intfdev, 2657 dev_dbg(hub->intfdev,
2656 "port_wait_reset: err = %d\n", 2658 "port_wait_reset: err = %d\n",
2657 status); 2659 status);
@@ -4094,9 +4096,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4094 goto fail; 4096 goto fail;
4095 } 4097 }
4096 if (r) { 4098 if (r) {
4097 dev_err(&udev->dev, 4099 if (r != -ENODEV)
4098 "device descriptor read/64, error %d\n", 4100 dev_err(&udev->dev, "device descriptor read/64, error %d\n",
4099 r); 4101 r);
4100 retval = -EMSGSIZE; 4102 retval = -EMSGSIZE;
4101 continue; 4103 continue;
4102 } 4104 }
@@ -4116,9 +4118,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4116 msleep(200); 4118 msleep(200);
4117 } 4119 }
4118 if (retval < 0) { 4120 if (retval < 0) {
4119 dev_err(&udev->dev, 4121 if (retval != -ENODEV)
4120 "device not accepting address %d, error %d\n", 4122 dev_err(&udev->dev, "device not accepting address %d, error %d\n",
4121 devnum, retval); 4123 devnum, retval);
4122 goto fail; 4124 goto fail;
4123 } 4125 }
4124 if (udev->speed == USB_SPEED_SUPER) { 4126 if (udev->speed == USB_SPEED_SUPER) {
@@ -4140,7 +4142,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4140 4142
4141 retval = usb_get_device_descriptor(udev, 8); 4143 retval = usb_get_device_descriptor(udev, 8);
4142 if (retval < 8) { 4144 if (retval < 8) {
4143 dev_err(&udev->dev, 4145 if (retval != -ENODEV)
4146 dev_err(&udev->dev,
4144 "device descriptor read/8, error %d\n", 4147 "device descriptor read/8, error %d\n",
4145 retval); 4148 retval);
4146 if (retval >= 0) 4149 if (retval >= 0)
@@ -4194,8 +4197,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4194 4197
4195 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); 4198 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
4196 if (retval < (signed)sizeof(udev->descriptor)) { 4199 if (retval < (signed)sizeof(udev->descriptor)) {
4197 dev_err(&udev->dev, "device descriptor read/all, error %d\n", 4200 if (retval != -ENODEV)
4198 retval); 4201 dev_err(&udev->dev, "device descriptor read/all, error %d\n",
4202 retval);
4199 if (retval >= 0) 4203 if (retval >= 0)
4200 retval = -ENOMSG; 4204 retval = -ENOMSG;
4201 goto fail; 4205 goto fail;
@@ -4377,7 +4381,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4377 USB_PORT_STAT_C_ENABLE)) { 4381 USB_PORT_STAT_C_ENABLE)) {
4378 status = hub_port_debounce_be_stable(hub, port1); 4382 status = hub_port_debounce_be_stable(hub, port1);
4379 if (status < 0) { 4383 if (status < 0) {
4380 if (printk_ratelimit()) 4384 if (status != -ENODEV && printk_ratelimit())
4381 dev_err(hub_dev, "connect-debounce failed, " 4385 dev_err(hub_dev, "connect-debounce failed, "
4382 "port %d disabled\n", port1); 4386 "port %d disabled\n", port1);
4383 portstatus &= ~USB_PORT_STAT_CONNECTION; 4387 portstatus &= ~USB_PORT_STAT_CONNECTION;
@@ -4406,6 +4410,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4406 else 4410 else
4407 unit_load = 100; 4411 unit_load = 100;
4408 4412
4413 status = 0;
4409 for (i = 0; i < SET_CONFIG_TRIES; i++) { 4414 for (i = 0; i < SET_CONFIG_TRIES; i++) {
4410 4415
4411 /* reallocate for each attempt, since references 4416 /* reallocate for each attempt, since references
@@ -4530,9 +4535,11 @@ loop:
4530 } 4535 }
4531 if (hub->hdev->parent || 4536 if (hub->hdev->parent ||
4532 !hcd->driver->port_handed_over || 4537 !hcd->driver->port_handed_over ||
4533 !(hcd->driver->port_handed_over)(hcd, port1)) 4538 !(hcd->driver->port_handed_over)(hcd, port1)) {
4534 dev_err(hub_dev, "unable to enumerate USB device on port %d\n", 4539 if (status != -ENOTCONN && status != -ENODEV)
4535 port1); 4540 dev_err(hub_dev, "unable to enumerate USB device on port %d\n",
4541 port1);
4542 }
4536 4543
4537done: 4544done:
4538 hub_port_disable(hub, port1, 1); 4545 hub_port_disable(hub, port1, 1);