Commit e9e88fb7 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Tested-by: default avatarJenya Y <jy.gerstmaier@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b1337975
...@@ -169,7 +169,7 @@ static int generic_probe(struct usb_device *udev) ...@@ -169,7 +169,7 @@ static int generic_probe(struct usb_device *udev)
c = usb_choose_configuration(udev); c = usb_choose_configuration(udev);
if (c >= 0) { if (c >= 0) {
err = usb_set_configuration(udev, c); err = usb_set_configuration(udev, c);
if (err) { if (err && err != -ENODEV) {
dev_err(&udev->dev, "can't set config #%d, error %d\n", dev_err(&udev->dev, "can't set config #%d, error %d\n",
c, err); c, err);
/* This need not be fatal. The user can try to /* This need not be fatal. The user can try to
......
...@@ -555,8 +555,9 @@ static int hub_port_status(struct usb_hub *hub, int port1, ...@@ -555,8 +555,9 @@ static int hub_port_status(struct usb_hub *hub, int port1,
mutex_lock(&hub->status_mutex); mutex_lock(&hub->status_mutex);
ret = get_port_status(hub->hdev, port1, &hub->status->port); ret = get_port_status(hub->hdev, port1, &hub->status->port);
if (ret < 4) { if (ret < 4) {
dev_err(hub->intfdev, if (ret != -ENODEV)
"%s failed (err = %d)\n", __func__, ret); dev_err(hub->intfdev,
"%s failed (err = %d)\n", __func__, ret);
if (ret >= 0) if (ret >= 0)
ret = -EIO; ret = -EIO;
} else { } else {
...@@ -699,7 +700,7 @@ static void hub_tt_work(struct work_struct *work) ...@@ -699,7 +700,7 @@ static void hub_tt_work(struct work_struct *work)
/* drop lock so HCD can concurrently report other TT errors */ /* drop lock so HCD can concurrently report other TT errors */
spin_unlock_irqrestore (&hub->tt.lock, flags); spin_unlock_irqrestore (&hub->tt.lock, flags);
status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt);
if (status) if (status && status != -ENODEV)
dev_err (&hdev->dev, dev_err (&hdev->dev,
"clear tt %d (%04x) error %d\n", "clear tt %d (%04x) error %d\n",
clear->tt, clear->devinfo, status); clear->tt, clear->devinfo, status);
...@@ -837,10 +838,11 @@ static int hub_hub_status(struct usb_hub *hub, ...@@ -837,10 +838,11 @@ static int hub_hub_status(struct usb_hub *hub,
mutex_lock(&hub->status_mutex); mutex_lock(&hub->status_mutex);
ret = get_hub_status(hub->hdev, &hub->status->hub); ret = get_hub_status(hub->hdev, &hub->status->hub);
if (ret < 0) if (ret < 0) {
dev_err (hub->intfdev, if (ret != -ENODEV)
"%s failed (err = %d)\n", __func__, ret); dev_err(hub->intfdev,
else { "%s failed (err = %d)\n", __func__, ret);
} else {
*status = le16_to_cpu(hub->status->hub.wHubStatus); *status = le16_to_cpu(hub->status->hub.wHubStatus);
*change = le16_to_cpu(hub->status->hub.wHubChange); *change = le16_to_cpu(hub->status->hub.wHubChange);
ret = 0; ret = 0;
...@@ -877,11 +879,8 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int port1) ...@@ -877,11 +879,8 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
return -EINVAL; return -EINVAL;
ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
if (ret) { if (ret)
dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
port1, ret);
return ret; return ret;
}
/* Wait for the link to enter the disabled state. */ /* Wait for the link to enter the disabled state. */
for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { 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,7 +917,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
ret = usb_clear_port_feature(hdev, port1, ret = usb_clear_port_feature(hdev, port1,
USB_PORT_FEAT_ENABLE); USB_PORT_FEAT_ENABLE);
} }
if (ret) if (ret && ret != -ENODEV)
dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
port1, ret); port1, ret);
return ret; return ret;
...@@ -2196,8 +2195,9 @@ static int usb_enumerate_device(struct usb_device *udev) ...@@ -2196,8 +2195,9 @@ static int usb_enumerate_device(struct usb_device *udev)
if (udev->config == NULL) { if (udev->config == NULL) {
err = usb_get_configuration(udev); err = usb_get_configuration(udev);
if (err < 0) { if (err < 0) {
dev_err(&udev->dev, "can't read configurations, error %d\n", if (err != -ENODEV)
err); dev_err(&udev->dev, "can't read configurations, error %d\n",
err);
return err; return err;
} }
} }
...@@ -2644,14 +2644,16 @@ static int hub_port_reset(struct usb_hub *hub, int port1, ...@@ -2644,14 +2644,16 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
status = set_port_feature(hub->hdev, port1, (warm ? status = set_port_feature(hub->hdev, port1, (warm ?
USB_PORT_FEAT_BH_PORT_RESET : USB_PORT_FEAT_BH_PORT_RESET :
USB_PORT_FEAT_RESET)); USB_PORT_FEAT_RESET));
if (status) { if (status == -ENODEV) {
; /* The hub is gone */
} else if (status) {
dev_err(hub->intfdev, dev_err(hub->intfdev,
"cannot %sreset port %d (err = %d)\n", "cannot %sreset port %d (err = %d)\n",
warm ? "warm " : "", port1, status); warm ? "warm " : "", port1, status);
} else { } else {
status = hub_port_wait_reset(hub, port1, udev, delay, status = hub_port_wait_reset(hub, port1, udev, delay,
warm); warm);
if (status && status != -ENOTCONN) if (status && status != -ENOTCONN && status != -ENODEV)
dev_dbg(hub->intfdev, dev_dbg(hub->intfdev,
"port_wait_reset: err = %d\n", "port_wait_reset: err = %d\n",
status); status);
...@@ -4094,9 +4096,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4094,9 +4096,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
goto fail; goto fail;
} }
if (r) { if (r) {
dev_err(&udev->dev, if (r != -ENODEV)
"device descriptor read/64, error %d\n", dev_err(&udev->dev, "device descriptor read/64, error %d\n",
r); r);
retval = -EMSGSIZE; retval = -EMSGSIZE;
continue; continue;
} }
...@@ -4116,9 +4118,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4116,9 +4118,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
msleep(200); msleep(200);
} }
if (retval < 0) { if (retval < 0) {
dev_err(&udev->dev, if (retval != -ENODEV)
"device not accepting address %d, error %d\n", dev_err(&udev->dev, "device not accepting address %d, error %d\n",
devnum, retval); devnum, retval);
goto fail; goto fail;
} }
if (udev->speed == USB_SPEED_SUPER) { if (udev->speed == USB_SPEED_SUPER) {
...@@ -4140,7 +4142,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4140,7 +4142,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
retval = usb_get_device_descriptor(udev, 8); retval = usb_get_device_descriptor(udev, 8);
if (retval < 8) { if (retval < 8) {
dev_err(&udev->dev, if (retval != -ENODEV)
dev_err(&udev->dev,
"device descriptor read/8, error %d\n", "device descriptor read/8, error %d\n",
retval); retval);
if (retval >= 0) if (retval >= 0)
...@@ -4194,8 +4197,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4194,8 +4197,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
if (retval < (signed)sizeof(udev->descriptor)) { if (retval < (signed)sizeof(udev->descriptor)) {
dev_err(&udev->dev, "device descriptor read/all, error %d\n", if (retval != -ENODEV)
retval); dev_err(&udev->dev, "device descriptor read/all, error %d\n",
retval);
if (retval >= 0) if (retval >= 0)
retval = -ENOMSG; retval = -ENOMSG;
goto fail; goto fail;
...@@ -4377,7 +4381,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, ...@@ -4377,7 +4381,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
USB_PORT_STAT_C_ENABLE)) { USB_PORT_STAT_C_ENABLE)) {
status = hub_port_debounce_be_stable(hub, port1); status = hub_port_debounce_be_stable(hub, port1);
if (status < 0) { if (status < 0) {
if (printk_ratelimit()) if (status != -ENODEV && printk_ratelimit())
dev_err(hub_dev, "connect-debounce failed, " dev_err(hub_dev, "connect-debounce failed, "
"port %d disabled\n", port1); "port %d disabled\n", port1);
portstatus &= ~USB_PORT_STAT_CONNECTION; portstatus &= ~USB_PORT_STAT_CONNECTION;
...@@ -4406,6 +4410,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, ...@@ -4406,6 +4410,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
else else
unit_load = 100; unit_load = 100;
status = 0;
for (i = 0; i < SET_CONFIG_TRIES; i++) { for (i = 0; i < SET_CONFIG_TRIES; i++) {
/* reallocate for each attempt, since references /* reallocate for each attempt, since references
...@@ -4530,9 +4535,11 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, ...@@ -4530,9 +4535,11 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
} }
if (hub->hdev->parent || if (hub->hdev->parent ||
!hcd->driver->port_handed_over || !hcd->driver->port_handed_over ||
!(hcd->driver->port_handed_over)(hcd, port1)) !(hcd->driver->port_handed_over)(hcd, port1)) {
dev_err(hub_dev, "unable to enumerate USB device on port %d\n", if (status != -ENOTCONN && status != -ENODEV)
port1); dev_err(hub_dev, "unable to enumerate USB device on port %d\n",
port1);
}
done: done:
hub_port_disable(hub, port1, 1); hub_port_disable(hub, port1, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment