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>
This commit is contained in:
parent
58318cd4df
commit
baf12d6dde
|
@ -21,7 +21,6 @@
|
|||
#include <linux/usb/tmc.h>
|
||||
|
||||
|
||||
#define RIGOL 1
|
||||
#define USBTMC_HEADER_SIZE 12
|
||||
#define USBTMC_MINOR_BASE 176
|
||||
|
||||
|
@ -93,8 +92,6 @@ struct usbtmc_device_data {
|
|||
/* coalesced usb488_caps from usbtmc_dev_capabilities */
|
||||
__u8 usb488_caps;
|
||||
|
||||
u8 rigol_quirk;
|
||||
|
||||
/* attributes from the USB TMC spec for this device */
|
||||
u8 TermChar;
|
||||
bool TermCharEnabled;
|
||||
|
@ -110,17 +107,6 @@ struct usbtmc_device_data {
|
|||
};
|
||||
#define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref)
|
||||
|
||||
struct usbtmc_ID_rigol_quirk {
|
||||
__u16 idVendor;
|
||||
__u16 idProduct;
|
||||
};
|
||||
|
||||
static const struct usbtmc_ID_rigol_quirk usbtmc_id_quirk[] = {
|
||||
{ 0x1ab1, 0x0588 },
|
||||
{ 0x1ab1, 0x04b0 },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
static struct usb_driver usbtmc_driver;
|
||||
|
||||
|
@ -603,7 +589,6 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (data->rigol_quirk) {
|
||||
dev_dbg(dev, "usb_bulk_msg_in: count(%zu)\n", count);
|
||||
|
||||
retval = send_request_dev_dep_msg_in(data, count);
|
||||
|
@ -613,7 +598,6 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
|
|||
usbtmc_ioctl_abort_bulk_out(data);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop until we have fetched everything we requested */
|
||||
remaining = count;
|
||||
|
@ -621,23 +605,6 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
|
|||
done = 0;
|
||||
|
||||
while (remaining > 0) {
|
||||
if (!data->rigol_quirk) {
|
||||
dev_dbg(dev, "usb_bulk_msg_in: remaining(%zu), count(%zu)\n", remaining, count);
|
||||
|
||||
if (remaining > USBTMC_SIZE_IOBUFFER - USBTMC_HEADER_SIZE - 3)
|
||||
this_part = USBTMC_SIZE_IOBUFFER - USBTMC_HEADER_SIZE - 3;
|
||||
else
|
||||
this_part = remaining;
|
||||
|
||||
retval = send_request_dev_dep_msg_in(data, this_part);
|
||||
if (retval < 0) {
|
||||
dev_err(dev, "usb_bulk_msg returned %d\n", retval);
|
||||
if (data->auto_abort)
|
||||
usbtmc_ioctl_abort_bulk_out(data);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Send bulk URB */
|
||||
retval = usb_bulk_msg(data->usb_dev,
|
||||
usb_rcvbulkpipe(data->usb_dev,
|
||||
|
@ -658,7 +625,7 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
|
|||
}
|
||||
|
||||
/* Parse header in first packet */
|
||||
if ((done == 0) || !data->rigol_quirk) {
|
||||
if (done == 0) {
|
||||
/* Sanity checks for the header */
|
||||
if (actual < USBTMC_HEADER_SIZE) {
|
||||
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,
|
|||
actual -= USBTMC_HEADER_SIZE;
|
||||
|
||||
/* Check if the message is smaller than requested */
|
||||
if (data->rigol_quirk) {
|
||||
if (remaining > n_characters)
|
||||
remaining = n_characters;
|
||||
/* Remove padding if it exists */
|
||||
if (actual > remaining)
|
||||
actual = remaining;
|
||||
}
|
||||
else {
|
||||
if (this_part > n_characters)
|
||||
this_part = n_characters;
|
||||
/* Remove padding if it exists */
|
||||
if (actual > this_part)
|
||||
actual = this_part;
|
||||
}
|
||||
|
||||
dev_dbg(dev, "Bulk-IN header: N_characters(%u), bTransAttr(%u)\n", n_characters, buffer[8]);
|
||||
|
||||
|
@ -1365,7 +1323,6 @@ static int usbtmc_probe(struct usb_interface *intf,
|
|||
struct usbtmc_device_data *data;
|
||||
struct usb_host_interface *iface_desc;
|
||||
struct usb_endpoint_descriptor *bulk_in, *bulk_out, *int_in;
|
||||
int n;
|
||||
int retcode;
|
||||
|
||||
dev_dbg(&intf->dev, "%s called\n", __func__);
|
||||
|
@ -1385,20 +1342,6 @@ static int usbtmc_probe(struct usb_interface *intf,
|
|||
atomic_set(&data->srq_asserted, 0);
|
||||
data->zombie = 0;
|
||||
|
||||
/* Determine if it is a Rigol or not */
|
||||
data->rigol_quirk = 0;
|
||||
dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk\n",
|
||||
le16_to_cpu(data->usb_dev->descriptor.idVendor),
|
||||
le16_to_cpu(data->usb_dev->descriptor.idProduct));
|
||||
for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) {
|
||||
if ((usbtmc_id_quirk[n].idVendor == le16_to_cpu(data->usb_dev->descriptor.idVendor)) &&
|
||||
(usbtmc_id_quirk[n].idProduct == le16_to_cpu(data->usb_dev->descriptor.idProduct))) {
|
||||
dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk\n");
|
||||
data->rigol_quirk = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize USBTMC bTag and other fields */
|
||||
data->bTag = 1;
|
||||
data->TermCharEnabled = 0;
|
||||
|
|
Loading…
Reference in a new issue