diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2024-06-06 23:54:16 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2024-06-13 21:23:05 +0200 |
commit | f42cfd5ceced62799a7dd82899b03d7b9575fc22 (patch) | |
tree | 646c366f6d9cc2de544d0b01e1ff553f134e5faa /drivers/acpi/pmic/intel_pmic_chtdc_ti.c | |
parent | 1dd804af345a126594a8b8e80510590b5775073b (diff) |
ACPI: PMIC: Replace open coded be16_to_cpu()
It's easier to understand the nature of a data type when
it's written explicitly. With that, replace open coded
endianess conversion.
As a side effect it fixes the returned value of
intel_crc_pmic_update_aux() since ACPI PMIC core code
expects negative or zero and never uses positive one.
While at it, use macros from bits.h to reduce a room for mistake.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/pmic/intel_pmic_chtdc_ti.c')
-rw-r--r-- | drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c index 35744a0307aa..79f9df552524 100644 --- a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c +++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c @@ -8,12 +8,16 @@ */ #include <linux/acpi.h> +#include <linux/bits.h> #include <linux/init.h> #include <linux/mfd/intel_soc_pmic.h> #include <linux/platform_device.h> +#include <asm/byteorder.h> #include "intel_pmic.h" /* registers stored in 16bit BE (high:low, total 10bit) */ +#define PMIC_REG_MASK GENMASK(9, 0) + #define CHTDC_TI_VBAT 0x54 #define CHTDC_TI_DIETEMP 0x56 #define CHTDC_TI_BPTHERM 0x58 @@ -73,7 +77,7 @@ static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit, if (regmap_read(regmap, reg, &data)) return -EIO; - *value = data & 1; + *value = data & BIT(0); return 0; } @@ -85,13 +89,12 @@ static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit, static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg) { - u8 buf[2]; + __be16 buf; - if (regmap_bulk_read(regmap, reg, buf, sizeof(buf))) + if (regmap_bulk_read(regmap, reg, &buf, sizeof(buf))) return -EIO; - /* stored in big-endian */ - return ((buf[0] & 0x03) << 8) | buf[1]; + return be16_to_cpu(buf) & PMIC_REG_MASK; } static const struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = { |