Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 1 | /* |
| 2 | * nokia.c -- Nokia Composite Gadget Driver |
| 3 | * |
| 4 | * Copyright (C) 2008-2010 Nokia Corporation |
| 5 | * Contact: Felipe Balbi <felipe.balbi@nokia.com> |
| 6 | * |
| 7 | * This gadget driver borrows from serial.c which is: |
| 8 | * |
| 9 | * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) |
| 10 | * Copyright (C) 2008 by David Brownell |
| 11 | * Copyright (C) 2008 by Nokia Corporation |
| 12 | * |
| 13 | * This software is distributed under the terms of the GNU General |
| 14 | * Public License ("GPL") as published by the Free Software Foundation, |
| 15 | * version 2 of that License. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/kernel.h> |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 19 | #include <linux/module.h> |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 20 | #include <linux/device.h> |
| 21 | |
| 22 | #include "u_serial.h" |
| 23 | #include "u_ether.h" |
| 24 | #include "u_phonet.h" |
| 25 | #include "gadget_chips.h" |
| 26 | |
| 27 | /* Defines */ |
| 28 | |
| 29 | #define NOKIA_VERSION_NUM 0x0211 |
| 30 | #define NOKIA_LONG_NAME "N900 (PC-Suite Mode)" |
| 31 | |
| 32 | /*-------------------------------------------------------------------------*/ |
| 33 | |
| 34 | /* |
| 35 | * Kbuild is not very cooperative with respect to linking separately |
| 36 | * compiled library objects into one module. So for now we won't use |
| 37 | * separate compilation ... ensuring init/exit sections work to shrink |
| 38 | * the runtime footprint, and giving us at least some parts of what |
| 39 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
| 40 | */ |
Andrzej Pietrasiewicz | fee562a | 2013-05-23 10:32:03 +0200 | [diff] [blame] | 41 | #define USBF_ECM_INCLUDED |
Felipe Balbi | 9b192de | 2013-04-03 21:01:44 +0300 | [diff] [blame] | 42 | #include "f_ecm.c" |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 43 | #include "f_phonet.c" |
Andrzej Pietrasiewicz | f1a1823 | 2013-05-23 09:22:03 +0200 | [diff] [blame] | 44 | #include "u_ether.h" |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 45 | |
| 46 | /*-------------------------------------------------------------------------*/ |
Sebastian Andrzej Siewior | 7d16e8d | 2012-09-10 15:01:53 +0200 | [diff] [blame] | 47 | USB_GADGET_COMPOSITE_OPTIONS(); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 48 | |
Andrzej Pietrasiewicz | f1a1823 | 2013-05-23 09:22:03 +0200 | [diff] [blame] | 49 | USB_ETHERNET_MODULE_PARAMETERS(); |
| 50 | |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 51 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ |
| 52 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ |
| 53 | |
| 54 | /* string IDs are assigned dynamically */ |
| 55 | |
Sebastian Andrzej Siewior | 276e2e4 | 2012-09-06 20:11:21 +0200 | [diff] [blame] | 56 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 57 | |
| 58 | static char manufacturer_nokia[] = "Nokia"; |
| 59 | static const char product_nokia[] = NOKIA_LONG_NAME; |
| 60 | static const char description_nokia[] = "PC-Suite Configuration"; |
| 61 | |
| 62 | static struct usb_string strings_dev[] = { |
Sebastian Andrzej Siewior | 276e2e4 | 2012-09-06 20:11:21 +0200 | [diff] [blame] | 63 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer_nokia, |
| 64 | [USB_GADGET_PRODUCT_IDX].s = NOKIA_LONG_NAME, |
| 65 | [USB_GADGET_SERIAL_IDX].s = "", |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 66 | [STRING_DESCRIPTION_IDX].s = description_nokia, |
| 67 | { } /* end of list */ |
| 68 | }; |
| 69 | |
| 70 | static struct usb_gadget_strings stringtab_dev = { |
| 71 | .language = 0x0409, /* en-us */ |
| 72 | .strings = strings_dev, |
| 73 | }; |
| 74 | |
| 75 | static struct usb_gadget_strings *dev_strings[] = { |
| 76 | &stringtab_dev, |
| 77 | NULL, |
| 78 | }; |
| 79 | |
| 80 | static struct usb_device_descriptor device_desc = { |
| 81 | .bLength = USB_DT_DEVICE_SIZE, |
| 82 | .bDescriptorType = USB_DT_DEVICE, |
| 83 | .bcdUSB = __constant_cpu_to_le16(0x0200), |
| 84 | .bDeviceClass = USB_CLASS_COMM, |
| 85 | .idVendor = __constant_cpu_to_le16(NOKIA_VENDOR_ID), |
| 86 | .idProduct = __constant_cpu_to_le16(NOKIA_PRODUCT_ID), |
Sebastian Andrzej Siewior | ed9cbda | 2012-09-10 09:16:07 +0200 | [diff] [blame] | 87 | .bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM), |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 88 | /* .iManufacturer = DYNAMIC */ |
| 89 | /* .iProduct = DYNAMIC */ |
| 90 | .bNumConfigurations = 1, |
| 91 | }; |
| 92 | |
| 93 | /*-------------------------------------------------------------------------*/ |
| 94 | |
| 95 | /* Module */ |
| 96 | MODULE_DESCRIPTION("Nokia composite gadget driver for N900"); |
| 97 | MODULE_AUTHOR("Felipe Balbi"); |
| 98 | MODULE_LICENSE("GPL"); |
| 99 | |
| 100 | /*-------------------------------------------------------------------------*/ |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 101 | static struct usb_function *f_acm_cfg1; |
| 102 | static struct usb_function *f_acm_cfg2; |
Andrzej Pietrasiewicz | f1a1823 | 2013-05-23 09:22:03 +0200 | [diff] [blame] | 103 | static u8 host_mac[ETH_ALEN]; |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 104 | static struct usb_function *f_obex1_cfg1; |
| 105 | static struct usb_function *f_obex2_cfg1; |
| 106 | static struct usb_function *f_obex1_cfg2; |
| 107 | static struct usb_function *f_obex2_cfg2; |
Sebastian Andrzej Siewior | d6a0143 | 2012-12-23 21:10:12 +0100 | [diff] [blame] | 108 | static struct eth_dev *the_dev; |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 109 | |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 110 | static struct usb_configuration nokia_config_500ma_driver = { |
| 111 | .label = "Bus Powered", |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 112 | .bConfigurationValue = 1, |
| 113 | /* .iConfiguration = DYNAMIC */ |
| 114 | .bmAttributes = USB_CONFIG_ATT_ONE, |
Sebastian Andrzej Siewior | 8f900a9 | 2012-12-03 20:07:05 +0100 | [diff] [blame] | 115 | .MaxPower = 500, |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | static struct usb_configuration nokia_config_100ma_driver = { |
| 119 | .label = "Self Powered", |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 120 | .bConfigurationValue = 2, |
| 121 | /* .iConfiguration = DYNAMIC */ |
| 122 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
Sebastian Andrzej Siewior | 8f900a9 | 2012-12-03 20:07:05 +0100 | [diff] [blame] | 123 | .MaxPower = 100, |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 124 | }; |
| 125 | |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 126 | static struct usb_function_instance *fi_acm; |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 127 | static struct usb_function_instance *fi_obex1; |
| 128 | static struct usb_function_instance *fi_obex2; |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 129 | |
| 130 | static int __init nokia_bind_config(struct usb_configuration *c) |
| 131 | { |
| 132 | struct usb_function *f_acm; |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 133 | struct usb_function *f_obex1 = NULL; |
| 134 | struct usb_function *f_obex2 = NULL; |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 135 | int status = 0; |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 136 | int obex1_stat = 0; |
| 137 | int obex2_stat = 0; |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 138 | |
| 139 | status = phonet_bind_config(c); |
| 140 | if (status) |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 141 | pr_debug("could not bind phonet config\n"); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 142 | |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 143 | if (!IS_ERR(fi_obex1)) { |
| 144 | f_obex1 = usb_get_function(fi_obex1); |
| 145 | if (IS_ERR(f_obex1)) |
| 146 | pr_debug("could not get obex function 0\n"); |
| 147 | } |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 148 | |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 149 | if (!IS_ERR(fi_obex2)) { |
| 150 | f_obex2 = usb_get_function(fi_obex2); |
| 151 | if (IS_ERR(f_obex2)) |
| 152 | pr_debug("could not get obex function 1\n"); |
| 153 | } |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 154 | |
| 155 | f_acm = usb_get_function(fi_acm); |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 156 | if (IS_ERR(f_acm)) { |
| 157 | status = PTR_ERR(f_acm); |
| 158 | goto err_get_acm; |
| 159 | } |
| 160 | |
| 161 | if (!IS_ERR_OR_NULL(f_obex1)) { |
| 162 | obex1_stat = usb_add_function(c, f_obex1); |
| 163 | if (obex1_stat) |
| 164 | pr_debug("could not add obex function 0\n"); |
| 165 | } |
| 166 | |
| 167 | if (!IS_ERR_OR_NULL(f_obex2)) { |
| 168 | obex2_stat = usb_add_function(c, f_obex2); |
| 169 | if (obex2_stat) |
| 170 | pr_debug("could not add obex function 1\n"); |
| 171 | } |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 172 | |
| 173 | status = usb_add_function(c, f_acm); |
| 174 | if (status) |
| 175 | goto err_conf; |
| 176 | |
Andrzej Pietrasiewicz | f1a1823 | 2013-05-23 09:22:03 +0200 | [diff] [blame] | 177 | status = ecm_bind_config(c, host_mac, the_dev); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 178 | if (status) { |
| 179 | pr_debug("could not bind ecm config %d\n", status); |
| 180 | goto err_ecm; |
| 181 | } |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 182 | if (c == &nokia_config_500ma_driver) { |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 183 | f_acm_cfg1 = f_acm; |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 184 | f_obex1_cfg1 = f_obex1; |
| 185 | f_obex2_cfg1 = f_obex2; |
| 186 | } else { |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 187 | f_acm_cfg2 = f_acm; |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 188 | f_obex1_cfg2 = f_obex1; |
| 189 | f_obex2_cfg2 = f_obex2; |
| 190 | } |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 191 | |
| 192 | return status; |
| 193 | err_ecm: |
| 194 | usb_remove_function(c, f_acm); |
| 195 | err_conf: |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 196 | if (!obex2_stat) |
| 197 | usb_remove_function(c, f_obex2); |
| 198 | if (!obex1_stat) |
| 199 | usb_remove_function(c, f_obex1); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 200 | usb_put_function(f_acm); |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 201 | err_get_acm: |
| 202 | if (!IS_ERR_OR_NULL(f_obex2)) |
| 203 | usb_put_function(f_obex2); |
| 204 | if (!IS_ERR_OR_NULL(f_obex1)) |
| 205 | usb_put_function(f_obex1); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 206 | return status; |
| 207 | } |
| 208 | |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 209 | static int __init nokia_bind(struct usb_composite_dev *cdev) |
| 210 | { |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 211 | struct usb_gadget *gadget = cdev->gadget; |
| 212 | int status; |
| 213 | |
| 214 | status = gphonet_setup(cdev->gadget); |
| 215 | if (status < 0) |
| 216 | goto err_phonet; |
| 217 | |
Andrzej Pietrasiewicz | f1a1823 | 2013-05-23 09:22:03 +0200 | [diff] [blame] | 218 | the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac, |
| 219 | qmult); |
Sebastian Andrzej Siewior | d6a0143 | 2012-12-23 21:10:12 +0100 | [diff] [blame] | 220 | if (IS_ERR(the_dev)) { |
| 221 | status = PTR_ERR(the_dev); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 222 | goto err_ether; |
Sebastian Andrzej Siewior | d6a0143 | 2012-12-23 21:10:12 +0100 | [diff] [blame] | 223 | } |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 224 | |
Sebastian Andrzej Siewior | e1f15cc | 2012-09-06 20:11:16 +0200 | [diff] [blame] | 225 | status = usb_string_ids_tab(cdev, strings_dev); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 226 | if (status < 0) |
| 227 | goto err_usb; |
Sebastian Andrzej Siewior | 276e2e4 | 2012-09-06 20:11:21 +0200 | [diff] [blame] | 228 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
| 229 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
Sebastian Andrzej Siewior | e1f15cc | 2012-09-06 20:11:16 +0200 | [diff] [blame] | 230 | status = strings_dev[STRING_DESCRIPTION_IDX].id; |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 231 | nokia_config_500ma_driver.iConfiguration = status; |
| 232 | nokia_config_100ma_driver.iConfiguration = status; |
| 233 | |
Sebastian Andrzej Siewior | ed9cbda | 2012-09-10 09:16:07 +0200 | [diff] [blame] | 234 | if (!gadget_supports_altsettings(gadget)) |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 235 | goto err_usb; |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 236 | |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 237 | fi_obex1 = usb_get_function_instance("obex"); |
| 238 | if (IS_ERR(fi_obex1)) |
| 239 | pr_debug("could not find obex function 1\n"); |
| 240 | |
| 241 | fi_obex2 = usb_get_function_instance("obex"); |
| 242 | if (IS_ERR(fi_obex2)) |
| 243 | pr_debug("could not find obex function 2\n"); |
| 244 | |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 245 | fi_acm = usb_get_function_instance("acm"); |
| 246 | if (IS_ERR(fi_acm)) |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 247 | goto err_obex2_inst; |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 248 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 249 | /* finally register the configuration */ |
Uwe Kleine-König | c9bfff9 | 2010-08-12 17:43:55 +0200 | [diff] [blame] | 250 | status = usb_add_config(cdev, &nokia_config_500ma_driver, |
| 251 | nokia_bind_config); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 252 | if (status < 0) |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 253 | goto err_acm_inst; |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 254 | |
Uwe Kleine-König | c9bfff9 | 2010-08-12 17:43:55 +0200 | [diff] [blame] | 255 | status = usb_add_config(cdev, &nokia_config_100ma_driver, |
| 256 | nokia_bind_config); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 257 | if (status < 0) |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 258 | goto err_put_cfg1; |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 259 | |
Sebastian Andrzej Siewior | 7d16e8d | 2012-09-10 15:01:53 +0200 | [diff] [blame] | 260 | usb_composite_overwrite_options(cdev, &coverwrite); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 261 | dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); |
| 262 | |
| 263 | return 0; |
| 264 | |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 265 | err_put_cfg1: |
| 266 | usb_put_function(f_acm_cfg1); |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 267 | if (!IS_ERR_OR_NULL(f_obex1_cfg1)) |
| 268 | usb_put_function(f_obex1_cfg1); |
| 269 | if (!IS_ERR_OR_NULL(f_obex2_cfg1)) |
| 270 | usb_put_function(f_obex2_cfg1); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 271 | err_acm_inst: |
| 272 | usb_put_function_instance(fi_acm); |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 273 | err_obex2_inst: |
| 274 | if (!IS_ERR(fi_obex2)) |
| 275 | usb_put_function_instance(fi_obex2); |
| 276 | if (!IS_ERR(fi_obex1)) |
| 277 | usb_put_function_instance(fi_obex1); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 278 | err_usb: |
Sebastian Andrzej Siewior | d6a0143 | 2012-12-23 21:10:12 +0100 | [diff] [blame] | 279 | gether_cleanup(the_dev); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 280 | err_ether: |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 281 | gphonet_cleanup(); |
| 282 | err_phonet: |
| 283 | return status; |
| 284 | } |
| 285 | |
| 286 | static int __exit nokia_unbind(struct usb_composite_dev *cdev) |
| 287 | { |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 288 | if (!IS_ERR_OR_NULL(f_obex1_cfg2)) |
| 289 | usb_put_function(f_obex1_cfg2); |
| 290 | if (!IS_ERR_OR_NULL(f_obex2_cfg2)) |
| 291 | usb_put_function(f_obex2_cfg2); |
| 292 | if (!IS_ERR_OR_NULL(f_obex1_cfg1)) |
| 293 | usb_put_function(f_obex1_cfg1); |
| 294 | if (!IS_ERR_OR_NULL(f_obex2_cfg1)) |
| 295 | usb_put_function(f_obex2_cfg1); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 296 | usb_put_function(f_acm_cfg1); |
| 297 | usb_put_function(f_acm_cfg2); |
Andrzej Pietrasiewicz | 3a34344 | 2013-05-23 10:51:08 +0200 | [diff] [blame^] | 298 | if (!IS_ERR(fi_obex1)) |
| 299 | usb_put_function_instance(fi_obex1); |
| 300 | if (!IS_ERR(fi_obex2)) |
| 301 | usb_put_function_instance(fi_obex2); |
Sebastian Andrzej Siewior | 1576182 | 2013-01-25 14:09:17 +0100 | [diff] [blame] | 302 | usb_put_function_instance(fi_acm); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 303 | gphonet_cleanup(); |
Sebastian Andrzej Siewior | 19b10a8 | 2012-12-23 21:10:06 +0100 | [diff] [blame] | 304 | |
Sebastian Andrzej Siewior | d6a0143 | 2012-12-23 21:10:12 +0100 | [diff] [blame] | 305 | gether_cleanup(the_dev); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | |
Sebastian Andrzej Siewior | c2ec75c | 2012-09-06 20:11:03 +0200 | [diff] [blame] | 310 | static __refdata struct usb_composite_driver nokia_driver = { |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 311 | .name = "g_nokia", |
| 312 | .dev = &device_desc, |
| 313 | .strings = dev_strings, |
Tatyana Brokhman | 35a0e0b | 2011-06-29 16:41:49 +0300 | [diff] [blame] | 314 | .max_speed = USB_SPEED_HIGH, |
Sebastian Andrzej Siewior | 03e42bd | 2012-09-06 20:11:04 +0200 | [diff] [blame] | 315 | .bind = nokia_bind, |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 316 | .unbind = __exit_p(nokia_unbind), |
| 317 | }; |
| 318 | |
| 319 | static int __init nokia_init(void) |
| 320 | { |
Sebastian Andrzej Siewior | 03e42bd | 2012-09-06 20:11:04 +0200 | [diff] [blame] | 321 | return usb_composite_probe(&nokia_driver); |
Felipe Balbi | f358f5b | 2010-01-05 16:10:13 +0200 | [diff] [blame] | 322 | } |
| 323 | module_init(nokia_init); |
| 324 | |
| 325 | static void __exit nokia_cleanup(void) |
| 326 | { |
| 327 | usb_composite_unregister(&nokia_driver); |
| 328 | } |
| 329 | module_exit(nokia_cleanup); |