Skip to content

Commit dbb1f2f

Browse files
andy-shevjic23
authored andcommitted
iio: magnetometer: ak8975: reduce usage of magic lengths of the buffer
Reduce usage of magic lengths of the supplied buffer by replacing them with the corresponding sizeof():s. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 77e7524 commit dbb1f2f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

drivers/iio/magnetometer/ak8975.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,10 @@ static int ak8975_who_i_am(struct i2c_client *client,
489489
* AK8975 | DEVICE_ID | NA
490490
* AK8963 | DEVICE_ID | NA
491491
*/
492-
ret = i2c_smbus_read_i2c_block_data_or_emulated(
493-
client, AK09912_REG_WIA1, 2, wia_val);
492+
ret = i2c_smbus_read_i2c_block_data_or_emulated(client,
493+
AK09912_REG_WIA1,
494+
sizeof(wia_val),
495+
wia_val);
494496
if (ret < 0) {
495497
dev_err(&client->dev, "Error reading WIA\n");
496498
return ret;
@@ -609,9 +611,10 @@ static int ak8975_setup(struct i2c_client *client)
609611
}
610612

611613
/* Get asa data and store in the device data. */
612-
ret = i2c_smbus_read_i2c_block_data_or_emulated(
613-
client, data->def->ctrl_regs[ASA_BASE],
614-
3, data->asa);
614+
ret = i2c_smbus_read_i2c_block_data_or_emulated(client,
615+
data->def->ctrl_regs[ASA_BASE],
616+
sizeof(data->asa),
617+
data->asa);
615618
if (ret < 0) {
616619
dev_err(&client->dev, "Not able to read asa data\n");
617620
return ret;
@@ -866,7 +869,7 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev)
866869
*/
867870
ret = i2c_smbus_read_i2c_block_data_or_emulated(client,
868871
def->data_regs[0],
869-
3 * sizeof(fval[0]),
872+
sizeof(fval),
870873
(u8 *)fval);
871874
if (ret < 0)
872875
goto unlock;

0 commit comments

Comments
 (0)