// SPDX-License-Identifier: GPL-2.0+
/**
* drivers/usb/class/usbtmc.c - USB Test & Measurement class driver
*
* Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/kref.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/mutex.h>
#include <linux/usb.h>
#include <linux/usb/tmc.h>
#define RIGOL 1
#define USBTMC_HEADER_SIZE 12
#define USBTMC_MINOR_BASE 176
/*
* Size of driver internal IO buffer. Must be multiple of 4 and at least as
* large as wMaxPacketSize (which is usually 512 bytes).
*/
#define USBTMC_SIZE_IOBUFFER 2048
/* Default USB timeout (in milliseconds) */
#define USBTMC_TIMEOUT 5000
/*
* Maximum number of read cycles to empty bulk in endpoint during CLEAR and
* ABORT_BULK_IN requests. Ends the loop if (for whatever reason) a short
* packet is never read.
*/
#define USBTMC_MAX_READS_TO_CLEAR_BULK_IN 100
static const struct usb_device_id usbtmc_devices[] = {
{