All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] ACPI: PMIC: Use sizeof() instead of hard coded value
@ 2022-08-30 17:11 Andy Shevchenko
  2022-08-30 17:11 ` [PATCH v2 2/3] ACPI: PMIC: Replace open coded be16_to_cpu() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Andy Shevchenko @ 2022-08-30 17:11 UTC (permalink / raw)
  To: Andy Shevchenko, Hans de Goede, linux-acpi, linux-kernel
  Cc: Rafael J. Wysocki, Len Brown, Andy Shevchenko, Mika Westerberg

It's better to use sizeof() of a given buffer than spreading
a hard coded value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: updated another driver as well (due to this no tag added)
 drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +-
 drivers/acpi/pmic/intel_pmic_xpower.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
index 418eec523025..6c2a6da430ed 100644
--- a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
+++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
@@ -87,7 +87,7 @@ static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
 {
 	u8 buf[2];
 
-	if (regmap_bulk_read(regmap, reg, buf, 2))
+	if (regmap_bulk_read(regmap, reg, buf, sizeof(buf)))
 		return -EIO;
 
 	/* stored in big-endian */
diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
index 61bbe4c24d87..33c5e85294cd 100644
--- a/drivers/acpi/pmic/intel_pmic_xpower.c
+++ b/drivers/acpi/pmic/intel_pmic_xpower.c
@@ -255,7 +255,7 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
 	if (ret)
 		return ret;
 
-	ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
+	ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, sizeof(buf));
 	if (ret == 0)
 		ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
 
-- 
2.35.1


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

end of thread, other threads:[~2022-08-31 10:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-30 17:11 [PATCH v2 1/3] ACPI: PMIC: Use sizeof() instead of hard coded value Andy Shevchenko
2022-08-30 17:11 ` [PATCH v2 2/3] ACPI: PMIC: Replace open coded be16_to_cpu() Andy Shevchenko
2022-08-31  5:43   ` Mika Westerberg
2022-08-31  9:34     ` Andy Shevchenko
2022-08-31  9:37       ` Hans de Goede
2022-08-31  9:48         ` Mika Westerberg
2022-08-31 10:06           ` David Laight
2022-08-31 10:27             ` Andy Shevchenko
2022-08-30 17:11 ` [PATCH v2 3/3] ACPI: PMIC: Convert pr_*() to dev_*() printing macros Andy Shevchenko
2022-08-31  5:44   ` Mika Westerberg
2022-08-31  5:37 ` [PATCH v2 1/3] ACPI: PMIC: Use sizeof() instead of hard coded value Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.