summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Heidelberg <david@ixit.cz>2025-03-19 21:59:47 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2025-04-22 19:09:54 +0100
commit868fb0708087a9583cbf33ebc15eb6d2898b8787 (patch)
tree0696ebc7efc58c95db047c3228f89df89b14cff5
parent2eaf77b4645ef43f8ad04bfefb9275c45eabada4 (diff)
iio: light: al3320a: Split set_pwr function into set_pwr_on and _off
Simplifies later conversion to the regmap framework. Signed-off-by: David Heidelberg <david@ixit.cz> Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-8-1310729d0543@ixit.cz Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/light/al3320a.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c
index 9817cfe8ae18a..1b2b0359ed5da 100644
--- a/drivers/iio/light/al3320a.c
+++ b/drivers/iio/light/al3320a.c
@@ -80,24 +80,23 @@ static const struct attribute_group al3320a_attribute_group = {
.attrs = al3320a_attributes,
};
-static int al3320a_set_pwr(struct i2c_client *client, bool pwr)
+static int al3320a_set_pwr_on(struct i2c_client *client)
{
- u8 val = pwr ? AL3320A_CONFIG_ENABLE : AL3320A_CONFIG_DISABLE;
- return i2c_smbus_write_byte_data(client, AL3320A_REG_CONFIG, val);
+ return i2c_smbus_write_byte_data(client, AL3320A_REG_CONFIG, AL3320A_CONFIG_ENABLE);
}
static void al3320a_set_pwr_off(void *_data)
{
struct al3320a_data *data = _data;
- al3320a_set_pwr(data->client, false);
+ i2c_smbus_write_byte_data(data->client, AL3320A_REG_CONFIG, AL3320A_CONFIG_DISABLE);
}
static int al3320a_init(struct al3320a_data *data)
{
int ret;
- ret = al3320a_set_pwr(data->client, true);
+ ret = al3320a_set_pwr_on(data->client);
if (ret < 0)
return ret;
@@ -221,12 +220,15 @@ static int al3320a_probe(struct i2c_client *client)
static int al3320a_suspend(struct device *dev)
{
- return al3320a_set_pwr(to_i2c_client(dev), false);
+ struct al3320a_data *data = iio_priv(dev_get_drvdata(dev));
+
+ al3320a_set_pwr_off(data);
+ return 0;
}
static int al3320a_resume(struct device *dev)
{
- return al3320a_set_pwr(to_i2c_client(dev), true);
+ return al3320a_set_pwr_on(to_i2c_client(dev));
}
static DEFINE_SIMPLE_DEV_PM_OPS(al3320a_pm_ops, al3320a_suspend,