From patchwork Wed Oct 24 15:05:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10654751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E711713A9 for ; Wed, 24 Oct 2018 15:05:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13FDC2A089 for ; Wed, 24 Oct 2018 15:05:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0812E2A953; Wed, 24 Oct 2018 15:05:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DBEB2A089 for ; Wed, 24 Oct 2018 15:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727135AbeJXXeA (ORCPT ); Wed, 24 Oct 2018 19:34:00 -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 S1726497AbeJXXd7 (ORCPT ); Wed, 24 Oct 2018 19:33:59 -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:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,420,1534834800"; d="scan'208";a="102104679" 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:30 -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 2/5] usb: typec: mux: Find the muxes by also matching against the device node Date: Wed, 24 Oct 2018 18:05:22 +0300 Message-Id: <20181024150525.11552-3-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 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/mux.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index d990aa510fab..161a96280296 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -11,6 +11,7 @@ #include #include #include +#include #include static DEFINE_MUTEX(switch_lock); @@ -23,9 +24,14 @@ static void *typec_switch_match(struct device_connection *con, int ep, { struct typec_switch *sw; - list_for_each_entry(sw, &switch_list, entry) - if (!strcmp(con->endpoint[ep], dev_name(sw->dev))) + list_for_each_entry(sw, &switch_list, entry) { + if (con->fwnode) { + if (dev_fwnode(sw->dev) == con->fwnode) + return sw; + } else if (!strcmp(con->endpoint[ep], dev_name(sw->dev))) { return sw; + } + } /* * We only get called if a connection was found, tell the caller to @@ -114,9 +120,14 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data) { struct typec_mux *mux; - list_for_each_entry(mux, &mux_list, entry) - if (!strcmp(con->endpoint[ep], dev_name(mux->dev))) + list_for_each_entry(mux, &mux_list, entry) { + if (con->fwnode) { + if (dev_fwnode(mux->dev) == con->fwnode) + return mux; + } else if (!strcmp(con->endpoint[ep], dev_name(mux->dev))) { return mux; + } + } /* * We only get called if a connection was found, tell the caller to