Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp178960yba; Fri, 19 Apr 2019 23:42:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk177W7xPaLojhLv68sUifmw/pOoPzHBnmi+HDnVYOom9V9M6iP88s2Y/1moivo/weu6DV X-Received: by 2002:a62:2587:: with SMTP id l129mr8212079pfl.151.1555742573281; Fri, 19 Apr 2019 23:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555742573; cv=none; d=google.com; s=arc-20160816; b=ULJiEj5fleHm/3PPREPto5QDffltEHQtio0xgUpqD+H3mlReJOxvJgHLHZa9x6rpyg YMjwlQcLE0c9QCYzIMWExYbxR7umXpQbYWiFfqdkOKFX33yoUTpFUonMt8AoMYM/bhth N/DjVDVEHdHEhx+MgZMuHoM5kn+p4mZmCCWvfvKkuzjDPwjGiJVdoVnkU0mozZOw8yA/ 6PtiSbj5umrq122HT/m2U8Ri2MxqJTQQn1yuTqFoP+Gf0xPiW4Tud10jp8zd+2Ur9kXu EdnlviL6I/yicJ5YXqaPjBE+y2wSqu6WGHuFMSByGNgAzWkqPdn3HGOwyVF72YEyMUaa Yd+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=l/RhpRHrGaIR1VwPTOrmxxAZY1mtHNLNxZ0NEbIAcnM=; b=m9W2ZhPuyJiUbToUpkuX4cvqBEePq9xFc29r3OKCmjJsk8D1fNQ8lGlIH/bSU1aN5n 7WsOZoexdxIz8I9S1mdHSnPMxIh7JAob1t57fSq1zK4+KI1spGCBbBKmpv995wzBj0bM 5n++9yAiz9TrzldT2/IAcu2iDPHm9qV+EH0tWMu7u4zJusvtd6pmnOkgraN1qKLYqX97 bPodoIPhrBtWX2nLxiP7c2zdK79Jhb9+Bzw6PX+E+0Kd2a+4Uu99QRG1c4Dre6wpLRGo H3vRrOW53CQszMdXBtFQ7qL4b3DM6OwTyYPJgIMk+nZk3MrkFy89est7+DjGhlnkawLV oABw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a67si7295104pla.350.2019.04.19.23.42.38; Fri, 19 Apr 2019 23:42:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728323AbfDTGlZ (ORCPT + 99 others); Sat, 20 Apr 2019 02:41:25 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39644 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728308AbfDTGlY (ORCPT ); Sat, 20 Apr 2019 02:41:24 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6B28A591AFA00F114309; Sat, 20 Apr 2019 14:40:44 +0800 (CST) Received: from vm100-107-113-134.huawei.com (100.107.113.134) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Sat, 20 Apr 2019 14:40:34 +0800 From: Yu Chen To: , , CC: , , , , , , , , , , , , , , Yu Chen , Andy Shevchenko , Felipe Balbi , "Greg Kroah-Hartman" , Binghui Wang Subject: [PATCH v6 12/13] usb: gadget: Add configfs attribuite for controling match_existing_only Date: Sat, 20 Apr 2019 14:40:18 +0800 Message-ID: <20190420064019.57522-13-chenyu56@huawei.com> X-Mailer: git-send-email 2.15.0-rc2 In-Reply-To: <20190420064019.57522-1-chenyu56@huawei.com> References: <20190420064019.57522-1-chenyu56@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [100.107.113.134] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: John Stultz Cc: Binghui Wang Signed-off-by: Yu Chen --- 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