From patchwork Fri Dec 6 17:08:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 180929 Delivered-To: patches@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1054016ile; Fri, 6 Dec 2019 09:08:29 -0800 (PST) X-Received: by 2002:ac2:44d9:: with SMTP id d25mr1901450lfm.15.1575652109529; Fri, 06 Dec 2019 09:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575652109; cv=none; d=google.com; s=arc-20160816; b=WNgXYjCg/W6pNo1WI8yOSxKy7AwU5exC2axlDewNVKcgDXIhaPwcVYGnlkEQtPFo9a yWEFaLv19HbfYVLSrKPXIV7OJibA7PvcBqFJqQ5ivaKLoLK0QLz158Tl62mGkOkYQcRI LCI/paTj9F87PwnOZGgUiUdmEHrj57szlbAs2mWZTL9mA2To/KVLlT+1qonfMsTe0+C+ K4V+A3ukipCwVE/xxD6XY06Bk2zsK+T9/GTuDU494u0JBQDtTSbBKgIA5jMPrDwvRkhW zVUWKd/+Vizjy6nx/qBv5glDMi8QA1Sx1RAhqUZwfJAZbr+zhk5zaYS26prlHfDahsKm k7og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tc0ll2qvZbYOgB1NJXHvXGod64HQcRRr8FCccHB+Mbo=; b=v6hHWsOAFcPHXnrxZLkPYmNOdqN3vI2mYRihTFXomM7GLdAtjHdt2uee11ZJ2gwN5W mP9LfHd9Lmqe0Z5QgDZDCjV9rBjdhUPcz0Um12CJpOz91zoE/czhx+PnDRvL/rxdyGDL Ci2HPZtxsQzbqDt+dMDWmQp3O/ryAxyJTrY+7JwUxslyIz5GRrIugS55+nPuyOv5aHzB 79Q6/+avgVKikku6a4v+hwMyIHNBVLu4IKszrgUH4Gt4Nu08YK6WPMujwNCNaMpn2GMd 93as0Q1w+qI5wRNgwZG9TAP1N5z6zB2ZvnhYZJbLkjYHAtTrVOOrmT18dnMDp9kMpq3l sxZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UVN+/T66"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z22sor9758940ljk.32.2019.12.06.09.08.29 for (Google Transport Security); Fri, 06 Dec 2019 09:08:29 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UVN+/T66"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tc0ll2qvZbYOgB1NJXHvXGod64HQcRRr8FCccHB+Mbo=; b=UVN+/T663mUhqim4xp5tSzBrDpM4zamkdPd2rvkI7p0byDS105QidHpYzjZF9WTCIu 2iZQ95AgneiQAgWZ3s+no2dI5E2eoQVv6oUallZjmhGSJwld85N5cGu+CfT06WkLA5nr qIW5tTZn1pINZ0OxEwutwT0W03C7jwLXn9QnJiPHcgKjU97/H1VzlQu7BjbLRhR8bIkN /95c2w8BEBDdbvSL+aHHvT6EWFf4qWcnEFWgYMWhi1mPKzRk2iDHDR4pDQL41Fesjjep ZdqqmjJ7dFyKNOFkdjj7lmX4iMoZzqm/mO1IDMH954dopApBaC8OYv70qsFzaWgDd2Wc Aunw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Tc0ll2qvZbYOgB1NJXHvXGod64HQcRRr8FCccHB+Mbo=; b=MRoeWBdHtco9CgHseipgJzpfyj8a3rEi2PjoUUYVv/Us5uLFLnZtGdkivTyybsY0Sm Hj6OXcfp8173vdN9bO8INEUfBn+nPDwce9Er0IX+tRFwk9Z9TI/V7MrTrBX0Jc+snp3Q M9mcqX/7JS009toHL1FymfF1eEf9gW/4fGQP5DMBORzmOajGjdp7wbE/weTK6+pZPOvc wsXliaK3IUmjEzOWOsl/eB/Gk/S6x6CtXkOyqjEEu82GAGZkx5AqvpJq+C/Tqn6CqMuY 9dEYRqbvyD53+lSGcz1xAqEFQNa3gv8t7zbRRHYl1QPZV5UCJNzFdoXmFI9eJykzdRz1 c44Q== X-Gm-Message-State: APjAAAUtXp83FIDBRg+snW7m6uu5YGEIWSa7R1hFhpEe4JJZufmOETK7 OKvjSOSpMA+LnKCtSNxIb7YBbF4F X-Google-Smtp-Source: APXvYqzIH2UOZMCFS0O7h7tlkyhvsc6gGyD9c/1FA0z09LKEVM71/em3Cz0KCi4ymObLcQ1Gvrb06w== X-Received: by 2002:a2e:5304:: with SMTP id h4mr9565183ljb.75.1575652109117; Fri, 06 Dec 2019 09:08:29 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id z9sm6905283ljm.40.2019.12.06.09.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 09:08:28 -0800 (PST) From: Ulf Hansson To: linux-gpio@vger.kernel.org, Linus Walleij Cc: linux-mmc@vger.kernel.org, Ulf Hansson Subject: [PATCH 1/9] pinctrl: core: Add pinctrl_select_default_state() and export it Date: Fri, 6 Dec 2019 18:08:13 +0100 Message-Id: <20191206170821.29711-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191206170821.29711-1-ulf.hansson@linaro.org> References: <20191206170821.29711-1-ulf.hansson@linaro.org> It has turned out that some mmc host drivers, but perhaps also others drivers, needs to reset the pinctrl into the default state (PINCTRL_STATE_DEFAULT). However, they can't use the existing pinctrl_pm_select_default_state(), as that requires CONFIG_PM to be set. This leads to open coding, as they need to look up the default state themselves and then select it. To avoid the open coding, let's introduce pinctrl_select_default_state() and make it available independently of CONFIG_PM. As a matter of fact, this makes it more consistent with the behaviour of the driver core, as it already tries to looks up the default state during probe. Going forward, users of pinctrl_pm_select_default_state() are encouraged to move to pinctrl_select_default_state(), so the old API can be removed. Signed-off-by: Ulf Hansson --- drivers/pinctrl/core.c | 33 ++++++++++++++++++-------------- include/linux/pinctrl/consumer.h | 6 ++++++ 2 files changed, 25 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 2bbd8ee93507..46600d9380ea 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1535,15 +1535,8 @@ int pinctrl_init_done(struct device *dev) return ret; } -#ifdef CONFIG_PM - -/** - * pinctrl_pm_select_state() - select pinctrl state for PM - * @dev: device to select default state for - * @state: state to set - */ -static int pinctrl_pm_select_state(struct device *dev, - struct pinctrl_state *state) +static int pinctrl_select_bound_state(struct device *dev, + struct pinctrl_state *state) { struct dev_pin_info *pins = dev->pins; int ret; @@ -1558,15 +1551,27 @@ static int pinctrl_pm_select_state(struct device *dev, } /** - * pinctrl_pm_select_default_state() - select default pinctrl state for PM + * pinctrl_select_default_state() - select default pinctrl state * @dev: device to select default state for */ -int pinctrl_pm_select_default_state(struct device *dev) +int pinctrl_select_default_state(struct device *dev) { if (!dev->pins) return 0; - return pinctrl_pm_select_state(dev, dev->pins->default_state); + return pinctrl_select_bound_state(dev, dev->pins->default_state); +} +EXPORT_SYMBOL_GPL(pinctrl_select_default_state); + +#ifdef CONFIG_PM + +/** + * pinctrl_pm_select_default_state() - select default pinctrl state for PM + * @dev: device to select default state for + */ +int pinctrl_pm_select_default_state(struct device *dev) +{ + return pinctrl_select_default_state(dev); } EXPORT_SYMBOL_GPL(pinctrl_pm_select_default_state); @@ -1579,7 +1584,7 @@ int pinctrl_pm_select_sleep_state(struct device *dev) if (!dev->pins) return 0; - return pinctrl_pm_select_state(dev, dev->pins->sleep_state); + return pinctrl_select_bound_state(dev, dev->pins->sleep_state); } EXPORT_SYMBOL_GPL(pinctrl_pm_select_sleep_state); @@ -1592,7 +1597,7 @@ int pinctrl_pm_select_idle_state(struct device *dev) if (!dev->pins) return 0; - return pinctrl_pm_select_state(dev, dev->pins->idle_state); + return pinctrl_select_bound_state(dev, dev->pins->idle_state); } EXPORT_SYMBOL_GPL(pinctrl_pm_select_idle_state); #endif diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 7f8c7d9583d3..019fecd75d0c 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h @@ -40,6 +40,7 @@ extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s); extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev); extern void devm_pinctrl_put(struct pinctrl *p); +extern int pinctrl_select_default_state(struct device *dev); #ifdef CONFIG_PM extern int pinctrl_pm_select_default_state(struct device *dev); @@ -122,6 +123,11 @@ static inline void devm_pinctrl_put(struct pinctrl *p) { } +static inline int pinctrl_select_default_state(struct device *dev) +{ + return 0; +} + static inline int pinctrl_pm_select_default_state(struct device *dev) { return 0;