mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] gnss: serial: power down active receiver on deregistration
Date: Fri, 30 Oct 2026 18:00:45 +0200	[thread overview]
Message-ID: <20261030160044.2496071-2-thnkslprpt@gmail.com> (raw)

When a GNSS device is removed with an open descriptor,
gnss_deregister_device() calls gnss_serial_close(), which releases its
runtime-PM reference asynchronously. gnss_serial_deregister() then
disables runtime PM and can cancel the pending suspend, leaving the
receiver supply enabled when the regulator handle is released.

Power off the receiver after disabling runtime PM if it is still active.
Leave an already-suspended receiver alone to avoid disabling its supply
twice.

Fixes: 37768b054f20 ("gnss: add generic serial driver")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 drivers/gnss/serial.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gnss/serial.c b/drivers/gnss/serial.c
index 0e43bf6294f87..e1fb3dcc5f391 100644
--- a/drivers/gnss/serial.c
+++ b/drivers/gnss/serial.c
@@ -203,10 +203,12 @@ void gnss_serial_deregister(struct gnss_serial *gserial)
 
 	gnss_deregister_device(gserial->gdev);
 
-	if (IS_ENABLED(CONFIG_PM))
+	if (IS_ENABLED(CONFIG_PM)) {
 		pm_runtime_disable(&serdev->dev);
-	else
-		gnss_serial_set_power(gserial, GNSS_SERIAL_OFF);
+		if (pm_runtime_status_suspended(&serdev->dev))
+			return;
+	}
+	gnss_serial_set_power(gserial, GNSS_SERIAL_OFF);
 }
 EXPORT_SYMBOL_GPL(gnss_serial_deregister);
 

base-commit: d89e1d186ec9271bf78e62771779e9fc03bf0fc3
-- 
2.43.0


                 reply	other threads:[~2026-10-30 16:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261030160044.2496071-2-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®