Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752630AbdIAVtC (ORCPT ); Fri, 1 Sep 2017 17:49:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52268 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbdIAVs5 (ORCPT ); Fri, 1 Sep 2017 17:48:57 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E9A7261483 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com From: Hans de Goede To: MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Heikki Krogerus , Darren Hart , Andy Shevchenko , Peter Rosin , Mathias Nyman Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, devel@driverdev.osuosl.org, Kuppuswamy Sathyanarayanan , Sathyanarayanan Kuppuswamy Natarajan , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH 01/11] mux: core: Add of_mux_control_get helper function Date: Fri, 1 Sep 2017 23:48:35 +0200 Message-Id: <20170901214845.7153-2-hdegoede@redhat.com> In-Reply-To: <20170901214845.7153-1-hdegoede@redhat.com> References: <20170901214845.7153-1-hdegoede@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 01 Sep 2017 21:48:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1965 Lines: 59 Currently the mux_control_get implementation only deals with getting mux controllers on DT platforms. This commit renames the current implementation to of_mux_control_get to reflect this and makes mux_control_get a wrapper around of_mux_control_get. This is a preparation patch for adding support for getting muxes on non DT platforms. Signed-off-by: Hans de Goede --- drivers/mux/core.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index e75d5adc5949..6142493c327b 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -422,14 +422,8 @@ static struct mux_chip *of_get_mux_chip_by_node(struct device_node *np) return dev ? to_mux_chip(dev) : NULL; } -/** - * mux_control_get() - Get the mux-control for a device. - * @dev: The device that needs a mux-control. - * @mux_name: The name identifying the mux-control. - * - * Return: A pointer to the mux-control, or an ERR_PTR with a negative errno. - */ -struct mux_control *mux_control_get(struct device *dev, const char *mux_name) +static struct mux_control *of_mux_control_get(struct device *dev, + const char *mux_name) { struct device_node *np = dev->of_node; struct of_phandle_args args; @@ -483,6 +477,22 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name) return &mux_chip->mux[controller]; } + +/** + * mux_control_get() - Get the mux-control for a device. + * @dev: The device that needs a mux-control. + * @mux_name: The name identifying the mux-control. + * + * Return: A pointer to the mux-control, or an ERR_PTR with a negative errno. + */ +struct mux_control *mux_control_get(struct device *dev, const char *mux_name) +{ + /* look up via DT first */ + if (IS_ENABLED(CONFIG_OF) && dev->of_node) + return of_mux_control_get(dev, mux_name); + + return ERR_PTR(-ENODEV); +} EXPORT_SYMBOL_GPL(mux_control_get); /** -- 2.13.5