Lines Matching refs:ecm
375 static void ecm_do_notify(struct f_ecm *ecm) in ecm_do_notify() argument
377 struct usb_request *req = ecm->notify_req; in ecm_do_notify()
379 struct usb_composite_dev *cdev = ecm->port.func.config->cdev; in ecm_do_notify()
384 if (atomic_read(&ecm->notify_count)) in ecm_do_notify()
388 switch (ecm->notify_state) { in ecm_do_notify()
394 if (ecm->is_open) in ecm_do_notify()
402 ecm->is_open ? "true" : "false"); in ecm_do_notify()
403 ecm->notify_state = ECM_NOTIFY_SPEED; in ecm_do_notify()
418 ecm->notify_state = ECM_NOTIFY_NONE; in ecm_do_notify()
422 event->wIndex = cpu_to_le16(ecm->ctrl_id); in ecm_do_notify()
424 atomic_inc(&ecm->notify_count); in ecm_do_notify()
425 status = usb_ep_queue(ecm->notify, req, GFP_ATOMIC); in ecm_do_notify()
427 atomic_dec(&ecm->notify_count); in ecm_do_notify()
432 static void ecm_notify(struct f_ecm *ecm) in ecm_notify() argument
439 ecm->notify_state = ECM_NOTIFY_CONNECT; in ecm_notify()
440 ecm_do_notify(ecm); in ecm_notify()
445 struct f_ecm *ecm = req->context; in ecm_notify_complete() local
446 struct usb_composite_dev *cdev = ecm->port.func.config->cdev; in ecm_notify_complete()
452 atomic_dec(&ecm->notify_count); in ecm_notify_complete()
456 atomic_set(&ecm->notify_count, 0); in ecm_notify_complete()
457 ecm->notify_state = ECM_NOTIFY_NONE; in ecm_notify_complete()
462 atomic_dec(&ecm->notify_count); in ecm_notify_complete()
465 ecm_do_notify(ecm); in ecm_notify_complete()
470 struct f_ecm *ecm = func_to_ecm(f); in ecm_setup() local
487 if (w_length != 0 || w_index != ecm->ctrl_id) in ecm_setup()
494 ecm->port.cdc_filter = w_value; in ecm_setup()
535 struct f_ecm *ecm = func_to_ecm(f); in ecm_set_alt() local
539 if (intf == ecm->ctrl_id) { in ecm_set_alt()
544 usb_ep_disable(ecm->notify); in ecm_set_alt()
545 if (!(ecm->notify->desc)) { in ecm_set_alt()
547 if (config_ep_by_speed(cdev->gadget, f, ecm->notify)) in ecm_set_alt()
550 usb_ep_enable(ecm->notify); in ecm_set_alt()
553 } else if (intf == ecm->data_id) { in ecm_set_alt()
557 if (ecm->port.in_ep->enabled) { in ecm_set_alt()
559 gether_disconnect(&ecm->port); in ecm_set_alt()
562 if (!ecm->port.in_ep->desc || in ecm_set_alt()
563 !ecm->port.out_ep->desc) { in ecm_set_alt()
566 ecm->port.in_ep) || in ecm_set_alt()
568 ecm->port.out_ep)) { in ecm_set_alt()
569 ecm->port.in_ep->desc = NULL; in ecm_set_alt()
570 ecm->port.out_ep->desc = NULL; in ecm_set_alt()
584 ecm->port.is_zlp_ok = in ecm_set_alt()
586 ecm->port.cdc_filter = DEFAULT_FILTER; in ecm_set_alt()
588 net = gether_connect(&ecm->port); in ecm_set_alt()
599 ecm_notify(ecm); in ecm_set_alt()
613 struct f_ecm *ecm = func_to_ecm(f); in ecm_get_alt() local
615 if (intf == ecm->ctrl_id) in ecm_get_alt()
617 return ecm->port.in_ep->enabled ? 1 : 0; in ecm_get_alt()
622 struct f_ecm *ecm = func_to_ecm(f); in ecm_disable() local
627 if (ecm->port.in_ep->enabled) { in ecm_disable()
628 gether_disconnect(&ecm->port); in ecm_disable()
630 ecm->port.in_ep->desc = NULL; in ecm_disable()
631 ecm->port.out_ep->desc = NULL; in ecm_disable()
634 usb_ep_disable(ecm->notify); in ecm_disable()
635 ecm->notify->desc = NULL; in ecm_disable()
660 struct f_ecm *ecm = func_to_ecm(&geth->func); in ecm_open() local
662 DBG(ecm->port.func.config->cdev, "%s\n", __func__); in ecm_open()
664 ecm->is_open = true; in ecm_open()
665 ecm_notify(ecm); in ecm_open()
670 struct f_ecm *ecm = func_to_ecm(&geth->func); in ecm_close() local
672 DBG(ecm->port.func.config->cdev, "%s\n", __func__); in ecm_close()
674 ecm->is_open = false; in ecm_close()
675 ecm_notify(ecm); in ecm_close()
686 struct f_ecm *ecm = func_to_ecm(f); in ecm_bind() local
715 ecm_string_defs[1].s = ecm->ethaddr; in ecm_bind()
730 ecm->ctrl_id = status; in ecm_bind()
739 ecm->data_id = status; in ecm_bind()
751 ecm->port.in_ep = ep; in ecm_bind()
756 ecm->port.out_ep = ep; in ecm_bind()
765 ecm->notify = ep; in ecm_bind()
770 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); in ecm_bind()
771 if (!ecm->notify_req) in ecm_bind()
773 ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL); in ecm_bind()
774 if (!ecm->notify_req->buf) in ecm_bind()
776 ecm->notify_req->context = ecm; in ecm_bind()
777 ecm->notify_req->complete = ecm_notify_complete; in ecm_bind()
803 ecm->port.open = ecm_open; in ecm_bind()
804 ecm->port.close = ecm_close; in ecm_bind()
809 ecm->port.in_ep->name, ecm->port.out_ep->name, in ecm_bind()
810 ecm->notify->name); in ecm_bind()
814 if (ecm->notify_req) { in ecm_bind()
815 kfree(ecm->notify_req->buf); in ecm_bind()
816 usb_ep_free_request(ecm->notify, ecm->notify_req); in ecm_bind()
831 USB_ETHERNET_CONFIGFS_ITEM(ecm);
834 USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ecm);
837 USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ecm);
840 USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
843 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
894 struct f_ecm *ecm; in ecm_free() local
897 ecm = func_to_ecm(f); in ecm_free()
899 kfree(ecm); in ecm_free()
907 struct f_ecm *ecm = func_to_ecm(f); in ecm_unbind() local
913 if (atomic_read(&ecm->notify_count)) { in ecm_unbind()
914 usb_ep_dequeue(ecm->notify, ecm->notify_req); in ecm_unbind()
915 atomic_set(&ecm->notify_count, 0); in ecm_unbind()
918 kfree(ecm->notify_req->buf); in ecm_unbind()
919 usb_ep_free_request(ecm->notify, ecm->notify_req); in ecm_unbind()
924 struct f_ecm *ecm; in ecm_alloc() local
929 ecm = kzalloc(sizeof(*ecm), GFP_KERNEL); in ecm_alloc()
930 if (!ecm) in ecm_alloc()
938 status = gether_get_host_addr_cdc(opts->net, ecm->ethaddr, in ecm_alloc()
939 sizeof(ecm->ethaddr)); in ecm_alloc()
941 kfree(ecm); in ecm_alloc()
946 ecm->port.ioport = netdev_priv(opts->net); in ecm_alloc()
948 ecm->port.cdc_filter = DEFAULT_FILTER; in ecm_alloc()
950 ecm->port.func.name = "cdc_ethernet"; in ecm_alloc()
952 ecm->port.func.bind = ecm_bind; in ecm_alloc()
953 ecm->port.func.unbind = ecm_unbind; in ecm_alloc()
954 ecm->port.func.set_alt = ecm_set_alt; in ecm_alloc()
955 ecm->port.func.get_alt = ecm_get_alt; in ecm_alloc()
956 ecm->port.func.setup = ecm_setup; in ecm_alloc()
957 ecm->port.func.disable = ecm_disable; in ecm_alloc()
958 ecm->port.func.free_func = ecm_free; in ecm_alloc()
960 return &ecm->port.func; in ecm_alloc()
963 DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc);