Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1143548ybb; Thu, 28 Mar 2019 21:16:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgwaiFDL7ZvNI6wVVpMKl/tXB8j64jBSyrtZJF/aoWe9KtFSseOV1QDB3ChSOwUDcVtbWF X-Received: by 2002:aa7:9193:: with SMTP id x19mr36405490pfa.108.1553832983192; Thu, 28 Mar 2019 21:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553832983; cv=none; d=google.com; s=arc-20160816; b=NKY83QbhCs7wIQuj74VxMmmfsLrg/udWcE4+JCjpOQ1GeL2HOqoGpAX6e1q0fmzxlL eE/YhSGlsTGE+9RENcbwley4oxtcY/8z6JRt3/l4TSlJE2E7OxjF498A4tY/cy4gM7KG E1/OhGMOl+GEVxvGUmPNieMVlK7COjeJbLy/rvG+Z2QRUoCeAB2qsxGlvrZQSbMUyK4n V4VC52Gvcsg4A2umdC2ptwSwMtu4obaw/DjPfsTl0FsZ4cmNQECYWUVeCuDNmo11tQdK gIoItsOW0l2W0K3nnQXT7vdpP4c6hSkWhteaVf1R2ohP30xx+aVwKHpkZt+py9Kn0rR2 Utgw== 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=ilX1fpx8FzgQHqW/1W2aREczl/ktXgLfLH1l6+SxDxIYrBA7rGpDvwnHxchEy2ZFtI U2glxoNUKNmY5yZV7DPCw0aXoa74lyYKKiEHd95hV9RGkAvWX60wch1E3sMxZOXaKX+Y G8tCnGgqLSGnk1Sxd6rV9RwORg3U5tnBQkecYXrLP8b/m9Td894Na2lQP/o0Vy21F2Ec zeVgQd/HEWrUYXm23jxEP14pnLZnauiGxZLtPL2VxggR3CziM0bK5jeVMplgt8jruXOg 34s8NdgsATRGe4yX/EcHa3y7JCWqcNg0MvxEO/FrV/eU7h83UY9gNqAyPjnZuC2/0y/f BDSA== 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 q4si961033plr.376.2019.03.28.21.16.07; Thu, 28 Mar 2019 21:16:23 -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 S1728787AbfC2EPE (ORCPT + 99 others); Fri, 29 Mar 2019 00:15:04 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:48900 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725850AbfC2EOh (ORCPT ); Fri, 29 Mar 2019 00:14:37 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 32EC5F7D24E89D5D1D18; Fri, 29 Mar 2019 12:14:35 +0800 (CST) Received: from vm100-107-113-134.huawei.com (100.107.113.134) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Fri, 29 Mar 2019 12:14:27 +0800 From: Yu Chen To: , , CC: , , , , , , , , , , , , , , Yu Chen , Andy Shevchenko , Felipe Balbi , "Greg Kroah-Hartman" , Binghui Wang Subject: [PATCH v5 12/13] usb: gadget: Add configfs attribuite for controling match_existing_only Date: Fri, 29 Mar 2019 12:14:08 +0800 Message-ID: <20190329041409.70138-13-chenyu56@huawei.com> X-Mailer: git-send-email 2.15.0-rc2 In-Reply-To: <20190329041409.70138-1-chenyu56@huawei.com> References: <20190329041409.70138-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