Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp737368imm; Fri, 8 Jun 2018 04:33:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMVUIscJAn6AVxIGBOmnjqPgoNR0GP0UyEJhloR/Pge15WN5jIy8pJn1DH2oq4wpPFmxoo X-Received: by 2002:a17:902:784d:: with SMTP id e13-v6mr6335071pln.197.1528457633319; Fri, 08 Jun 2018 04:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528457633; cv=none; d=google.com; s=arc-20160816; b=X/9Ds6Q1v8MznWY9HrNp/EhcfQNV5E+Hq5NkBeZAu/iITWIoG/ItNpGYDRAqt7ScYF YrEiFsSkgBvgomn9+j3OWPGRV7YJtc9YHcvDz5yfVEk4hQL7a3zJBdsgUt7UJexpb9a7 5QhiJ3igeMpmyjs3i/LlWxSzkFepuiCy7CFgRW3M6DUeKngtCt9yBmTFRoXa8+hF7GRN MDTKuRSZhWCI66smlun26yJlcwhXgpbmJedahn1KWDGI9/u2vAIrWO7pHvpymUWoRs4G VG3xDFrROhbJN591BpBmM2J2lWHbDmUtJ6NBlYjMyMyl/ajeFjcLlsTh7ngc0/r6N4z5 BKDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Tq1K3TqPF87QrPaXmwMYHeB4xWMcfWpytn9N0bPy4a4=; b=AKhLrZZoA5VV3x38H3hczXRphFPaUulwhTrUYu/5aIWFjg5XcXM5RXfkAhGhZep7C0 oHJ1RMzfC5JD8t9rEslHXN+IA5+gb51RHQbwi5C8uUSLXMJrwshGuLwCpgGjP3rrVc8o xn0hUh6uZCKhbJ64qhnxYg1EYvvka54IDTgg42lU/5KVGTOVYALII30aNFCSEy0+YKtt 2NQPoEfFHhb49WhYWr5UjcaGTG5eYlU3jal8a+6wznnxUEaJqEVZwWDmojf7ve4Nqp1c xQtqdj769iF0AlqPUN0KDmLAr7Gg4zVVLsrqkR9U1bimL/Ox67tvj0SVyM9mLwPHChKi JVlA== 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 u6-v6si43584004pgv.420.2018.06.08.04.33.38; Fri, 08 Jun 2018 04:33:53 -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 S932138AbeFHLbc (ORCPT + 99 others); Fri, 8 Jun 2018 07:31:32 -0400 Received: from mga17.intel.com ([192.55.52.151]:32416 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752780AbeFHL3v (ORCPT ); Fri, 8 Jun 2018 07:29:51 -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 fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 04:29:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,490,1520924400"; d="scan'208";a="62388990" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Jun 2018 04:29:48 -0700 From: Heikki Krogerus To: Guenter Roeck , Hans de Goede Cc: Greg Kroah-Hartman , Jun Li , Mats Karrman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v4 3/8] usb: typec: mux: Get the mux identifier from function parameter Date: Fri, 8 Jun 2018 14:29:36 +0300 Message-Id: <20180608112941.26332-4-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180608112941.26332-1-heikki.krogerus@linux.intel.com> References: <20180608112941.26332-1-heikki.krogerus@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 02db9bcbac0c..49468f5329d6 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1356,7 +1356,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 9d8330e9c431..ddaac63ecf12 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); -- 2.17.1