Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp546941ybv; Thu, 13 Feb 2020 05:26:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxLUTGHI+yGh1vZhFRJhr7lKKNjI+J2edG5wCTNN/5we3H8CNNH8MY9lHzVTr3/x7RN1L4R X-Received: by 2002:a9d:2dea:: with SMTP id g97mr13457753otb.33.1581600402672; Thu, 13 Feb 2020 05:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581600402; cv=none; d=google.com; s=arc-20160816; b=FbRJs7xcNYdBGAGoMhCLZYxyopp6nLTEUrn3uaH4VhYqj51U6VI584PobliHgMNfxr +0a3QnEDdIwPI4lRrSmthzxuvhyPhYfimevEt4eJPbcC3ZQFpmGQeNe62E6W9uCFx//A kKhlVXdzlrz6Z+okqAJOX/exMTfrxcYze7vHpjuos7BsaOGyZrJ8keu7wupAltyNb/bs FcKB423C6f++YewZGcgpwcHCYfb2hXhmXZhYVioAC9EDniFWmgWKFe2jKGTAMO8YQYzk 7BMzE7KnSIJKSproZCnZYdg044UFvaYREAr1cn2UlYb9x9NzvB4lIsKxHQpZY6Sv7+R4 TyrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IUxgJwH363VeGTIyGziXsfie3bXBSl6/cGLGqMOv2pg=; b=ZoYkvCOTnVHz4C1eOzOsMfBO+/hw+R043+WWvjIKVPcdUi7iIdbC/Gr/pgsIBlD2Dj HXNXGHzlxYGZs35s1GugBByd2AsUKmAMTn5nuhCrwwXc37IvYBKK3GJ/RHGAJRk2L32q ipmdF6L2FT+OdueqNAH7umJab2iMCrvjEqq18t9lEIp1qn15hzIjvsq6fJwZ8p0EuXKe RecqLhixzjxXHslDhBMkGfxeZdpxDoeCHfo0t84Gkkl6NKAp3D2KjAk78XxISxneZrYg eeTqPVJ+1yB/yx/ElUgbvJAYjQaAjpu1CjHKFgGFrHSvy4fxAWC4tlTuDhgTK2l+nIHG b2QA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20si1062454oib.26.2020.02.13.05.26.30; Thu, 13 Feb 2020 05:26:42 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730114AbgBMNZA (ORCPT + 99 others); Thu, 13 Feb 2020 08:25:00 -0500 Received: from mga06.intel.com ([134.134.136.31]:44559 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730062AbgBMNYn (ORCPT ); Thu, 13 Feb 2020 08:24:43 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 05:24:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,436,1574150400"; d="scan'208";a="347728505" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 13 Feb 2020 05:24:41 -0800 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Benson Leung , Prashant Malani , Mika Westerberg , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 6/9] usb: roles: Allow the role switches to be named Date: Thu, 13 Feb 2020 16:24:25 +0300 Message-Id: <20200213132428.53374-7-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213132428.53374-1-heikki.krogerus@linux.intel.com> References: <20200213132428.53374-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The switch devices have been named by using the name of the parent device as base for now, but if for example the parent device controls multiple muxes, that will not work. Adding an optional member "name" to the switch descriptor that can be used for naming the switch during registration. Signed-off-by: Heikki Krogerus --- drivers/usb/roles/class.c | 3 ++- include/linux/usb/role.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index d5e57d26c31f..e17df54f2852 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -330,7 +330,8 @@ usb_role_switch_register(struct device *parent, sw->dev.class = role_class; sw->dev.type = &usb_role_dev_type; sw->dev.driver_data = desc->driver_data; - dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); + dev_set_name(&sw->dev, "%s-role-switch", + desc->name ? desc->name : dev_name(parent)); ret = device_register(&sw->dev); if (ret) { diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h index c028ba8029ad..0164fed31b06 100644 --- a/include/linux/usb/role.h +++ b/include/linux/usb/role.h @@ -27,6 +27,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct usb_role_switch *sw); * @get: Callback for getting the role (optional) * @allow_userspace_control: If true userspace may change the role through sysfs * @driver_data: Private data pointer + * @name: Name for the switch (optional) * * @usb2_port and @usb3_port will point to the USB host port and @udc to the USB * device controller behind the USB connector with the role switch. If @@ -43,6 +44,7 @@ struct usb_role_switch_desc { usb_role_switch_get_t get; bool allow_userspace_control; void *driver_data; + const char *name; }; -- 2.25.0