diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2013-05-28 03:15:54 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-06-10 10:58:07 -0400 |
commit | 8af5232d6f48896b151898ccb2e9e155481bb785 (patch) | |
tree | e20bd9739b68769851e4a81cc75b702c3a2d2223 /drivers/usb/gadget | |
parent | 8cedba7c73af1369599b1111639cfeb66fe13aaa (diff) |
usb: gadget: ether: convert to new interface of f_subset
teach ethernet code about the new interface of f_subset so
the old one can eventually be removed.
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>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/ether.c | 104 |
2 files changed, 58 insertions, 47 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 803aa93f3aa5..0a444f39109f 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -644,6 +644,7 @@ config USB_ETH | |||
644 | select USB_U_ETHER | 644 | select USB_U_ETHER |
645 | select USB_U_RNDIS | 645 | select USB_U_RNDIS |
646 | select USB_F_ECM | 646 | select USB_F_ECM |
647 | select USB_F_SUBSET | ||
647 | select CRC32 | 648 | select CRC32 |
648 | help | 649 | help |
649 | This driver implements Ethernet style communication, in one of | 650 | This driver implements Ethernet style communication, in one of |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 31739662ad00..9e96d5583e4c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -14,6 +14,7 @@ | |||
14 | /* #define VERBOSE_DEBUG */ | 14 | /* #define VERBOSE_DEBUG */ |
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/netdevice.h> | ||
17 | 18 | ||
18 | #if defined USB_ETH_RNDIS | 19 | #if defined USB_ETH_RNDIS |
19 | # undef USB_ETH_RNDIS | 20 | # undef USB_ETH_RNDIS |
@@ -103,8 +104,7 @@ static inline bool has_rndis(void) | |||
103 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 104 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
104 | */ | 105 | */ |
105 | #include "u_ecm.h" | 106 | #include "u_ecm.h" |
106 | #define USB_FSUBSET_INCLUDED | 107 | #include "u_gether.h" |
107 | #include "f_subset.c" | ||
108 | #ifdef USB_ETH_RNDIS | 108 | #ifdef USB_ETH_RNDIS |
109 | #include "f_rndis.c" | 109 | #include "f_rndis.c" |
110 | #include "rndis.h" | 110 | #include "rndis.h" |
@@ -220,6 +220,9 @@ static struct usb_function *f_ecm; | |||
220 | static struct usb_function_instance *fi_eem; | 220 | static struct usb_function_instance *fi_eem; |
221 | static struct usb_function *f_eem; | 221 | static struct usb_function *f_eem; |
222 | 222 | ||
223 | static struct usb_function_instance *fi_geth; | ||
224 | static struct usb_function *f_geth; | ||
225 | |||
223 | /*-------------------------------------------------------------------------*/ | 226 | /*-------------------------------------------------------------------------*/ |
224 | 227 | ||
225 | /* | 228 | /* |
@@ -290,8 +293,17 @@ static int __init eth_do_config(struct usb_configuration *c) | |||
290 | usb_put_function(f_ecm); | 293 | usb_put_function(f_ecm); |
291 | 294 | ||
292 | return status; | 295 | return status; |
293 | } else | 296 | } else { |
294 | return geth_bind_config(c, host_mac, the_dev); | 297 | f_geth = usb_get_function(fi_geth); |
298 | if (IS_ERR(f_geth)) | ||
299 | return PTR_ERR(f_geth); | ||
300 | |||
301 | status = usb_add_function(c, f_geth); | ||
302 | if (status < 0) | ||
303 | usb_put_function(f_geth); | ||
304 | |||
305 | return status; | ||
306 | } | ||
295 | 307 | ||
296 | } | 308 | } |
297 | 309 | ||
@@ -309,16 +321,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
309 | struct usb_gadget *gadget = cdev->gadget; | 321 | struct usb_gadget *gadget = cdev->gadget; |
310 | struct f_eem_opts *eem_opts = NULL; | 322 | struct f_eem_opts *eem_opts = NULL; |
311 | struct f_ecm_opts *ecm_opts = NULL; | 323 | struct f_ecm_opts *ecm_opts = NULL; |
324 | struct f_gether_opts *geth_opts = NULL; | ||
325 | struct net_device *net; | ||
312 | int status; | 326 | int status; |
313 | 327 | ||
314 | if (!use_eem && !can_support_ecm(gadget)) { | ||
315 | /* set up network link layer */ | ||
316 | the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, | ||
317 | host_mac, qmult); | ||
318 | if (IS_ERR(the_dev)) | ||
319 | return PTR_ERR(the_dev); | ||
320 | } | ||
321 | |||
322 | /* set up main config label and device descriptor */ | 328 | /* set up main config label and device descriptor */ |
323 | if (use_eem) { | 329 | if (use_eem) { |
324 | /* EEM */ | 330 | /* EEM */ |
@@ -328,13 +334,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
328 | 334 | ||
329 | eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst); | 335 | eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst); |
330 | 336 | ||
331 | gether_set_qmult(eem_opts->net, qmult); | 337 | net = eem_opts->net; |
332 | if (!gether_set_host_addr(eem_opts->net, host_addr)) | 338 | the_dev = netdev_priv(net); |
333 | pr_info("using host ethernet address: %s", host_addr); | ||
334 | if (!gether_set_dev_addr(eem_opts->net, dev_addr)) | ||
335 | pr_info("using self ethernet address: %s", dev_addr); | ||
336 | |||
337 | the_dev = netdev_priv(eem_opts->net); | ||
338 | 339 | ||
339 | eth_config_driver.label = "CDC Ethernet (EEM)"; | 340 | eth_config_driver.label = "CDC Ethernet (EEM)"; |
340 | device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM); | 341 | device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM); |
@@ -348,17 +349,23 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
348 | 349 | ||
349 | ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); | 350 | ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); |
350 | 351 | ||
351 | gether_set_qmult(ecm_opts->net, qmult); | 352 | net = ecm_opts->net; |
352 | if (!gether_set_host_addr(ecm_opts->net, host_addr)) | 353 | the_dev = netdev_priv(net); |
353 | pr_info("using host ethernet address: %s", host_addr); | ||
354 | if (!gether_set_dev_addr(ecm_opts->net, dev_addr)) | ||
355 | pr_info("using self ethernet address: %s", dev_addr); | ||
356 | |||
357 | the_dev = netdev_priv(ecm_opts->net); | ||
358 | 354 | ||
359 | eth_config_driver.label = "CDC Ethernet (ECM)"; | 355 | eth_config_driver.label = "CDC Ethernet (ECM)"; |
360 | } else { | 356 | } else { |
361 | /* CDC Subset */ | 357 | /* CDC Subset */ |
358 | |||
359 | fi_geth = usb_get_function_instance("geth"); | ||
360 | if (IS_ERR(fi_geth)) | ||
361 | return PTR_ERR(fi_geth); | ||
362 | |||
363 | geth_opts = container_of(fi_geth, struct f_gether_opts, | ||
364 | func_inst); | ||
365 | |||
366 | net = geth_opts->net; | ||
367 | the_dev = netdev_priv(net); | ||
368 | |||
362 | eth_config_driver.label = "CDC Subset/SAFE"; | 369 | eth_config_driver.label = "CDC Subset/SAFE"; |
363 | 370 | ||
364 | device_desc.idVendor = cpu_to_le16(SIMPLE_VENDOR_NUM); | 371 | device_desc.idVendor = cpu_to_le16(SIMPLE_VENDOR_NUM); |
@@ -367,23 +374,26 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
367 | device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; | 374 | device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; |
368 | } | 375 | } |
369 | 376 | ||
377 | gether_set_qmult(net, qmult); | ||
378 | if (!gether_set_host_addr(net, host_addr)) | ||
379 | pr_info("using host ethernet address: %s", host_addr); | ||
380 | if (!gether_set_dev_addr(net, dev_addr)) | ||
381 | pr_info("using self ethernet address: %s", dev_addr); | ||
382 | |||
370 | if (has_rndis()) { | 383 | if (has_rndis()) { |
371 | /* RNDIS plus ECM-or-Subset */ | 384 | /* RNDIS plus ECM-or-Subset */ |
372 | if (use_eem) { | 385 | gether_set_gadget(net, cdev->gadget); |
373 | gether_set_gadget(eem_opts->net, cdev->gadget); | 386 | status = gether_register_netdev(net); |
374 | status = gether_register_netdev(eem_opts->net); | 387 | if (status) |
375 | if (status) | 388 | goto fail; |
376 | goto fail; | 389 | gether_get_host_addr_u8(net, host_mac); |
390 | |||
391 | if (use_eem) | ||
377 | eem_opts->bound = true; | 392 | eem_opts->bound = true; |
378 | gether_get_host_addr_u8(eem_opts->net, host_mac); | 393 | else if (can_support_ecm(gadget)) |
379 | } else if (can_support_ecm(gadget)) { | ||
380 | gether_set_gadget(ecm_opts->net, cdev->gadget); | ||
381 | status = gether_register_netdev(ecm_opts->net); | ||
382 | if (status) | ||
383 | goto fail; | ||
384 | ecm_opts->bound = true; | 394 | ecm_opts->bound = true; |
385 | gether_get_host_addr_u8(ecm_opts->net, host_mac); | 395 | else |
386 | } | 396 | geth_opts->bound = true; |
387 | 397 | ||
388 | device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM); | 398 | device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM); |
389 | device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM); | 399 | device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM); |
@@ -419,23 +429,23 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
419 | return 0; | 429 | return 0; |
420 | 430 | ||
421 | fail: | 431 | fail: |
422 | if (!use_eem && !can_support_ecm(gadget)) | 432 | if (use_eem) |
423 | gether_cleanup(the_dev); | ||
424 | else if (use_eem) | ||
425 | usb_put_function_instance(fi_eem); | 433 | usb_put_function_instance(fi_eem); |
426 | else | 434 | else if (can_support_ecm(gadget)) |
427 | usb_put_function_instance(fi_ecm); | 435 | usb_put_function_instance(fi_ecm); |
436 | else | ||
437 | usb_put_function_instance(fi_geth); | ||
428 | return status; | 438 | return status; |
429 | } | 439 | } |
430 | 440 | ||
431 | static int __exit eth_unbind(struct usb_composite_dev *cdev) | 441 | static int __exit eth_unbind(struct usb_composite_dev *cdev) |
432 | { | 442 | { |
433 | if (!use_eem && !can_support_ecm(cdev->gadget)) | 443 | if (use_eem) |
434 | gether_cleanup(the_dev); | ||
435 | else if (use_eem) | ||
436 | usb_put_function_instance(fi_eem); | 444 | usb_put_function_instance(fi_eem); |
437 | else | 445 | else if (can_support_ecm(cdev->gadget)) |
438 | usb_put_function_instance(fi_ecm); | 446 | usb_put_function_instance(fi_ecm); |
447 | else | ||
448 | usb_put_function_instance(fi_geth); | ||
439 | return 0; | 449 | return 0; |
440 | } | 450 | } |
441 | 451 | ||