lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250319-al3010-iio-regmap-v2-7-1310729d0543@ixit.cz>
Date: Wed, 19 Mar 2025 21:59:46 +0100
From: David Heidelberg via B4 Relay <devnull+david.ixit.cz@...nel.org>
To: Jonathan Cameron <jic23@...nel.org>, 
 Lars-Peter Clausen <lars@...afoo.de>
Cc: Svyatoslav Ryhel <clamor95@...il.com>, 
 Robert Eckelmann <longnoserob@...il.com>, linux-iio@...r.kernel.org, 
 linux-kernel@...r.kernel.org, David Heidelberg <david@...t.cz>
Subject: [PATCH v2 07/13] iio: light: al3010: Split set_pwr function into
 set_pwr_on and _off

From: David Heidelberg <david@...t.cz>

Simplifies later conversion to the regmap framework.

Signed-off-by: David Heidelberg <david@...t.cz>
---
 drivers/iio/light/al3010.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/al3010.c b/drivers/iio/light/al3010.c
index c8f528f3636a2eb0f0c9586da64a6560d4b42e29..8c004a9239aef246a8c6f6c3f4acd6b760ee8249 100644
--- a/drivers/iio/light/al3010.c
+++ b/drivers/iio/light/al3010.c
@@ -67,24 +67,25 @@ static const struct attribute_group al3010_attribute_group = {
 	.attrs = al3010_attributes,
 };
 
-static int al3010_set_pwr(struct i2c_client *client, bool pwr)
+static int al3010_set_pwr_on(struct i2c_client *client)
 {
-	u8 val = pwr ? AL3010_CONFIG_ENABLE : AL3010_CONFIG_DISABLE;
-	return i2c_smbus_write_byte_data(client, AL3010_REG_SYSTEM, val);
+	return i2c_smbus_write_byte_data(client, AL3010_REG_SYSTEM,
+					 AL3010_CONFIG_ENABLE);
 }
 
 static void al3010_set_pwr_off(void *_data)
 {
 	struct al3010_data *data = _data;
 
-	al3010_set_pwr(data->client, false);
+	i2c_smbus_write_byte_data(data->client, AL3010_REG_SYSTEM,
+				  AL3010_CONFIG_DISABLE);
 }
 
 static int al3010_init(struct al3010_data *data)
 {
 	int ret;
 
-	ret = al3010_set_pwr(data->client, true);
+	ret = al3010_set_pwr_on(data->client);
 	if (ret < 0)
 		return ret;
 
@@ -199,12 +200,15 @@ static int al3010_probe(struct i2c_client *client)
 
 static int al3010_suspend(struct device *dev)
 {
-	return al3010_set_pwr(to_i2c_client(dev), false);
+	struct al3010_data *data = iio_priv(dev_get_drvdata(dev));
+
+	al3010_set_pwr_off(data);
+	return 0;
 }
 
 static int al3010_resume(struct device *dev)
 {
-	return al3010_set_pwr(to_i2c_client(dev), true);
+	return al3010_set_pwr_on(to_i2c_client(dev));
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(al3010_pm_ops, al3010_suspend, al3010_resume);

-- 
2.49.0



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ