]> Git Repo - linux.git/blame - drivers/usb/serial/navman.c
Merge tag 'kbuild-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[linux.git] / drivers / usb / serial / navman.c
CommitLineData
5fd54ace 1// SPDX-License-Identifier: GPL-2.0
e9a66c64
GKH
2/*
3 * Navman Serial USB driver
4 *
5 * Copyright (C) 2006 Greg Kroah-Hartman <[email protected]>
6 *
a5b6f60c
AC
7 * TODO:
8 * Add termios method that uses copy_hw but also kills all echo
9 * flags as the navman is rx only so cannot echo.
e9a66c64
GKH
10 */
11
5a0e3ad6 12#include <linux/gfp.h>
e9a66c64 13#include <linux/kernel.h>
e9a66c64
GKH
14#include <linux/tty.h>
15#include <linux/tty_flip.h>
16#include <linux/module.h>
17#include <linux/usb.h>
a969888c 18#include <linux/usb/serial.h>
e9a66c64 19
7d40d7e8 20static const struct usb_device_id id_table[] = {
e9a66c64 21 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */
0eee6a2b 22 { USB_DEVICE(0x0df7, 0x0900) }, /* Mobile Action i-gotU */
e9a66c64
GKH
23 { },
24};
25MODULE_DEVICE_TABLE(usb, id_table);
26
7d12e780 27static void navman_read_int_callback(struct urb *urb)
e9a66c64
GKH
28{
29 struct usb_serial_port *port = urb->context;
30 unsigned char *data = urb->transfer_buffer;
9965d612 31 int status = urb->status;
e9a66c64
GKH
32 int result;
33
9965d612 34 switch (status) {
e9a66c64
GKH
35 case 0:
36 /* success */
37 break;
38 case -ECONNRESET:
39 case -ENOENT:
40 case -ESHUTDOWN:
41 /* this urb is terminated, clean up */
00c533fd
GKH
42 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n",
43 __func__, status);
e9a66c64
GKH
44 return;
45 default:
00c533fd
GKH
46 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n",
47 __func__, status);
e9a66c64
GKH
48 goto exit;
49 }
50
59d33f2f 51 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
e9a66c64 52
2e124b4a 53 if (urb->actual_length) {
05c7cd39 54 tty_insert_flip_string(&port->port, data, urb->actual_length);
2e124b4a 55 tty_flip_buffer_push(&port->port);
e9a66c64
GKH
56 }
57
58exit:
59 result = usb_submit_urb(urb, GFP_ATOMIC);
60 if (result)
61 dev_err(&urb->dev->dev,
62 "%s - Error %d submitting interrupt urb\n",
441b62c1 63 __func__, result);
e9a66c64
GKH
64}
65
a509a7e4 66static int navman_open(struct tty_struct *tty, struct usb_serial_port *port)
e9a66c64
GKH
67{
68 int result = 0;
69
e9a66c64 70 if (port->interrupt_in_urb) {
00c533fd
GKH
71 dev_dbg(&port->dev, "%s - adding interrupt input for treo\n",
72 __func__);
e9a66c64
GKH
73 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
74 if (result)
75 dev_err(&port->dev,
76 "%s - failed submitting interrupt urb, error %d\n",
441b62c1 77 __func__, result);
e9a66c64
GKH
78 }
79 return result;
80}
81
335f8514 82static void navman_close(struct usb_serial_port *port)
e9a66c64 83{
9aac10ff 84 usb_kill_urb(port->interrupt_in_urb);
e9a66c64
GKH
85}
86
95da310e 87static int navman_write(struct tty_struct *tty, struct usb_serial_port *port,
e9a66c64
GKH
88 const unsigned char *buf, int count)
89{
e9a66c64
GKH
90 /*
91 * This device can't write any data, only read from the device
e9a66c64 92 */
a5b6f60c 93 return -EOPNOTSUPP;
e9a66c64
GKH
94}
95
96static struct usb_serial_driver navman_device = {
97 .driver = {
98 .owner = THIS_MODULE,
99 .name = "navman",
100 },
101 .id_table = id_table,
e9a66c64
GKH
102 .num_ports = 1,
103 .open = navman_open,
104 .close = navman_close,
105 .write = navman_write,
106 .read_int_callback = navman_read_int_callback,
107};
108
f667ddad
AS
109static struct usb_serial_driver * const serial_drivers[] = {
110 &navman_device, NULL
111};
112
68e24113 113module_usb_serial_driver(serial_drivers, id_table);
e9a66c64 114
627cfa89 115MODULE_LICENSE("GPL v2");
This page took 1.473871 seconds and 4 git commands to generate.