Skip to content

Commit 93219a4

Browse files
andy-shevalexandrebelloni
authored andcommitted
rtc: isl12022: Explicitly use __le16 type for ISL12022_REG_TEMP_L
We are reading 10-bit value in a 16-bit register in LE format. Make this explicit by using __le16 type for it and corresponding conversion function. Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Rasmus Villemoes <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent f525b21 commit 93219a4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/rtc/rtc-isl12022.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <linux/regmap.h>
2020
#include <linux/hwmon.h>
2121

22+
#include <asm/byteorder.h>
23+
2224
/* ISL register offsets */
2325
#define ISL12022_REG_SC 0x00
2426
#define ISL12022_REG_MN 0x01
@@ -63,17 +65,16 @@ static umode_t isl12022_hwmon_is_visible(const void *data,
6365
static int isl12022_hwmon_read_temp(struct device *dev, long *mC)
6466
{
6567
struct regmap *regmap = dev_get_drvdata(dev);
66-
u8 temp_buf[2];
6768
int temp, ret;
69+
__le16 buf;
6870

69-
ret = regmap_bulk_read(regmap, ISL12022_REG_TEMP_L,
70-
temp_buf, sizeof(temp_buf));
71+
ret = regmap_bulk_read(regmap, ISL12022_REG_TEMP_L, &buf, sizeof(buf));
7172
if (ret)
7273
return ret;
7374
/*
7475
* Temperature is represented as a 10-bit number, unit half-Kelvins.
7576
*/
76-
temp = (temp_buf[1] << 8) | temp_buf[0];
77+
temp = le16_to_cpu(buf);
7778
temp *= 500;
7879
temp -= 273000;
7980

0 commit comments

Comments
 (0)