diff options
author | Johan Hovold <johan@kernel.org> | 2017-06-20 06:52:03 -0400 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-06-21 03:40:07 -0400 |
commit | c22ac6d29f18d3210c545f77e4f95b856ab5f983 (patch) | |
tree | ff1af4ebd80766423bd762abc0a5e9736096d4f5 /drivers/usb/serial/usb-serial.c | |
parent | 45e5d4d418f37cb9b2746c1fc63ab89b7b521d78 (diff) |
USB: serial: propagate late probe errors
Propagate errnos for late probe errors (e.g. -ENOMEM on allocation
failures) instead of always returning -EIO.
Note that some drivers are currently returning -ENODEV from their attach
callbacks when a device is not supported, but this has also been mapped
to -EIO.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index f68275dd1e9f..bb34f9f7eaf4 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -962,8 +962,10 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
962 | dev_dbg(ddev, "setting up %d port structure(s)\n", max_endpoints); | 962 | dev_dbg(ddev, "setting up %d port structure(s)\n", max_endpoints); |
963 | for (i = 0; i < max_endpoints; ++i) { | 963 | for (i = 0; i < max_endpoints; ++i) { |
964 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); | 964 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); |
965 | if (!port) | 965 | if (!port) { |
966 | goto probe_error; | 966 | retval = -ENOMEM; |
967 | goto err_free_epds; | ||
968 | } | ||
967 | tty_port_init(&port->port); | 969 | tty_port_init(&port->port); |
968 | port->port.ops = &serial_port_ops; | 970 | port->port.ops = &serial_port_ops; |
969 | port->serial = serial; | 971 | port->serial = serial; |
@@ -984,14 +986,14 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
984 | for (i = 0; i < epds->num_bulk_in; ++i) { | 986 | for (i = 0; i < epds->num_bulk_in; ++i) { |
985 | retval = setup_port_bulk_in(serial->port[i], epds->bulk_in[i]); | 987 | retval = setup_port_bulk_in(serial->port[i], epds->bulk_in[i]); |
986 | if (retval) | 988 | if (retval) |
987 | goto probe_error; | 989 | goto err_free_epds; |
988 | } | 990 | } |
989 | 991 | ||
990 | for (i = 0; i < epds->num_bulk_out; ++i) { | 992 | for (i = 0; i < epds->num_bulk_out; ++i) { |
991 | retval = setup_port_bulk_out(serial->port[i], | 993 | retval = setup_port_bulk_out(serial->port[i], |
992 | epds->bulk_out[i]); | 994 | epds->bulk_out[i]); |
993 | if (retval) | 995 | if (retval) |
994 | goto probe_error; | 996 | goto err_free_epds; |
995 | } | 997 | } |
996 | 998 | ||
997 | if (serial->type->read_int_callback) { | 999 | if (serial->type->read_int_callback) { |
@@ -999,7 +1001,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
999 | retval = setup_port_interrupt_in(serial->port[i], | 1001 | retval = setup_port_interrupt_in(serial->port[i], |
1000 | epds->interrupt_in[i]); | 1002 | epds->interrupt_in[i]); |
1001 | if (retval) | 1003 | if (retval) |
1002 | goto probe_error; | 1004 | goto err_free_epds; |
1003 | } | 1005 | } |
1004 | } else if (epds->num_interrupt_in) { | 1006 | } else if (epds->num_interrupt_in) { |
1005 | dev_dbg(ddev, "The device claims to support interrupt in transfers, but read_int_callback is not defined\n"); | 1007 | dev_dbg(ddev, "The device claims to support interrupt in transfers, but read_int_callback is not defined\n"); |
@@ -1010,7 +1012,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1010 | retval = setup_port_interrupt_out(serial->port[i], | 1012 | retval = setup_port_interrupt_out(serial->port[i], |
1011 | epds->interrupt_out[i]); | 1013 | epds->interrupt_out[i]); |
1012 | if (retval) | 1014 | if (retval) |
1013 | goto probe_error; | 1015 | goto err_free_epds; |
1014 | } | 1016 | } |
1015 | } else if (epds->num_interrupt_out) { | 1017 | } else if (epds->num_interrupt_out) { |
1016 | dev_dbg(ddev, "The device claims to support interrupt out transfers, but write_int_callback is not defined\n"); | 1018 | dev_dbg(ddev, "The device claims to support interrupt out transfers, but write_int_callback is not defined\n"); |
@@ -1022,7 +1024,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1022 | if (type->attach) { | 1024 | if (type->attach) { |
1023 | retval = type->attach(serial); | 1025 | retval = type->attach(serial); |
1024 | if (retval < 0) | 1026 | if (retval < 0) |
1025 | goto probe_error; | 1027 | goto err_free_epds; |
1026 | serial->attached = 1; | 1028 | serial->attached = 1; |
1027 | if (retval > 0) { | 1029 | if (retval > 0) { |
1028 | /* quietly accept this device, but don't bind to a | 1030 | /* quietly accept this device, but don't bind to a |
@@ -1034,9 +1036,10 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1034 | serial->attached = 1; | 1036 | serial->attached = 1; |
1035 | } | 1037 | } |
1036 | 1038 | ||
1037 | if (allocate_minors(serial, num_ports)) { | 1039 | retval = allocate_minors(serial, num_ports); |
1040 | if (retval) { | ||
1038 | dev_err(ddev, "No more free serial minor numbers\n"); | 1041 | dev_err(ddev, "No more free serial minor numbers\n"); |
1039 | goto probe_error; | 1042 | goto err_free_epds; |
1040 | } | 1043 | } |
1041 | 1044 | ||
1042 | /* register all of the individual ports with the driver core */ | 1045 | /* register all of the individual ports with the driver core */ |
@@ -1058,8 +1061,6 @@ exit: | |||
1058 | module_put(type->driver.owner); | 1061 | module_put(type->driver.owner); |
1059 | return 0; | 1062 | return 0; |
1060 | 1063 | ||
1061 | probe_error: | ||
1062 | retval = -EIO; | ||
1063 | err_free_epds: | 1064 | err_free_epds: |
1064 | kfree(epds); | 1065 | kfree(epds); |
1065 | err_put_serial: | 1066 | err_put_serial: |