Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6056102imu; Wed, 30 Jan 2019 08:05:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4O57S+opb0b229Xfp/j4YZGgPCDaiXdGK+JeAInPa4JnCcIMoUxkn9PhjTlWjJ9y8A+h19 X-Received: by 2002:a63:c303:: with SMTP id c3mr28090218pgd.268.1548864309963; Wed, 30 Jan 2019 08:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548864309; cv=none; d=google.com; s=arc-20160816; b=lT22g3DgJahPG1jcDJYklgAiudy6IVmb/crMQQzkU+MKxED52LI4YU5zo8BRHHc5d/ QgDw7Dx9DCW6fmVEuFWKlAkyzfa5kQpdXD3FgRUdp2766OeMwDsI0+jWdWrfg7MDxuRg tOQmu4AXuDD9J+z0RBbqvi6LQxhzxcdM9WWuQZs2c9dvYSDHOkhJSRTUOwBCmpzN0vDg wzTUygDWhVFYlVyl0SEQIA6upOHrOLvEAvCk6IXiz/Oyxd/AYSgnS+iS+DQ76kO4exN3 7rgGW+YOAA5vgwcRlPbptcUNnk8I2AxBO65uawcZzMZnUiUScBZxrWvNgYmHXJuBlmwY VUZg== 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=QKd38dvvhfR1121FBQcExJ4yRYVldw18T4geO7Ktc28=; b=U5sKv9Z2zZRA6OBuo2CKLqEGN7By0Dxn+5ujL4GnI/WYMQg0VWcliXmf11T+F3+XM3 6goKExtCShsh8BCZKNf7Y0zN4Qe4jBbg7KnCrlvFylhgI2C/siml20Pq2mf+zE19Dmnl mKbxpmRhiIu2tEbi0IylqAIZqaug/RMt/8X//u9/x9Mb8gC4DZPC+3qUi/BWnlTwh9Qv +0K/IGktfaDUgkcPRm4cV96+ZTYQFFZKKXoRVoZLlibVnLi3iuIziMrRFnKaudnJ+Mok o5AW41016J//JMvLIdhyVzDZ/ahCG2O/fgj970A+lnm+Pd0hrQMD+AoFupIp9gBxlgjJ v/7A== 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 u123si1665887pgb.516.2019.01.30.08.04.54; Wed, 30 Jan 2019 08:05:09 -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 S1731991AbfA3QDw (ORCPT + 99 others); Wed, 30 Jan 2019 11:03:52 -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 S1731604AbfA3QDT (ORCPT ); Wed, 30 Jan 2019 11:03:19 -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:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,541,1539673200"; d="scan'208";a="142760936" 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:16 -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 7/9] usb: typec: Find the ports by also matching against the device node Date: Wed, 30 Jan 2019 19:02:57 +0300 Message-Id: <20190130160259.46919-8-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/typec/class.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index f50278dbef59..88adf0eaad34 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "bus.h" @@ -204,15 +205,32 @@ static void typec_altmode_put_partner(struct altmode *altmode) put_device(&adev->dev); } -static int __typec_port_match(struct device *dev, const void *name) +static int typec_port_fwnode_match(struct device *dev, const void *fwnode) +{ + return dev_fwnode(dev) == fwnode; +} + +static int typec_port_name_match(struct device *dev, const void *name) { return !strcmp((const char *)name, dev_name(dev)); } static void *typec_port_match(struct device_connection *con, int ep, void *data) { - return class_find_device(typec_class, NULL, con->endpoint[ep], - __typec_port_match); + struct device *dev; + + /* + * FIXME: Check does the fwnode supports the requested SVID. If it does + * we need to return ERR_PTR(-PROBE_DEFER) when there is no device. + */ + if (con->fwnode) + return class_find_device(typec_class, NULL, con->fwnode, + typec_port_fwnode_match); + + dev = class_find_device(typec_class, NULL, con->endpoint[ep], + typec_port_name_match); + + return dev ? dev : ERR_PTR(-EPROBE_DEFER); } struct typec_altmode * -- 2.20.1