summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm90.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2021-11-29 12:17:41 -0800
committerGuenter Roeck <linux@roeck-us.net>2022-07-13 08:38:17 -0700
commitca7b9b14a022b2d255133b7bce7536ac45441f5e (patch)
treed128c8110afa01d5c4105c4ea1da05bb44d24359 /drivers/hwmon/lm90.c
parentddf2a6093c56546e17c7038ac6275ef779682de9 (diff)
downloadlinux-ca7b9b14a022b2d255133b7bce7536ac45441f5e.tar.bz2
hwmon: (lm90) Move status register bit shifts to compile time
Handling bit shifts necessary to extract status bits during compile time reduces code and data size by almost 5% when building for x86_64. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 0f3fadc1631c..cc26dd08fbff 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1345,17 +1345,18 @@ static const u8 lm90_temp_emerg_index[3] = {
LOCAL_EMERG, REMOTE_EMERG, REMOTE2_EMERG
};
-static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
-static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
-static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
-static const u8 lm90_crit_alarm_bits_swapped[3] = { 1, 0, 9 };
-static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
-static const u8 lm90_fault_bits[3] = { 0, 2, 10 };
+static const u16 lm90_min_alarm_bits[3] = { BIT(5), BIT(3), BIT(11) };
+static const u16 lm90_max_alarm_bits[3] = { BIT(6), BIT(4), BIT(12) };
+static const u16 lm90_crit_alarm_bits[3] = { BIT(0), BIT(1), BIT(9) };
+static const u16 lm90_crit_alarm_bits_swapped[3] = { BIT(1), BIT(0), BIT(9) };
+static const u16 lm90_emergency_alarm_bits[3] = { BIT(15), BIT(13), BIT(14) };
+static const u16 lm90_fault_bits[3] = { BIT(0), BIT(2), BIT(10) };
static int lm90_temp_read(struct device *dev, u32 attr, int channel, long *val)
{
struct lm90_data *data = dev_get_drvdata(dev);
- int err, bit;
+ int err;
+ u16 bit;
mutex_lock(&data->update_lock);
err = lm90_update_device(dev);
@@ -1374,22 +1375,22 @@ static int lm90_temp_read(struct device *dev, u32 attr, int channel, long *val)
case hwmon_temp_fault:
switch (attr) {
case hwmon_temp_min_alarm:
- bit = BIT(lm90_min_alarm_bits[channel]);
+ bit = lm90_min_alarm_bits[channel];
break;
case hwmon_temp_max_alarm:
- bit = BIT(lm90_max_alarm_bits[channel]);
+ bit = lm90_max_alarm_bits[channel];
break;
case hwmon_temp_crit_alarm:
if (data->flags & LM90_HAVE_CRIT_ALRM_SWP)
- bit = BIT(lm90_crit_alarm_bits_swapped[channel]);
+ bit = lm90_crit_alarm_bits_swapped[channel];
else
- bit = BIT(lm90_crit_alarm_bits[channel]);
+ bit = lm90_crit_alarm_bits[channel];
break;
case hwmon_temp_emergency_alarm:
- bit = BIT(lm90_emergency_alarm_bits[channel]);
+ bit = lm90_emergency_alarm_bits[channel];
break;
case hwmon_temp_fault:
- bit = BIT(lm90_fault_bits[channel]);
+ bit = lm90_fault_bits[channel];
break;
}
*val = !!(data->alarms & bit);