diff options
author | Arve Hjønnevåg | 2013-03-04 19:41:34 -0600 |
---|---|---|
committer | Arve Hjønnevåg | 2013-03-11 18:20:33 -0500 |
commit | e448c9b714d75135f4d93fc8e92c4cde9831a9ba (patch) | |
tree | 0033e42f7c809baf40bd412da54bcf8c7dbfcf85 | |
parent | 8d92ee29d79222c24f22acc5edaf14ae9a9231a4 (diff) | |
download | kernel-common-e448c9b714d75135f4d93fc8e92c4cde9831a9ba.tar.gz kernel-common-e448c9b714d75135f4d93fc8e92c4cde9831a9ba.tar.xz kernel-common-e448c9b714d75135f4d93fc8e92c4cde9831a9ba.zip |
usb: gadget: android: Fixes and hacks to make android usb gadget compile on 3.9
Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r-- | drivers/usb/gadget/android.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index 11d247cc0e9..60072f3af96 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "f_audio_source.c" | 34 | #include "f_audio_source.c" |
35 | #include "f_mass_storage.c" | 35 | #include "f_mass_storage.c" |
36 | #include "u_serial.c" | 36 | #include "u_serial.c" |
37 | #define USB_FACM_INCLUDED | ||
37 | #include "f_acm.c" | 38 | #include "f_acm.c" |
38 | #include "f_mtp.c" | 39 | #include "f_mtp.c" |
39 | #include "f_accessory.c" | 40 | #include "f_accessory.c" |
@@ -149,7 +150,7 @@ static struct usb_configuration android_config_driver = { | |||
149 | .unbind = android_unbind_config, | 150 | .unbind = android_unbind_config, |
150 | .bConfigurationValue = 1, | 151 | .bConfigurationValue = 1, |
151 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | 152 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
152 | .bMaxPower = 0xFA, /* 500ma */ | 153 | .MaxPower = 500, /* 500ma */ |
153 | }; | 154 | }; |
154 | 155 | ||
155 | static void android_work(struct work_struct *data) | 156 | static void android_work(struct work_struct *data) |
@@ -366,22 +367,41 @@ static void functionfs_release_dev_callback(struct ffs_data *ffs_data) | |||
366 | #define MAX_ACM_INSTANCES 4 | 367 | #define MAX_ACM_INSTANCES 4 |
367 | struct acm_function_config { | 368 | struct acm_function_config { |
368 | int instances; | 369 | int instances; |
370 | unsigned char port_num[MAX_ACM_INSTANCES]; | ||
369 | }; | 371 | }; |
370 | 372 | ||
371 | static int | 373 | static int |
372 | acm_function_init(struct android_usb_function *f, | 374 | acm_function_init(struct android_usb_function *f, |
373 | struct usb_composite_dev *cdev) | 375 | struct usb_composite_dev *cdev) |
374 | { | 376 | { |
375 | f->config = kzalloc(sizeof(struct acm_function_config), GFP_KERNEL); | 377 | int i; |
376 | if (!f->config) | 378 | int ret; |
379 | struct acm_function_config *config; | ||
380 | |||
381 | config = kzalloc(sizeof(struct acm_function_config), GFP_KERNEL); | ||
382 | if (!config) | ||
377 | return -ENOMEM; | 383 | return -ENOMEM; |
384 | f->config = config; | ||
378 | 385 | ||
379 | return gserial_setup(cdev->gadget, MAX_ACM_INSTANCES); | 386 | for (i = 0; i < MAX_ACM_INSTANCES; i++) { |
387 | ret = gserial_alloc_line(&config->port_num[i]); | ||
388 | if (ret) | ||
389 | goto err_alloc_line; | ||
390 | } | ||
391 | return 0; | ||
392 | err_alloc_line: | ||
393 | while (i-- > 0) | ||
394 | gserial_free_line(config->port_num[i]); | ||
395 | return ret; | ||
380 | } | 396 | } |
381 | 397 | ||
382 | static void acm_function_cleanup(struct android_usb_function *f) | 398 | static void acm_function_cleanup(struct android_usb_function *f) |
383 | { | 399 | { |
384 | gserial_cleanup(); | 400 | int i; |
401 | struct acm_function_config *config = f->config; | ||
402 | |||
403 | for (i = 0; i < MAX_ACM_INSTANCES; i++) | ||
404 | gserial_free_line(config->port_num[i]); | ||
385 | kfree(f->config); | 405 | kfree(f->config); |
386 | f->config = NULL; | 406 | f->config = NULL; |
387 | } | 407 | } |
@@ -1311,7 +1331,7 @@ static int android_usb_unbind(struct usb_composite_dev *cdev) | |||
1311 | } | 1331 | } |
1312 | 1332 | ||
1313 | /* HACK: android needs to override setup for accessory to work */ | 1333 | /* HACK: android needs to override setup for accessory to work */ |
1314 | static int (*composite_setup)(struct usb_gadget *gadget, const struct usb_ctrlrequest *c); | 1334 | static int (*composite_setup_func)(struct usb_gadget *gadget, const struct usb_ctrlrequest *c); |
1315 | 1335 | ||
1316 | static int | 1336 | static int |
1317 | android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) | 1337 | android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) |
@@ -1342,7 +1362,7 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) | |||
1342 | value = acc_ctrlrequest(cdev, c); | 1362 | value = acc_ctrlrequest(cdev, c); |
1343 | 1363 | ||
1344 | if (value < 0) | 1364 | if (value < 0) |
1345 | value = composite_setup(gadget, c); | 1365 | value = composite_setup_func(gadget, c); |
1346 | 1366 | ||
1347 | spin_lock_irqsave(&cdev->lock, flags); | 1367 | spin_lock_irqsave(&cdev->lock, flags); |
1348 | if (!dev->connected) { | 1368 | if (!dev->connected) { |
@@ -1441,7 +1461,7 @@ static int __init init(void) | |||
1441 | } | 1461 | } |
1442 | 1462 | ||
1443 | /* HACK: exchange composite's setup with ours */ | 1463 | /* HACK: exchange composite's setup with ours */ |
1444 | composite_setup = android_usb_driver.gadget_driver.setup; | 1464 | composite_setup_func = android_usb_driver.gadget_driver.setup; |
1445 | android_usb_driver.gadget_driver.setup = android_setup; | 1465 | android_usb_driver.gadget_driver.setup = android_setup; |
1446 | 1466 | ||
1447 | return 0; | 1467 | return 0; |