summaryrefslogtreecommitdiff
path: root/patches.tizen/0626-usb-gadget-f_phonet-add-configfs-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches.tizen/0626-usb-gadget-f_phonet-add-configfs-support.patch')
-rw-r--r--patches.tizen/0626-usb-gadget-f_phonet-add-configfs-support.patch138
1 files changed, 138 insertions, 0 deletions
diff --git a/patches.tizen/0626-usb-gadget-f_phonet-add-configfs-support.patch b/patches.tizen/0626-usb-gadget-f_phonet-add-configfs-support.patch
new file mode 100644
index 00000000000..f8b7b5e09f6
--- /dev/null
+++ b/patches.tizen/0626-usb-gadget-f_phonet-add-configfs-support.patch
@@ -0,0 +1,138 @@
+From 6abeb50eceea55dec84e3b2c7ec7a6592df05992 Mon Sep 17 00:00:00 2001
+From: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
+Date: Thu, 23 May 2013 10:51:15 +0200
+Subject: [PATCH 0626/1302] 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>
+Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
+---
+ .../ABI/testing/configfs-usb-gadget-phonet | 8 ++++
+ drivers/usb/gadget/Kconfig | 10 ++++
+ drivers/usb/gadget/f_phonet.c | 56 ++++++++++++++++++++++
+ 3 files changed, 74 insertions(+)
+ create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-phonet
+
+diff --git a/Documentation/ABI/testing/configfs-usb-gadget-phonet b/Documentation/ABI/testing/configfs-usb-gadget-phonet
+new file mode 100644
+index 0000000..19b67d3
+--- /dev/null
++++ b/Documentation/ABI/testing/configfs-usb-gadget-phonet
+@@ -0,0 +1,8 @@
++What: /config/usb-gadget/gadget/functions/phonet.name
++Date: May 2013
++KenelVersion: 3.11
++Description:
++
++ This item contains just one readonly attribute: ifname.
++ It contains the network interface name assigned during
++ network device registration.
+diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
+index 52e117f..f0bafa6 100644
+--- a/drivers/usb/gadget/Kconfig
++++ b/drivers/usb/gadget/Kconfig
+@@ -549,6 +549,16 @@ choice
+
+ # this first set of drivers all depend on bulk-capable hardware.
+
++config USB_CONFIGFS_PHONET
++ boolean "Phonet protocol"
++ depends on USB_CONFIGFS
++ depends on NET
++ depends on PHONET
++ select USB_U_ETHER
++ select USB_F_PHONET
++ help
++ The Phonet protocol implementation for USB device.
++
+ config USB_ZERO
+ tristate "Gadget Zero (DEVELOPMENT)"
+ select USB_LIBCOMPOSITE
+diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
+index 5dd7748..7944fb0 100644
+--- a/drivers/usb/gadget/f_phonet.c
++++ b/drivers/usb/gadget/f_phonet.c
+@@ -26,6 +26,7 @@
+ #include <linux/usb/composite.h>
+
+ #include "u_phonet.h"
++#include "u_ether.h"
+
+ #define PN_MEDIA_USB 0x1B
+ #define MAXPACKET 512
+@@ -581,6 +582,58 @@ err:
+ return status;
+ }
+
++static inline struct f_phonet_opts *to_f_phonet_opts(struct config_item *item)
++{
++ return container_of(to_config_group(item), struct f_phonet_opts,
++ func_inst.group);
++}
++
++CONFIGFS_ATTR_STRUCT(f_phonet_opts);
++static ssize_t f_phonet_attr_show(struct config_item *item,
++ struct configfs_attribute *attr,
++ char *page)
++{
++ struct f_phonet_opts *opts = to_f_phonet_opts(item);
++ struct f_phonet_opts_attribute *f_phonet_opts_attr =
++ container_of(attr, struct f_phonet_opts_attribute, attr);
++ ssize_t ret = 0;
++
++ if (f_phonet_opts_attr->show)
++ ret = f_phonet_opts_attr->show(opts, page);
++ return ret;
++}
++
++static void phonet_attr_release(struct config_item *item)
++{
++ struct f_phonet_opts *opts = to_f_phonet_opts(item);
++
++ usb_put_function_instance(&opts->func_inst);
++}
++
++static struct configfs_item_operations phonet_item_ops = {
++ .release = phonet_attr_release,
++ .show_attribute = f_phonet_attr_show,
++};
++
++static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
++{
++ return gether_get_ifname(opts->net, page, PAGE_SIZE);
++}
++
++static struct f_phonet_opts_attribute f_phonet_ifname =
++ __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
++
++static struct configfs_attribute *phonet_attrs[] = {
++ &f_phonet_ifname.attr,
++ NULL,
++};
++
++static struct config_item_type phonet_func_type = {
++ .ct_item_ops = &phonet_item_ops,
++ .ct_attrs = phonet_attrs,
++ .ct_owner = THIS_MODULE,
++};
++
+ static void phonet_free_inst(struct usb_function_instance *f)
+ {
+ struct f_phonet_opts *opts;
+@@ -606,6 +659,9 @@ static struct usb_function_instance *phonet_alloc_inst(void)
+ if (IS_ERR(opts->net))
+ return ERR_PTR(PTR_ERR(opts->net));
+
++ config_group_init_type_name(&opts->func_inst.group, "",
++ &phonet_func_type);
++
+ return &opts->func_inst;
+ }
+
+--
+1.8.3.2
+