diff options
Diffstat (limited to 'drivers/usb/serial/cyberjack.c')
-rw-r--r-- | drivers/usb/serial/cyberjack.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 2a7aecc72237..4ee77dcbe690 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -55,9 +55,9 @@ | |||
55 | #define CYBERJACK_PRODUCT_ID 0x0100 | 55 | #define CYBERJACK_PRODUCT_ID 0x0100 |
56 | 56 | ||
57 | /* Function prototypes */ | 57 | /* Function prototypes */ |
58 | static int cyberjack_startup(struct usb_serial *serial); | ||
59 | static void cyberjack_disconnect(struct usb_serial *serial); | 58 | static void cyberjack_disconnect(struct usb_serial *serial); |
60 | static void cyberjack_release(struct usb_serial *serial); | 59 | static int cyberjack_port_probe(struct usb_serial_port *port); |
60 | static int cyberjack_port_remove(struct usb_serial_port *port); | ||
61 | static int cyberjack_open(struct tty_struct *tty, | 61 | static int cyberjack_open(struct tty_struct *tty, |
62 | struct usb_serial_port *port); | 62 | struct usb_serial_port *port); |
63 | static void cyberjack_close(struct usb_serial_port *port); | 63 | static void cyberjack_close(struct usb_serial_port *port); |
@@ -83,9 +83,9 @@ static struct usb_serial_driver cyberjack_device = { | |||
83 | .description = "Reiner SCT Cyberjack USB card reader", | 83 | .description = "Reiner SCT Cyberjack USB card reader", |
84 | .id_table = id_table, | 84 | .id_table = id_table, |
85 | .num_ports = 1, | 85 | .num_ports = 1, |
86 | .attach = cyberjack_startup, | ||
87 | .disconnect = cyberjack_disconnect, | 86 | .disconnect = cyberjack_disconnect, |
88 | .release = cyberjack_release, | 87 | .port_probe = cyberjack_port_probe, |
88 | .port_remove = cyberjack_port_remove, | ||
89 | .open = cyberjack_open, | 89 | .open = cyberjack_open, |
90 | .close = cyberjack_close, | 90 | .close = cyberjack_close, |
91 | .write = cyberjack_write, | 91 | .write = cyberjack_write, |
@@ -107,56 +107,45 @@ struct cyberjack_private { | |||
107 | short wrsent; /* Data already sent */ | 107 | short wrsent; /* Data already sent */ |
108 | }; | 108 | }; |
109 | 109 | ||
110 | /* do some startup allocations not currently performed by usb_serial_probe() */ | 110 | static int cyberjack_port_probe(struct usb_serial_port *port) |
111 | static int cyberjack_startup(struct usb_serial *serial) | ||
112 | { | 111 | { |
113 | struct cyberjack_private *priv; | 112 | struct cyberjack_private *priv; |
114 | int i; | 113 | int result; |
115 | 114 | ||
116 | /* allocate the private data structure */ | ||
117 | priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); | 115 | priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); |
118 | if (!priv) | 116 | if (!priv) |
119 | return -ENOMEM; | 117 | return -ENOMEM; |
120 | 118 | ||
121 | /* set initial values */ | ||
122 | spin_lock_init(&priv->lock); | 119 | spin_lock_init(&priv->lock); |
123 | priv->rdtodo = 0; | 120 | priv->rdtodo = 0; |
124 | priv->wrfilled = 0; | 121 | priv->wrfilled = 0; |
125 | priv->wrsent = 0; | 122 | priv->wrsent = 0; |
126 | usb_set_serial_port_data(serial->port[0], priv); | ||
127 | 123 | ||
128 | init_waitqueue_head(&serial->port[0]->write_wait); | 124 | usb_set_serial_port_data(port, priv); |
129 | 125 | ||
130 | for (i = 0; i < serial->num_ports; ++i) { | 126 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
131 | int result; | 127 | if (result) |
132 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, | 128 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
133 | GFP_KERNEL); | ||
134 | if (result) | ||
135 | dev_err(&serial->dev->dev, | ||
136 | "usb_submit_urb(read int) failed\n"); | ||
137 | dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n", | ||
138 | __func__); | ||
139 | } | ||
140 | 129 | ||
141 | return 0; | 130 | return 0; |
142 | } | 131 | } |
143 | 132 | ||
144 | static void cyberjack_disconnect(struct usb_serial *serial) | 133 | static int cyberjack_port_remove(struct usb_serial_port *port) |
145 | { | 134 | { |
146 | int i; | 135 | struct cyberjack_private *priv; |
147 | 136 | ||
148 | for (i = 0; i < serial->num_ports; ++i) | 137 | priv = usb_get_serial_port_data(port); |
149 | usb_kill_urb(serial->port[i]->interrupt_in_urb); | 138 | kfree(priv); |
139 | |||
140 | return 0; | ||
150 | } | 141 | } |
151 | 142 | ||
152 | static void cyberjack_release(struct usb_serial *serial) | 143 | static void cyberjack_disconnect(struct usb_serial *serial) |
153 | { | 144 | { |
154 | int i; | 145 | int i; |
155 | 146 | ||
156 | for (i = 0; i < serial->num_ports; ++i) { | 147 | for (i = 0; i < serial->num_ports; ++i) |
157 | /* My special items, the standard routines free my urbs */ | 148 | usb_kill_urb(serial->port[i]->interrupt_in_urb); |
158 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
159 | } | ||
160 | } | 149 | } |
161 | 150 | ||
162 | static int cyberjack_open(struct tty_struct *tty, | 151 | static int cyberjack_open(struct tty_struct *tty, |