[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190930103531.13764-2-oleksandr.suvorov@toradex.com>
Date: Mon, 30 Sep 2019 10:35:38 +0000
From: Oleksandr Suvorov <oleksandr.suvorov@...adex.com>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: Marcel Ziswiler <marcel.ziswiler@...adex.com>,
Jamie Lentin <jm@...tin.co.uk>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
Andrew Lunn <andrew@...n.ch>,
Igor Opaniuk <igor.opaniuk@...adex.com>,
Oleksandr Suvorov <oleksandr.suvorov@...adex.com>,
Sebastian Reichel <sre@...nel.org>
Subject: [PATCH 1/2] power: reset: gpio-poweroff: add force mode
Property "force-mode" tells the driver to replace previously
initialized power-off kernel hook and allows gpio-poweroff to
probe and operate successfully in any case.
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@...adex.com>
---
drivers/power/reset/gpio-poweroff.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
index 6a4bbb506551..cca9f36fdce6 100644
--- a/drivers/power/reset/gpio-poweroff.c
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -24,6 +24,7 @@ static struct gpio_desc *reset_gpio;
static u32 timeout = DEFAULT_TIMEOUT_MS;
static u32 active_delay = 100;
static u32 inactive_delay = 100;
+static void *prev_pm_power_off;
static void gpio_poweroff_do_poweroff(void)
{
@@ -49,14 +50,28 @@ static void gpio_poweroff_do_poweroff(void)
static int gpio_poweroff_probe(struct platform_device *pdev)
{
bool input = false;
+ bool force = false;
enum gpiod_flags flags;
- /* If a pm_power_off function has already been added, leave it alone */
+
+ force = device_property_read_bool(&pdev->dev, "force-mode");
+
+ /*
+ * If a pm_power_off function has already been added, leave it alone,
+ * if force-mode is not enabled.
+ */
if (pm_power_off != NULL) {
- dev_err(&pdev->dev,
- "%s: pm_power_off function already registered",
- __func__);
- return -EBUSY;
+ if (force) {
+ dev_warn(&pdev->dev,
+ "%s: pm_power_off function replaced",
+ __func__);
+ prev_pm_power_off = pm_power_off;
+ } else {
+ dev_err(&pdev->dev,
+ "%s: pm_power_off function already registered",
+ __func__);
+ return -EBUSY;
+ }
}
input = device_property_read_bool(&pdev->dev, "input");
@@ -81,7 +96,7 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
static int gpio_poweroff_remove(struct platform_device *pdev)
{
if (pm_power_off == &gpio_poweroff_do_poweroff)
- pm_power_off = NULL;
+ pm_power_off = prev_pm_power_off;
return 0;
}
--
2.20.1
Powered by blists - more mailing lists