aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-05-23 04:51:15 -0400
committerFelipe Balbi <balbi@ti.com>2013-06-10 10:57:39 -0400
commit83408745b202695e8911d71a9854c517e565c343 (patch)
treea27b4d1dce915e3a0e7be8e2b86f4356f8c79c3c
parentb904d0811dd3c878075d15b8cecbeb3bea89167d (diff)
usb: gadget: f_phonet: add configfs support
f_phonet learns about configfs so we can remove in-kernel gadget drivers. 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>
-rw-r--r--Documentation/ABI/testing/configfs-usb-gadget-phonet8
-rw-r--r--drivers/usb/gadget/Kconfig10
-rw-r--r--drivers/usb/gadget/f_phonet.c56
3 files changed, 74 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/configfs-usb-gadget-phonet b/Documentation/ABI/testing/configfs-usb-gadget-phonet
new file mode 100644
index 000000000000..19b67d3eab94
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-phonet
@@ -0,0 +1,8 @@
1What: /config/usb-gadget/gadget/functions/phonet.name
2Date: May 2013
3KenelVersion: 3.11
4Description:
5
6 This item contains just one readonly attribute: ifname.
7 It contains the network interface name assigned during
8 network device registration.
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 5022c2d3e365..d6c4e601d711 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -541,6 +541,16 @@ choice
541 541
542# this first set of drivers all depend on bulk-capable hardware. 542# this first set of drivers all depend on bulk-capable hardware.
543 543
544config USB_CONFIGFS_PHONET
545 boolean "Phonet protocol"
546 depends on USB_CONFIGFS
547 depends on NET
548 depends on PHONET
549 select USB_U_ETHER
550 select USB_F_PHONET
551 help
552 The Phonet protocol implementation for USB device.
553
544config USB_ZERO 554config USB_ZERO
545 tristate "Gadget Zero (DEVELOPMENT)" 555 tristate "Gadget Zero (DEVELOPMENT)"
546 select USB_LIBCOMPOSITE 556 select USB_LIBCOMPOSITE
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 5dd774876168..7944fb0efe3b 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -26,6 +26,7 @@
26#include <linux/usb/composite.h> 26#include <linux/usb/composite.h>
27 27
28#include "u_phonet.h" 28#include "u_phonet.h"
29#include "u_ether.h"
29 30
30#define PN_MEDIA_USB 0x1B 31#define PN_MEDIA_USB 0x1B
31#define MAXPACKET 512 32#define MAXPACKET 512
@@ -581,6 +582,58 @@ err:
581 return status; 582 return status;
582} 583}
583 584
585static inline struct f_phonet_opts *to_f_phonet_opts(struct config_item *item)
586{
587 return container_of(to_config_group(item), struct f_phonet_opts,
588 func_inst.group);
589}
590
591CONFIGFS_ATTR_STRUCT(f_phonet_opts);
592static ssize_t f_phonet_attr_show(struct config_item *item,
593 struct configfs_attribute *attr,
594 char *page)
595{
596 struct f_phonet_opts *opts = to_f_phonet_opts(item);
597 struct f_phonet_opts_attribute *f_phonet_opts_attr =
598 container_of(attr, struct f_phonet_opts_attribute, attr);
599 ssize_t ret = 0;
600
601 if (f_phonet_opts_attr->show)
602 ret = f_phonet_opts_attr->show(opts, page);
603 return ret;
604}
605
606static void phonet_attr_release(struct config_item *item)
607{
608 struct f_phonet_opts *opts = to_f_phonet_opts(item);
609
610 usb_put_function_instance(&opts->func_inst);
611}
612
613static struct configfs_item_operations phonet_item_ops = {
614 .release = phonet_attr_release,
615 .show_attribute = f_phonet_attr_show,
616};
617
618static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
619{
620 return gether_get_ifname(opts->net, page, PAGE_SIZE);
621}
622
623static struct f_phonet_opts_attribute f_phonet_ifname =
624 __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
625
626static struct configfs_attribute *phonet_attrs[] = {
627 &f_phonet_ifname.attr,
628 NULL,
629};
630
631static struct config_item_type phonet_func_type = {
632 .ct_item_ops = &phonet_item_ops,
633 .ct_attrs = phonet_attrs,
634 .ct_owner = THIS_MODULE,
635};
636
584static void phonet_free_inst(struct usb_function_instance *f) 637static void phonet_free_inst(struct usb_function_instance *f)
585{ 638{
586 struct f_phonet_opts *opts; 639 struct f_phonet_opts *opts;
@@ -606,6 +659,9 @@ static struct usb_function_instance *phonet_alloc_inst(void)
606 if (IS_ERR(opts->net)) 659 if (IS_ERR(opts->net))
607 return ERR_PTR(PTR_ERR(opts->net)); 660 return ERR_PTR(PTR_ERR(opts->net));
608 661
662 config_group_init_type_name(&opts->func_inst.group, "",
663 &phonet_func_type);
664
609 return &opts->func_inst; 665 return &opts->func_inst;
610} 666}
611 667