Removed unnecessary variables in iio
Subsystems (4)
cover Removed unnecessary variables in iio
Variables used just to store the return value of a function can be eliminated by modifying the return statement. The following patchset fixed the same in iio.
Tina Johnson (5):
drivers: staging: iio: accel: Removed unnecessary variable
drivers: staging: iio: meter: Removed unnecessary variable
drivers: staging: iio: meter: Removed unnecessary variable
drivers: staging: iio: meter: Removed unnecessary variable
drivers: staging: iio: meter: Removed unnecessary variable
drivers/staging/iio/accel/sca3000_core.c | 6 ++---- drivers/staging/iio/meter/ade7758_core.c | 5 ++--- drivers/staging/iio/meter/ade7758_ring.c | 3 +-- drivers/staging/iio/meter/ade7854-i2c.c | 5 +---- drivers/staging/iio/meter/ade7854-spi.c | 6 +----- 5 files changed, 7 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/5 drivers: staging: iio: accel: Removed unnecessary variable
Variable len is used only to store the return value. Hence len is removed and the return statement modified. Coccinelle was used to detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
--- drivers/staging/iio/accel/sca3000_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/iio/accel/sca3000_core.c +2 -4
@@ -870,7 +870,7 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,struct device_attribute *attr, char *buf) { - int ret, len; + int ret;struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct sca3000_state *st =iio_priv (indio_dev);int val;
@@ -881,9 +881,7 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,mutex_unlock (&st->lock);if (ret <0 )return ret; - len =sprintf (buf,"%d\n" , - !!(val &SCA3000_FREE_FALL_DETECT )); -return len; +return sprintf (buf,"%d\n" , !!(val &SCA3000_FREE_FALL_DETECT )); }/**
Signature · 1 line
1.7.10.4
PATCH 2/5 drivers: staging: iio: meter: Removed unnecessary variable
In reply to Tina JohnsonVariable len is used only to store the return value. Hence len is removed and the return statement modified. Coccinelle was used to detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
--- drivers/staging/iio/meter/ade7758_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/iio/meter/ade7758_core.c +2 -3
@@ -485,7 +485,7 @@ static ssize_t ade7758_read_frequency(struct device *dev,struct device_attribute *attr, char *buf) { - int ret, len = 0; + int ret;u8 t;int sps;
@@ -498,8 +498,7 @@ static ssize_t ade7758_read_frequency(struct device *dev, t = (t >>5 ) &0x3 ; sps =26040 / (1 << t); - len =sprintf (buf,"%d SPS\n" , sps); -return len; +return sprintf (buf,"%d SPS\n" , sps); } static ssize_t ade7758_write_frequency(struct device *dev,
Signature · 1 line
1.7.10.4
PATCH 3/5 drivers: staging: iio: meter: Removed unnecessary variable
In reply to Tina JohnsonVariable ret is used only to store the error code to be returned. Hence use of ret is removed and the return statement modified. Coccinelle was used to prepare the patch:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
--- drivers/staging/iio/meter/ade7758_ring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/iio/meter/ade7758_ring.c +1 -2
@@ -120,8 +120,7 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) buffer =iio_kfifo_allocate ();if (!buffer) { - ret = -ENOMEM ; -return ret; +return -ENOMEM ; }iio_device_attach_buffer (indio_dev, buffer);
Signature · 1 line
1.7.10.4
PATCH 4/5 drivers: staging: iio: meter: Removed unnecessary variable
In reply to Tina JohnsonVariable ret is used only to store the return value. Hence ret is removed and the return statement modified. Coccinelle was used to detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
--- drivers/staging/iio/meter/ade7854-i2c.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/iio/meter/ade7854-i2c.c +1 -4
@@ -205,7 +205,6 @@ out:static int ade7854_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id) { -int ret;struct ade7854_state *st;struct iio_dev *indio_dev;
@@ -225,9 +224,7 @@ static int ade7854_i2c_probe(struct i2c_client *client, st->i2c = client; st->irq = client->irq; - ret =ade7854_probe (indio_dev, &client->dev); - -return ret; +return ade7854_probe (indio_dev, &client->dev); }static int ade7854_i2c_remove (struct i2c_client *client)
Signature · 1 line
1.7.10.4
PATCH 5/5 drivers: staging: iio: meter: Removed unnecessary variable
In reply to Tina JohnsonVariable ret is used only to store the return value. Hence ret is removed and the return statement modified. Coccinelle was used to detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
--- drivers/staging/iio/meter/ade7854-spi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/staging/iio/meter/ade7854-spi.c +1 -5
@@ -274,7 +274,6 @@ error_ret:static int ade7854_spi_probe (struct spi_device *spi) { -int ret;struct ade7854_state *st;struct iio_dev *indio_dev;
@@ -294,10 +293,7 @@ static int ade7854_spi_probe(struct spi_device *spi) st->irq = spi->irq; st->spi = spi; - - ret =ade7854_probe (indio_dev, &spi->dev); - -return ret; +return ade7854_probe (indio_dev, &spi->dev); }static int ade7854_spi_remove (struct spi_device *spi)
Signature · 1 line
1.7.10.4