From patchwork Fri May 11 13:18:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10394231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 91D6A60170 for ; Fri, 11 May 2018 13:19:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 682D12859F for ; Fri, 11 May 2018 13:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C54C28C96; Fri, 11 May 2018 13:19:56 +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=unavailable 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 D23A2286C1 for ; Fri, 11 May 2018 13:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753065AbeEKNSp (ORCPT ); Fri, 11 May 2018 09:18:45 -0400 Received: from mga03.intel.com ([134.134.136.65]:43622 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753002AbeEKNSn (ORCPT ); Fri, 11 May 2018 09:18:43 -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 orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2018 06:18:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,388,1520924400"; d="scan'208";a="54341720" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 May 2018 06:18:41 -0700 From: Heikki Krogerus To: Guenter Roeck , Hans de Goede , Greg Kroah-Hartman Cc: Jun Li , Mats Karrman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v3 1/5] usb: typec: mux: Get the mux identifier from function parameter Date: Fri, 11 May 2018 16:18:34 +0300 Message-Id: <20180511131838.62064-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511131838.62064-1-heikki.krogerus@linux.intel.com> References: <20180511131838.62064-1-heikki.krogerus@linux.intel.com> 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 In order for the muxes to be usable with alternate modes, the alternate mode devices will need also to be able to get a handle to the muxes on top of the port devices. To make that possible, the muxes need to be possible to request with an identifier. This will change the API so that the mux identifier is given as a function parameter to typec_mux_get(), and the hard-coded "typec-mux" is replaced with that value. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/class.c | 2 +- drivers/usb/typec/mux.c | 6 +++--- include/linux/usb/typec_mux.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 53df10df2f9d..3753950a798d 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1345,7 +1345,7 @@ struct typec_port *typec_register_port(struct device *parent, goto err_switch; } - port->mux = typec_mux_get(cap->fwnode ? &port->dev : parent); + port->mux = typec_mux_get(parent, "typec-mux"); if (IS_ERR(port->mux)) { ret = PTR_ERR(port->mux); goto err_mux; diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index f89093bd7185..7446d6d1e424 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -123,19 +123,19 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data) /** * typec_mux_get - Find USB Type-C Multiplexer * @dev: The caller device + * @name: Mux identifier * * Finds a mux linked to the caller. This function is primarily meant for the * Type-C drivers. Returns a reference to the mux on success, NULL if no * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection * was found but the mux has not been enumerated yet. */ -struct typec_mux *typec_mux_get(struct device *dev) +struct typec_mux *typec_mux_get(struct device *dev, const char *name) { struct typec_mux *mux; mutex_lock(&mux_lock); - mux = device_connection_find_match(dev, "typec-mux", NULL, - typec_mux_match); + mux = device_connection_find_match(dev, name, NULL, typec_mux_match); if (!IS_ERR_OR_NULL(mux)) get_device(mux->dev); mutex_unlock(&mux_lock); diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index 12c1b057834b..79293f630ee1 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -47,7 +47,7 @@ void typec_switch_put(struct typec_switch *sw); int typec_switch_register(struct typec_switch *sw); void typec_switch_unregister(struct typec_switch *sw); -struct typec_mux *typec_mux_get(struct device *dev); +struct typec_mux *typec_mux_get(struct device *dev, const char *name); void typec_mux_put(struct typec_mux *mux); int typec_mux_register(struct typec_mux *mux); void typec_mux_unregister(struct typec_mux *mux);