[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190329041409.70138-13-chenyu56@huawei.com>
Date: Fri, 29 Mar 2019 12:14:08 +0800
From: Yu Chen <chenyu56@...wei.com>
To: <linux-usb@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: <john.stultz@...aro.org>, <suzhuangluan@...ilicon.com>,
<kongfei@...ilicon.com>, <liuyu712@...ilicon.com>,
<wanghu17@...ilicon.com>, <butao@...ilicon.com>,
<chenyao11@...wei.com>, <fangshengzhou@...ilicon.com>,
<lipengcheng8@...wei.com>, <songxiaowei@...ilicon.com>,
<xuyiping@...ilicon.com>, <xuyoujun4@...wei.com>,
<yudongbin@...ilicon.com>, <zangleigang@...ilicon.com>,
Yu Chen <chenyu56@...wei.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Felipe Balbi <balbi@...nel.org>,
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
Binghui Wang <wangbinghui@...ilicon.com>
Subject: [PATCH v5 12/13] usb: gadget: Add configfs attribuite for controling match_existing_only
Currently the "match_existing_only" of usb_gadget_driver in configfs is
set to one which is not flexible.
Dwc3 udc will be removed when usb core switch to host mode. This causes
failure of writing name of dwc3 udc to configfs's UDC attribuite.
To fix this we need to add a way to change the config of
"match_existing_only".
There are systems like Android do not support udev, so adding
"match_existing_only" attribute to allow configuration by user is cost little.
This patch adds a configfs attribuite for controling match_existing_only
which allow user to config "match_existing_only".
Cc: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Felipe Balbi <balbi@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: John Stultz <john.stultz@...aro.org>
Cc: Binghui Wang <wangbinghui@...ilicon.com>
Signed-off-by: Yu Chen <chenyu56@...wei.com>
---
drivers/usb/gadget/configfs.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 025129942894..be85104bfab9 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -291,6 +291,36 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
return ret;
}
+static ssize_t gadget_driver_match_existing_only_store(struct config_item *item,
+ const char *page, size_t len)
+{
+ struct gadget_info *gi = to_gadget_info(item);
+ struct usb_gadget_driver *gadget_driver = &(gi->composite.gadget_driver);
+ bool match_existing_only;
+ int ret;
+
+ ret = kstrtobool(page, &match_existing_only);
+ if (ret)
+ return ret;
+
+ if (match_existing_only)
+ gadget_driver->match_existing_only = 1;
+ else
+ gadget_driver->match_existing_only = 0;
+
+ return len;
+}
+
+static ssize_t gadget_driver_match_existing_only_show(struct config_item *item,
+ char *page)
+{
+ struct gadget_info *gi = to_gadget_info(item);
+ struct usb_gadget_driver *gadget_driver = &(gi->composite.gadget_driver);
+ bool match_existing_only = !!gadget_driver->match_existing_only;
+
+ return sprintf(page, "%s\n", match_existing_only ? "true" : "false");
+}
+
CONFIGFS_ATTR(gadget_dev_desc_, bDeviceClass);
CONFIGFS_ATTR(gadget_dev_desc_, bDeviceSubClass);
CONFIGFS_ATTR(gadget_dev_desc_, bDeviceProtocol);
@@ -300,6 +330,7 @@ CONFIGFS_ATTR(gadget_dev_desc_, idProduct);
CONFIGFS_ATTR(gadget_dev_desc_, bcdDevice);
CONFIGFS_ATTR(gadget_dev_desc_, bcdUSB);
CONFIGFS_ATTR(gadget_dev_desc_, UDC);
+CONFIGFS_ATTR(gadget_, driver_match_existing_only);
static struct configfs_attribute *gadget_root_attrs[] = {
&gadget_dev_desc_attr_bDeviceClass,
@@ -311,6 +342,7 @@ static struct configfs_attribute *gadget_root_attrs[] = {
&gadget_dev_desc_attr_bcdDevice,
&gadget_dev_desc_attr_bcdUSB,
&gadget_dev_desc_attr_UDC,
+ &gadget_attr_driver_match_existing_only,
NULL,
};
--
2.15.0-rc2
Powered by blists - more mailing lists