From: Abhash Jha <abhashkumarjha123@gmail.com>
To: linux-iio@vger.kernel.org
Cc: anshulusr@gmail.com, jic23@kernel.org, lars@metafoo.de,
linux-kernel@vger.kernel.org,
Abhash Jha <abhashkumarjha123@gmail.com>
Subject: [PATCH 2/4] iio: light: ltr390: Suspend and Resume support
Date: Mon, 9 Sep 2024 16:06:21 +0530 [thread overview]
Message-ID: <20240909103623.264113-3-abhashkumarjha123@gmail.com> (raw)
In-Reply-To: <20240909103623.264113-1-abhashkumarjha123@gmail.com>
Added support for suspend and resume PM ops.
We suspend the sensor by clearing the ALS_UVS_EN bit in the MAIN CONTROL
register. And we resume it by setting that bit.
Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com>
---
drivers/iio/light/ltr390.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/iio/light/ltr390.c b/drivers/iio/light/ltr390.c
index 73ef4a5a0..c4ff26d68 100644
--- a/drivers/iio/light/ltr390.c
+++ b/drivers/iio/light/ltr390.c
@@ -432,6 +432,24 @@ static int ltr390_probe(struct i2c_client *client)
return devm_iio_device_register(dev, indio_dev);
}
+static int ltr390_suspend(struct device *dev)
+{
+ struct ltr390_data *data = iio_priv(i2c_get_clientdata(
+ to_i2c_client(dev)));
+
+ return regmap_clear_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_SENSOR_ENABLE);
+}
+
+static int ltr390_resume(struct device *dev)
+{
+ struct ltr390_data *data = iio_priv(i2c_get_clientdata(
+ to_i2c_client(dev)));
+
+ return regmap_set_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_SENSOR_ENABLE);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(ltr390_pm_ops, ltr390_suspend, ltr390_resume);
+
static const struct i2c_device_id ltr390_id[] = {
{ "ltr390" },
{ /* Sentinel */ }
@@ -448,6 +466,7 @@ static struct i2c_driver ltr390_driver = {
.driver = {
.name = "ltr390",
.of_match_table = ltr390_of_table,
+ .pm = pm_sleep_ptr(<r390_pm_ops),
},
.probe = ltr390_probe,
.id_table = ltr390_id,
--
2.43.0
next prev parent reply other threads:[~2024-09-09 10:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 10:36 [PATCH 0/4] Threshold event and Sampling freq support for LTR390 Abhash Jha
2024-09-09 10:36 ` [PATCH 1/4] iio: light: ltr390: Added configurable sampling frequency support Abhash Jha
2024-09-09 10:36 ` Abhash Jha [this message]
2024-09-09 10:36 ` [PATCH 3/4] iio: light: ltr390: Interrupts and threshold event support Abhash Jha
2024-09-09 23:58 ` kernel test robot
2024-09-10 7:05 ` kernel test robot
2024-09-09 10:36 ` [PATCH 4/4] iio: light: ltr390: Add interrupt persistance support Abhash Jha
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=20240909103623.264113-3-abhashkumarjha123@gmail.com \
--to=abhashkumarjha123@gmail.com \
--cc=anshulusr@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.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