From: Johan Hovold <johan@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andreas Kemnade <andreas@kemnade.info>, Johan Hovold <johan@kernel.org>
Subject: [PATCH 2/3] gnss: sirf: force hibernate mode on probe
Date: Tue, 22 Jan 2019 18:22:54 +0100 [thread overview]
Message-ID: <20190122172255.17944-3-johan@kernel.org> (raw)
In-Reply-To: <20190122172255.17944-1-johan@kernel.org>
Make sure to put the receiver in hibernate mode in case it is already
active during probe in order to avoid wasting power until first open or
suspend.
This can happen, for example, after a reset or non-clean shutdown, and
possibly also due to glitches during power-on.
Reported-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/gnss/sirf.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c
index 8e3f6a776e02..f9a9d00dec98 100644
--- a/drivers/gnss/sirf.c
+++ b/drivers/gnss/sirf.c
@@ -320,6 +320,11 @@ static int sirf_probe(struct serdev_device *serdev)
}
if (data->wakeup) {
+ ret = gpiod_get_value_cansleep(data->wakeup);
+ if (ret < 0)
+ goto err_disable_vcc;
+ data->active = ret;
+
ret = gpiod_to_irq(data->wakeup);
if (ret < 0)
goto err_disable_vcc;
@@ -332,6 +337,18 @@ static int sirf_probe(struct serdev_device *serdev)
goto err_disable_vcc;
}
+ if (data->on_off) {
+ /* Force hibernate mode if already active. */
+ if (data->active) {
+ ret = sirf_set_active(data, false);
+ if (ret) {
+ dev_err(dev, "failed to set hibernate mode: %d\n",
+ ret);
+ goto err_free_irq;
+ }
+ }
+ }
+
if (IS_ENABLED(CONFIG_PM)) {
pm_runtime_set_suspended(dev); /* clear runtime_error flag */
pm_runtime_enable(dev);
--
2.20.1
next prev parent reply other threads:[~2019-01-22 17:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 17:22 [PATCH 0/3] gnss: sirf: fixes and cleanup Johan Hovold
2019-01-22 17:22 ` [PATCH 1/3] gnss: sirf: fix premature wakeup interrupt enable Johan Hovold
2019-01-22 17:22 ` Johan Hovold [this message]
2019-01-22 17:22 ` [PATCH 3/3] gnss: sirf: drop redundant double negation Johan Hovold
2019-01-22 22:10 ` [PATCH 0/3] gnss: sirf: fixes and cleanup Andreas Kemnade
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190122172255.17944-3-johan@kernel.org \
--to=johan@kernel.org \
--cc=andreas@kemnade.info \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.