iio: Drop use of %hhx and %hx format strings
Subsystems (2)
Jonathan Cameron
maintainercover iio: Drop use of %hhx and %hx format strings
From: Jonathan Cameron <[email protected]>
Resent because for some reason this didn't reach the mailing list (I'm not sure it reached anywhere at all!)
A wrong use of one of these in
https://lore.kernel.org/linux-iio/[email protected]/
included a reference from Nathan to a patch discouraging the use of these strings in general:
https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20e0Q@mail.gmail.com/
I did a quick grep and established we only have a few instances of these in IIO anyway, so in the interests of avoiding those existing cases getting cut and paste into new drivers, let's just clear them out now.
Cc: Nathan Chancellor <[email protected]>
Jonathan Cameron (4):
iio: imu: inv_mpu6050: Drop use of %hhx format string.
iio: light: si1133: Drop remaining uses of %hhx format string.
iio: light: si1145: Drop use of %hhx format specifier.
iio: chemical: sgp30: Drop use of %hx in format string.
drivers/iio/chemical/sgp30.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 ++--- drivers/iio/light/si1133.c | 14 +++++++------- drivers/iio/light/si1145.c | 10 +++++----- 4 files changed, 15 insertions(+), 16 deletions(-)
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 1/4 iio: imu: inv_mpu6050: Drop use of %hhx format string.
From: Jonathan Cameron <[email protected]>
Since:
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.
Part of a series removing all uses from IIO in the interestings of avoiding providing bad examples for people to copy.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -3
@@ -1314,8 +1314,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)for (i =0 ; i <INV_NUM_PARTS ; ++i) {if (regval == hw_info[i].whoami) {dev_warn (regmap_get_device (st->map), -"whoami mismatch got %#02x (%s)" -"expected %#02hhx (%s)\n" , +"whoami mismatch got %#02x (%s) expected %#02x (%s)\n" , regval, hw_info[i].name, st->hw->whoami, st->hw->name);break ;
@@ -1323,7 +1322,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st) }if (i >=INV_NUM_PARTS ) {dev_err (regmap_get_device (st->map), -"invalid whoami %#02x expected %#02hhx (%s)\n" , +"invalid whoami %#02x expected %#02x (%s)\n" , regval, st->hw->whoami, st->hw->name);return -ENODEV ; }
Signature · 1 line
2.31.1
Re: [PATCH 1/4] iio: imu: inv_mpu6050: Drop use of %hhx format string.
Quoted 7 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Since:
commitcbacb5ab0aa0("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.
Quoted 5 lines
Part of a series removing all uses from IIO in the interestings of avoiding providing bad examples for people to copy.
Signed-off-by Jonathan Cameron <[email protected]>Cc Nathan Chancellor <[email protected]>
Quoted 28 lines
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2
-3@@ -1314,8 +1314,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)for (i =0 ; i <INV_NUM_PARTS ; ++i) {if (regval == hw_info[i].whoami) {dev_warn (regmap_get_device (st->map), -"whoami mismatch got %#02x (%s)" -"expected %#02hhx (%s)\n" , +"whoami mismatch got %#02x (%s) expected %#02x (%s)\n" , regval, hw_info[i].name, st->hw->whoami, st->hw->name);break ;@@ -1323,7 +1322,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st) }if (i >=INV_NUM_PARTS ) {dev_err (regmap_get_device (st->map), -"invalid whoami %#02x expected %#02hhx (%s)\n" , +"invalid whoami %#02x expected %#02x (%s)\n" , regval, st->hw->whoami, st->hw->name);return -ENODEV ; }
Jonathan Cameron
maintainerPATCH 2/4 iio: light: si1133: Drop remaining uses of %hhx format string.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Since:
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.
As there are not that many in IIO, this is part of an effort to clear them out so we don't have any instances that might get coppied into new drivers.
--- drivers/iio/light/si1133.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/light/si1133.c +7 -7
@@ -352,22 +352,22 @@ static int si1133_parse_response_err(struct device *dev, u32 resp, u8 cmd)switch (resp) {case SI1133_ERR_OUTPUT_BUFFER_OVERFLOW : -dev_warn (dev,"Output buffer overflow: %#02hhx\n" , cmd); +dev_warn (dev,"Output buffer overflow: %#02x\n" , cmd);return -EOVERFLOW ;case SI1133_ERR_SATURATION_ADC_OR_OVERFLOW_ACCUMULATION : -dev_warn (dev,"Saturation of the ADC or overflow of accumulation: %#02hhx\n" , +dev_warn (dev,"Saturation of the ADC or overflow of accumulation: %#02x\n" , cmd);return -EOVERFLOW ;case SI1133_ERR_INVALID_LOCATION_CMD :dev_warn (dev, -"Parameter access to an invalid location: %#02hhx\n" , +"Parameter access to an invalid location: %#02x\n" , cmd);return -EINVAL ;case SI1133_ERR_INVALID_CMD : -dev_warn (dev,"Invalid command %#02hhx\n" , cmd); +dev_warn (dev,"Invalid command %#02x\n" , cmd);return -EINVAL ;default : -dev_warn (dev,"Unknown error %#02hhx\n" , cmd); +dev_warn (dev,"Unknown error %#02x\n" , cmd);return -EINVAL ; } }
@@ -400,7 +400,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) err =regmap_write (data->regmap,SI1133_REG_COMMAND , cmd);if (err) { -dev_warn (dev,"Failed to write command %#02hhx, ret=%d\n" , cmd, +dev_warn (dev,"Failed to write command %#02x, ret=%d\n" , cmd, err); goto out; }
@@ -425,7 +425,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) SI1133_CMD_TIMEOUT_MS * 1000);if (err) {dev_warn (dev, -"Failed to read command %#02hhx, ret=%d\n" , +"Failed to read command %#02x, ret=%d\n" , cmd, err); goto out; }
Signature · 1 line
2.31.1
Re: [PATCH 2/4] iio: light: si1133: Drop remaining uses of %hhx format string.
Quoted 7 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Since:
commitcbacb5ab0aa0("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.
Quoted 7 lines
As there are not that many in IIO, this is part of an effort to clear them out so we don't have any instances that might get coppied into new drivers.
Signed-off-by Jonathan Cameron <[email protected]>Cc Maxime Roussin-Bélanger <[email protected]>Cc Nathan Chancellor <[email protected]>
Quoted 55 lines
--- drivers/iio/light/si1133.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/iio/light/si1133.c +7
-7@@ -352,22 +352,22 @@ static int si1133_parse_response_err(struct device *dev, u32 resp, u8 cmd)switch (resp) {case SI1133_ERR_OUTPUT_BUFFER_OVERFLOW : -dev_warn (dev,"Output buffer overflow: %#02hhx\n" , cmd); +dev_warn (dev,"Output buffer overflow: %#02x\n" , cmd);return -EOVERFLOW ;case SI1133_ERR_SATURATION_ADC_OR_OVERFLOW_ACCUMULATION : -dev_warn (dev,"Saturation of the ADC or overflow of accumulation: %#02hhx\n" , +dev_warn (dev,"Saturation of the ADC or overflow of accumulation: %#02x\n" , cmd);return -EOVERFLOW ;case SI1133_ERR_INVALID_LOCATION_CMD :dev_warn (dev, -"Parameter access to an invalid location: %#02hhx\n" , +"Parameter access to an invalid location: %#02x\n" , cmd);return -EINVAL ;case SI1133_ERR_INVALID_CMD : -dev_warn (dev,"Invalid command %#02hhx\n" , cmd); +dev_warn (dev,"Invalid command %#02x\n" , cmd);return -EINVAL ;default : -dev_warn (dev,"Unknown error %#02hhx\n" , cmd); +dev_warn (dev,"Unknown error %#02x\n" , cmd);return -EINVAL ; } }@@ -400,7 +400,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) err =regmap_write (data->regmap,SI1133_REG_COMMAND , cmd);if (err) { -dev_warn (dev,"Failed to write command %#02hhx, ret=%d\n" , cmd, +dev_warn (dev,"Failed to write command %#02x, ret=%d\n" , cmd, err); goto out; }@@ -425,7 +425,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) SI1133_CMD_TIMEOUT_MS * 1000);if (err) {dev_warn (dev, -"Failed to read command %#02hhx, ret=%d\n" , +"Failed to read command %#02x, ret=%d\n" , cmd, err); goto out; }
Jonathan Cameron
maintainerPATCH 3/4 iio: light: si1145: Drop use of %hhx format specifier.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Since:
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged. As there are only a few such instances in IIO, this is part of a series clearing them out so they don't get copied into new drivers.
--- drivers/iio/light/si1145.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/light/si1145.c +5 -5
@@ -271,7 +271,7 @@ static int si1145_command(struct si1145_data *data, u8 cmd)if ((ret & ~SI1145_RSP_COUNTER_MASK ) ==0 ) {if (ret == data->rsp_seq) {if (time_after (jiffies, stop_jiffies)) { -dev_warn (dev,"timeout on command %#02hhx\n" , +dev_warn (dev,"timeout on command %#02x\n" , cmd); ret = -ETIMEDOUT ;break ;
@@ -291,12 +291,12 @@ static int si1145_command(struct si1145_data *data, u8 cmd) ret = -EIO ; }else {if (ret ==SI1145_RSP_INVALID_SETTING ) { -dev_warn (dev,"INVALID_SETTING error on command %#02hhx\n" , +dev_warn (dev,"INVALID_SETTING error on command %#02x\n" , cmd); ret = -EINVAL ; }else {/* All overflows are treated identically */ -dev_dbg (dev,"overflow, ret=%d, cmd=%#02hhx\n" , +dev_dbg (dev,"overflow, ret=%d, cmd=%#02x\n" , ret, cmd); ret = -EOVERFLOW ; }
@@ -1299,10 +1299,10 @@ static int si1145_probe(struct i2c_client *client, SI1145_REG_SEQ_ID);if (ret <0 )return ret; -dev_info (&client->dev,"device ID part %#02hhx rev %#02hhx seq %#02hhx\n" , +dev_info (&client->dev,"device ID part %#02x rev %#02x seq %#02x\n" , part_id, rev_id, seq_id);if (part_id != data->part_info->part) { -dev_err (&client->dev,"part ID mismatch got %#02hhx, expected %#02x\n" , +dev_err (&client->dev,"part ID mismatch got %#02x, expected %#02x\n" , part_id, data->part_info->part);return -ENODEV ; }
Signature · 1 line
2.31.1
Re: [PATCH 3/4] iio: light: si1145: Drop use of %hhx format specifier.
Quoted 11 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Since:
commitcbacb5ab0aa0("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged. As there are only a few such instances in IIO, this is part of a series clearing them out so they don't get copied into new drivers.Signed-off-by Jonathan Cameron <[email protected]>Cc Nathan Chancellor <[email protected]>
Quoted 46 lines
--- drivers/iio/light/si1145.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/iio/light/si1145.c +5
-5@@ -271,7 +271,7 @@ static int si1145_command(struct si1145_data *data, u8 cmd)if ((ret & ~SI1145_RSP_COUNTER_MASK ) ==0 ) {if (ret == data->rsp_seq) {if (time_after (jiffies, stop_jiffies)) { -dev_warn (dev,"timeout on command %#02hhx\n" , +dev_warn (dev,"timeout on command %#02x\n" , cmd); ret = -ETIMEDOUT ;break ;@@ -291,12 +291,12 @@ static int si1145_command(struct si1145_data *data, u8 cmd) ret = -EIO ; }else {if (ret ==SI1145_RSP_INVALID_SETTING ) { -dev_warn (dev,"INVALID_SETTING error on command %#02hhx\n" , +dev_warn (dev,"INVALID_SETTING error on command %#02x\n" , cmd); ret = -EINVAL ; }else {/* All overflows are treated identically */ -dev_dbg (dev,"overflow, ret=%d, cmd=%#02hhx\n" , +dev_dbg (dev,"overflow, ret=%d, cmd=%#02x\n" , ret, cmd); ret = -EOVERFLOW ; }@@ -1299,10 +1299,10 @@ static int si1145_probe(struct i2c_client *client, SI1145_REG_SEQ_ID);if (ret <0 )return ret; -dev_info (&client->dev,"device ID part %#02hhx rev %#02hhx seq %#02hhx\n" , +dev_info (&client->dev,"device ID part %#02x rev %#02x seq %#02x\n" , part_id, rev_id, seq_id);if (part_id != data->part_info->part) { -dev_err (&client->dev,"part ID mismatch got %#02hhx, expected %#02x\n" , +dev_err (&client->dev,"part ID mismatch got %#02x, expected %#02x\n" , part_id, data->part_info->part);return -ENODEV ; }
Jonathan Cameron
maintainerPATCH 4/4 iio: chemical: sgp30: Drop use of %hx in format string.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Since:
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.
As there are only a few such uses in IIO, lets clear them all out and avoid chance of them getting copied into new drivers.
--- drivers/iio/chemical/sgp30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sgp30.c +1 -1
@@ -425,7 +425,7 @@ static int sgp_check_compat(struct sgp_data *data, product =SGP_VERS_PRODUCT (data);if (product != product_id) { -dev_err (dev,"sensor reports a different product: 0x%04hx\n" , +dev_err (dev,"sensor reports a different product: 0x%04x\n" , product);return -ENODEV ; }
Signature · 1 line
2.31.1
Re: [PATCH 4/4] iio: chemical: sgp30: Drop use of %hx in format string.
Quoted 7 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Since:
commitcbacb5ab0aa0("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.
Quoted 6 lines
As there are only a few such uses in IIO, lets clear them all out and avoid chance of them getting copied into new drivers.
Signed-off-by Jonathan Cameron <[email protected]>Cc Nathan Chancellor <[email protected]>Cc Andreas Brauchli <[email protected]>
Quoted 18 lines
--- drivers/iio/chemical/sgp30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/chemical/sgp30.c +1
-1@@ -425,7 +425,7 @@ static int sgp_check_compat(struct sgp_data *data, product =SGP_VERS_PRODUCT (data);if (product != product_id) { -dev_err (dev,"sensor reports a different product: 0x%04hx\n" , +dev_err (dev,"sensor reports a different product: 0x%04x\n" , product);return -ENODEV ; }
Jonathan Cameron
maintainerQuoted 11 lines · On Mon, 17 May 2021 13:55:50 +0100 Jonathan Cameron <[email protected]> wrote:
From: Jonathan Cameron <[email protected]>
Resent because for some reason this didn't reach the mailing list (I'm not sure it reached anywhere at all!)
A wrong use of one of these in
https://lore.kernel.org/linux-iio/[email protected]/
included a reference from Nathan to a patch discouraging the use of these strings in general:
https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20e0Q@mail.gmail.com/
Quoted 3 lines
I did a quick grep and established we only have a few instances of these in IIO anyway, so in the interests of avoiding those existing cases getting cut and paste into new drivers, let's just clear them out now.
Series applied to the togreg branch of iio.git and pushed out as testing to let 0-day poke at it before I push it out for linux-next.
Thanks,
Jonathan
Quoted 14 lines
Cc: Nathan Chancellor <[email protected]>
Jonathan Cameron (4):
iio: imu:inv_mpu6050: Drop use of %hhx format string.
iio: light: si1133: Drop remaining uses of %hhx format string.
iio: light: si1145: Drop use of %hhx format specifier.
iio: chemical: sgp30: Drop use of %hx in format string.drivers/iio/chemical/sgp30.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 ++--- drivers/iio/light/si1133.c | 14 +++++++------- drivers/iio/light/si1145.c | 10 +++++----- 4 files changed, 15 insertions(+), 16 deletions(-)
Jonathan Cameron
maintainerQuoted 14 lines · On Sat, 22 May 2021 19:20:31 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 11 lines · On Mon, 17 May 2021 13:55:50 +0100 Jonathan Cameron <[email protected]> wrote:
From: Jonathan Cameron <[email protected]>
Resent because for some reason this didn't reach the mailing list (I'm not sure it reached anywhere at all!)
A wrong use of one of these in
https://lore.kernel.org/linux-iio/[email protected]/
included a reference from Nathan to a patch discouraging the use of these strings in general:
https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20e0Q@mail.gmail.com/
Quoted 6 lines
Quoted 3 lines
I did a quick grep and established we only have a few instances of these in IIO anyway, so in the interests of avoiding those existing cases getting cut and paste into new drivers, let's just clear them out now.
Series applied to the togreg branch of iio.git and pushed out as testing to let 0-day poke at it before I push it out for linux-next.
And I dropped 3 of these, because as Joe Perches pointed out %#02x is a very odd specifier to use as the length includes the 0x prefix and thus might as well not be there at all.
Intention was almost certainly either
%#04x or 0x%02x
I prefer the second one so have rerolled the first 3 of these to take that approach. The 4th is unaffected so I have left it applied.
Thanks,
Jonathan
Quoted 20 lines
Thanks,
Jonathan
Quoted 14 lines
Cc: Nathan Chancellor <[email protected]>
Jonathan Cameron (4):
iio: imu:inv_mpu6050: Drop use of %hhx format string.
iio: light: si1133: Drop remaining uses of %hhx format string.
iio: light: si1145: Drop use of %hhx format specifier.
iio: chemical: sgp30: Drop use of %hx in format string.drivers/iio/chemical/sgp30.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 ++--- drivers/iio/light/si1133.c | 14 +++++++------- drivers/iio/light/si1145.c | 10 +++++----- 4 files changed, 15 insertions(+), 16 deletions(-)