Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp713345ima; Wed, 24 Oct 2018 08:06:46 -0700 (PDT) X-Google-Smtp-Source: AJdET5d1DkfHf/aXNtKHOFo59Z9jTrG0gKEBhjikpKHCoSjucGG1iCr7bZQN2lzwx2TTY3nZ1Z+h X-Received: by 2002:a17:902:8c86:: with SMTP id t6-v6mr2910111plo.55.1540393606717; Wed, 24 Oct 2018 08:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540393606; cv=none; d=google.com; s=arc-20160816; b=lcba1dier7bc6j/8sXwVLnK/4w3cxfZwtDILtPTmIG17pafWG+sKX9DTHH6x4Wors5 5myu6osMRUdSP80RVDe80pIZj/iKYxDMM3y9zBVCkRgoG1wJthL5L3Bp3cwqTZkRQJ1x XVE8m4VE0VbmFwRpvNyGTOnD8S+hw99Z0TP/gAAHQqS5DlSDHnWC5wvGYRiBCaUvfpSI CChSHfICN6Esqu0IRNNzO59DK3KYfDTtsb7y0K/pFFaIdWMauLZNaC3kfKd5WVtRHhUI Wh20D8pdPVIe7QDBL/Dz1Y7N2k6x/BU2p0rVBm3fQrOm4XunpY/Ld1B+dVaxpO35kSYM wb9Q== 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=XkcRtlJtalz3Hrz+HOXlP5t8Dceph3AiOgcSLtWDEhg=; b=ndGcd6PCagoyuEtMXMEMPjEa6/OZhfIbZYm+s4IznTJPW9H4h64dIDAXmAoq8NVvvg boBJx70GK2j8aBoR/1iOGq/MgsinO2vIN7kBhQBEjr9Qu0LMo6TQ/IfTqqjtyZVwS1io OXQgvnjrPsJApbdn6r1pMN+Lw1zmeVVB4H7n50lpOPNg+3i8Oq3d/awPBINYA1XRAB0W so5tWMrHk1YdT8HMSvcPmcubvYMBSmBokL6ARiDaAzqSAggL9k6In3y4zrJJqezbMk9d YsVMMHiv2/GGdJ7kN3sXN++2mCeQaQdyekNTgf7M3VKb/7lPqvOO1FK6Wt0k0mCpmF8m 2uAA== 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 187-v6si4806420pfe.182.2018.10.24.08.06.23; Wed, 24 Oct 2018 08:06:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727209AbeJXXeE (ORCPT + 99 others); Wed, 24 Oct 2018 19:34:04 -0400 Received: from mga12.intel.com ([192.55.52.136]:34388 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbeJXXeD (ORCPT ); Wed, 24 Oct 2018 19:34:03 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2018 08:05:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,420,1534834800"; d="scan'208";a="102104720" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 24 Oct 2018 08:05:34 -0700 From: Heikki Krogerus To: Heiko Stuebner Cc: Guenter Roeck , Hans de Goede , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/5] usb: typec: Find the ports by also matching against the device node Date: Wed, 24 Oct 2018 18:05:24 +0300 Message-Id: <20181024150525.11552-5-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181024150525.11552-1-heikki.krogerus@linux.intel.com> References: <20181024150525.11552-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 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 5db0593ca0bd..fe6f3a932a88 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -204,15 +204,28 @@ 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_name(fwnode) == 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; + + if (con->fwnode) + dev = class_find_device(typec_class, NULL, con->fwnode, + typec_port_fwnode_match); + else + 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.19.1