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]
Date:   Sun,  3 Sep 2023 12:55:48 +0100
From:   Biju Das <biju.das.jz@...renesas.com>
To:     Jonathan Cameron <jic23@...nel.org>
Cc:     Biju Das <biju.das.jz@...renesas.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>, Marek Vasut <marex@...x.de>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Biju Das <biju.das.au@...il.com>
Subject: [PATCH v3 4/4] iio: dac: mcp4725: Add dac_reg_offset to struct mcp4725_chip_info

The MCP4725 has a register offset '3' for reading DAC value compared to
'4' for MCP4726. Add dac_reg_offset variable to struct mcp4725_chip_info
to handle this difference.

Drop chip_id from struct mcp4725_chip_info as it is unused.

Signed-off-by: Biju Das <biju.das.jz@...renesas.com>
---
v3:
 * New patch.
---
 drivers/iio/dac/mcp4725.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 9cbea6f223e4..25bb1c0490af 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -32,7 +32,7 @@
 
 struct mcp4725_chip_info {
 	const struct iio_chan_spec *chan_spec;
-	unsigned int chip_id;
+	u8 dac_reg_offset;
 	bool use_ext_ref_voltage;
 };
 
@@ -463,7 +463,7 @@ static int mcp4725_probe(struct i2c_client *client)
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
 	/* read current DAC value and settings */
-	err = i2c_master_recv(client, inbuf, info->chip_id == MCP4725 ? 3 : 4);
+	err = i2c_master_recv(client, inbuf, info->dac_reg_offset);
 
 	if (err < 0) {
 		dev_err(&client->dev, "failed to read DAC value");
@@ -515,13 +515,13 @@ static void mcp4725_remove(struct i2c_client *client)
 
 static const struct mcp4725_chip_info mcp4725 = {
 	.chan_spec = &mcp472x_channel[MCP4725],
-	.chip_id = MCP4725,
+	.dac_reg_offset = 3,
 	.use_ext_ref_voltage = true,
 };
 
 static const struct mcp4725_chip_info mcp4726 = {
 	.chan_spec = &mcp472x_channel[MCP4726],
-	.chip_id = MCP4726,
+	.dac_reg_offset = 4,
 };
 
 static const struct i2c_device_id mcp4725_id[] = {
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ