On Sun, Apr 09, 2023 at 01:47:17PM +1000, Frank Crawford wrote: > Handle errors from it87_update_device(), which currently only occurs if > SMBus access locking fails. > > Signed-off-by: Frank Crawford <frank@xxxxxxxxxxxxxxxxxx> This patch needs to come first, before it87_update_device() can return an error. Guenter > --- > drivers/hwmon/it87.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c > index 1ca3247efb9e..a3d26ef2cd31 100644 > --- a/drivers/hwmon/it87.c > +++ b/drivers/hwmon/it87.c > @@ -968,6 +968,9 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, > int index = sattr->index; > int nr = sattr->nr; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%d\n", in_from_reg(data, nr, data->in[nr][index])); > } > > @@ -1060,6 +1063,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, > int index = sattr->index; > struct it87_data *data = it87_update_device(dev); > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])); > } > > @@ -1140,6 +1146,9 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, > u8 reg = data->sensor; /* In case value is updated while used */ > u8 extra = data->extra; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > if ((has_temp_peci(data, nr) && (reg >> 6 == nr + 1)) || > (has_temp_old_peci(data, nr) && (extra & 0x80))) > return sprintf(buf, "6\n"); /* Intel PECI */ > @@ -1237,6 +1246,9 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, > int speed; > struct it87_data *data = it87_update_device(dev); > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > speed = has_16bit_fans(data) ? > FAN16_FROM_REG(data->fan[nr][index]) : > FAN_FROM_REG(data->fan[nr][index], > @@ -1251,6 +1263,9 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, > struct it87_data *data = it87_update_device(dev); > int nr = sensor_attr->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%lu\n", DIV_FROM_REG(data->fan_div[nr])); > } > > @@ -1261,6 +1276,9 @@ static ssize_t show_pwm_enable(struct device *dev, > struct it87_data *data = it87_update_device(dev); > int nr = sensor_attr->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%d\n", pwm_mode(data, nr)); > } > > @@ -1271,6 +1289,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, > struct it87_data *data = it87_update_device(dev); > int nr = sensor_attr->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%d\n", > pwm_from_reg(data, data->pwm_duty[nr])); > } > @@ -1284,6 +1305,9 @@ static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *attr, > unsigned int freq; > int index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > if (has_pwm_freq2(data) && nr == 1) > index = (data->extra >> 4) & 0x07; > else > @@ -1589,6 +1613,9 @@ static ssize_t show_pwm_temp_map(struct device *dev, > int nr = sensor_attr->index; > int map; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > map = data->pwm_temp_map[nr]; > if (map >= 3) > map = 0; /* Should never happen */ > @@ -1657,6 +1684,9 @@ static ssize_t show_auto_pwm(struct device *dev, struct device_attribute *attr, > int nr = sensor_attr->nr; > int point = sensor_attr->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%d\n", > pwm_from_reg(data, data->auto_pwm[nr][point])); > } > @@ -1697,6 +1727,9 @@ static ssize_t show_auto_pwm_slope(struct device *dev, > struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); > int nr = sensor_attr->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%d\n", data->auto_pwm[nr][1] & 0x7f); > } > > @@ -1734,6 +1767,9 @@ static ssize_t show_auto_temp(struct device *dev, struct device_attribute *attr, > int point = sensor_attr->index; > int reg; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > if (has_old_autopwm(data) || point) > reg = data->auto_temp[nr][point]; > else > @@ -1958,6 +1994,9 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, > { > struct it87_data *data = it87_update_device(dev); > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%u\n", data->alarms); > } > static DEVICE_ATTR_RO(alarms); > @@ -1968,6 +2007,9 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, > struct it87_data *data = it87_update_device(dev); > int bitnr = to_sensor_dev_attr(attr)->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); > } > > @@ -2025,6 +2067,9 @@ static ssize_t show_beep(struct device *dev, struct device_attribute *attr, > struct it87_data *data = it87_update_device(dev); > int bitnr = to_sensor_dev_attr(attr)->index; > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%u\n", (data->beeps >> bitnr) & 1); > } > > @@ -2102,6 +2147,9 @@ static ssize_t cpu0_vid_show(struct device *dev, > { > struct it87_data *data = it87_update_device(dev); > > + if (IS_ERR(data)) > + return PTR_ERR(data); > + > return sprintf(buf, "%ld\n", (long)vid_from_reg(data->vid, data->vrm)); > } > static DEVICE_ATTR_RO(cpu0_vid);