linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shreeya Patel <shreeya.patel23498@gmail.com>
To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org,
	knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, shreeya.patel23498@gmail.com
Subject: [PATCH v2 2/3] Staging: iio: adt7316: Remove multi read and write functions
Date: Sun, 20 Jan 2019 00:09:31 +0530	[thread overview]
Message-ID: <20190119183932.14321-3-shreeya.patel23498@gmail.com> (raw)
In-Reply-To: <20190119183932.14321-1-shreeya.patel23498@gmail.com>

Currently, adt7316 doesn't use multi read and multi write
functions hence remove the redundant code and make the
necessary changes in the code.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
 drivers/staging/iio/addac/adt7316-i2c.c | 40 -------------------------
 drivers/staging/iio/addac/adt7316-spi.c | 31 ++++---------------
 drivers/staging/iio/addac/adt7316.h     |  2 --
 3 files changed, 6 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c
index 335c17731cf7..40aa9e2f1966 100644
--- a/drivers/staging/iio/addac/adt7316-i2c.c
+++ b/drivers/staging/iio/addac/adt7316-i2c.c
@@ -56,44 +56,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data)
 	return ret;
 }
 
-static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data)
-{
-	struct i2c_client *cl = client;
-	int i, ret = 0;
-
-	if (count > ADT7316_REG_MAX_ADDR)
-		count = ADT7316_REG_MAX_ADDR;
-
-	for (i = 0; i < count; i++) {
-		ret = adt7316_i2c_read(cl, reg, &data[i]);
-		if (ret < 0) {
-			dev_err(&cl->dev, "I2C multi read error\n");
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data)
-{
-	struct i2c_client *cl = client;
-	int i, ret = 0;
-
-	if (count > ADT7316_REG_MAX_ADDR)
-		count = ADT7316_REG_MAX_ADDR;
-
-	for (i = 0; i < count; i++) {
-		ret = adt7316_i2c_write(cl, reg, data[i]);
-		if (ret < 0) {
-			dev_err(&cl->dev, "I2C multi write error\n");
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
 /*
  * device probe and remove
  */
@@ -105,8 +67,6 @@ static int adt7316_i2c_probe(struct i2c_client *client,
 		.client = client,
 		.read = adt7316_i2c_read,
 		.write = adt7316_i2c_write,
-		.multi_read = adt7316_i2c_multi_read,
-		.multi_write = adt7316_i2c_multi_write,
 	};
 
 	return adt7316_probe(&client->dev, &bus, id->name, client->irq);
diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c
index adaaa3eecd04..1a78dc1e2840 100644
--- a/drivers/staging/iio/addac/adt7316-spi.c
+++ b/drivers/staging/iio/addac/adt7316-spi.c
@@ -23,15 +23,12 @@
  * adt7316 register access by SPI
  */
 
-static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data)
+static int adt7316_spi_read(void *client, u8 reg, u8 *data)
 {
 	struct spi_device *spi_dev = client;
 	u8 cmd[2];
 	int ret = 0;
 
-	if (count > ADT7316_REG_MAX_ADDR)
-		count = ADT7316_REG_MAX_ADDR;
-
 	cmd[0] = ADT7316_SPI_CMD_WRITE;
 	cmd[1] = reg;
 
@@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data)
 
 	cmd[0] = ADT7316_SPI_CMD_READ;
 
-	ret = spi_write_then_read(spi_dev, cmd, 1, data, count);
+	ret = spi_write_then_read(spi_dev, cmd, 1, data, 1);
 	if (ret < 0) {
 		dev_err(&spi_dev->dev, "SPI read data error\n");
 		return ret;
@@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data)
 	return 0;
 }
 
-static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data)
+static int adt7316_spi_write(void *client, u8 reg, u8 val)
 {
 	struct spi_device *spi_dev = client;
 	u8 buf[ADT7316_REG_MAX_ADDR + 2];
-	int i, ret = 0;
-
-	if (count > ADT7316_REG_MAX_ADDR)
-		count = ADT7316_REG_MAX_ADDR;
+	int ret = 0;
 
 	buf[0] = ADT7316_SPI_CMD_WRITE;
 	buf[1] = reg;
-	for (i = 0; i < count; i++)
-		buf[i + 2] = data[i];
+	buf[2] = val;
 
-	ret = spi_write(spi_dev, buf, count + 2);
+	ret = spi_write(spi_dev, buf, 3);
 	if (ret < 0) {
 		dev_err(&spi_dev->dev, "SPI write error\n");
 		return ret;
@@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data)
 	return ret;
 }
 
-static int adt7316_spi_read(void *client, u8 reg, u8 *data)
-{
-	return adt7316_spi_multi_read(client, reg, 1, data);
-}
-
-static int adt7316_spi_write(void *client, u8 reg, u8 val)
-{
-	return adt7316_spi_multi_write(client, reg, 1, &val);
-}
-
 /*
  * device probe and remove
  */
@@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev)
 		.client = spi_dev,
 		.read = adt7316_spi_read,
 		.write = adt7316_spi_write,
-		.multi_read = adt7316_spi_multi_read,
-		.multi_write = adt7316_spi_multi_write,
 	};
 
 	/* don't exceed max specified SPI CLK frequency */
diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h
index 03d5300a98cd..e9f288420234 100644
--- a/drivers/staging/iio/addac/adt7316.h
+++ b/drivers/staging/iio/addac/adt7316.h
@@ -18,8 +18,6 @@ struct adt7316_bus {
 	void *client;
 	int (*read)(void *client, u8 reg, u8 *data);
 	int (*write)(void *client, u8 reg, u8 val);
-	int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data);
-	int (*multi_write)(void *client, u8 first_reg, u8 count, u8 *data);
 };
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.17.1


  parent reply	other threads:[~2019-01-19 18:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-19 18:39 [PATCH v2 0/3] adt7316 regmap implementation Shreeya Patel
2019-01-19 18:39 ` [PATCH v2 1/3] Staging: iio: adt7316: Remove irq from bus structure Shreeya Patel
2019-01-19 19:03   ` Jonathan Cameron
2019-01-19 18:39 ` Shreeya Patel [this message]
2019-01-19 18:39 ` [PATCH v2 3/3] Staging: iio: adt7316: Add regmap support Shreeya Patel
2019-01-19 19:04 ` [PATCH v2 0/3] adt7316 regmap implementation Jonathan Cameron
2019-01-19 19:09   ` Shreeya Patel

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=20190119183932.14321-3-shreeya.patel23498@gmail.com \
    --to=shreeya.patel23498@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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;
as well as URLs for NNTP newsgroup(s).