Lines Matching refs:ecm
368 static void ecm_do_notify(struct f_ecm *ecm) in ecm_do_notify() argument
370 struct usb_request *req = ecm->notify_req; in ecm_do_notify()
372 struct usb_composite_dev *cdev = ecm->port.func.config->cdev; in ecm_do_notify()
377 if (atomic_read(&ecm->notify_count)) in ecm_do_notify()
381 switch (ecm->notify_state) { in ecm_do_notify()
387 if (ecm->is_open) in ecm_do_notify()
394 DBG(cdev, "notify connect %s\n", str_true_false(ecm->is_open)); in ecm_do_notify()
395 ecm->notify_state = ECM_NOTIFY_SPEED; in ecm_do_notify()
410 ecm->notify_state = ECM_NOTIFY_NONE; in ecm_do_notify()
414 event->wIndex = cpu_to_le16(ecm->ctrl_id); in ecm_do_notify()
416 atomic_inc(&ecm->notify_count); in ecm_do_notify()
417 status = usb_ep_queue(ecm->notify, req, GFP_ATOMIC); in ecm_do_notify()
419 atomic_dec(&ecm->notify_count); in ecm_do_notify()
424 static void ecm_notify(struct f_ecm *ecm) in ecm_notify() argument
431 ecm->notify_state = ECM_NOTIFY_CONNECT; in ecm_notify()
432 ecm_do_notify(ecm); in ecm_notify()
437 struct f_ecm *ecm = req->context; in ecm_notify_complete() local
438 struct usb_composite_dev *cdev = ecm->port.func.config->cdev; in ecm_notify_complete()
444 atomic_dec(&ecm->notify_count); in ecm_notify_complete()
448 atomic_set(&ecm->notify_count, 0); in ecm_notify_complete()
449 ecm->notify_state = ECM_NOTIFY_NONE; in ecm_notify_complete()
454 atomic_dec(&ecm->notify_count); in ecm_notify_complete()
457 ecm_do_notify(ecm); in ecm_notify_complete()
462 struct f_ecm *ecm = func_to_ecm(f); in ecm_setup() local
479 if (w_length != 0 || w_index != ecm->ctrl_id) in ecm_setup()
486 ecm->port.cdc_filter = w_value; in ecm_setup()
527 struct f_ecm *ecm = func_to_ecm(f); in ecm_set_alt() local
531 if (intf == ecm->ctrl_id) { in ecm_set_alt()
536 usb_ep_disable(ecm->notify); in ecm_set_alt()
537 if (!(ecm->notify->desc)) { in ecm_set_alt()
539 if (config_ep_by_speed(cdev->gadget, f, ecm->notify)) in ecm_set_alt()
542 usb_ep_enable(ecm->notify); in ecm_set_alt()
545 } else if (intf == ecm->data_id) { in ecm_set_alt()
549 if (ecm->port.in_ep->enabled) { in ecm_set_alt()
551 gether_disconnect(&ecm->port); in ecm_set_alt()
554 if (!ecm->port.in_ep->desc || in ecm_set_alt()
555 !ecm->port.out_ep->desc) { in ecm_set_alt()
558 ecm->port.in_ep) || in ecm_set_alt()
560 ecm->port.out_ep)) { in ecm_set_alt()
561 ecm->port.in_ep->desc = NULL; in ecm_set_alt()
562 ecm->port.out_ep->desc = NULL; in ecm_set_alt()
576 ecm->port.is_zlp_ok = in ecm_set_alt()
578 ecm->port.cdc_filter = DEFAULT_FILTER; in ecm_set_alt()
580 net = gether_connect(&ecm->port); in ecm_set_alt()
591 ecm_notify(ecm); in ecm_set_alt()
605 struct f_ecm *ecm = func_to_ecm(f); in ecm_get_alt() local
607 if (intf == ecm->ctrl_id) in ecm_get_alt()
609 return ecm->port.in_ep->enabled ? 1 : 0; in ecm_get_alt()
614 struct f_ecm *ecm = func_to_ecm(f); in ecm_disable() local
619 if (ecm->port.in_ep->enabled) { in ecm_disable()
620 gether_disconnect(&ecm->port); in ecm_disable()
622 ecm->port.in_ep->desc = NULL; in ecm_disable()
623 ecm->port.out_ep->desc = NULL; in ecm_disable()
626 usb_ep_disable(ecm->notify); in ecm_disable()
627 ecm->notify->desc = NULL; in ecm_disable()
652 struct f_ecm *ecm = func_to_ecm(&geth->func); in ecm_open() local
654 DBG(ecm->port.func.config->cdev, "%s\n", __func__); in ecm_open()
656 ecm->is_open = true; in ecm_open()
657 ecm_notify(ecm); in ecm_open()
662 struct f_ecm *ecm = func_to_ecm(&geth->func); in ecm_close() local
664 DBG(ecm->port.func.config->cdev, "%s\n", __func__); in ecm_close()
666 ecm->is_open = false; in ecm_close()
667 ecm_notify(ecm); in ecm_close()
678 struct f_ecm *ecm = func_to_ecm(f); in ecm_bind() local
704 ecm_string_defs[1].s = ecm->ethaddr; in ecm_bind()
719 ecm->ctrl_id = status; in ecm_bind()
728 ecm->data_id = status; in ecm_bind()
738 ecm->port.in_ep = ep; in ecm_bind()
743 ecm->port.out_ep = ep; in ecm_bind()
752 ecm->notify = ep; in ecm_bind()
761 request->context = ecm; in ecm_bind()
788 ecm->port.open = ecm_open; in ecm_bind()
789 ecm->port.close = ecm_close; in ecm_bind()
791 ecm->notify_req = no_free_ptr(request); in ecm_bind()
794 ecm->port.in_ep->name, ecm->port.out_ep->name, in ecm_bind()
795 ecm->notify->name); in ecm_bind()
806 USB_ETHERNET_CONFIGFS_ITEM(ecm);
809 USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ecm);
812 USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ecm);
815 USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
818 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
869 struct f_ecm *ecm = func_to_ecm(f); in ecm_suspend() local
870 struct usb_composite_dev *cdev = ecm->port.func.config->cdev; in ecm_suspend()
874 gether_suspend(&ecm->port); in ecm_suspend()
879 struct f_ecm *ecm = func_to_ecm(f); in ecm_resume() local
880 struct usb_composite_dev *cdev = ecm->port.func.config->cdev; in ecm_resume()
884 gether_resume(&ecm->port); in ecm_resume()
895 struct f_ecm *ecm; in ecm_free() local
898 ecm = func_to_ecm(f); in ecm_free()
900 kfree(ecm); in ecm_free()
908 struct f_ecm *ecm = func_to_ecm(f); in ecm_unbind() local
914 if (atomic_read(&ecm->notify_count)) { in ecm_unbind()
915 usb_ep_dequeue(ecm->notify, ecm->notify_req); in ecm_unbind()
916 atomic_set(&ecm->notify_count, 0); in ecm_unbind()
919 kfree(ecm->notify_req->buf); in ecm_unbind()
920 usb_ep_free_request(ecm->notify, ecm->notify_req); in ecm_unbind()
925 struct f_ecm *ecm; in ecm_alloc() local
930 ecm = kzalloc_obj(*ecm); in ecm_alloc()
931 if (!ecm) in ecm_alloc()
939 status = gether_get_host_addr_cdc(opts->net, ecm->ethaddr, in ecm_alloc()
940 sizeof(ecm->ethaddr)); in ecm_alloc()
942 kfree(ecm); in ecm_alloc()
947 ecm->port.ioport = netdev_priv(opts->net); in ecm_alloc()
949 ecm->port.cdc_filter = DEFAULT_FILTER; in ecm_alloc()
951 ecm->port.func.name = "cdc_ethernet"; in ecm_alloc()
953 ecm->port.func.bind = ecm_bind; in ecm_alloc()
954 ecm->port.func.unbind = ecm_unbind; in ecm_alloc()
955 ecm->port.func.set_alt = ecm_set_alt; in ecm_alloc()
956 ecm->port.func.get_alt = ecm_get_alt; in ecm_alloc()
957 ecm->port.func.setup = ecm_setup; in ecm_alloc()
958 ecm->port.func.disable = ecm_disable; in ecm_alloc()
959 ecm->port.func.free_func = ecm_free; in ecm_alloc()
960 ecm->port.func.suspend = ecm_suspend; in ecm_alloc()
961 ecm->port.func.get_status = ecm_get_status; in ecm_alloc()
962 ecm->port.func.resume = ecm_resume; in ecm_alloc()
964 return &ecm->port.func; in ecm_alloc()
967 DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc);