diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-28 08:02:07 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-28 08:02:07 -0400 |
commit | 0e4b470c0af6df6cd1456ef8482db1d07f14ae33 (patch) | |
tree | fc4e59d47fb04d4530f5b5822dcc8551ec8ecae0 | |
parent | f0d657e80d788c43ff4a5dbeb47d2ad60059f1c7 (diff) | |
parent | c22ac6d29f18d3210c545f77e4f95b856ab5f983 (diff) |
Merge tag 'usb-serial-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next
Johan writes:
USB-serial updates for v4.13-rc1
Here are the USB-serial updates for 4.13, including support for
manipulating the modem-control signals of qcserial devices, propagation
of errnos after late probe errors from usb-serial core, and a couple of
clean ups.
All have been in linux-next with no reported issues.
Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r-- | drivers/usb/serial/qcserial.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/upd78f0730.c | 6 | ||||
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 243 |
3 files changed, 146 insertions, 105 deletions
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index fd509ed6cf70..4ac137d070fb 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c | |||
@@ -454,6 +454,8 @@ static struct usb_serial_driver qcdevice = { | |||
454 | .write = usb_wwan_write, | 454 | .write = usb_wwan_write, |
455 | .write_room = usb_wwan_write_room, | 455 | .write_room = usb_wwan_write_room, |
456 | .chars_in_buffer = usb_wwan_chars_in_buffer, | 456 | .chars_in_buffer = usb_wwan_chars_in_buffer, |
457 | .tiocmget = usb_wwan_tiocmget, | ||
458 | .tiocmset = usb_wwan_tiocmset, | ||
457 | .attach = qc_attach, | 459 | .attach = qc_attach, |
458 | .release = qc_release, | 460 | .release = qc_release, |
459 | .port_probe = usb_wwan_port_probe, | 461 | .port_probe = usb_wwan_port_probe, |
diff --git a/drivers/usb/serial/upd78f0730.c b/drivers/usb/serial/upd78f0730.c index a028dd2310c9..6819a3486e5d 100644 --- a/drivers/usb/serial/upd78f0730.c +++ b/drivers/usb/serial/upd78f0730.c | |||
@@ -288,7 +288,7 @@ static void upd78f0730_dtr_rts(struct usb_serial_port *port, int on) | |||
288 | static speed_t upd78f0730_get_baud_rate(struct tty_struct *tty) | 288 | static speed_t upd78f0730_get_baud_rate(struct tty_struct *tty) |
289 | { | 289 | { |
290 | const speed_t baud_rate = tty_get_baud_rate(tty); | 290 | const speed_t baud_rate = tty_get_baud_rate(tty); |
291 | const speed_t supported[] = { | 291 | static const speed_t supported[] = { |
292 | 0, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 153600 | 292 | 0, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 153600 |
293 | }; | 293 | }; |
294 | int i; | 294 | int i; |
@@ -384,7 +384,7 @@ static void upd78f0730_set_termios(struct tty_struct *tty, | |||
384 | 384 | ||
385 | static int upd78f0730_open(struct tty_struct *tty, struct usb_serial_port *port) | 385 | static int upd78f0730_open(struct tty_struct *tty, struct usb_serial_port *port) |
386 | { | 386 | { |
387 | struct upd78f0730_open_close request = { | 387 | static const struct upd78f0730_open_close request = { |
388 | .opcode = UPD78F0730_CMD_OPEN_CLOSE, | 388 | .opcode = UPD78F0730_CMD_OPEN_CLOSE, |
389 | .state = UPD78F0730_PORT_OPEN | 389 | .state = UPD78F0730_PORT_OPEN |
390 | }; | 390 | }; |
@@ -402,7 +402,7 @@ static int upd78f0730_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
402 | 402 | ||
403 | static void upd78f0730_close(struct usb_serial_port *port) | 403 | static void upd78f0730_close(struct usb_serial_port *port) |
404 | { | 404 | { |
405 | struct upd78f0730_open_close request = { | 405 | static const struct upd78f0730_open_close request = { |
406 | .opcode = UPD78F0730_CMD_OPEN_CLOSE, | 406 | .opcode = UPD78F0730_CMD_OPEN_CLOSE, |
407 | .state = UPD78F0730_PORT_CLOSE | 407 | .state = UPD78F0730_PORT_CLOSE |
408 | }; | 408 | }; |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index c7ca95f64edc..bb34f9f7eaf4 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -742,6 +742,124 @@ static void find_endpoints(struct usb_serial *serial, | |||
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
745 | static int setup_port_bulk_in(struct usb_serial_port *port, | ||
746 | struct usb_endpoint_descriptor *epd) | ||
747 | { | ||
748 | struct usb_serial_driver *type = port->serial->type; | ||
749 | struct usb_device *udev = port->serial->dev; | ||
750 | int buffer_size; | ||
751 | int i; | ||
752 | |||
753 | buffer_size = max_t(int, type->bulk_in_size, usb_endpoint_maxp(epd)); | ||
754 | port->bulk_in_size = buffer_size; | ||
755 | port->bulk_in_endpointAddress = epd->bEndpointAddress; | ||
756 | |||
757 | for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { | ||
758 | set_bit(i, &port->read_urbs_free); | ||
759 | port->read_urbs[i] = usb_alloc_urb(0, GFP_KERNEL); | ||
760 | if (!port->read_urbs[i]) | ||
761 | return -ENOMEM; | ||
762 | port->bulk_in_buffers[i] = kmalloc(buffer_size, GFP_KERNEL); | ||
763 | if (!port->bulk_in_buffers[i]) | ||
764 | return -ENOMEM; | ||
765 | usb_fill_bulk_urb(port->read_urbs[i], udev, | ||
766 | usb_rcvbulkpipe(udev, epd->bEndpointAddress), | ||
767 | port->bulk_in_buffers[i], buffer_size, | ||
768 | type->read_bulk_callback, port); | ||
769 | } | ||
770 | |||
771 | port->read_urb = port->read_urbs[0]; | ||
772 | port->bulk_in_buffer = port->bulk_in_buffers[0]; | ||
773 | |||
774 | return 0; | ||
775 | } | ||
776 | |||
777 | static int setup_port_bulk_out(struct usb_serial_port *port, | ||
778 | struct usb_endpoint_descriptor *epd) | ||
779 | { | ||
780 | struct usb_serial_driver *type = port->serial->type; | ||
781 | struct usb_device *udev = port->serial->dev; | ||
782 | int buffer_size; | ||
783 | int i; | ||
784 | |||
785 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) | ||
786 | return -ENOMEM; | ||
787 | if (type->bulk_out_size) | ||
788 | buffer_size = type->bulk_out_size; | ||
789 | else | ||
790 | buffer_size = usb_endpoint_maxp(epd); | ||
791 | port->bulk_out_size = buffer_size; | ||
792 | port->bulk_out_endpointAddress = epd->bEndpointAddress; | ||
793 | |||
794 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { | ||
795 | set_bit(i, &port->write_urbs_free); | ||
796 | port->write_urbs[i] = usb_alloc_urb(0, GFP_KERNEL); | ||
797 | if (!port->write_urbs[i]) | ||
798 | return -ENOMEM; | ||
799 | port->bulk_out_buffers[i] = kmalloc(buffer_size, GFP_KERNEL); | ||
800 | if (!port->bulk_out_buffers[i]) | ||
801 | return -ENOMEM; | ||
802 | usb_fill_bulk_urb(port->write_urbs[i], udev, | ||
803 | usb_sndbulkpipe(udev, epd->bEndpointAddress), | ||
804 | port->bulk_out_buffers[i], buffer_size, | ||
805 | type->write_bulk_callback, port); | ||
806 | } | ||
807 | |||
808 | port->write_urb = port->write_urbs[0]; | ||
809 | port->bulk_out_buffer = port->bulk_out_buffers[0]; | ||
810 | |||
811 | return 0; | ||
812 | } | ||
813 | |||
814 | static int setup_port_interrupt_in(struct usb_serial_port *port, | ||
815 | struct usb_endpoint_descriptor *epd) | ||
816 | { | ||
817 | struct usb_serial_driver *type = port->serial->type; | ||
818 | struct usb_device *udev = port->serial->dev; | ||
819 | int buffer_size; | ||
820 | |||
821 | port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
822 | if (!port->interrupt_in_urb) | ||
823 | return -ENOMEM; | ||
824 | buffer_size = usb_endpoint_maxp(epd); | ||
825 | port->interrupt_in_endpointAddress = epd->bEndpointAddress; | ||
826 | port->interrupt_in_buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
827 | if (!port->interrupt_in_buffer) | ||
828 | return -ENOMEM; | ||
829 | usb_fill_int_urb(port->interrupt_in_urb, udev, | ||
830 | usb_rcvintpipe(udev, epd->bEndpointAddress), | ||
831 | port->interrupt_in_buffer, buffer_size, | ||
832 | type->read_int_callback, port, | ||
833 | epd->bInterval); | ||
834 | |||
835 | return 0; | ||
836 | } | ||
837 | |||
838 | static int setup_port_interrupt_out(struct usb_serial_port *port, | ||
839 | struct usb_endpoint_descriptor *epd) | ||
840 | { | ||
841 | struct usb_serial_driver *type = port->serial->type; | ||
842 | struct usb_device *udev = port->serial->dev; | ||
843 | int buffer_size; | ||
844 | |||
845 | port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
846 | if (!port->interrupt_out_urb) | ||
847 | return -ENOMEM; | ||
848 | buffer_size = usb_endpoint_maxp(epd); | ||
849 | port->interrupt_out_size = buffer_size; | ||
850 | port->interrupt_out_endpointAddress = epd->bEndpointAddress; | ||
851 | port->interrupt_out_buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
852 | if (!port->interrupt_out_buffer) | ||
853 | return -ENOMEM; | ||
854 | usb_fill_int_urb(port->interrupt_out_urb, udev, | ||
855 | usb_sndintpipe(udev, epd->bEndpointAddress), | ||
856 | port->interrupt_out_buffer, buffer_size, | ||
857 | type->write_int_callback, port, | ||
858 | epd->bInterval); | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | |||
745 | static int usb_serial_probe(struct usb_interface *interface, | 863 | static int usb_serial_probe(struct usb_interface *interface, |
746 | const struct usb_device_id *id) | 864 | const struct usb_device_id *id) |
747 | { | 865 | { |
@@ -749,13 +867,10 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
749 | struct usb_device *dev = interface_to_usbdev(interface); | 867 | struct usb_device *dev = interface_to_usbdev(interface); |
750 | struct usb_serial *serial = NULL; | 868 | struct usb_serial *serial = NULL; |
751 | struct usb_serial_port *port; | 869 | struct usb_serial_port *port; |
752 | struct usb_endpoint_descriptor *endpoint; | ||
753 | struct usb_serial_endpoints *epds; | 870 | struct usb_serial_endpoints *epds; |
754 | struct usb_serial_driver *type = NULL; | 871 | struct usb_serial_driver *type = NULL; |
755 | int retval; | 872 | int retval; |
756 | int buffer_size; | ||
757 | int i; | 873 | int i; |
758 | int j; | ||
759 | int num_ports = 0; | 874 | int num_ports = 0; |
760 | unsigned char max_endpoints; | 875 | unsigned char max_endpoints; |
761 | 876 | ||
@@ -847,8 +962,10 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
847 | 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); |
848 | for (i = 0; i < max_endpoints; ++i) { | 963 | for (i = 0; i < max_endpoints; ++i) { |
849 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); | 964 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); |
850 | if (!port) | 965 | if (!port) { |
851 | goto probe_error; | 966 | retval = -ENOMEM; |
967 | goto err_free_epds; | ||
968 | } | ||
852 | tty_port_init(&port->port); | 969 | tty_port_init(&port->port); |
853 | port->port.ops = &serial_port_ops; | 970 | port->port.ops = &serial_port_ops; |
854 | port->serial = serial; | 971 | port->serial = serial; |
@@ -867,86 +984,24 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
867 | 984 | ||
868 | /* set up the endpoint information */ | 985 | /* set up the endpoint information */ |
869 | for (i = 0; i < epds->num_bulk_in; ++i) { | 986 | for (i = 0; i < epds->num_bulk_in; ++i) { |
870 | endpoint = epds->bulk_in[i]; | 987 | retval = setup_port_bulk_in(serial->port[i], epds->bulk_in[i]); |
871 | port = serial->port[i]; | 988 | if (retval) |
872 | buffer_size = max_t(int, serial->type->bulk_in_size, | 989 | goto err_free_epds; |
873 | usb_endpoint_maxp(endpoint)); | ||
874 | port->bulk_in_size = buffer_size; | ||
875 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; | ||
876 | |||
877 | for (j = 0; j < ARRAY_SIZE(port->read_urbs); ++j) { | ||
878 | set_bit(j, &port->read_urbs_free); | ||
879 | port->read_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | ||
880 | if (!port->read_urbs[j]) | ||
881 | goto probe_error; | ||
882 | port->bulk_in_buffers[j] = kmalloc(buffer_size, | ||
883 | GFP_KERNEL); | ||
884 | if (!port->bulk_in_buffers[j]) | ||
885 | goto probe_error; | ||
886 | usb_fill_bulk_urb(port->read_urbs[j], dev, | ||
887 | usb_rcvbulkpipe(dev, | ||
888 | endpoint->bEndpointAddress), | ||
889 | port->bulk_in_buffers[j], buffer_size, | ||
890 | serial->type->read_bulk_callback, | ||
891 | port); | ||
892 | } | ||
893 | |||
894 | port->read_urb = port->read_urbs[0]; | ||
895 | port->bulk_in_buffer = port->bulk_in_buffers[0]; | ||
896 | } | 990 | } |
897 | 991 | ||
898 | for (i = 0; i < epds->num_bulk_out; ++i) { | 992 | for (i = 0; i < epds->num_bulk_out; ++i) { |
899 | endpoint = epds->bulk_out[i]; | 993 | retval = setup_port_bulk_out(serial->port[i], |
900 | port = serial->port[i]; | 994 | epds->bulk_out[i]); |
901 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) | 995 | if (retval) |
902 | goto probe_error; | 996 | goto err_free_epds; |
903 | buffer_size = serial->type->bulk_out_size; | ||
904 | if (!buffer_size) | ||
905 | buffer_size = usb_endpoint_maxp(endpoint); | ||
906 | port->bulk_out_size = buffer_size; | ||
907 | port->bulk_out_endpointAddress = endpoint->bEndpointAddress; | ||
908 | |||
909 | for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) { | ||
910 | set_bit(j, &port->write_urbs_free); | ||
911 | port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | ||
912 | if (!port->write_urbs[j]) | ||
913 | goto probe_error; | ||
914 | port->bulk_out_buffers[j] = kmalloc(buffer_size, | ||
915 | GFP_KERNEL); | ||
916 | if (!port->bulk_out_buffers[j]) | ||
917 | goto probe_error; | ||
918 | usb_fill_bulk_urb(port->write_urbs[j], dev, | ||
919 | usb_sndbulkpipe(dev, | ||
920 | endpoint->bEndpointAddress), | ||
921 | port->bulk_out_buffers[j], buffer_size, | ||
922 | serial->type->write_bulk_callback, | ||
923 | port); | ||
924 | } | ||
925 | |||
926 | port->write_urb = port->write_urbs[0]; | ||
927 | port->bulk_out_buffer = port->bulk_out_buffers[0]; | ||
928 | } | 997 | } |
929 | 998 | ||
930 | if (serial->type->read_int_callback) { | 999 | if (serial->type->read_int_callback) { |
931 | for (i = 0; i < epds->num_interrupt_in; ++i) { | 1000 | for (i = 0; i < epds->num_interrupt_in; ++i) { |
932 | endpoint = epds->interrupt_in[i]; | 1001 | retval = setup_port_interrupt_in(serial->port[i], |
933 | port = serial->port[i]; | 1002 | epds->interrupt_in[i]); |
934 | port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 1003 | if (retval) |
935 | if (!port->interrupt_in_urb) | 1004 | goto err_free_epds; |
936 | goto probe_error; | ||
937 | buffer_size = usb_endpoint_maxp(endpoint); | ||
938 | port->interrupt_in_endpointAddress = | ||
939 | endpoint->bEndpointAddress; | ||
940 | port->interrupt_in_buffer = kmalloc(buffer_size, | ||
941 | GFP_KERNEL); | ||
942 | if (!port->interrupt_in_buffer) | ||
943 | goto probe_error; | ||
944 | usb_fill_int_urb(port->interrupt_in_urb, dev, | ||
945 | usb_rcvintpipe(dev, | ||
946 | endpoint->bEndpointAddress), | ||
947 | port->interrupt_in_buffer, buffer_size, | ||
948 | serial->type->read_int_callback, port, | ||
949 | endpoint->bInterval); | ||
950 | } | 1005 | } |
951 | } else if (epds->num_interrupt_in) { | 1006 | } else if (epds->num_interrupt_in) { |
952 | 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"); |
@@ -954,25 +1009,10 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
954 | 1009 | ||
955 | if (serial->type->write_int_callback) { | 1010 | if (serial->type->write_int_callback) { |
956 | for (i = 0; i < epds->num_interrupt_out; ++i) { | 1011 | for (i = 0; i < epds->num_interrupt_out; ++i) { |
957 | endpoint = epds->interrupt_out[i]; | 1012 | retval = setup_port_interrupt_out(serial->port[i], |
958 | port = serial->port[i]; | 1013 | epds->interrupt_out[i]); |
959 | port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); | 1014 | if (retval) |
960 | if (!port->interrupt_out_urb) | 1015 | goto err_free_epds; |
961 | goto probe_error; | ||
962 | buffer_size = usb_endpoint_maxp(endpoint); | ||
963 | port->interrupt_out_size = buffer_size; | ||
964 | port->interrupt_out_endpointAddress = | ||
965 | endpoint->bEndpointAddress; | ||
966 | port->interrupt_out_buffer = kmalloc(buffer_size, | ||
967 | GFP_KERNEL); | ||
968 | if (!port->interrupt_out_buffer) | ||
969 | goto probe_error; | ||
970 | usb_fill_int_urb(port->interrupt_out_urb, dev, | ||
971 | usb_sndintpipe(dev, | ||
972 | endpoint->bEndpointAddress), | ||
973 | port->interrupt_out_buffer, buffer_size, | ||
974 | serial->type->write_int_callback, port, | ||
975 | endpoint->bInterval); | ||
976 | } | 1016 | } |
977 | } else if (epds->num_interrupt_out) { | 1017 | } else if (epds->num_interrupt_out) { |
978 | 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"); |
@@ -984,7 +1024,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
984 | if (type->attach) { | 1024 | if (type->attach) { |
985 | retval = type->attach(serial); | 1025 | retval = type->attach(serial); |
986 | if (retval < 0) | 1026 | if (retval < 0) |
987 | goto probe_error; | 1027 | goto err_free_epds; |
988 | serial->attached = 1; | 1028 | serial->attached = 1; |
989 | if (retval > 0) { | 1029 | if (retval > 0) { |
990 | /* quietly accept this device, but don't bind to a | 1030 | /* quietly accept this device, but don't bind to a |
@@ -996,9 +1036,10 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
996 | serial->attached = 1; | 1036 | serial->attached = 1; |
997 | } | 1037 | } |
998 | 1038 | ||
999 | if (allocate_minors(serial, num_ports)) { | 1039 | retval = allocate_minors(serial, num_ports); |
1040 | if (retval) { | ||
1000 | dev_err(ddev, "No more free serial minor numbers\n"); | 1041 | dev_err(ddev, "No more free serial minor numbers\n"); |
1001 | goto probe_error; | 1042 | goto err_free_epds; |
1002 | } | 1043 | } |
1003 | 1044 | ||
1004 | /* register all of the individual ports with the driver core */ | 1045 | /* register all of the individual ports with the driver core */ |
@@ -1020,8 +1061,6 @@ exit: | |||
1020 | module_put(type->driver.owner); | 1061 | module_put(type->driver.owner); |
1021 | return 0; | 1062 | return 0; |
1022 | 1063 | ||
1023 | probe_error: | ||
1024 | retval = -EIO; | ||
1025 | err_free_epds: | 1064 | err_free_epds: |
1026 | kfree(epds); | 1065 | kfree(epds); |
1027 | err_put_serial: | 1066 | err_put_serial: |