aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-03-23 17:07:37 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2009-04-03 14:54:27 -0700
commita9ea226670ffe24dd9b2f8ccc0909dfb14e35dd1 (patch)
tree1bcbcf933dfcdbc2a78792e3c5234a359d51f06f /drivers/staging
parent5ca0121ff24d2efba208a0f6df2cb6e372170d1d (diff)
Staging: serqt_usb: Lindent the code
Run Lindent on the code to give us someplace to work from Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/serqt_usb/serqt_usb.c4026
1 files changed, 1945 insertions, 2081 deletions
diff --git a/drivers/staging/serqt_usb/serqt_usb.c b/drivers/staging/serqt_usb/serqt_usb.c
index 7ababa0dfa7..c9a7499c786 100644
--- a/drivers/staging/serqt_usb/serqt_usb.c
+++ b/drivers/staging/serqt_usb/serqt_usb.c
@@ -20,34 +20,31 @@
//#define DEBUG_ON
//#undef dbg
#ifdef DEBUG_ON
- #define mydbg(const...) printk(const)
+#define mydbg(const...) printk(const)
#else
- #define mydbg(const...)
+#define mydbg(const...)
#endif
-
/* parity check flag */
#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
#define SERIAL_TTY_MAJOR 0 /* Nice legal number now */
#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
#define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */
#define PREFUFF_LEVEL_CONSERVATIVE 128
#define ATC_DISABLED 0x00
-#define RR_BITS 0x03 //for clearing clock bits
+#define RR_BITS 0x03 //for clearing clock bits
#define DUPMODE_BITS 0xc0
#define RS232_MODE 0x00
#define RTSCTS_TO_CONNECTOR 0x40
-#define CLKS_X4 0x02 ///
+#define CLKS_X4 0x02 ///
-#define LOOPMODE_BITS 0x41 //LOOP1 = b6, LOOP0 = b0 (PORT B)
+#define LOOPMODE_BITS 0x41 //LOOP1 = b6, LOOP0 = b0 (PORT B)
#define ALL_LOOPBACK 0x01
#define MODEM_CTRL 0x40
-
#define THISCHAR data[i]
#define NEXTCHAR data[i + 1]
#define THIRDCHAR data[i + 2]
@@ -58,7 +55,6 @@
#define FULLPWRBIT 0x00000080
#define NEXT_BOARD_POWER_BIT 0x00000004
-
#define SERIAL_LSR_OE 0x02
#define SERIAL_LSR_PE 0x04
#define SERIAL_LSR_FE 0x08
@@ -76,7 +72,6 @@
#define LINE_STATUS_REGISTER 0x05
#define MODEM_STATUS_REGISTER 0x06
-
#define SERIAL_MCR_DTR 0x01
#define SERIAL_MCR_RTS 0x02
#define SERIAL_MCR_LOOP 0x10
@@ -100,7 +95,6 @@
#define MAX_BAUD_RATE 460800
#define MAX_BAUD_REMAINDER 4608
-
#define QT_SET_GET_DEVICE 0xc2
#define QT_OPEN_CLOSE_CHANNEL 0xca
#define QT_GET_SET_PREBUF_TRIG_LVL 0xcc
@@ -119,8 +113,7 @@
#define SERIALQT_GET_THIS_UNIT _IOR(SERIALQT_PCI_IOC_MAGIC, 3, void *)
#define SERIALQT_READ_QOPR _IOR(SERIALQT_PCI_IOC_MAGIC, 4, int)
#define SERIALQT_READ_QMCR _IOR(SERIALQT_PCI_IOC_MAGIC, 5, int)
-#define SERIALQT_IS422_EXTENDED _IOR(SERIALQT_PCI_IOC_MAGIC, 6, int) //returns successful if 422 extended
-
+#define SERIALQT_IS422_EXTENDED _IOR(SERIALQT_PCI_IOC_MAGIC, 6, int) //returns successful if 422 extended
#define USBD_TRANSFER_DIRECTION_IN 0xc0
#define USBD_TRANSFER_DIRECTION_OUT 0x40
@@ -129,7 +122,7 @@
#define ATC_RTS_ENABLED 0x02
#define ATC_DTR_ENABLED 0x01
-#define RR_BITS 0x03 //for clearing clock bits
+#define RR_BITS 0x03 //for clearing clock bits
#define DUPMODE_BITS 0xc0
#define FULL_DUPLEX 0x00
@@ -147,75 +140,71 @@
#define QMCR_ALL_LOOPBACK 0x10
#define QMCR_MODEM_CONTROL 0X00
-
-
#define SERIALQT_IOC_MAXNR 6
struct usb_serial_port {
- struct usb_serial *serial; /* pointer back to the owner of this port */
- struct tty_struct * tty; /* the coresponding tty for this port */
- unsigned char number;
- char active; /* someone has this device open */
-
- unsigned char * interrupt_in_buffer;
- struct urb * interrupt_in_urb;
- __u8 interrupt_in_endpointAddress;
-
- unsigned char * bulk_in_buffer;
- unsigned char * xfer_to_tty_buffer;
- struct urb * read_urb;
- __u8 bulk_in_endpointAddress;
-
- unsigned char * bulk_out_buffer;
- int bulk_out_size;
- struct urb * write_urb;
- __u8 bulk_out_endpointAddress;
-
- wait_queue_head_t write_wait;
- wait_queue_head_t wait;
- struct work_struct work;
-
- int open_count; /* number of times this port has been opened */
- struct semaphore sem; /* locks this structure */
-
- __u8 shadowLCR; /* last LCR value received */
- __u8 shadowMCR; /* last MCR value received */
- __u8 shadowMSR; /* last MSR value received */
- __u8 shadowLSR; /* last LSR value received */
- int RxHolding;
- char closePending;
- int ReadBulkStopped;
-
- void * private; /* data private to the specific port */
+ struct usb_serial *serial; /* pointer back to the owner of this port */
+ struct tty_struct *tty; /* the coresponding tty for this port */
+ unsigned char number;
+ char active; /* someone has this device open */
+
+ unsigned char *interrupt_in_buffer;
+ struct urb *interrupt_in_urb;
+ __u8 interrupt_in_endpointAddress;
+
+ unsigned char *bulk_in_buffer;
+ unsigned char *xfer_to_tty_buffer;
+ struct urb *read_urb;
+ __u8 bulk_in_endpointAddress;
+
+ unsigned char *bulk_out_buffer;
+ int bulk_out_size;
+ struct urb *write_urb;
+ __u8 bulk_out_endpointAddress;
+
+ wait_queue_head_t write_wait;
+ wait_queue_head_t wait;
+ struct work_struct work;
+
+ int open_count; /* number of times this port has been opened */
+ struct semaphore sem; /* locks this structure */
+
+ __u8 shadowLCR; /* last LCR value received */
+ __u8 shadowMCR; /* last MCR value received */
+ __u8 shadowMSR; /* last MSR value received */
+ __u8 shadowLSR; /* last LSR value received */
+ int RxHolding;
+ char closePending;
+ int ReadBulkStopped;
+
+ void *private; /* data private to the specific port */
};
struct identity {
- int index;
- int n_identity;
+ int index;
+ int n_identity;
};
struct usb_serial {
- struct usb_device * dev;
- struct usb_interface * interface; /* the interface for this device */
- struct tty_driver * tty_driver; /* the tty_driver for this device */
- unsigned char minor; /* the starting minor number for this device */
- unsigned char num_ports; /* the number of ports this device has */
- char num_interrupt_in; /* number of interrupt in endpoints we have */
- char num_bulk_in; /* number of bulk in endpoints we have */
- char num_bulk_out; /* number of bulk out endpoints we have */
- unsigned char num_OpenCount; /* the number of ports this device has */
-
-
- __u16 vendor; /* vendor id of this device */
- __u16 product; /* product id of this device */
- struct usb_serial_port port[MAX_NUM_PORTS];
-
- void * private; /* data private to the specific driver */
+ struct usb_device *dev;
+ struct usb_interface *interface; /* the interface for this device */
+ struct tty_driver *tty_driver; /* the tty_driver for this device */
+ unsigned char minor; /* the starting minor number for this device */
+ unsigned char num_ports; /* the number of ports this device has */
+ char num_interrupt_in; /* number of interrupt in endpoints we have */
+ char num_bulk_in; /* number of bulk in endpoints we have */
+ char num_bulk_out; /* number of bulk out endpoints we have */
+ unsigned char num_OpenCount; /* the number of ports this device has */
+
+ __u16 vendor; /* vendor id of this device */
+ __u16 product; /* product id of this device */
+ struct usb_serial_port port[MAX_NUM_PORTS];
+
+ void *private; /* data private to the specific driver */
};
-
-
-static inline int port_paranoia_check (struct usb_serial_port *port, const char *function)
+static inline int port_paranoia_check(struct usb_serial_port *port,
+ const char *function)
{
if (!port) {
dbg("%s - port == NULL", function);
@@ -233,9 +222,9 @@ static inline int port_paranoia_check (struct usb_serial_port *port, const char
return 0;
}
-
/* Inline functions to check the sanity of a pointer that is passed to us */
-static inline int serial_paranoia_check (struct usb_serial *serial, const char *function)
+static inline int serial_paranoia_check(struct usb_serial *serial,
+ const char *function)
{
if (!serial) {
dbg("%s - serial == NULL\n", function);
@@ -245,13 +234,13 @@ static inline int serial_paranoia_check (struct usb_serial *serial, const char *
return 0;
}
-
-static inline struct usb_serial* get_usb_serial (struct usb_serial_port *port, const char *function)
+static inline struct usb_serial *get_usb_serial(struct usb_serial_port *port,
+ const char *function)
{
/* if no port was specified, or it fails a paranoia check */
if (!port ||
- port_paranoia_check (port, function) ||
- serial_paranoia_check (port->serial, function)) {
+ port_paranoia_check(port, function) ||
+ serial_paranoia_check(port->serial, function)) {
/* then say that we dont have a valid usb_serial thing, which will
* end up genrating -ENODEV return values */
return NULL;
@@ -260,90 +249,99 @@ static inline struct usb_serial* get_usb_serial (struct usb_serial_port *port, c
return port->serial;
}
-
-struct qt_get_device_data
-{
+struct qt_get_device_data {
__u8 porta;
__u8 portb;
__u8 portc;
};
-struct qt_open_channel_data
-{
+struct qt_open_channel_data {
__u8 line_status;
__u8 modem_status;
};
-static void ProcessLineStatus(struct usb_serial_port *port, unsigned char line_status);
-static void ProcessModemStatus(struct usb_serial_port *port, unsigned char modem_status);
+static void ProcessLineStatus(struct usb_serial_port *port,
+ unsigned char line_status);
+static void ProcessModemStatus(struct usb_serial_port *port,
+ unsigned char modem_status);
static void ProcessRxChar(struct usb_serial_port *port, unsigned char Data);
-static struct usb_serial *get_free_serial (int num_ports, int *minor);
-
+static struct usb_serial *get_free_serial(int num_ports, int *minor);
static int serqt_probe(struct usb_interface *interface,
- const struct usb_device_id *id);
-
+ const struct usb_device_id *id);
static void serqt_usb_disconnect(struct usb_interface *interface);
-static int box_set_device(struct usb_serial *serial, struct qt_get_device_data *pDeviceData);
-static int box_get_device(struct usb_serial *serial, struct qt_get_device_data *pDeviceData);
-static int serial_open (struct tty_struct *tty, struct file * filp);
-static void serial_close(struct tty_struct *tty, struct file * filp);
-static int serial_write_room (struct tty_struct *tty);
-static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
-static void serial_set_termios (struct tty_struct *tty, struct ktermios * old);
-static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count);
-
-static void serial_throttle (struct tty_struct * tty);
-static void serial_unthrottle (struct tty_struct * tty);
-static int serial_break (struct tty_struct *tty, int break_state);
-static int serial_chars_in_buffer (struct tty_struct *tty);
-static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data);
-
-static int qt_open (struct usb_serial_port *port, struct file *filp);
+static int box_set_device(struct usb_serial *serial,
+ struct qt_get_device_data *pDeviceData);
+static int box_get_device(struct usb_serial *serial,
+ struct qt_get_device_data *pDeviceData);
+static int serial_open(struct tty_struct *tty, struct file *filp);
+static void serial_close(struct tty_struct *tty, struct file *filp);
+static int serial_write_room(struct tty_struct *tty);
+static int serial_ioctl(struct tty_struct *tty, struct file *file,
+ unsigned int cmd, unsigned long arg);
+static void serial_set_termios(struct tty_struct *tty, struct ktermios *old);
+static int serial_write(struct tty_struct *tty, const unsigned char *buf,
+ int count);
+
+static void serial_throttle(struct tty_struct *tty);
+static void serial_unthrottle(struct tty_struct *tty);
+static int serial_break(struct tty_struct *tty, int break_state);
+static int serial_chars_in_buffer(struct tty_struct *tty);
+static int serial_read_proc(char *page, char **start, off_t off, int count,
+ int *eof, void *data);
+
+static int qt_open(struct usb_serial_port *port, struct file *filp);
static int BoxSetPrebufferLevel(struct usb_serial *serial);
static int BoxSetATC(struct usb_serial *serial, __u16 n_Mode);
-static int BoxSetUart(struct usb_serial *serial, unsigned short Uart_Number, unsigned short default_divisor, unsigned char default_LCR );
-
-
-static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number, __u16 OpenClose, struct qt_open_channel_data *pDeviceData);
-static void qt_close (struct usb_serial_port *port, struct file * filp);
-static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number,unsigned short Register_Num, __u8 *pValue);
-static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number, unsigned short Register_Num, unsigned short Value );
+static int BoxSetUart(struct usb_serial *serial, unsigned short Uart_Number,
+ unsigned short default_divisor,
+ unsigned char default_LCR);
+
+static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number,
+ __u16 OpenClose,
+ struct qt_open_channel_data *pDeviceData);
+static void qt_close(struct usb_serial_port *port, struct file *filp);
+static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number,
+ unsigned short Register_Num, __u8 * pValue);
+static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number,
+ unsigned short Register_Num, unsigned short Value);
static void qt_write_bulk_callback(struct urb *urb);
-static int qt_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int qt_write(struct usb_serial_port *port, int from_user,
+ const unsigned char *buf, int count);
static void port_softint(struct work_struct *work);
-static int qt_write_room (struct usb_serial_port *port);
-static int qt_chars_in_buffer (struct usb_serial_port *port);
-static int qt_ioctl(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void qt_set_termios(struct usb_serial_port *port, struct ktermios *old_termios);
-static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber, int bSet);
+static int qt_write_room(struct usb_serial_port *port);
+static int qt_chars_in_buffer(struct usb_serial_port *port);
+static int qt_ioctl(struct usb_serial_port *port, struct file *file,
+ unsigned int cmd, unsigned long arg);
+static void qt_set_termios(struct usb_serial_port *port,
+ struct ktermios *old_termios);
+static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber,
+ int bSet);
static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber);
static int EmulateWriteQMCR_Reg(int index, unsigned uc_value);
static int EmulateReadQMCR_Reg(int index, unsigned *uc_value);
static struct usb_serial *find_the_box(unsigned int index);
-int ioctl_serial_usb (struct inode *innod, struct file *filp, unsigned int cmd, unsigned long arg);
+int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd,
+ unsigned long arg);
-
-static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 Uart, unsigned char stop_char, unsigned char start_char);
+static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 Uart,
+ unsigned char stop_char, unsigned char start_char);
static void qt_read_bulk_callback(struct urb *urb);
static void port_sofrint(void *private);
static void return_serial(struct usb_serial *serial);
-
-static int serial_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
+static int serial_tiocmset(struct tty_struct *tty, struct file *file,
+ unsigned int set, unsigned int clear);
static int serial_tiocmget(struct tty_struct *tty, struct file *file);
+static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
+ unsigned int value);
-
-static int qt_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int value);
-
-static int qt_tiocmget(struct usb_serial_port *port, struct file * file);
-
-
+static int qt_tiocmget(struct usb_serial_port *port, struct file *file);
/* Version Information */
#define DRIVER_VERSION "v2.14"
@@ -370,34 +368,39 @@ static int qt_tiocmget(struct usb_serial_port *port, struct file * file);
#define DEVICE_ID_QUATECH_RS422_16_PORT_C 0xC0B2 //HSU200C
#define DEVICE_ID_QUATECH_RS422_16_PORT_D 0xC0B3 //HSU200D
-
/* table of Quatech devices */
-static struct usb_device_id serqt_table [] = {
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_SINGLE_PORT)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_SINGLE_PORT)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_DUAL_PORT)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_DUAL_PORT)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_FOUR_PORT)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_FOUR_PORT)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_EIGHT_PORT_A)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_EIGHT_PORT_B)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_EIGHT_PORT_A)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_EIGHT_PORT_B)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_A)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_B)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_C)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_D)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_A)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_B)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_C)},
- { USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_D)},
- {} /* Terminating entry */
+static struct usb_device_id serqt_table[] = {
+ {USB_DEVICE
+ (USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_SINGLE_PORT)},
+ {USB_DEVICE
+ (USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_SINGLE_PORT)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_DUAL_PORT)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_DUAL_PORT)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_FOUR_PORT)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_FOUR_PORT)},
+ {USB_DEVICE
+ (USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_EIGHT_PORT_A)},
+ {USB_DEVICE
+ (USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_EIGHT_PORT_B)},
+ {USB_DEVICE
+ (USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_EIGHT_PORT_A)},
+ {USB_DEVICE
+ (USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_EIGHT_PORT_B)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_A)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_B)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_C)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS232_16_PORT_D)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_A)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_B)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_C)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, DEVICE_ID_QUATECH_RS422_16_PORT_D)},
+ {} /* Terminating entry */
};
+
MODULE_DEVICE_TABLE(usb, serqt_table);
static int major_number;
-static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */
-
+static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */
/* table of Quatech 422devices */
static unsigned int serqt_422_table[] = {
@@ -410,66 +413,64 @@ static unsigned int serqt_422_table[] = {
DEVICE_ID_QUATECH_RS422_16_PORT_B,
DEVICE_ID_QUATECH_RS422_16_PORT_C,
DEVICE_ID_QUATECH_RS422_16_PORT_D,
- 0 /* terminate with zero */
+ 0 /* terminate with zero */
};
-
-
/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver serqt_usb_driver = {
- .name = "quatech-usb-serial",
- .probe = serqt_probe,
- .disconnect = serqt_usb_disconnect,
- .id_table = serqt_table,
+ .name = "quatech-usb-serial",
+ .probe = serqt_probe,
+ .disconnect = serqt_usb_disconnect,
+ .id_table = serqt_table,
};
static struct ktermios *serial_termios[SERIAL_TTY_MINORS];
static struct ktermios *serial_termios_locked[SERIAL_TTY_MINORS];
static const struct tty_operations serial_ops = {
- .open = serial_open,
- .close = serial_close,
- .write = serial_write,
- .write_room = serial_write_room,
- .ioctl = serial_ioctl,
- .set_termios = serial_set_termios,
- .throttle = serial_throttle,
- .unthrottle = serial_unthrottle,
- .break_ctl = serial_break,
- .chars_in_buffer = serial_chars_in_buffer,
- .read_proc = serial_read_proc,
- .tiocmset = serial_tiocmset,
- .tiocmget = serial_tiocmget,
+ .open = serial_open,
+ .close = serial_close,
+ .write = serial_write,
+ .write_room = serial_write_room,
+ .ioctl = serial_ioctl,
+ .set_termios = serial_set_termios,
+ .throttle = serial_throttle,
+ .unthrottle = serial_unthrottle,
+ .break_ctl = serial_break,
+ .chars_in_buffer = serial_chars_in_buffer,
+ .read_proc = serial_read_proc,
+ .tiocmset = serial_tiocmset,
+ .tiocmget = serial_tiocmget,
};
static struct tty_driver serial_tty_driver = {
- .magic = TTY_DRIVER_MAGIC,
- .driver_name = "Quatech usb-serial",
- .name = "ttyQT_USB",
- .major = SERIAL_TTY_MAJOR,
- .minor_start = 0,
- .num = SERIAL_TTY_MINORS,
- .type = TTY_DRIVER_TYPE_SERIAL,
- .subtype = SERIAL_TYPE_NORMAL,
- .flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV,
-
- .termios = serial_termios,
- .termios_locked = serial_termios_locked,
- .init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL,
-
- .init_termios.c_iflag = ICRNL | IXON,
- .init_termios.c_oflag = OPOST,
-
- .init_termios.c_lflag= ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN,
+ .magic = TTY_DRIVER_MAGIC,
+ .driver_name = "Quatech usb-serial",
+ .name = "ttyQT_USB",
+ .major = SERIAL_TTY_MAJOR,
+ .minor_start = 0,
+ .num = SERIAL_TTY_MINORS,
+ .type = TTY_DRIVER_TYPE_SERIAL,
+ .subtype = SERIAL_TYPE_NORMAL,
+ .flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV,
+
+ .termios = serial_termios,
+ .termios_locked = serial_termios_locked,
+ .init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL,
+
+ .init_termios.c_iflag = ICRNL | IXON,
+ .init_termios.c_oflag = OPOST,
+
+ .init_termios.c_lflag =
+ ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN,
};
//fops for parent device
static struct file_operations serialqt_usb_fops = {
- .ioctl = ioctl_serial_usb,
+ .ioctl = ioctl_serial_usb,
};
-
/**
* serqt_probe
*
@@ -478,341 +479,299 @@ static struct file_operations serialqt_usb_fops = {
*
*/
static int serqt_probe(struct usb_interface *interface,
- const struct usb_device_id *id)
+ const struct usb_device_id *id)
{
- struct usb_device *dev = interface_to_usbdev(interface);
- struct usb_serial *serial = NULL;
- struct usb_serial_port *port;
- struct usb_endpoint_descriptor *endpoint;
- struct usb_endpoint_descriptor *interrupt_in_endpoint[MAX_NUM_PORTS];
- struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS];
- struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
- int minor;
- int buffer_size;
- int i;
- struct usb_host_interface *iface_desc;
- int num_interrupt_in = 0;
- int num_bulk_in = 0;
- int num_bulk_out = 0;
- int num_ports;
- struct qt_get_device_data DeviceData;
- int status;
+ struct usb_device *dev = interface_to_usbdev(interface);
+ struct usb_serial *serial = NULL;
+ struct usb_serial_port *port;
+ struct usb_endpoint_descriptor *endpoint;
+ struct usb_endpoint_descriptor *interrupt_in_endpoint[MAX_NUM_PORTS];
+ struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS];
+ struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
+ int minor;
+ int buffer_size;
+ int i;
+ struct usb_host_interface *iface_desc;
+ int num_interrupt_in = 0;
+ int num_bulk_in = 0;
+ int num_bulk_out = 0;
+ int num_ports;
+ struct qt_get_device_data DeviceData;
+ int status;
mydbg("In %s\n", __FUNCTION__);
- /* let's find the endpoints needed */
- /* check out the endpoints */
- iface_desc = interface->cur_altsetting;;
- for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
- {
- endpoint = &iface_desc->endpoint[i].desc;
-
- if ((endpoint->bEndpointAddress & 0x80) &&
- ((endpoint->bmAttributes & 3) == 0x02))
- {
- /* we found a bulk in endpoint */
- mydbg("found bulk in");
- bulk_in_endpoint[num_bulk_in] = endpoint;
- ++num_bulk_in;
- }
-
- if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
- ((endpoint->bmAttributes & 3) == 0x02))
- {
- /* we found a bulk out endpoint */
- mydbg("found bulk out\n");
- bulk_out_endpoint[num_bulk_out] = endpoint;
- ++num_bulk_out;
- }
-
- if ((endpoint->bEndpointAddress & 0x80) &&
- ((endpoint->bmAttributes & 3) == 0x03))
- {
- /* we found a interrupt in endpoint */
- mydbg("found interrupt in\n");
- interrupt_in_endpoint[num_interrupt_in] = endpoint;
- ++num_interrupt_in;
- }
- }
-
- /* found all that we need */
- dev_info(&interface->dev, "Quatech converter detected\n");
- num_ports = num_bulk_out;
- if (num_ports == 0)
- {
- err("Quatech device with no bulk out, not allowed.");
- return -ENODEV;
-
- }
-
- serial = get_free_serial (num_ports, &minor);
- if (serial == NULL)
- {
- err("No more free serial devices");
- return -ENODEV;
- }
-
- serial->dev = dev;
- serial->interface = interface;
- serial->minor = minor;
- serial->num_ports = num_ports;
- serial->num_bulk_in = num_bulk_in;
- serial->num_bulk_out = num_bulk_out;
- serial->num_interrupt_in = num_interrupt_in;
- serial->vendor = dev->descriptor.idVendor;
- serial->product = dev->descriptor.idProduct;
-
-
- /* set up the endpoint information */
- for (i = 0; i < num_bulk_in; ++i)
- {
- endpoint = bulk_in_endpoint[i];
- port = &serial->port[i];
- port->read_urb = usb_alloc_urb (0, GFP_KERNEL);
- if (!port->read_urb)
- {
- err("No free urbs available");
- goto probe_error;
- }
- buffer_size = endpoint->wMaxPacketSize;
- port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
- port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
- port->xfer_to_tty_buffer = kmalloc (buffer_size, GFP_KERNEL);
- if (!port->bulk_in_buffer)
- {
- err("Couldn't allocate bulk_in_buffer");
- goto probe_error;
- }
- usb_fill_bulk_urb (port->read_urb, dev,
- usb_rcvbulkpipe (dev,
- endpoint->bEndpointAddress),
- port->bulk_in_buffer, buffer_size,
- qt_read_bulk_callback,
- port);
- }
-
- for (i = 0; i < num_bulk_out; ++i)
- {
- endpoint = bulk_out_endpoint[i];
- port = &serial->port[i];
- port->write_urb = usb_alloc_urb (0, GFP_KERNEL);
- if (!port->write_urb)
- {
- err("No free urbs available");
- goto probe_error;
- }
- buffer_size = endpoint->wMaxPacketSize;
- port->bulk_out_size = buffer_size;
- port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
- port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
- if (!port->bulk_out_buffer)
- {
- err("Couldn't allocate bulk_out_buffer");
- goto probe_error;
- }
- usb_fill_bulk_urb (port->write_urb, dev,
- usb_sndbulkpipe (dev,
- endpoint->bEndpointAddress),
- port->bulk_out_buffer, buffer_size,
- qt_write_bulk_callback,
- port);
-
-
- }
-
- //For us numb of bulkin or out = number of ports
-
- mydbg("%s - setting up %d port structures for this device\n", __FUNCTION__, num_bulk_in);
- for (i = 0; i < num_bulk_in; ++i)
- {
- port = &serial->port[i];
- port->number = i + serial->minor;
- port->serial = serial;
-
- INIT_WORK(&port->work, port_softint);
-
- init_MUTEX (&port->sem);
-
-
-
- }
- status = box_get_device(serial, &DeviceData);
- if (status < 0)
- {
- mydbg(__FILE__"box_get_device failed");
- goto probe_error;
- }
-
- mydbg(__FILE__"DeviceData.portb = 0x%x",DeviceData.portb);
-
- DeviceData.portb &= ~FULLPWRBIT;
- mydbg(__FILE__"Changing DeviceData.portb to 0x%x",DeviceData.portb);
-
- status = box_set_device(serial, &DeviceData);
- if (status < 0)
- {
- mydbg(__FILE__"box_set_device failed\n");
- goto probe_error;
- }
-
-
-
- /* initialize the devfs nodes for this device and let the user know what ports we are bound to */
- for (i = 0; i < serial->num_ports; ++i)
- {
- dev_info(&interface->dev, "Converter now attached to ttyUSB%d (or usb/tts/%d for devfs)",
- serial->port[i].number, serial->port[i].number);
- }
+ /* let's find the endpoints needed */
+ /* check out the endpoints */
+ iface_desc = interface->cur_altsetting;;
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
+ endpoint = &iface_desc->endpoint[i].desc;
+
+ if ((endpoint->bEndpointAddress & 0x80) &&
+ ((endpoint->bmAttributes & 3) == 0x02)) {
+ /* we found a bulk in endpoint */
+ mydbg("found bulk in");
+ bulk_in_endpoint[num_bulk_in] = endpoint;
+ ++num_bulk_in;
+ }
+
+ if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
+ ((endpoint->bmAttributes & 3) == 0x02)) {
+ /* we found a bulk out endpoint */
+ mydbg("found bulk out\n");
+ bulk_out_endpoint[num_bulk_out] = endpoint;
+ ++num_bulk_out;
+ }
+
+ if ((endpoint->bEndpointAddress & 0x80) &&
+ ((endpoint->bmAttributes & 3) == 0x03)) {
+ /* we found a interrupt in endpoint */
+ mydbg("found interrupt in\n");
+ interrupt_in_endpoint[num_interrupt_in] = endpoint;
+ ++num_interrupt_in;
+ }
+ }
+
+ /* found all that we need */
+ dev_info(&interface->dev, "Quatech converter detected\n");
+ num_ports = num_bulk_out;
+ if (num_ports == 0) {
+ err("Quatech device with no bulk out, not allowed.");
+ return -ENODEV;
+
+ }
+
+ serial = get_free_serial(num_ports, &minor);
+ if (serial == NULL) {
+ err("No more free serial devices");
+ return -ENODEV;
+ }
+
+ serial->dev = dev;
+ serial->interface = interface;
+ serial->minor = minor;
+ serial->num_ports = num_ports;
+ serial->num_bulk_in = num_bulk_in;
+ serial->num_bulk_out = num_bulk_out;
+ serial->num_interrupt_in = num_interrupt_in;
+ serial->vendor = dev->descriptor.idVendor;
+ serial->product = dev->descriptor.idProduct;
+
+ /* set up the endpoint information */
+ for (i = 0; i < num_bulk_in; ++i) {
+ endpoint = bulk_in_endpoint[i];
+ port = &serial->port[i];
+ port->read_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!port->read_urb) {
+ err("No free urbs available");
+ goto probe_error;
+ }
+ buffer_size = endpoint->wMaxPacketSize;
+ port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
+ port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
+ port->xfer_to_tty_buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (!port->bulk_in_buffer) {
+ err("Couldn't allocate bulk_in_buffer");
+ goto probe_error;
+ }
+ usb_fill_bulk_urb(port->read_urb, dev,
+ usb_rcvbulkpipe(dev,
+ endpoint->bEndpointAddress),
+ port->bulk_in_buffer, buffer_size,
+ qt_read_bulk_callback, port);
+ }
+
+ for (i = 0; i < num_bulk_out; ++i) {
+ endpoint = bulk_out_endpoint[i];
+ port = &serial->port[i];
+ port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!port->write_urb) {
+ err("No free urbs available");
+ goto probe_error;
+ }
+ buffer_size = endpoint->wMaxPacketSize;
+ port->bulk_out_size = buffer_size;
+ port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
+ port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (!port->bulk_out_buffer) {
+ err("Couldn't allocate bulk_out_buffer");
+ goto probe_error;
+ }
+ usb_fill_bulk_urb(port->write_urb, dev,
+ usb_sndbulkpipe(dev,
+ endpoint->bEndpointAddress),
+ port->bulk_out_buffer, buffer_size,
+ qt_write_bulk_callback, port);
+
+ }
+
+ //For us numb of bulkin or out = number of ports
+
+ mydbg("%s - setting up %d port structures for this device\n",
+ __FUNCTION__, num_bulk_in);
+ for (i = 0; i < num_bulk_in; ++i) {
+ port = &serial->port[i];
+ port->number = i + serial->minor;
+ port->serial = serial;
+
+ INIT_WORK(&port->work, port_softint);
+
+ init_MUTEX(&port->sem);
+
+ }
+ status = box_get_device(serial, &DeviceData);
+ if (status < 0) {
+ mydbg(__FILE__ "box_get_device failed");
+ goto probe_error;
+ }
+
+ mydbg(__FILE__ "DeviceData.portb = 0x%x", DeviceData.portb);
+
+ DeviceData.portb &= ~FULLPWRBIT;
+ mydbg(__FILE__ "Changing DeviceData.portb to 0x%x", DeviceData.portb);
+
+ status = box_set_device(serial, &DeviceData);
+ if (status < 0) {
+ mydbg(__FILE__ "box_set_device failed\n");
+ goto probe_error;
+ }
+
+ /* initialize the devfs nodes for this device and let the user know what ports we are bound to */
+ for (i = 0; i < serial->num_ports; ++i) {
+ dev_info(&interface->dev,
+ "Converter now attached to ttyUSB%d (or usb/tts/%d for devfs)",
+ serial->port[i].number, serial->port[i].number);
+ }
//usb_serial_console_init (debug, minor);
- ///***********TAG add start next board here ****///
- status = box_get_device(serial, &DeviceData);
- if (status < 0)
- {
- mydbg(__FILE__"box_get_device failed");
- goto probe_error;
- }
-
- //*****************and before we power up lets initialiaze parnent device stuff here before
- //*****************we set thmem via any other method such as the property pages
- switch (serial->product)
- {
- case DEVICE_ID_QUATECH_RS232_SINGLE_PORT:
- case DEVICE_ID_QUATECH_RS232_DUAL_PORT:
- case DEVICE_ID_QUATECH_RS232_FOUR_PORT:
- case DEVICE_ID_QUATECH_RS232_EIGHT_PORT_A:
- case DEVICE_ID_QUATECH_RS232_EIGHT_PORT_B:
- case DEVICE_ID_QUATECH_RS232_16_PORT_A:
- case DEVICE_ID_QUATECH_RS232_16_PORT_B:
- case DEVICE_ID_QUATECH_RS232_16_PORT_C:
- case DEVICE_ID_QUATECH_RS232_16_PORT_D:
- DeviceData.porta &= ~(RR_BITS | DUPMODE_BITS);
- DeviceData.porta |= CLKS_X4;
- DeviceData.portb &= ~(LOOPMODE_BITS);
- DeviceData.portb |= RS232_MODE;
- break;
-
-
- case DEVICE_ID_QUATECH_RS422_SINGLE_PORT:
- case DEVICE_ID_QUATECH_RS422_DUAL_PORT:
- case DEVICE_ID_QUATECH_RS422_FOUR_PORT:
- case DEVICE_ID_QUATECH_RS422_EIGHT_PORT_A:
- case DEVICE_ID_QUATECH_RS422_EIGHT_PORT_B:
- case DEVICE_ID_QUATECH_RS422_16_PORT_A:
- case DEVICE_ID_QUATECH_RS422_16_PORT_B:
- case DEVICE_ID_QUATECH_RS422_16_PORT_C:
- case DEVICE_ID_QUATECH_RS422_16_PORT_D:
- DeviceData.porta &= ~(RR_BITS | DUPMODE_BITS);
- DeviceData.porta |= CLKS_X4;
- DeviceData.portb &= ~(LOOPMODE_BITS);
- DeviceData.portb |= ALL_LOOPBACK;
- break;
- default:
- DeviceData.porta &= ~(RR_BITS | DUPMODE_BITS);
- DeviceData.porta |= CLKS_X4;
- DeviceData.portb &= ~(LOOPMODE_BITS);
- DeviceData.portb |= RS232_MODE;
- break;
-
- }
- status = BoxSetPrebufferLevel(serial); //sets to default vaue
- if (status < 0)
- {
- mydbg(__FILE__"BoxSetPrebufferLevel failed\n");
- goto probe_error;
- }
-
- status = BoxSetATC(serial, ATC_DISABLED);
- if (status < 0)
- {
- mydbg(__FILE__"BoxSetATC failed\n");
- goto probe_error;
- }
- //****************************************************************************
- mydbg(__FILE__"DeviceData.portb = 0x%x",DeviceData.portb);
-
-