diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/Kconfig | 7 | ||||
-rw-r--r-- | drivers/usb/serial/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/serial/navman.c | 157 |
3 files changed, 165 insertions, 0 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index be5dc80836c3..5a8a2c91c2b2 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -403,6 +403,13 @@ config USB_SERIAL_MCT_U232 | |||
403 | To compile this driver as a module, choose M here: the | 403 | To compile this driver as a module, choose M here: the |
404 | module will be called mct_u232. | 404 | module will be called mct_u232. |
405 | 405 | ||
406 | config USB_SERIAL_NAVMAN | ||
407 | tristate "USB Navman GPS device" | ||
408 | depends on USB_SERIAL | ||
409 | help | ||
410 | To compile this driver as a module, choose M here: the | ||
411 | module will be called navman. | ||
412 | |||
406 | config USB_SERIAL_PL2303 | 413 | config USB_SERIAL_PL2303 |
407 | tristate "USB Prolific 2303 Single Port Serial Driver" | 414 | tristate "USB Prolific 2303 Single Port Serial Driver" |
408 | depends on USB_SERIAL | 415 | depends on USB_SERIAL |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index f0b04420cea1..f7fe4172efed 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -32,6 +32,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o | |||
32 | obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o | 32 | obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o |
33 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o | 33 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o |
34 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o | 34 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o |
35 | obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o | ||
35 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o | 36 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o |
36 | obj-$(CONFIG_USB_SERIAL_OPTION) += option.o | 37 | obj-$(CONFIG_USB_SERIAL_OPTION) += option.o |
37 | obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o | 38 | obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o |
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c new file mode 100644 index 000000000000..7f544081032e --- /dev/null +++ b/drivers/usb/serial/navman.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * Navman Serial USB driver | ||
3 | * | ||
4 | * Copyright (C) 2006 Greg Kroah-Hartman <gregkh@suse.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/tty.h> | ||
14 | #include <linux/tty_flip.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/usb.h> | ||
17 | #include "usb-serial.h" | ||
18 | |||
19 | static int debug; | ||
20 | |||
21 | static struct usb_device_id id_table [] = { | ||
22 | { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ | ||
23 | { }, | ||
24 | }; | ||
25 | MODULE_DEVICE_TABLE(usb, id_table); | ||
26 | |||
27 | static struct usb_driver navman_driver = { | ||
28 | .name = "navman", | ||
29 | .probe = usb_serial_probe, | ||
30 | .disconnect = usb_serial_disconnect, | ||
31 | .id_table = id_table, | ||
32 | .no_dynamic_id = 1, | ||
33 | }; | ||
34 | |||
35 | static void navman_read_int_callback(struct urb *urb, struct pt_regs *regs) | ||
36 | { | ||
37 | struct usb_serial_port *port = urb->context; | ||
38 | unsigned char *data = urb->transfer_buffer; | ||
39 | struct tty_struct *tty; | ||
40 | int result; | ||
41 | |||
42 | switch (urb->status) { | ||
43 | case 0: | ||
44 | /* success */ | ||
45 | break; | ||
46 | case -ECONNRESET: | ||
47 | case -ENOENT: | ||
48 | case -ESHUTDOWN: | ||
49 | /* this urb is terminated, clean up */ | ||
50 | dbg("%s - urb shutting down with status: %d", | ||
51 | __FUNCTION__, urb->status); | ||
52 | return; | ||
53 | default: | ||
54 | dbg("%s - nonzero urb status received: %d", | ||
55 | __FUNCTION__, urb->status); | ||
56 | goto exit; | ||
57 | } | ||
58 | |||
59 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, | ||
60 | urb->actual_length, data); | ||
61 | |||
62 | tty = port->tty; | ||
63 | if (tty && urb->actual_length) { | ||
64 | tty_buffer_request_room(tty, urb->actual_length); | ||
65 | tty_insert_flip_string(tty, data, urb->actual_length); | ||
66 | tty_flip_buffer_push(tty); | ||
67 | } | ||
68 | |||
69 | exit: | ||
70 | result = usb_submit_urb(urb, GFP_ATOMIC); | ||
71 | if (result) | ||
72 | dev_err(&urb->dev->dev, | ||
73 | "%s - Error %d submitting interrupt urb\n", | ||
74 | __FUNCTION__, result); | ||
75 | } | ||
76 | |||
77 | static int navman_open(struct usb_serial_port *port, struct file *filp) | ||
78 | { | ||
79 | int result = 0; | ||
80 | |||
81 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
82 | |||
83 | if (port->interrupt_in_urb) { | ||
84 | dbg("%s - adding interrupt input for treo", __FUNCTION__); | ||
85 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | ||
86 | if (result) | ||
87 | dev_err(&port->dev, | ||
88 | "%s - failed submitting interrupt urb, error %d\n", | ||
89 | __FUNCTION__, result); | ||
90 | } | ||
91 | return result; | ||
92 | } | ||
93 | |||
94 | static void navman_close(struct usb_serial_port *port, struct file *filp) | ||
95 | { | ||
96 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
97 | |||
98 | if (port->interrupt_in_urb) | ||
99 | usb_kill_urb(port->interrupt_in_urb); | ||
100 | } | ||
101 | |||
102 | static int navman_write(struct usb_serial_port *port, | ||
103 | const unsigned char *buf, int count) | ||
104 | { | ||
105 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
106 | |||
107 | /* | ||
108 | * This device can't write any data, only read from the device | ||
109 | * so we just silently eat all data sent to us and say it was | ||
110 | * successfully sent. | ||
111 | * Evil, I know, but do you have a better idea? | ||
112 | */ | ||
113 | |||
114 | return count; | ||
115 | } | ||
116 | |||
117 | static struct usb_serial_driver navman_device = { | ||
118 | .driver = { | ||
119 | .owner = THIS_MODULE, | ||
120 | .name = "navman", | ||
121 | }, | ||
122 | .id_table = id_table, | ||
123 | .num_interrupt_in = NUM_DONT_CARE, | ||
124 | .num_bulk_in = NUM_DONT_CARE, | ||
125 | .num_bulk_out = NUM_DONT_CARE, | ||
126 | .num_ports = 1, | ||
127 | .open = navman_open, | ||
128 | .close = navman_close, | ||
129 | .write = navman_write, | ||
130 | .read_int_callback = navman_read_int_callback, | ||
131 | }; | ||
132 | |||
133 | static int __init navman_init(void) | ||
134 | { | ||
135 | int retval; | ||
136 | |||
137 | retval = usb_serial_register(&navman_device); | ||
138 | if (retval) | ||
139 | return retval; | ||
140 | retval = usb_register(&navman_driver); | ||
141 | if (retval) | ||
142 | usb_serial_deregister(&navman_device); | ||
143 | return retval; | ||
144 | } | ||
145 | |||
146 | static void __exit navman_exit(void) | ||
147 | { | ||
148 | usb_deregister(&navman_driver); | ||
149 | usb_serial_deregister(&navman_device); | ||
150 | } | ||
151 | |||
152 | module_init(navman_init); | ||
153 | module_exit(navman_exit); | ||
154 | MODULE_LICENSE("GPL"); | ||
155 | |||
156 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
157 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||