linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: iio: adt7316: drop unnecessary initialization of variables
@ 2018-12-12 16:47 Hardik Singh Rathore
  2018-12-16 12:05 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Hardik Singh Rathore @ 2018-12-12 16:47 UTC (permalink / raw)
  To: jic23
  Cc: Hardik Singh Rathore, Lars-Peter Clausen, Michael Hennerich,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Initialization is unnecessary when the variable is written before it is
read. There were some occasions in which the driver would initialize `ret'
during declaration without need.

Purely a cosmetic change with no functional impact.

Signed-off-by: Hardik Singh Rathore <hardiksingh.k@gmail.com>
---
 drivers/staging/iio/addac/adt7316-i2c.c | 6 +++---
 drivers/staging/iio/addac/adt7316-spi.c | 4 ++--
 drivers/staging/iio/addac/adt7316.c     | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c
index 473e5e34ec00..48736c0ab0ef 100644
--- a/drivers/staging/iio/addac/adt7316-i2c.c
+++ b/drivers/staging/iio/addac/adt7316-i2c.c
@@ -47,7 +47,7 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data)
 static int adt7316_i2c_write(void *client, u8 reg, u8 data)
 {
 	struct i2c_client *cl = client;
-	int ret = 0;
+	int ret;
 
 	ret = i2c_smbus_write_byte_data(cl, reg, data);
 	if (ret < 0)
@@ -59,7 +59,7 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data)
 static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data)
 {
 	struct i2c_client *cl = client;
-	int i, ret = 0;
+	int i, ret;
 
 	if (count > ADT7316_REG_MAX_ADDR)
 		count = ADT7316_REG_MAX_ADDR;
@@ -78,7 +78,7 @@ static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data)
 static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data)
 {
 	struct i2c_client *cl = client;
-	int i, ret = 0;
+	int i, ret;
 
 	if (count > ADT7316_REG_MAX_ADDR)
 		count = ADT7316_REG_MAX_ADDR;
diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c
index 5cd22743e140..f524b4ccf5c7 100644
--- a/drivers/staging/iio/addac/adt7316-spi.c
+++ b/drivers/staging/iio/addac/adt7316-spi.c
@@ -27,7 +27,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data)
 {
 	struct spi_device *spi_dev = client;
 	u8 cmd[2];
-	int ret = 0;
+	int ret;
 
 	if (count > ADT7316_REG_MAX_ADDR)
 		count = ADT7316_REG_MAX_ADDR;
@@ -56,7 +56,7 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data)
 {
 	struct spi_device *spi_dev = client;
 	u8 buf[ADT7316_REG_MAX_ADDR + 2];
-	int i, ret = 0;
+	int i, ret;
 
 	if (count > ADT7316_REG_MAX_ADDR)
 		count = ADT7316_REG_MAX_ADDR;
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
index 2f8a122f475d..2d1e707a8676 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -2104,7 +2104,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
 	struct adt7316_chip_info *chip;
 	struct iio_dev *indio_dev;
 	unsigned short *adt7316_platform_data = dev->platform_data;
-	int ret = 0;
+	int ret;
 
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*chip));
 	if (!indio_dev)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: iio: adt7316: drop unnecessary initialization of variables
  2018-12-12 16:47 [PATCH] staging: iio: adt7316: drop unnecessary initialization of variables Hardik Singh Rathore
@ 2018-12-16 12:05 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-12-16 12:05 UTC (permalink / raw)
  To: Hardik Singh Rathore
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Wed, 12 Dec 2018 22:17:46 +0530
Hardik Singh Rathore <hardiksingh.k@gmail.com> wrote:

> Initialization is unnecessary when the variable is written before it is
> read. There were some occasions in which the driver would initialize `ret'
> during declaration without need.
> 
> Purely a cosmetic change with no functional impact.
> 
> Signed-off-by: Hardik Singh Rathore <hardiksingh.k@gmail.com>
There is a lot of churn in this driver at the moment (this is one or
3 patch sets I'm reviewing for it today), but this seems to still be
relevant so I dealt with manually applying it.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/addac/adt7316-i2c.c | 6 +++---
>  drivers/staging/iio/addac/adt7316-spi.c | 4 ++--
>  drivers/staging/iio/addac/adt7316.c     | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c
> index 473e5e34ec00..48736c0ab0ef 100644
> --- a/drivers/staging/iio/addac/adt7316-i2c.c
> +++ b/drivers/staging/iio/addac/adt7316-i2c.c
> @@ -47,7 +47,7 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data)
>  static int adt7316_i2c_write(void *client, u8 reg, u8 data)
>  {
>  	struct i2c_client *cl = client;
> -	int ret = 0;
> +	int ret;
>  
>  	ret = i2c_smbus_write_byte_data(cl, reg, data);
>  	if (ret < 0)
> @@ -59,7 +59,7 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data)
>  static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data)
>  {
>  	struct i2c_client *cl = client;
> -	int i, ret = 0;
> +	int i, ret;
>  
>  	if (count > ADT7316_REG_MAX_ADDR)
>  		count = ADT7316_REG_MAX_ADDR;
> @@ -78,7 +78,7 @@ static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data)
>  static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data)
>  {
>  	struct i2c_client *cl = client;
> -	int i, ret = 0;
> +	int i, ret;
>  
>  	if (count > ADT7316_REG_MAX_ADDR)
>  		count = ADT7316_REG_MAX_ADDR;
> diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c
> index 5cd22743e140..f524b4ccf5c7 100644
> --- a/drivers/staging/iio/addac/adt7316-spi.c
> +++ b/drivers/staging/iio/addac/adt7316-spi.c
> @@ -27,7 +27,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data)
>  {
>  	struct spi_device *spi_dev = client;
>  	u8 cmd[2];
> -	int ret = 0;
> +	int ret;
>  
>  	if (count > ADT7316_REG_MAX_ADDR)
>  		count = ADT7316_REG_MAX_ADDR;
> @@ -56,7 +56,7 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data)
>  {
>  	struct spi_device *spi_dev = client;
>  	u8 buf[ADT7316_REG_MAX_ADDR + 2];
> -	int i, ret = 0;
> +	int i, ret;
>  
>  	if (count > ADT7316_REG_MAX_ADDR)
>  		count = ADT7316_REG_MAX_ADDR;
> diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
> index 2f8a122f475d..2d1e707a8676 100644
> --- a/drivers/staging/iio/addac/adt7316.c
> +++ b/drivers/staging/iio/addac/adt7316.c
> @@ -2104,7 +2104,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
>  	struct adt7316_chip_info *chip;
>  	struct iio_dev *indio_dev;
>  	unsigned short *adt7316_platform_data = dev->platform_data;
> -	int ret = 0;
> +	int ret;
>  
>  	indio_dev = devm_iio_device_alloc(dev, sizeof(*chip));
>  	if (!indio_dev)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-16 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 16:47 [PATCH] staging: iio: adt7316: drop unnecessary initialization of variables Hardik Singh Rathore
2018-12-16 12:05 ` Jonathan Cameron

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).