aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/usbtmc.c
diff options
context:
space:
mode:
authorGuido Kiener <guido@kiener-muenchen.de>2018-05-17 13:03:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-18 09:56:40 -0400
commitbaf12d6ddeae74dfcfd5d19fce86260a2e1e44f2 (patch)
tree2239b7fc7188a9bc31b8e3b928945bc0223cc4d4 /drivers/usb/class/usbtmc.c
parent58318cd4df415aaeaad1a7306cf1d35dad9a21c3 (diff)
usb: usbtmc: Remove rigol_quirk
All T&M instruments should also work with rigol_quirk = 1 code path. So remove unnecessary code in rigol_quirk = 0 code path to simplify the driver. Tested-by: Dave Penkler <dpenkler@gmail.com> Reviewed-by: Steve Bayless <steve_bayless@keysight.com> Signed-off-by: Guido Kiener <guido.kiener@rohde-schwarz.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/class/usbtmc.c')
-rw-r--r--drivers/usb/class/usbtmc.c81
1 files changed, 12 insertions, 69 deletions
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index bdb1de0c0cef..529295a17579 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -21,7 +21,6 @@
21#include <linux/usb/tmc.h> 21#include <linux/usb/tmc.h>
22 22
23 23
24#define RIGOL 1
25#define USBTMC_HEADER_SIZE 12 24#define USBTMC_HEADER_SIZE 12
26#define USBTMC_MINOR_BASE 176 25#define USBTMC_MINOR_BASE 176
27 26
@@ -93,8 +92,6 @@ struct usbtmc_device_data {
93 /* coalesced usb488_caps from usbtmc_dev_capabilities */ 92 /* coalesced usb488_caps from usbtmc_dev_capabilities */
94 __u8 usb488_caps; 93 __u8 usb488_caps;
95 94
96 u8 rigol_quirk;
97
98 /* attributes from the USB TMC spec for this device */ 95 /* attributes from the USB TMC spec for this device */
99 u8 TermChar; 96 u8 TermChar;
100 bool TermCharEnabled; 97 bool TermCharEnabled;
@@ -110,17 +107,6 @@ struct usbtmc_device_data {
110}; 107};
111#define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref) 108#define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref)
112 109
113struct usbtmc_ID_rigol_quirk {
114 __u16 idVendor;
115 __u16 idProduct;
116};
117
118static const struct usbtmc_ID_rigol_quirk usbtmc_id_quirk[] = {
119 { 0x1ab1, 0x0588 },
120 { 0x1ab1, 0x04b0 },
121 { 0, 0 }
122};
123
124/* Forward declarations */ 110/* Forward declarations */
125static struct usb_driver usbtmc_driver; 111static struct usb_driver usbtmc_driver;
126 112
@@ -603,16 +589,14 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
603 goto exit; 589 goto exit;
604 } 590 }
605 591
606 if (data->rigol_quirk) { 592 dev_dbg(dev, "usb_bulk_msg_in: count(%zu)\n", count);
607 dev_dbg(dev, "usb_bulk_msg_in: count(%zu)\n", count);
608 593
609 retval = send_request_dev_dep_msg_in(data, count); 594 retval = send_request_dev_dep_msg_in(data, count);
610 595
611 if (retval < 0) { 596 if (retval < 0) {
612 if (data->auto_abort) 597 if (data->auto_abort)
613 usbtmc_ioctl_abort_bulk_out(data); 598 usbtmc_ioctl_abort_bulk_out(data);
614 goto exit; 599 goto exit;
615 }
616 } 600 }
617 601
618 /* Loop until we have fetched everything we requested */ 602 /* Loop until we have fetched everything we requested */
@@ -621,23 +605,6 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
621 done = 0; 605 done = 0;
622 606
623 while (remaining > 0) { 607 while (remaining > 0) {
624 if (!data->rigol_quirk) {
625 dev_dbg(dev, "usb_bulk_msg_in: remaining(%zu), count(%zu)\n", remaining, count);
626
627 if (remaining > USBTMC_SIZE_IOBUFFER - USBTMC_HEADER_SIZE - 3)
628 this_part = USBTMC_SIZE_IOBUFFER - USBTMC_HEADER_SIZE - 3;
629 else
630 this_part = remaining;
631
632 retval = send_request_dev_dep_msg_in(data, this_part);
633 if (retval < 0) {
634 dev_err(dev, "usb_bulk_msg returned %d\n", retval);
635 if (data->auto_abort)
636 usbtmc_ioctl_abort_bulk_out(data);
637 goto exit;
638 }
639 }
640
641 /* Send bulk URB */ 608 /* Send bulk URB */
642 retval = usb_bulk_msg(data->usb_dev, 609 retval = usb_bulk_msg(data->usb_dev,
643 usb_rcvbulkpipe(data->usb_dev, 610 usb_rcvbulkpipe(data->usb_dev,
@@ -658,7 +625,7 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
658 } 625 }
659 626
660 /* Parse header in first packet */ 627 /* Parse header in first packet */
661 if ((done == 0) || !data->rigol_quirk) { 628 if (done == 0) {
662 /* Sanity checks for the header */ 629 /* Sanity checks for the header */
663 if (actual < USBTMC_HEADER_SIZE) { 630 if (actual < USBTMC_HEADER_SIZE) {
664 dev_err(dev, "Device sent too small first packet: %u < %u\n", actual, USBTMC_HEADER_SIZE); 631 dev_err(dev, "Device sent too small first packet: %u < %u\n", actual, USBTMC_HEADER_SIZE);
@@ -698,20 +665,11 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
698 actual -= USBTMC_HEADER_SIZE; 665 actual -= USBTMC_HEADER_SIZE;
699 666
700 /* Check if the message is smaller than requested */ 667 /* Check if the message is smaller than requested */
701 if (data->rigol_quirk) { 668 if (remaining > n_characters)
702 if (remaining > n_characters) 669 remaining = n_characters;
703 remaining = n_characters; 670 /* Remove padding if it exists */
704 /* Remove padding if it exists */ 671 if (actual > remaining)
705 if (actual > remaining) 672 actual = remaining;
706 actual = remaining;
707 }
708 else {
709 if (this_part > n_characters)
710 this_part = n_characters;
711 /* Remove padding if it exists */
712 if (actual > this_part)
713 actual = this_part;
714 }
715 673
716 dev_dbg(dev, "Bulk-IN header: N_characters(%u), bTransAttr(%u)\n", n_characters, buffer[8]); 674 dev_dbg(dev, "Bulk-IN header: N_characters(%u), bTransAttr(%u)\n", n_characters, buffer[8]);
717 675
@@ -1365,7 +1323,6 @@ static int usbtmc_probe(struct usb_interface *intf,
1365 struct usbtmc_device_data *data; 1323 struct usbtmc_device_data *data;
1366 struct usb_host_interface *iface_desc; 1324 struct usb_host_interface *iface_desc;
1367 struct usb_endpoint_descriptor *bulk_in, *bulk_out, *int_in; 1325 struct usb_endpoint_descriptor *bulk_in, *bulk_out, *int_in;
1368 int n;
1369 int retcode; 1326 int retcode;
1370 1327
1371 dev_dbg(&intf->dev, "%s called\n", __func__); 1328 dev_dbg(&intf->dev, "%s called\n", __func__);
@@ -1385,20 +1342,6 @@ static int usbtmc_probe(struct usb_interface *intf,
1385 atomic_set(&data->srq_asserted, 0); 1342 atomic_set(&data->srq_asserted, 0);
1386 data->zombie = 0; 1343 data->zombie = 0;
1387 1344
1388 /* Determine if it is a Rigol or not */
1389 data->rigol_quirk = 0;
1390 dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk\n",
1391 le16_to_cpu(data->usb_dev->descriptor.idVendor),
1392 le16_to_cpu(data->usb_dev->descriptor.idProduct));
1393 for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) {
1394 if ((usbtmc_id_quirk[n].idVendor == le16_to_cpu(data->usb_dev->descriptor.idVendor)) &&
1395 (usbtmc_id_quirk[n].idProduct == le16_to_cpu(data->usb_dev->descriptor.idProduct))) {
1396 dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk\n");
1397 data->rigol_quirk = 1;
1398 break;
1399 }
1400 }
1401
1402 /* Initialize USBTMC bTag and other fields */ 1345 /* Initialize USBTMC bTag and other fields */
1403 data->bTag = 1; 1346 data->bTag = 1;
1404 data->TermCharEnabled = 0; 1347 data->TermCharEnabled = 0;