Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6055640imu; Wed, 30 Jan 2019 08:04:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN68swZY9OiPH6ipCAANeZ7YpZb6PXyAvt4guiXGokP5Zk7YqJr5j1Jd9zjLWJhenC3DvKne X-Received: by 2002:a63:6906:: with SMTP id e6mr27606597pgc.144.1548864286498; Wed, 30 Jan 2019 08:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548864286; cv=none; d=google.com; s=arc-20160816; b=DhB1/rdjaxk8PcrnGkd4QzCBppdg+f88U0LDZn5mSN9AIZZoTmWqQIr/yYyPDxn7c2 7piVCSf1vIDMEh5ZzNt4or3NxXrC4bRzj6/hkL2LsKtkFrIb6mWPKIWNUjI7ltdMRJC2 MlxG/rn2A7Dz75c6yN2d42WxAjytsTBPlXYb21iXNMI0g3jm+DWDq4iEPTjtnC2y5+xh siNJN9NbhBS/D3c6KC7VrC+F509DKD4U7XaFNUdqLx1O98yGkxXEn4eQNkqA7/EzZ0iQ 484N35ZjcKgmJsHP6aDZuH1bLz+2OqAzlFuyWxL6CRuuwA40Ei17zqkGVxKahEegrNUb Cjog== 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=w7gdW30St31MwVpO7aoABhEZyIW9oVsGxi/4pZcZzvA=; b=0qzLJ9zPwoIqrYk0BCTRk/lXFL98pD8u7HdjdD+Sn9Sigvi2LkuuitBTW8ehj5Ihau U3ep1SAIHL0Ogp7IlSwPdL9rbWAFTN50lCbpjnC5UWRgxK/6WuaxjXYVNs4+0rDSSteo bMWWzznfj/mCZblRE2RU6q28JbtzB6o6kwD1vVhkcCyuxaMzBkODN/YJdAIfGaQ4Jhqu X6U+5aM3qdvq5x9YZ61WnOGG+pDCyCdsd6e6G4LxvMN6RMyBnKWqY5LI/xKzSEtRs6xk 97sG+uVtmOpV47/PwCYojSVlt1EQv351wsvEXgLqJ5ND6VA8oq+QjjpemJTslrVJeMqV pb6A== 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 m10si1723005plt.295.2019.01.30.08.04.15; Wed, 30 Jan 2019 08:04:46 -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 S1731929AbfA3QDU (ORCPT + 99 others); Wed, 30 Jan 2019 11:03:20 -0500 Received: from mga02.intel.com ([134.134.136.20]:60152 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731914AbfA3QDR (ORCPT ); Wed, 30 Jan 2019 11:03:17 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2019 08:03:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,541,1539673200"; d="scan'208";a="142760922" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 30 Jan 2019 08:03:14 -0800 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Andy Shevchenko , Chen Yu , Jun Li , Hans de Goede , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node Date: Wed, 30 Jan 2019 19:02:56 +0300 Message-Id: <20190130160259.46919-7-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130160259.46919-1-heikki.krogerus@linux.intel.com> References: <20190130160259.46919-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 When the connections are defined in firmware, struct device_connection will have the fwnode member pointing to the device node (struct fwnode_handle) of the requested device, and the endpoint will not be used at all in that case. Signed-off-by: Heikki Krogerus --- drivers/usb/roles/class.c | 21 ++++++++++++++++++--- include/linux/usb/role.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 99116af07f1d..f45d8df5cfb8 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_get_role); -static int __switch_match(struct device *dev, const void *name) +static int switch_fwnode_match(struct device *dev, const void *fwnode) +{ + return dev_fwnode(dev) == fwnode; +} + +static int switch_name_match(struct device *dev, const void *name) { return !strcmp((const char *)name, dev_name(dev)); } @@ -94,8 +100,16 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, { struct device *dev; - dev = class_find_device(role_class, NULL, con->endpoint[ep], - __switch_match); + if (con->fwnode) { + if (!fwnode_property_present(con->fwnode, con->id)) + return NULL; + + dev = class_find_device(role_class, NULL, con->fwnode, + switch_fwnode_match); + } else { + dev = class_find_device(role_class, NULL, con->endpoint[ep], + switch_name_match); + } return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); } @@ -266,6 +280,7 @@ usb_role_switch_register(struct device *parent, sw->get = desc->get; sw->dev.parent = parent; + sw->dev.fwnode = desc->fwnode; sw->dev.class = role_class; sw->dev.type = &usb_role_dev_type; dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h index edc51be4a77c..9684a8734757 100644 --- a/include/linux/usb/role.h +++ b/include/linux/usb/role.h @@ -32,6 +32,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct device *dev); * usb_role_switch_register() before registering the switch. */ struct usb_role_switch_desc { + struct fwnode_handle *fwnode; struct device *usb2_port; struct device *usb3_port; struct device *udc; -- 2.20.1