| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#include <linux/kernel.h> |
| 16 |
#include <linux/errno.h> |
| 17 |
#include <linux/slab.h> |
| 18 |
#include <linux/tty.h> |
| 19 |
#include <linux/tty_driver.h> |
| 20 |
#include <linux/tty_flip.h> |
| 21 |
#include <linux/module.h> |
| 22 |
#include <linux/spinlock.h> |
| 23 |
#include <linux/uaccess.h> |
| 24 |
#include <linux/usb.h> |
| 25 |
#include <linux/usb/serial.h> |
| 26 |
|
| 27 |
#define DRIVER_AUTHOR "Greg Kroah-Hartman <[email protected]>, Gary Brubaker <[email protected]>" |
| 28 |
#define DRIVER_DESC "USB Empeg Mark I/II Driver" |
| 29 |
|
| 30 |
#define EMPEG_VENDOR_ID 0x084f |
| 31 |
#define EMPEG_PRODUCT_ID 0x0001 |
| 32 |
|
| 33 |
|
| 34 |
static int empeg_startup(struct usb_serial *serial); |
| 35 |
static void empeg_init_termios(struct tty_struct *tty); |
| 36 |
|
| 37 |
static const struct usb_device_id id_table[] = { |
| 38 |
{ USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, |
| 39 |
{ } |
| 40 |
}; |
| 41 |
|
| 42 |
MODULE_DEVICE_TABLE(usb, id_table); |
| 43 |
|
| 44 |
static struct usb_serial_driver empeg_device = { |
| 45 |
.driver = { |
| 46 |
.name = "empeg", |
| 47 |
}, |
| 48 |
.id_table = id_table, |
| 49 |
.num_ports = 1, |
| 50 |
.bulk_out_size = 256, |
| 51 |
.throttle = usb_serial_generic_throttle, |
| 52 |
.unthrottle = usb_serial_generic_unthrottle, |
| 53 |
.attach = empeg_startup, |
| 54 |
.init_termios = empeg_init_termios, |
| 55 |
}; |
| 56 |
|
| 57 |
static struct usb_serial_driver * const serial_drivers[] = { |
| 58 |
&empeg_device, NULL |
| 59 |
}; |
| 60 |
|
| 61 |
static int empeg_startup(struct usb_serial *serial) |
| 62 |
{ |
| 63 |
int r; |
| 64 |
|
| 65 |
if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
| 66 |
dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
| 67 |
serial->dev->actconfig->desc.bConfigurationValue); |
| 68 |
return -ENODEV; |
| 69 |
} |
| 70 |
|
| 71 |
r = usb_reset_configuration(serial->dev); |
| 72 |
|
| 73 |
|
| 74 |
return r; |
| 75 |
} |
| 76 |
|
| 77 |
static void empeg_init_termios(struct tty_struct *tty) |
| 78 |
{ |
| 79 |
struct ktermios *termios = &tty->termios; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
termios->c_iflag |
| 91 |
&= ~(IGNBRK |
| 92 |
| BRKINT |
| 93 |
| PARMRK |
| 94 |
| ISTRIP |
| 95 |
| INLCR |
| 96 |
| IGNCR |
| 97 |
| ICRNL |
| 98 |
| IXON); |
| 99 |
|
| 100 |
termios->c_oflag |
| 101 |
&= ~OPOST; |
| 102 |
|
| 103 |
termios->c_lflag |
| 104 |
&= ~(ECHO |
| 105 |
| ECHONL |
| 106 |
| ICANON |
| 107 |
| ISIG |
| 108 |
| IEXTEN); |
| 109 |
|
| 110 |
termios->c_cflag |
| 111 |
&= ~(CSIZE |
| 112 |
| PARENB |
| 113 |
| CBAUD); |
| 114 |
|
| 115 |
termios->c_cflag |
| 116 |
|= CS8; |
| 117 |
|
| 118 |
tty_encode_baud_rate(tty, 115200, 115200); |
| 119 |
} |
| 120 |
|
| 121 |
module_usb_serial_driver(serial_drivers, id_table); |
| 122 |
|
| 123 |
MODULE_AUTHOR(DRIVER_AUTHOR); |
| 124 |
MODULE_DESCRIPTION(DRIVER_DESC); |
| 125 |
MODULE_LICENSE("GPL v2"); |