diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2013-05-23 04:51:14 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-06-10 10:32:23 -0400 |
commit | b904d0811dd3c878075d15b8cecbeb3bea89167d (patch) | |
tree | bbabf105283b95440cf254ba37c630c4c85eb086 | |
parent | 0383070e8d904f006b6eaffceb3fae4cdd25c01a (diff) |
usb: gadget: nokia: convert to new interface of f_ecm
this will let us deprecate (and remove) the old interface.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/nokia.c | 66 |
2 files changed, 36 insertions, 31 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 313ed5a7f6ed..5022c2d3e365 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -862,6 +862,7 @@ config USB_G_NOKIA | |||
862 | select USB_F_ACM | 862 | select USB_F_ACM |
863 | select USB_F_OBEX | 863 | select USB_F_OBEX |
864 | select USB_F_PHONET | 864 | select USB_F_PHONET |
865 | select USB_F_ECM | ||
865 | help | 866 | help |
866 | The Nokia composite gadget provides support for acm, obex | 867 | The Nokia composite gadget provides support for acm, obex |
867 | and phonet in only one composite gadget driver. | 868 | and phonet in only one composite gadget driver. |
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index 084f947ffd79..0a8099a488c4 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "u_serial.h" | 22 | #include "u_serial.h" |
23 | #include "u_ether.h" | 23 | #include "u_ether.h" |
24 | #include "u_phonet.h" | 24 | #include "u_phonet.h" |
25 | #include "u_ecm.h" | ||
25 | #include "gadget_chips.h" | 26 | #include "gadget_chips.h" |
26 | 27 | ||
27 | /* Defines */ | 28 | /* Defines */ |
@@ -29,20 +30,6 @@ | |||
29 | #define NOKIA_VERSION_NUM 0x0211 | 30 | #define NOKIA_VERSION_NUM 0x0211 |
30 | #define NOKIA_LONG_NAME "N900 (PC-Suite Mode)" | 31 | #define NOKIA_LONG_NAME "N900 (PC-Suite Mode)" |
31 | 32 | ||
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 | */ | ||
41 | #define USBF_ECM_INCLUDED | ||
42 | #include "f_ecm.c" | ||
43 | #include "u_ether.h" | ||
44 | |||
45 | /*-------------------------------------------------------------------------*/ | ||
46 | USB_GADGET_COMPOSITE_OPTIONS(); | 33 | USB_GADGET_COMPOSITE_OPTIONS(); |
47 | 34 | ||
48 | USB_ETHERNET_MODULE_PARAMETERS(); | 35 | USB_ETHERNET_MODULE_PARAMETERS(); |
@@ -99,14 +86,14 @@ MODULE_LICENSE("GPL"); | |||
99 | /*-------------------------------------------------------------------------*/ | 86 | /*-------------------------------------------------------------------------*/ |
100 | static struct usb_function *f_acm_cfg1; | 87 | static struct usb_function *f_acm_cfg1; |
101 | static struct usb_function *f_acm_cfg2; | 88 | static struct usb_function *f_acm_cfg2; |
102 | static u8 host_mac[ETH_ALEN]; | 89 | static struct usb_function *f_ecm_cfg1; |
90 | static struct usb_function *f_ecm_cfg2; | ||
103 | static struct usb_function *f_obex1_cfg1; | 91 | static struct usb_function *f_obex1_cfg1; |
104 | static struct usb_function *f_obex2_cfg1; | 92 | static struct usb_function *f_obex2_cfg1; |
105 | static struct usb_function *f_obex1_cfg2; | 93 | static struct usb_function *f_obex1_cfg2; |
106 | static struct usb_function *f_obex2_cfg2; | 94 | static struct usb_function *f_obex2_cfg2; |
107 | static struct usb_function *f_phonet_cfg1; | 95 | static struct usb_function *f_phonet_cfg1; |
108 | static struct usb_function *f_phonet_cfg2; | 96 | static struct usb_function *f_phonet_cfg2; |
109 | static struct eth_dev *the_dev; | ||
110 | 97 | ||
111 | 98 | ||
112 | static struct usb_configuration nokia_config_500ma_driver = { | 99 | static struct usb_configuration nokia_config_500ma_driver = { |
@@ -126,6 +113,7 @@ static struct usb_configuration nokia_config_100ma_driver = { | |||
126 | }; | 113 | }; |
127 | 114 | ||
128 | static struct usb_function_instance *fi_acm; | 115 | static struct usb_function_instance *fi_acm; |
116 | static struct usb_function_instance *fi_ecm; | ||
129 | static struct usb_function_instance *fi_obex1; | 117 | static struct usb_function_instance *fi_obex1; |
130 | static struct usb_function_instance *fi_obex2; | 118 | static struct usb_function_instance *fi_obex2; |
131 | static struct usb_function_instance *fi_phonet; | 119 | static struct usb_function_instance *fi_phonet; |
@@ -135,6 +123,7 @@ static int __init nokia_bind_config(struct usb_configuration *c) | |||
135 | struct usb_function *f_acm; | 123 | struct usb_function *f_acm; |
136 | struct usb_function *f_phonet = NULL; | 124 | struct usb_function *f_phonet = NULL; |
137 | struct usb_function *f_obex1 = NULL; | 125 | struct usb_function *f_obex1 = NULL; |
126 | struct usb_function *f_ecm; | ||
138 | struct usb_function *f_obex2 = NULL; | 127 | struct usb_function *f_obex2 = NULL; |
139 | int status = 0; | 128 | int status = 0; |
140 | int obex1_stat = 0; | 129 | int obex1_stat = 0; |
@@ -165,6 +154,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) | |||
165 | goto err_get_acm; | 154 | goto err_get_acm; |
166 | } | 155 | } |
167 | 156 | ||
157 | f_ecm = usb_get_function(fi_ecm); | ||
158 | if (IS_ERR(f_ecm)) { | ||
159 | status = PTR_ERR(f_ecm); | ||
160 | goto err_get_ecm; | ||
161 | } | ||
162 | |||
168 | if (!IS_ERR_OR_NULL(f_phonet)) { | 163 | if (!IS_ERR_OR_NULL(f_phonet)) { |
169 | phonet_stat = usb_add_function(c, f_phonet); | 164 | phonet_stat = usb_add_function(c, f_phonet); |
170 | if (phonet_stat) | 165 | if (phonet_stat) |
@@ -187,18 +182,20 @@ static int __init nokia_bind_config(struct usb_configuration *c) | |||
187 | if (status) | 182 | if (status) |
188 | goto err_conf; | 183 | goto err_conf; |
189 | 184 | ||
190 | status = ecm_bind_config(c, host_mac, the_dev); | 185 | status = usb_add_function(c, f_ecm); |
191 | if (status) { | 186 | if (status) { |
192 | pr_debug("could not bind ecm config %d\n", status); | 187 | pr_debug("could not bind ecm config %d\n", status); |
193 | goto err_ecm; | 188 | goto err_ecm; |
194 | } | 189 | } |
195 | if (c == &nokia_config_500ma_driver) { | 190 | if (c == &nokia_config_500ma_driver) { |
196 | f_acm_cfg1 = f_acm; | 191 | f_acm_cfg1 = f_acm; |
192 | f_ecm_cfg1 = f_ecm; | ||
197 | f_phonet_cfg1 = f_phonet; | 193 | f_phonet_cfg1 = f_phonet; |
198 | f_obex1_cfg1 = f_obex1; | 194 | f_obex1_cfg1 = f_obex1; |
199 | f_obex2_cfg1 = f_obex2; | 195 | f_obex2_cfg1 = f_obex2; |
200 | } else { | 196 | } else { |
201 | f_acm_cfg2 = f_acm; | 197 | f_acm_cfg2 = f_acm; |
198 | f_ecm_cfg2 = f_ecm; | ||
202 | f_phonet_cfg2 = f_phonet; | 199 | f_phonet_cfg2 = f_phonet; |
203 | f_obex1_cfg2 = f_obex1; | 200 | f_obex1_cfg2 = f_obex1; |
204 | f_obex2_cfg2 = f_obex2; | 201 | f_obex2_cfg2 = f_obex2; |
@@ -214,6 +211,8 @@ err_conf: | |||
214 | usb_remove_function(c, f_obex1); | 211 | usb_remove_function(c, f_obex1); |
215 | if (!phonet_stat) | 212 | if (!phonet_stat) |
216 | usb_remove_function(c, f_phonet); | 213 | usb_remove_function(c, f_phonet); |
214 | usb_put_function(f_ecm); | ||
215 | err_get_ecm: | ||
217 | usb_put_function(f_acm); | 216 | usb_put_function(f_acm); |
218 | err_get_acm: | 217 | err_get_acm: |
219 | if (!IS_ERR_OR_NULL(f_obex2)) | 218 | if (!IS_ERR_OR_NULL(f_obex2)) |
@@ -230,13 +229,6 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
230 | struct usb_gadget *gadget = cdev->gadget; | 229 | struct usb_gadget *gadget = cdev->gadget; |
231 | int status; | 230 | int status; |
232 | 231 | ||
233 | the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac, | ||
234 | qmult); | ||
235 | if (IS_ERR(the_dev)) { | ||
236 | status = PTR_ERR(the_dev); | ||
237 | goto err_ether; | ||
238 | } | ||
239 | |||
240 | status = usb_string_ids_tab(cdev, strings_dev); | 232 | status = usb_string_ids_tab(cdev, strings_dev); |
241 | if (status < 0) | 233 | if (status < 0) |
242 | goto err_usb; | 234 | goto err_usb; |
@@ -246,8 +238,10 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
246 | nokia_config_500ma_driver.iConfiguration = status; | 238 | nokia_config_500ma_driver.iConfiguration = status; |
247 | nokia_config_100ma_driver.iConfiguration = status; | 239 | nokia_config_100ma_driver.iConfiguration = status; |
248 | 240 | ||
249 | if (!gadget_supports_altsettings(gadget)) | 241 | if (!gadget_supports_altsettings(gadget)) { |
242 | status = -ENODEV; | ||
250 | goto err_usb; | 243 | goto err_usb; |
244 | } | ||
251 | 245 | ||
252 | fi_phonet = usb_get_function_instance("phonet"); | 246 | fi_phonet = usb_get_function_instance("phonet"); |
253 | if (IS_ERR(fi_phonet)) | 247 | if (IS_ERR(fi_phonet)) |
@@ -262,14 +256,22 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
262 | pr_debug("could not find obex function 2\n"); | 256 | pr_debug("could not find obex function 2\n"); |
263 | 257 | ||
264 | fi_acm = usb_get_function_instance("acm"); | 258 | fi_acm = usb_get_function_instance("acm"); |
265 | if (IS_ERR(fi_acm)) | 259 | if (IS_ERR(fi_acm)) { |
260 | status = PTR_ERR(fi_acm); | ||
266 | goto err_obex2_inst; | 261 | goto err_obex2_inst; |
262 | } | ||
263 | |||
264 | fi_ecm = usb_get_function_instance("ecm"); | ||
265 | if (IS_ERR(fi_ecm)) { | ||
266 | status = PTR_ERR(fi_ecm); | ||
267 | goto err_acm_inst; | ||
268 | } | ||
267 | 269 | ||
268 | /* finally register the configuration */ | 270 | /* finally register the configuration */ |
269 | status = usb_add_config(cdev, &nokia_config_500ma_driver, | 271 | status = usb_add_config(cdev, &nokia_config_500ma_driver, |
270 | nokia_bind_config); | 272 | nokia_bind_config); |
271 | if (status < 0) | 273 | if (status < 0) |
272 | goto err_acm_inst; | 274 | goto err_ecm_inst; |
273 | 275 | ||
274 | status = usb_add_config(cdev, &nokia_config_100ma_driver, | 276 | status = usb_add_config(cdev, &nokia_config_100ma_driver, |
275 | nokia_bind_config); | 277 | nokia_bind_config); |
@@ -289,6 +291,9 @@ err_put_cfg1: | |||
289 | usb_put_function(f_obex2_cfg1); | 291 | usb_put_function(f_obex2_cfg1); |
290 | if (!IS_ERR_OR_NULL(f_phonet_cfg1)) | 292 | if (!IS_ERR_OR_NULL(f_phonet_cfg1)) |
291 | usb_put_function(f_phonet_cfg1); | 293 | usb_put_function(f_phonet_cfg1); |
294 | usb_put_function(f_ecm_cfg1); | ||
295 | err_ecm_inst: | ||
296 | usb_put_function_instance(fi_ecm); | ||
292 | err_acm_inst: | 297 | err_acm_inst: |
293 | usb_put_function_instance(fi_acm); | 298 | usb_put_function_instance(fi_acm); |
294 | err_obex2_inst: | 299 | err_obex2_inst: |
@@ -299,8 +304,6 @@ err_obex2_inst: | |||
299 | if (!IS_ERR(fi_phonet)) | 304 | if (!IS_ERR(fi_phonet)) |
300 | usb_put_function_instance(fi_phonet); | 305 | usb_put_function_instance(fi_phonet); |
301 | err_usb: | 306 | err_usb: |
302 | gether_cleanup(the_dev); | ||
303 | err_ether: | ||
304 | return status; | 307 | return status; |
305 | } | 308 | } |
306 | 309 | ||
@@ -320,7 +323,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev) | |||
320 | usb_put_function(f_phonet_cfg2); | 323 | usb_put_function(f_phonet_cfg2); |
321 | usb_put_function(f_acm_cfg1); | 324 | usb_put_function(f_acm_cfg1); |
322 | usb_put_function(f_acm_cfg2); | 325 | usb_put_function(f_acm_cfg2); |
326 | usb_put_function(f_ecm_cfg1); | ||
327 | usb_put_function(f_ecm_cfg2); | ||
323 | 328 | ||
329 | usb_put_function_instance(fi_ecm); | ||
324 | if (!IS_ERR(fi_obex2)) | 330 | if (!IS_ERR(fi_obex2)) |
325 | usb_put_function_instance(fi_obex2); | 331 | usb_put_function_instance(fi_obex2); |
326 | if (!IS_ERR(fi_obex1)) | 332 | if (!IS_ERR(fi_obex1)) |
@@ -329,8 +335,6 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev) | |||
329 | usb_put_function_instance(fi_phonet); | 335 | usb_put_function_instance(fi_phonet); |
330 | usb_put_function_instance(fi_acm); | 336 | usb_put_function_instance(fi_acm); |
331 | 337 | ||
332 | gether_cleanup(the_dev); | ||
333 | |||
334 | return 0; | 338 | return 0; |
335 | } | 339 | } |
336 | 340 | ||