diff mbox series

drivers: iio: Drop unnecessary explicit casting

Message ID 20200318100754.25667-1-nish.malpani25@gmail.com (mailing list archive)
State New, archived
Headers show
Series drivers: iio: Drop unnecessary explicit casting | expand

Commit Message

Nishant Malpani March 18, 2020, 10:07 a.m. UTC
Provide correct specifiers while printing error logs to discard the use
of unnecessary explicit casting.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
---

Based on previous conversations which can be found here [1].

[1] https://marc.info/?l=linux-iio&m=158427554607223&w=2
---
 drivers/iio/accel/kxsd9-i2c.c              | 4 ++--
 drivers/iio/gyro/bmg160_i2c.c              | 4 ++--
 drivers/iio/gyro/bmg160_spi.c              | 4 ++--
 drivers/iio/gyro/mpu3050-i2c.c             | 4 ++--
 drivers/iio/imu/bmi160/bmi160_i2c.c        | 4 ++--
 drivers/iio/imu/bmi160/bmi160_spi.c        | 4 ++--
 drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  | 4 ++--
 drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  | 4 ++--
 drivers/iio/magnetometer/bmc150_magn_spi.c | 4 ++--
 9 files changed, 18 insertions(+), 18 deletions(-)

Comments

Jonathan Cameron March 21, 2020, 11:05 a.m. UTC | #1
On Wed, 18 Mar 2020 15:37:54 +0530
Nishant Malpani <nish.malpani25@gmail.com> wrote:

> Provide correct specifiers while printing error logs to discard the use
> of unnecessary explicit casting.
> 
> Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>

Looks good in general, but I'd prefer one patch per driver
(all in a series for easy applying).

The reason is that these may need to be applied by someone as a
precursor to an actual fix.  If we have them as one big set
they have to do considerably more work to use them than if
we keep the patches independent for each of the drivers.

Except in very rare cases we try to avoid patches that cover
multiple otherwise independent bits of code.

Thanks,

Jonathan

> ---
> 
> Based on previous conversations which can be found here [1].
> 
> [1] https://marc.info/?l=linux-iio&m=158427554607223&w=2
> ---
>  drivers/iio/accel/kxsd9-i2c.c              | 4 ++--
>  drivers/iio/gyro/bmg160_i2c.c              | 4 ++--
>  drivers/iio/gyro/bmg160_spi.c              | 4 ++--
>  drivers/iio/gyro/mpu3050-i2c.c             | 4 ++--
>  drivers/iio/imu/bmi160/bmi160_i2c.c        | 4 ++--
>  drivers/iio/imu/bmi160/bmi160_spi.c        | 4 ++--
>  drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  | 4 ++--
>  drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  | 4 ++--
>  drivers/iio/magnetometer/bmc150_magn_spi.c | 4 ++--
>  9 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
> index 38411e1c155b..6a2fb2e84170 100644
> --- a/drivers/iio/accel/kxsd9-i2c.c
> +++ b/drivers/iio/accel/kxsd9-i2c.c
> @@ -21,8 +21,8 @@ static int kxsd9_i2c_probe(struct i2c_client *i2c,
>  
>  	regmap = devm_regmap_init_i2c(i2c, &config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&i2c->dev, "Failed to register i2c regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/gyro/bmg160_i2c.c b/drivers/iio/gyro/bmg160_i2c.c
> index 4fc9c6a3321f..abb11855e1b2 100644
> --- a/drivers/iio/gyro/bmg160_i2c.c
> +++ b/drivers/iio/gyro/bmg160_i2c.c
> @@ -21,8 +21,8 @@ static int bmg160_i2c_probe(struct i2c_client *client,
>  
>  	regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/gyro/bmg160_spi.c b/drivers/iio/gyro/bmg160_spi.c
> index 182a59c42507..104f1bac7805 100644
> --- a/drivers/iio/gyro/bmg160_spi.c
> +++ b/drivers/iio/gyro/bmg160_spi.c
> @@ -19,8 +19,8 @@ static int bmg160_spi_probe(struct spi_device *spi)
>  
>  	regmap = devm_regmap_init_spi(spi, &bmg160_regmap_spi_conf);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
> index afa8018b9238..9de9ca295742 100644
> --- a/drivers/iio/gyro/mpu3050-i2c.c
> +++ b/drivers/iio/gyro/mpu3050-i2c.c
> @@ -51,8 +51,8 @@ static int mpu3050_i2c_probe(struct i2c_client *client,
>  
>  	regmap = devm_regmap_init_i2c(client, &mpu3050_i2c_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/imu/bmi160/bmi160_i2c.c b/drivers/iio/imu/bmi160/bmi160_i2c.c
> index e36f5e82d400..6179d60d3968 100644
> --- a/drivers/iio/imu/bmi160/bmi160_i2c.c
> +++ b/drivers/iio/imu/bmi160/bmi160_i2c.c
> @@ -24,8 +24,8 @@ static int bmi160_i2c_probe(struct i2c_client *client,
>  
>  	regmap = devm_regmap_init_i2c(client, &bmi160_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/imu/bmi160/bmi160_spi.c b/drivers/iio/imu/bmi160/bmi160_spi.c
> index c19e3df35559..38fc4d124cc0 100644
> --- a/drivers/iio/imu/bmi160/bmi160_spi.c
> +++ b/drivers/iio/imu/bmi160/bmi160_spi.c
> @@ -20,8 +20,8 @@ static int bmi160_spi_probe(struct spi_device *spi)
>  
>  	regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  	return bmi160_core_probe(&spi->dev, regmap, id->name, true);
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index 6993d3b87bb0..90f1f4c79605 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -122,8 +122,8 @@ static int inv_mpu_probe(struct i2c_client *client,
>  
>  	regmap = devm_regmap_init_i2c(client, &inv_mpu_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> index 673b198e6368..7ee275547531 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> @@ -53,8 +53,8 @@ static int inv_mpu_probe(struct spi_device *spi)
>  
>  	regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> diff --git a/drivers/iio/magnetometer/bmc150_magn_spi.c b/drivers/iio/magnetometer/bmc150_magn_spi.c
> index ed9be0490d77..f4afad0c44cc 100644
> --- a/drivers/iio/magnetometer/bmc150_magn_spi.c
> +++ b/drivers/iio/magnetometer/bmc150_magn_spi.c
> @@ -22,8 +22,8 @@ static int bmc150_magn_spi_probe(struct spi_device *spi)
>  
>  	regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
> +			PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  	return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name);
Joe Perches March 21, 2020, 12:26 p.m. UTC | #2
On Wed, 2020-03-18 at 15:37 +0530, Nishant Malpani wrote:
> Provide correct specifiers while printing error logs to discard the use
> of unnecessary explicit casting.
[]
> diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
[]
> @@ -21,8 +21,8 @@ static int kxsd9_i2c_probe(struct i2c_client *i2c,
>  
>  	regmap = devm_regmap_init_i2c(i2c, &config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
> -			(int)PTR_ERR(regmap));
> +		dev_err(&i2c->dev, "Failed to register i2c regmap %ld\n",
> +			PTR_ERR(regmap));

Another option would be to use %pe to print the error identifier
and not the error number

etc...
Nishant Malpani March 21, 2020, 6:26 p.m. UTC | #3
On 21/03/20 5:56 pm, Joe Perches wrote:
> On Wed, 2020-03-18 at 15:37 +0530, Nishant Malpani wrote:
>> Provide correct specifiers while printing error logs to discard the use
>> of unnecessary explicit casting.
> []
>> diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
> []
>> @@ -21,8 +21,8 @@ static int kxsd9_i2c_probe(struct i2c_client *i2c,
>>   
>>   	regmap = devm_regmap_init_i2c(i2c, &config);
>>   	if (IS_ERR(regmap)) {
>> -		dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
>> -			(int)PTR_ERR(regmap));
>> +		dev_err(&i2c->dev, "Failed to register i2c regmap %ld\n",
>> +			PTR_ERR(regmap));
> 
> Another option would be to use %pe to print the error identifier
> and not the error number
> 
By 'error identifier' you mean the symbolic error name (as described in 
docs [1]), right? Yes, to me, it makes sense too, as it would be more 
"readable" during debugging. Jonathan, if you agree, do I send a 
patchset replacing with %pe specifier for all the drivers in consideration?

With regards,
Nishant Malpani

[1] 
https://www.kernel.org/doc/html/latest/core-api/printk-formats.html#error-pointers

> etc...
> 
>
Joe Perches March 21, 2020, 6:33 p.m. UTC | #4
On Sat, 2020-03-21 at 23:56 +0530, Nishant Malpani wrote:
> On 21/03/20 5:56 pm, Joe Perches wrote:
> > On Wed, 2020-03-18 at 15:37 +0530, Nishant Malpani wrote:
> > > Provide correct specifiers while printing error logs to discard the use
> > > of unnecessary explicit casting.
> > []
> > > diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
> > []
> > > @@ -21,8 +21,8 @@ static int kxsd9_i2c_probe(struct i2c_client *i2c,
> > >   
> > >   	regmap = devm_regmap_init_i2c(i2c, &config);
> > >   	if (IS_ERR(regmap)) {
> > > -		dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
> > > -			(int)PTR_ERR(regmap));
> > > +		dev_err(&i2c->dev, "Failed to register i2c regmap %ld\n",
> > > +			PTR_ERR(regmap));
> > 
> > Another option would be to use %pe to print the error identifier
> > and not the error number
> > 
> By 'error identifier' you mean the symbolic error name (as described in 
> docs [1]), right?

Yes

> https://www.kernel.org/doc/html/latest/core-api/printk-formats.html#error-pointers
Jonathan Cameron March 21, 2020, 6:47 p.m. UTC | #5
On Sat, 21 Mar 2020 05:26:52 -0700
Joe Perches <joe@perches.com> wrote:

> On Wed, 2020-03-18 at 15:37 +0530, Nishant Malpani wrote:
> > Provide correct specifiers while printing error logs to discard the use
> > of unnecessary explicit casting.  
> []
> > diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c  
> []
> > @@ -21,8 +21,8 @@ static int kxsd9_i2c_probe(struct i2c_client *i2c,
> >  
> >  	regmap = devm_regmap_init_i2c(i2c, &config);
> >  	if (IS_ERR(regmap)) {
> > -		dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
> > -			(int)PTR_ERR(regmap));
> > +		dev_err(&i2c->dev, "Failed to register i2c regmap %ld\n",
> > +			PTR_ERR(regmap));  
> 
> Another option would be to use %pe to print the error identifier
> and not the error number
> 
> etc...
> 
> 

Indeed that would be even better.  I'd missed that one being added
to the magic of prink :)

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
index 38411e1c155b..6a2fb2e84170 100644
--- a/drivers/iio/accel/kxsd9-i2c.c
+++ b/drivers/iio/accel/kxsd9-i2c.c
@@ -21,8 +21,8 @@  static int kxsd9_i2c_probe(struct i2c_client *i2c,
 
 	regmap = devm_regmap_init_i2c(i2c, &config);
 	if (IS_ERR(regmap)) {
-		dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&i2c->dev, "Failed to register i2c regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/gyro/bmg160_i2c.c b/drivers/iio/gyro/bmg160_i2c.c
index 4fc9c6a3321f..abb11855e1b2 100644
--- a/drivers/iio/gyro/bmg160_i2c.c
+++ b/drivers/iio/gyro/bmg160_i2c.c
@@ -21,8 +21,8 @@  static int bmg160_i2c_probe(struct i2c_client *client,
 
 	regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
 	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/gyro/bmg160_spi.c b/drivers/iio/gyro/bmg160_spi.c
index 182a59c42507..104f1bac7805 100644
--- a/drivers/iio/gyro/bmg160_spi.c
+++ b/drivers/iio/gyro/bmg160_spi.c
@@ -19,8 +19,8 @@  static int bmg160_spi_probe(struct spi_device *spi)
 
 	regmap = devm_regmap_init_spi(spi, &bmg160_regmap_spi_conf);
 	if (IS_ERR(regmap)) {
-		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
index afa8018b9238..9de9ca295742 100644
--- a/drivers/iio/gyro/mpu3050-i2c.c
+++ b/drivers/iio/gyro/mpu3050-i2c.c
@@ -51,8 +51,8 @@  static int mpu3050_i2c_probe(struct i2c_client *client,
 
 	regmap = devm_regmap_init_i2c(client, &mpu3050_i2c_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/imu/bmi160/bmi160_i2c.c b/drivers/iio/imu/bmi160/bmi160_i2c.c
index e36f5e82d400..6179d60d3968 100644
--- a/drivers/iio/imu/bmi160/bmi160_i2c.c
+++ b/drivers/iio/imu/bmi160/bmi160_i2c.c
@@ -24,8 +24,8 @@  static int bmi160_i2c_probe(struct i2c_client *client,
 
 	regmap = devm_regmap_init_i2c(client, &bmi160_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/imu/bmi160/bmi160_spi.c b/drivers/iio/imu/bmi160/bmi160_spi.c
index c19e3df35559..38fc4d124cc0 100644
--- a/drivers/iio/imu/bmi160/bmi160_spi.c
+++ b/drivers/iio/imu/bmi160/bmi160_spi.c
@@ -20,8 +20,8 @@  static int bmi160_spi_probe(struct spi_device *spi)
 
 	regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 	return bmi160_core_probe(&spi->dev, regmap, id->name, true);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index 6993d3b87bb0..90f1f4c79605 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -122,8 +122,8 @@  static int inv_mpu_probe(struct i2c_client *client,
 
 	regmap = devm_regmap_init_i2c(client, &inv_mpu_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 673b198e6368..7ee275547531 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -53,8 +53,8 @@  static int inv_mpu_probe(struct spi_device *spi)
 
 	regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
diff --git a/drivers/iio/magnetometer/bmc150_magn_spi.c b/drivers/iio/magnetometer/bmc150_magn_spi.c
index ed9be0490d77..f4afad0c44cc 100644
--- a/drivers/iio/magnetometer/bmc150_magn_spi.c
+++ b/drivers/iio/magnetometer/bmc150_magn_spi.c
@@ -22,8 +22,8 @@  static int bmc150_magn_spi_probe(struct spi_device *spi)
 
 	regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&spi->dev, "Failed to register spi regmap %d\n",
-			(int)PTR_ERR(regmap));
+		dev_err(&spi->dev, "Failed to register spi regmap %ld\n",
+			PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 	return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name);