Lines Matching refs:func
92 static void ffs_func_eps_disable(struct ffs_function *func);
93 static int __must_check ffs_func_eps_enable(struct ffs_function *func);
105 static int ffs_func_revmap_ep(struct ffs_function *func, u8 num);
106 static int ffs_func_revmap_intf(struct ffs_function *func, u8 intf);
567 struct ffs_function *func = ffs->func; in ffs_ep0_ioctl() local
568 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; in ffs_ep0_ioctl()
1612 static void ffs_func_eps_disable(struct ffs_function *func) in ffs_func_eps_disable() argument
1614 struct ffs_ep *ep = func->eps; in ffs_func_eps_disable()
1615 struct ffs_epfile *epfile = func->ffs->epfiles; in ffs_func_eps_disable()
1616 unsigned count = func->ffs->eps_count; in ffs_func_eps_disable()
1619 spin_lock_irqsave(&func->ffs->eps_lock, flags); in ffs_func_eps_disable()
1631 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); in ffs_func_eps_disable()
1634 static int ffs_func_eps_enable(struct ffs_function *func) in ffs_func_eps_enable() argument
1636 struct ffs_data *ffs = func->ffs; in ffs_func_eps_enable()
1637 struct ffs_ep *ep = func->eps; in ffs_func_eps_enable()
1643 spin_lock_irqsave(&func->ffs->eps_lock, flags); in ffs_func_eps_enable()
1681 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); in ffs_func_eps_enable()
2465 struct ffs_function *func = priv; in __ffs_func_bind_do_descs() local
2480 if (func->function.ss_descriptors) { in __ffs_func_bind_do_descs()
2482 func->function.ss_descriptors[(long)valuep] = desc; in __ffs_func_bind_do_descs()
2483 } else if (func->function.hs_descriptors) { in __ffs_func_bind_do_descs()
2485 func->function.hs_descriptors[(long)valuep] = desc; in __ffs_func_bind_do_descs()
2488 func->function.fs_descriptors[(long)valuep] = desc; in __ffs_func_bind_do_descs()
2494 idx = ffs_ep_addr2idx(func->ffs, ds->bEndpointAddress) - 1; in __ffs_func_bind_do_descs()
2498 ffs_ep = func->eps + idx; in __ffs_func_bind_do_descs()
2524 ep = usb_ep_autoconfig(func->gadget, ds); in __ffs_func_bind_do_descs()
2527 ep->driver_data = func->eps + idx; in __ffs_func_bind_do_descs()
2535 func->eps_revmap[ds->bEndpointAddress & in __ffs_func_bind_do_descs()
2541 if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR) in __ffs_func_bind_do_descs()
2553 struct ffs_function *func = priv; in __ffs_func_bind_do_nums() local
2565 if (func->interfaces_nums[idx] < 0) { in __ffs_func_bind_do_nums()
2566 int id = usb_interface_id(func->conf, &func->function); in __ffs_func_bind_do_nums()
2569 func->interfaces_nums[idx] = id; in __ffs_func_bind_do_nums()
2571 newValue = func->interfaces_nums[idx]; in __ffs_func_bind_do_nums()
2576 newValue = func->ffs->stringtabs[0]->strings[*valuep - 1].id; in __ffs_func_bind_do_nums()
2588 if (unlikely(!func->eps[idx].ep)) in __ffs_func_bind_do_nums()
2593 descs = func->eps[idx].descs; in __ffs_func_bind_do_nums()
2608 struct ffs_function *func = priv; in __ffs_func_bind_do_os_desc() local
2616 t = &func->function.os_desc_table[desc->bFirstInterfaceNumber]; in __ffs_func_bind_do_os_desc()
2617 t->if_id = func->interfaces_nums[desc->bFirstInterfaceNumber]; in __ffs_func_bind_do_os_desc()
2631 t = &func->function.os_desc_table[h->interface]; in __ffs_func_bind_do_os_desc()
2632 t->if_id = func->interfaces_nums[h->interface]; in __ffs_func_bind_do_os_desc()
2634 ext_prop = func->ffs->ms_os_descs_ext_prop_avail; in __ffs_func_bind_do_os_desc()
2635 func->ffs->ms_os_descs_ext_prop_avail += sizeof(*ext_prop); in __ffs_func_bind_do_os_desc()
2643 ext_prop_name = func->ffs->ms_os_descs_ext_prop_name_avail; in __ffs_func_bind_do_os_desc()
2644 func->ffs->ms_os_descs_ext_prop_name_avail += in __ffs_func_bind_do_os_desc()
2647 ext_prop_data = func->ffs->ms_os_descs_ext_prop_data_avail; in __ffs_func_bind_do_os_desc()
2648 func->ffs->ms_os_descs_ext_prop_data_avail += in __ffs_func_bind_do_os_desc()
2686 struct ffs_function *func = ffs_func_from_usb(f); in ffs_do_functionfs_bind() local
2703 func->ffs = ffs_opts->dev->ffs_data; in ffs_do_functionfs_bind()
2709 func->conf = c; in ffs_do_functionfs_bind()
2710 func->gadget = c->cdev->gadget; in ffs_do_functionfs_bind()
2720 ret = functionfs_bind(func->ffs, c->cdev); in ffs_do_functionfs_bind()
2725 func->function.strings = func->ffs->stringtabs; in ffs_do_functionfs_bind()
2733 struct ffs_function *func = ffs_func_from_usb(f); in _ffs_func_bind() local
2734 struct ffs_data *ffs = func->ffs; in _ffs_func_bind()
2736 const int full = !!func->ffs->fs_descs_count; in _ffs_func_bind()
2737 const int high = gadget_is_dualspeed(func->gadget) && in _ffs_func_bind()
2738 func->ffs->hs_descs_count; in _ffs_func_bind()
2739 const int super = gadget_is_superspeed(func->gadget) && in _ffs_func_bind()
2740 func->ffs->ss_descs_count; in _ffs_func_bind()
2801 func->eps = vla_ptr(vlabuf, d, eps); in _ffs_func_bind()
2802 func->interfaces_nums = vla_ptr(vlabuf, d, inums); in _ffs_func_bind()
2810 func->function.fs_descriptors = vla_ptr(vlabuf, d, fs_descs); in _ffs_func_bind()
2814 __ffs_func_bind_do_descs, func); in _ffs_func_bind()
2824 func->function.hs_descriptors = vla_ptr(vlabuf, d, hs_descs); in _ffs_func_bind()
2828 __ffs_func_bind_do_descs, func); in _ffs_func_bind()
2838 func->function.ss_descriptors = vla_ptr(vlabuf, d, ss_descs); in _ffs_func_bind()
2842 __ffs_func_bind_do_descs, func); in _ffs_func_bind()
2860 __ffs_func_bind_do_nums, func); in _ffs_func_bind()
2864 func->function.os_desc_table = vla_ptr(vlabuf, d, os_desc_table); in _ffs_func_bind()
2869 desc = func->function.os_desc_table[i].os_desc = in _ffs_func_bind()
2880 __ffs_func_bind_do_os_desc, func); in _ffs_func_bind()
2883 func->function.os_desc_n = in _ffs_func_bind()
2919 struct ffs_function *func = ffs_func_from_usb(f); in ffs_func_set_alt() local
2920 struct ffs_data *ffs = func->ffs; in ffs_func_set_alt()
2924 intf = ffs_func_revmap_intf(func, interface); in ffs_func_set_alt()
2929 if (ffs->func) in ffs_func_set_alt()
2930 ffs_func_eps_disable(ffs->func); in ffs_func_set_alt()
2943 ffs->func = NULL; in ffs_func_set_alt()
2948 ffs->func = func; in ffs_func_set_alt()
2949 ret = ffs_func_eps_enable(func); in ffs_func_set_alt()
2963 struct ffs_function *func = ffs_func_from_usb(f); in ffs_func_setup() local
2964 struct ffs_data *ffs = func->ffs; in ffs_func_setup()
2990 ret = ffs_func_revmap_intf(func, le16_to_cpu(creq->wIndex)); in ffs_func_setup()
2996 ret = ffs_func_revmap_ep(func, le16_to_cpu(creq->wIndex)); in ffs_func_setup()
2999 if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR) in ffs_func_setup()
3000 ret = func->ffs->eps_addrmap[ret]; in ffs_func_setup()
3031 static int ffs_func_revmap_ep(struct ffs_function *func, u8 num) in ffs_func_revmap_ep() argument
3033 num = func->eps_revmap[num & USB_ENDPOINT_NUMBER_MASK]; in ffs_func_revmap_ep()
3037 static int ffs_func_revmap_intf(struct ffs_function *func, u8 intf) in ffs_func_revmap_intf() argument
3039 short *nums = func->interfaces_nums; in ffs_func_revmap_intf()
3040 unsigned count = func->ffs->interfaces_count; in ffs_func_revmap_intf()
3044 return nums - func->interfaces_nums; in ffs_func_revmap_intf()
3209 struct ffs_function *func = ffs_func_from_usb(f); in ffs_func_unbind() local
3210 struct ffs_data *ffs = func->ffs; in ffs_func_unbind()
3213 struct ffs_ep *ep = func->eps; in ffs_func_unbind()
3218 if (ffs->func == func) { in ffs_func_unbind()
3219 ffs_func_eps_disable(func); in ffs_func_unbind()
3220 ffs->func = NULL; in ffs_func_unbind()
3227 spin_lock_irqsave(&func->ffs->eps_lock, flags); in ffs_func_unbind()
3234 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); in ffs_func_unbind()
3235 kfree(func->eps); in ffs_func_unbind()
3236 func->eps = NULL; in ffs_func_unbind()
3241 func->function.fs_descriptors = NULL; in ffs_func_unbind()
3242 func->function.hs_descriptors = NULL; in ffs_func_unbind()
3243 func->function.ss_descriptors = NULL; in ffs_func_unbind()
3244 func->interfaces_nums = NULL; in ffs_func_unbind()
3251 struct ffs_function *func; in ffs_alloc() local
3255 func = kzalloc(sizeof(*func), GFP_KERNEL); in ffs_alloc()
3256 if (unlikely(!func)) in ffs_alloc()
3259 func->function.name = "Function FS Gadget"; in ffs_alloc()
3261 func->function.bind = ffs_func_bind; in ffs_alloc()
3262 func->function.unbind = ffs_func_unbind; in ffs_alloc()
3263 func->function.set_alt = ffs_func_set_alt; in ffs_alloc()
3264 func->function.disable = ffs_func_disable; in ffs_alloc()
3265 func->function.setup = ffs_func_setup; in ffs_alloc()
3266 func->function.suspend = ffs_func_suspend; in ffs_alloc()
3267 func->function.resume = ffs_func_resume; in ffs_alloc()
3268 func->function.free_func = ffs_free; in ffs_alloc()
3270 return &func->function; in ffs_alloc()