aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-03-27 07:13:25 -0400
committerFelipe Balbi <balbi@ti.com>2013-04-03 07:43:36 -0400
commitecfd3f7bb3d5dceb8e7ad1c117303c774cb90234 (patch)
treecc7c6d14bd0008222797589eedc097c332d4eff3 /drivers/usb/gadget
parentd1412794b33ab0cb3dcc4c820e9595354b7e6e59 (diff)
usb: gadget: f_obex: add configfs support
f_obex learns about our new configfs-based interface, which will allow gadgets to be bound to controllers through userland. 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/f_obex.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 439b666120c2..29a348a2a294 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -456,6 +456,59 @@ int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
456 456
457#else 457#else
458 458
459static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
460{
461 return container_of(to_config_group(item), struct f_serial_opts,
462 func_inst.group);
463}
464
465CONFIGFS_ATTR_STRUCT(f_serial_opts);
466static ssize_t f_obex_attr_show(struct config_item *item,
467 struct configfs_attribute *attr,
468 char *page)
469{
470 struct f_serial_opts *opts = to_f_serial_opts(item);
471 struct f_serial_opts_attribute *f_serial_opts_attr =
472 container_of(attr, struct f_serial_opts_attribute, attr);
473 ssize_t ret = 0;
474
475 if (f_serial_opts_attr->show)
476 ret = f_serial_opts_attr->show(opts, page);
477
478 return ret;
479}
480
481static void obex_attr_release(struct config_item *item)
482{
483 struct f_serial_opts *opts = to_f_serial_opts(item);
484
485 usb_put_function_instance(&opts->func_inst);
486}
487
488static struct configfs_item_operations obex_item_ops = {
489 .release = obex_attr_release,
490 .show_attribute = f_obex_attr_show,
491};
492
493static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page)
494{
495 return sprintf(page, "%u\n", opts->port_num);
496}
497
498static struct f_serial_opts_attribute f_obex_port_num =
499 __CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show);
500
501static struct configfs_attribute *acm_attrs[] = {
502 &f_obex_port_num.attr,
503 NULL,
504};
505
506static struct config_item_type obex_func_type = {
507 .ct_item_ops = &obex_item_ops,
508 .ct_attrs = acm_attrs,
509 .ct_owner = THIS_MODULE,
510};
511
459static void obex_free_inst(struct usb_function_instance *f) 512static void obex_free_inst(struct usb_function_instance *f)
460{ 513{
461 struct f_serial_opts *opts; 514 struct f_serial_opts *opts;
@@ -480,6 +533,8 @@ static struct usb_function_instance *obex_alloc_inst(void)
480 kfree(opts); 533 kfree(opts);
481 return ERR_PTR(ret); 534 return ERR_PTR(ret);
482 } 535 }
536 config_group_init_type_name(&opts->func_inst.group, "",
537 &obex_func_type);
483 538
484 return &opts->func_inst; 539 return &opts->func_inst;
485} 540}