aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-04 21:03:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-04 21:03:51 -0400
commit8f28472a739e8e39adc6e64ee5b460df039f0e4f (patch)
tree979e35f3d1d2be94c06c942bcdc9ee68cbebaacb /tools
parent4ac4d584886a4f47f8ff3bca0f32ff9a2987d3e5 (diff)
parentc034a43e72dda58e4a184d71f5502ef356e04453 (diff)
Merge tag 'usb-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH: "Here is the big USB patchset for 4.12-rc1. Lots of good stuff here, after many many many attempts, the kernel finally has a working typeC interface, many thanks to Heikki and Guenter and others who have taken the time to get this merged. It wasn't an easy path for them at all. There's also a staging driver that uses this new api, which is why it's coming in through this tree. Along with that, there's the usual huge number of changes for gadget drivers, xhci, and other stuff. Johan also finally refactored pretty much every driver that was looking at USB endpoints to do it in a common way, which will help prevent any "badly-formed" devices from causing problems in drivers. That too wasn't a simple task. All of these have been in linux-next for a while with no reported issues" * tag 'usb-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits) staging: typec: Fairchild FUSB302 Type-c chip driver staging: typec: Type-C Port Controller Interface driver (tcpci) staging: typec: USB Type-C Port Manager (tcpm) usb: host: xhci: remove #ifdef around PM functions usb: musb: don't mark of_dev_auxdata as initdata usb: misc: legousbtower: Fix buffers on stack USB: Revert "cdc-wdm: fix "out-of-sync" due to missing notifications" usb: Make sure usb/phy/of gets built-in USB: storage: e-mail update in drivers/usb/storage/unusual_devs.h usb: host: xhci: print correct command ring address usb: host: xhci: delete sp_dma_buffers for scratchpad usb: host: xhci: using correct specification chapter reference for DCBAAP xhci: switch to pci_alloc_irq_vectors usb: host: xhci-plat: set resume_quirk() for R-Car controllers usb: host: xhci-plat: add resume_quirk() usb: host: xhci-plat: enable clk in resume timing usb: host: plat: Enable xHCI plat runtime PM USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit USB: serial: constify static arrays usb: fix some references for /proc/bus/usb ...
Diffstat (limited to 'tools')
-rw-r--r--tools/usb/.gitignore2
-rw-r--r--tools/usb/usbip/README2
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.c9
-rw-r--r--tools/usb/usbip/libsrc/usbip_host_common.c28
-rw-r--r--tools/usb/usbip/libsrc/vhci_driver.c28
-rw-r--r--tools/usb/usbip/src/usbip.c2
6 files changed, 41 insertions, 30 deletions
diff --git a/tools/usb/.gitignore b/tools/usb/.gitignore
new file mode 100644
index 000000000000..1b7448981435
--- /dev/null
+++ b/tools/usb/.gitignore
@@ -0,0 +1,2 @@
1ffs-test
2testusb
diff --git a/tools/usb/usbip/README b/tools/usb/usbip/README
index 5eb2b6c7722b..7844490fc603 100644
--- a/tools/usb/usbip/README
+++ b/tools/usb/usbip/README
@@ -244,7 +244,7 @@ Detach the imported device:
244 - See 'Debug Tips' on the project wiki. 244 - See 'Debug Tips' on the project wiki.
245 - http://usbip.wiki.sourceforge.net/how-to-debug-usbip 245 - http://usbip.wiki.sourceforge.net/how-to-debug-usbip
246 - usbip-host.ko must be bound to the target device. 246 - usbip-host.ko must be bound to the target device.
247 - See /proc/bus/usb/devices and find "Driver=..." lines of the device. 247 - See /sys/kernel/debug/usb/devices and find "Driver=..." lines of the device.
248 - Target USB gadget must be bound to vudc 248 - Target USB gadget must be bound to vudc
249 (using USB gadget susbsys, not usbip bind command) 249 (using USB gadget susbsys, not usbip bind command)
250 - Shutdown firewall. 250 - Shutdown firewall.
diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index ac73710473de..1517a232ab18 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -215,9 +215,16 @@ int read_usb_interface(struct usbip_usb_device *udev, int i,
215 struct usbip_usb_interface *uinf) 215 struct usbip_usb_interface *uinf)
216{ 216{
217 char busid[SYSFS_BUS_ID_SIZE]; 217 char busid[SYSFS_BUS_ID_SIZE];
218 int size;
218 struct udev_device *sif; 219 struct udev_device *sif;
219 220
220 sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i); 221 size = snprintf(busid, sizeof(busid), "%s:%d.%d",
222 udev->busid, udev->bConfigurationValue, i);
223 if (size < 0 || (unsigned int)size >= sizeof(busid)) {
224 err("busid length %i >= %lu or < 0", size,
225 (long unsigned)sizeof(busid));
226 return -1;
227 }
221 228
222 sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid); 229 sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid);
223 if (!sif) { 230 if (!sif) {
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
index 9d415228883d..6ff7b601f854 100644
--- a/tools/usb/usbip/libsrc/usbip_host_common.c
+++ b/tools/usb/usbip/libsrc/usbip_host_common.c
@@ -40,13 +40,20 @@ struct udev *udev_context;
40static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) 40static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
41{ 41{
42 char status_attr_path[SYSFS_PATH_MAX]; 42 char status_attr_path[SYSFS_PATH_MAX];
43 int size;
43 int fd; 44 int fd;
44 int length; 45 int length;
45 char status; 46 char status;
46 int value = 0; 47 int value = 0;
47 48
48 snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status", 49 size = snprintf(status_attr_path, sizeof(status_attr_path),
49 udev->path); 50 "%s/usbip_status", udev->path);
51 if (size < 0 || (unsigned int)size >= sizeof(status_attr_path)) {
52 err("usbip_status path length %i >= %lu or < 0", size,
53 (long unsigned)sizeof(status_attr_path));
54 return -1;
55 }
56
50 57
51 fd = open(status_attr_path, O_RDONLY); 58 fd = open(status_attr_path, O_RDONLY);
52 if (fd < 0) { 59 if (fd < 0) {
@@ -218,6 +225,7 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
218{ 225{
219 char attr_name[] = "usbip_sockfd"; 226 char attr_name[] = "usbip_sockfd";
220 char sockfd_attr_path[SYSFS_PATH_MAX]; 227 char sockfd_attr_path[SYSFS_PATH_MAX];
228 int size;
221 char sockfd_buff[30]; 229 char sockfd_buff[30];
222 int ret; 230 int ret;
223 231
@@ -237,10 +245,20 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
237 } 245 }
238 246
239 /* only the first interface is true */ 247 /* only the first interface is true */
240 snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 248 size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s",
241 edev->udev.path, attr_name); 249 edev->udev.path, attr_name);
250 if (size < 0 || (unsigned int)size >= sizeof(sockfd_attr_path)) {
251 err("exported device path length %i >= %lu or < 0", size,
252 (long unsigned)sizeof(sockfd_attr_path));
253 return -1;
254 }
242 255
243 snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 256 size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
257 if (size < 0 || (unsigned int)size >= sizeof(sockfd_buff)) {
258 err("socket length %i >= %lu or < 0", size,
259 (long unsigned)sizeof(sockfd_buff));
260 return -1;
261 }
244 262
245 ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff, 263 ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff,
246 strlen(sockfd_buff)); 264 strlen(sockfd_buff));
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index ad9204773533..f659c146cdc8 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -123,33 +123,15 @@ static int refresh_imported_device_list(void)
123 123
124static int get_nports(void) 124static int get_nports(void)
125{ 125{
126 char *c; 126 const char *attr_nports;
127 int nports = 0;
128 const char *attr_status;
129 127
130 attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device, 128 attr_nports = udev_device_get_sysattr_value(vhci_driver->hc_device, "nports");
131 "status"); 129 if (!attr_nports) {
132 if (!attr_status) { 130 err("udev_device_get_sysattr_value nports failed");
133 err("udev_device_get_sysattr_value failed");
134 return -1; 131 return -1;
135 } 132 }
136 133
137 /* skip a header line */ 134 return (int)strtoul(attr_nports, NULL, 10);
138 c = strchr(attr_status, '\n');
139 if (!c)
140 return 0;
141 c++;
142
143 while (*c != '\0') {
144 /* go to the next line */
145 c = strchr(c, '\n');
146 if (!c)
147 return nports;
148 c++;
149 nports += 1;
150 }
151
152 return nports;
153} 135}
154 136
155/* 137/*
diff --git a/tools/usb/usbip/src/usbip.c b/tools/usb/usbip/src/usbip.c
index d7599d943529..73d8eee8130b 100644
--- a/tools/usb/usbip/src/usbip.c
+++ b/tools/usb/usbip/src/usbip.c
@@ -176,6 +176,8 @@ int main(int argc, char *argv[])
176 break; 176 break;
177 case '?': 177 case '?':
178 printf("usbip: invalid option\n"); 178 printf("usbip: invalid option\n");
179 /* Terminate after printing error */
180 /* FALLTHRU */
179 default: 181 default:
180 usbip_usage(); 182 usbip_usage();
181 goto out; 183 goto out;