Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (occ) Prevent sysfs error attribute from returning error

The error sysfs attribute returns the stored error state of the OCC and
doesn't depend on the OCC poll response. Therefore, split the error
attribute into it's own function to avoid failing out of the function if
the poll response fails.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Eddie James and committed by
Guenter Roeck
afe8419e b5c46a53

+13 -6
+13 -6
drivers/hwmon/occ/sysfs.c
··· 63 63 else 64 64 val = 1; 65 65 break; 66 - case 8: 67 - val = occ->error; 68 - break; 69 66 default: 70 67 return -EINVAL; 71 68 } 72 69 73 70 return snprintf(buf, PAGE_SIZE - 1, "%d\n", val); 71 + } 72 + 73 + static ssize_t occ_error_show(struct device *dev, 74 + struct device_attribute *attr, char *buf) 75 + { 76 + struct occ *occ = dev_get_drvdata(dev); 77 + 78 + occ_update_response(occ); 79 + 80 + return snprintf(buf, PAGE_SIZE - 1, "%d\n", occ->error); 74 81 } 75 82 76 83 static SENSOR_DEVICE_ATTR(occ_master, 0444, occ_sysfs_show, NULL, 0); ··· 88 81 static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, 5); 89 82 static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6); 90 83 static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7); 91 - static SENSOR_DEVICE_ATTR(occ_error, 0444, occ_sysfs_show, NULL, 8); 84 + static DEVICE_ATTR_RO(occ_error); 92 85 93 86 static struct attribute *occ_attributes[] = { 94 87 &sensor_dev_attr_occ_master.dev_attr.attr, ··· 99 92 &sensor_dev_attr_occ_quick_pwr_drop.dev_attr.attr, 100 93 &sensor_dev_attr_occ_state.dev_attr.attr, 101 94 &sensor_dev_attr_occs_present.dev_attr.attr, 102 - &sensor_dev_attr_occ_error.dev_attr.attr, 95 + &dev_attr_occ_error.attr, 103 96 NULL 104 97 }; 105 98 ··· 163 156 } 164 157 165 158 if (occ->error && occ->error != occ->prev_error) { 166 - name = sensor_dev_attr_occ_error.dev_attr.attr.name; 159 + name = dev_attr_occ_error.attr.name; 167 160 sysfs_notify(&occ->bus_dev->kobj, NULL, name); 168 161 } 169 162