diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-04-16 12:01:30 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-17 13:05:35 -0400 |
commit | a85796ee514954b1ef5efe8928ef38777aab8c2d (patch) | |
tree | e7bca8f72e96c427e19291ea72226d49ec667e8f | |
parent | ef31025d6811320ead36a8902b16090dea01b34c (diff) |
USB: symbolserial: move private-data allocation to port_probe
Allocate port-private data in port-probe rather than in attach.
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/serial/symbolserial.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 2c2bfa1994f8..9b1648945e7a 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Symbol USB barcode to serial driver | 2 | * Symbol USB barcode to serial driver |
3 | * | 3 | * |
4 | * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com> | ||
4 | * Copyright (C) 2009 Greg Kroah-Hartman <gregkh@suse.de> | 5 | * Copyright (C) 2009 Greg Kroah-Hartman <gregkh@suse.de> |
5 | * Copyright (C) 2009 Novell Inc. | 6 | * Copyright (C) 2009 Novell Inc. |
6 | * | 7 | * |
@@ -35,7 +36,7 @@ struct symbol_private { | |||
35 | static void symbol_int_callback(struct urb *urb) | 36 | static void symbol_int_callback(struct urb *urb) |
36 | { | 37 | { |
37 | struct usb_serial_port *port = urb->context; | 38 | struct usb_serial_port *port = urb->context; |
38 | struct symbol_private *priv = usb_get_serial_data(port->serial); | 39 | struct symbol_private *priv = usb_get_serial_port_data(port); |
39 | unsigned char *data = urb->transfer_buffer; | 40 | unsigned char *data = urb->transfer_buffer; |
40 | int status = urb->status; | 41 | int status = urb->status; |
41 | int result; | 42 | int result; |
@@ -153,30 +154,36 @@ static void symbol_unthrottle(struct tty_struct *tty) | |||
153 | 154 | ||
154 | static int symbol_startup(struct usb_serial *serial) | 155 | static int symbol_startup(struct usb_serial *serial) |
155 | { | 156 | { |
156 | struct symbol_private *priv; | ||
157 | |||
158 | if (!serial->num_interrupt_in) { | 157 | if (!serial->num_interrupt_in) { |
159 | dev_err(&serial->dev->dev, "no interrupt-in endpoint\n"); | 158 | dev_err(&serial->dev->dev, "no interrupt-in endpoint\n"); |
160 | return -ENODEV; | 159 | return -ENODEV; |
161 | } | 160 | } |
162 | 161 | ||
163 | /* create our private serial structure */ | 162 | return 0; |
163 | } | ||
164 | |||
165 | static int symbol_port_probe(struct usb_serial_port *port) | ||
166 | { | ||
167 | struct symbol_private *priv; | ||
168 | |||
164 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 169 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
165 | if (priv == NULL) { | 170 | if (!priv) |
166 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); | ||
167 | return -ENOMEM; | 171 | return -ENOMEM; |
168 | } | 172 | |
169 | spin_lock_init(&priv->lock); | 173 | spin_lock_init(&priv->lock); |
170 | 174 | ||
171 | usb_set_serial_data(serial, priv); | 175 | usb_set_serial_port_data(port, priv); |
176 | |||
172 | return 0; | 177 | return 0; |
173 | } | 178 | } |
174 | 179 | ||
175 | static void symbol_release(struct usb_serial *serial) | 180 | static int symbol_port_remove(struct usb_serial_port *port) |
176 | { | 181 | { |
177 | struct symbol_private *priv = usb_get_serial_data(serial); | 182 | struct symbol_private *priv = usb_get_serial_port_data(port); |
178 | 183 | ||
179 | kfree(priv); | 184 | kfree(priv); |
185 | |||
186 | return 0; | ||
180 | } | 187 | } |
181 | 188 | ||
182 | static struct usb_serial_driver symbol_device = { | 189 | static struct usb_serial_driver symbol_device = { |
@@ -187,9 +194,10 @@ static struct usb_serial_driver symbol_device = { | |||
187 | .id_table = id_table, | 194 | .id_table = id_table, |
188 | .num_ports = 1, | 195 | .num_ports = 1, |
189 | .attach = symbol_startup, | 196 | .attach = symbol_startup, |
197 | .port_probe = symbol_port_probe, | ||
198 | .port_remove = symbol_port_remove, | ||
190 | .open = symbol_open, | 199 | .open = symbol_open, |
191 | .close = symbol_close, | 200 | .close = symbol_close, |
192 | .release = symbol_release, | ||
193 | .throttle = symbol_throttle, | 201 | .throttle = symbol_throttle, |
194 | .unthrottle = symbol_unthrottle, | 202 | .unthrottle = symbol_unthrottle, |
195 | .read_int_callback = symbol_int_callback, | 203 | .read_int_callback = symbol_int_callback, |