aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_ecm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_ecm.c')
-rw-r--r--drivers/usb/gadget/f_ecm.c73
1 files changed, 1 insertions, 72 deletions
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 8d9e6f7e8f1a..798760fa7e70 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -691,7 +691,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
691 int status; 691 int status;
692 struct usb_ep *ep; 692 struct usb_ep *ep;
693 693
694#ifndef USBF_ECM_INCLUDED
695 struct f_ecm_opts *ecm_opts; 694 struct f_ecm_opts *ecm_opts;
696 695
697 if (!can_support_ecm(cdev->gadget)) 696 if (!can_support_ecm(cdev->gadget))
@@ -715,7 +714,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
715 return status; 714 return status;
716 ecm_opts->bound = true; 715 ecm_opts->bound = true;
717 } 716 }
718#endif 717
719 us = usb_gstrings_attach(cdev, ecm_strings, 718 us = usb_gstrings_attach(cdev, ecm_strings,
720 ARRAY_SIZE(ecm_string_defs)); 719 ARRAY_SIZE(ecm_string_defs));
721 if (IS_ERR(us)) 720 if (IS_ERR(us))
@@ -834,74 +833,6 @@ fail:
834 return status; 833 return status;
835} 834}
836 835
837#ifdef USBF_ECM_INCLUDED
838
839static void
840ecm_old_unbind(struct usb_configuration *c, struct usb_function *f)
841{
842 struct f_ecm *ecm = func_to_ecm(f);
843
844 DBG(c->cdev, "ecm unbind\n");
845
846 usb_free_all_descriptors(f);
847
848 kfree(ecm->notify_req->buf);
849 usb_ep_free_request(ecm->notify, ecm->notify_req);
850 kfree(ecm);
851}
852
853/**
854 * ecm_bind_config - add CDC Ethernet network link to a configuration
855 * @c: the configuration to support the network link
856 * @ethaddr: a buffer in which the ethernet address of the host side
857 * side of the link was recorded
858 * @dev: eth_dev structure
859 * Context: single threaded during gadget setup
860 *
861 * Returns zero on success, else negative errno.
862 *
863 * Caller must have called @gether_setup(). Caller is also responsible
864 * for calling @gether_cleanup() before module unload.
865 */
866int
867ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
868 struct eth_dev *dev)
869{
870 struct f_ecm *ecm;
871 int status;
872
873 if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
874 return -EINVAL;
875
876 /* allocate and initialize one new instance */
877 ecm = kzalloc(sizeof *ecm, GFP_KERNEL);
878 if (!ecm)
879 return -ENOMEM;
880
881 /* export host's Ethernet address in CDC format */
882 snprintf(ecm->ethaddr, sizeof ecm->ethaddr, "%pm", ethaddr);
883 ecm_string_defs[1].s = ecm->ethaddr;
884
885 ecm->port.ioport = dev;
886 ecm->port.cdc_filter = DEFAULT_FILTER;
887
888 ecm->port.func.name = "cdc_ethernet";
889 /* descriptors are per-instance copies */
890 ecm->port.func.bind = ecm_bind;
891 ecm->port.func.unbind = ecm_old_unbind;
892 ecm->port.func.set_alt = ecm_set_alt;
893 ecm->port.func.get_alt = ecm_get_alt;
894 ecm->port.func.setup = ecm_setup;
895 ecm->port.func.disable = ecm_disable;
896
897 status = usb_add_function(c, &ecm->port.func);
898 if (status)
899 kfree(ecm);
900 return status;
901}
902
903#else
904
905static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item) 836static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item)
906{ 837{
907 return container_of(to_config_group(item), struct f_ecm_opts, 838 return container_of(to_config_group(item), struct f_ecm_opts,
@@ -1040,5 +971,3 @@ static struct usb_function *ecm_alloc(struct usb_function_instance *fi)
1040DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc); 971DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc);
1041MODULE_LICENSE("GPL"); 972MODULE_LICENSE("GPL");
1042MODULE_AUTHOR("David Brownell"); 973MODULE_AUTHOR("David Brownell");
1043
1044#endif