diff options
| -rw-r--r-- | drivers/hwmon/vexpress.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c index 7f9690560f40..8242b75d96c8 100644 --- a/drivers/hwmon/vexpress.c +++ b/drivers/hwmon/vexpress.c | |||
| @@ -43,9 +43,6 @@ static ssize_t vexpress_hwmon_label_show(struct device *dev, | |||
| 43 | { | 43 | { |
| 44 | const char *label = of_get_property(dev->of_node, "label", NULL); | 44 | const char *label = of_get_property(dev->of_node, "label", NULL); |
| 45 | 45 | ||
| 46 | if (!label) | ||
| 47 | return -ENOENT; | ||
| 48 | |||
| 49 | return snprintf(buffer, PAGE_SIZE, "%s\n", label); | 46 | return snprintf(buffer, PAGE_SIZE, "%s\n", label); |
| 50 | } | 47 | } |
| 51 | 48 | ||
| @@ -84,6 +81,20 @@ static ssize_t vexpress_hwmon_u64_show(struct device *dev, | |||
| 84 | to_sensor_dev_attr(dev_attr)->index)); | 81 | to_sensor_dev_attr(dev_attr)->index)); |
| 85 | } | 82 | } |
| 86 | 83 | ||
| 84 | static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj, | ||
| 85 | struct attribute *attr, int index) | ||
| 86 | { | ||
| 87 | struct device *dev = kobj_to_dev(kobj); | ||
| 88 | struct device_attribute *dev_attr = container_of(attr, | ||
| 89 | struct device_attribute, attr); | ||
| 90 | |||
| 91 | if (dev_attr->show == vexpress_hwmon_label_show && | ||
| 92 | !of_get_property(dev->of_node, "label", NULL)) | ||
| 93 | return 0; | ||
| 94 | |||
| 95 | return attr->mode; | ||
| 96 | } | ||
| 97 | |||
| 87 | static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL); | 98 | static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL); |
| 88 | 99 | ||
| 89 | #define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr) \ | 100 | #define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr) \ |
| @@ -105,6 +116,7 @@ static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show, | |||
| 105 | NULL, 1000); | 116 | NULL, 1000); |
| 106 | static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input); | 117 | static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input); |
| 107 | static struct attribute_group vexpress_hwmon_group_volt = { | 118 | static struct attribute_group vexpress_hwmon_group_volt = { |
| 119 | .is_visible = vexpress_hwmon_attr_is_visible, | ||
| 108 | .attrs = vexpress_hwmon_attrs_volt, | 120 | .attrs = vexpress_hwmon_attrs_volt, |
| 109 | }; | 121 | }; |
| 110 | static struct vexpress_hwmon_type vexpress_hwmon_volt = { | 122 | static struct vexpress_hwmon_type vexpress_hwmon_volt = { |
| @@ -121,6 +133,7 @@ static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show, | |||
| 121 | NULL, 1000); | 133 | NULL, 1000); |
| 122 | static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input); | 134 | static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input); |
| 123 | static struct attribute_group vexpress_hwmon_group_amp = { | 135 | static struct attribute_group vexpress_hwmon_group_amp = { |
| 136 | .is_visible = vexpress_hwmon_attr_is_visible, | ||
| 124 | .attrs = vexpress_hwmon_attrs_amp, | 137 | .attrs = vexpress_hwmon_attrs_amp, |
| 125 | }; | 138 | }; |
| 126 | static struct vexpress_hwmon_type vexpress_hwmon_amp = { | 139 | static struct vexpress_hwmon_type vexpress_hwmon_amp = { |
| @@ -136,6 +149,7 @@ static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show, | |||
| 136 | NULL, 1000); | 149 | NULL, 1000); |
| 137 | static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input); | 150 | static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input); |
| 138 | static struct attribute_group vexpress_hwmon_group_temp = { | 151 | static struct attribute_group vexpress_hwmon_group_temp = { |
| 152 | .is_visible = vexpress_hwmon_attr_is_visible, | ||
| 139 | .attrs = vexpress_hwmon_attrs_temp, | 153 | .attrs = vexpress_hwmon_attrs_temp, |
| 140 | }; | 154 | }; |
| 141 | static struct vexpress_hwmon_type vexpress_hwmon_temp = { | 155 | static struct vexpress_hwmon_type vexpress_hwmon_temp = { |
| @@ -151,6 +165,7 @@ static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show, | |||
| 151 | NULL, 1); | 165 | NULL, 1); |
| 152 | static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input); | 166 | static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input); |
| 153 | static struct attribute_group vexpress_hwmon_group_power = { | 167 | static struct attribute_group vexpress_hwmon_group_power = { |
| 168 | .is_visible = vexpress_hwmon_attr_is_visible, | ||
| 154 | .attrs = vexpress_hwmon_attrs_power, | 169 | .attrs = vexpress_hwmon_attrs_power, |
| 155 | }; | 170 | }; |
| 156 | static struct vexpress_hwmon_type vexpress_hwmon_power = { | 171 | static struct vexpress_hwmon_type vexpress_hwmon_power = { |
| @@ -166,6 +181,7 @@ static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show, | |||
| 166 | NULL, 1); | 181 | NULL, 1); |
| 167 | static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input); | 182 | static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input); |
| 168 | static struct attribute_group vexpress_hwmon_group_energy = { | 183 | static struct attribute_group vexpress_hwmon_group_energy = { |
| 184 | .is_visible = vexpress_hwmon_attr_is_visible, | ||
| 169 | .attrs = vexpress_hwmon_attrs_energy, | 185 | .attrs = vexpress_hwmon_attrs_energy, |
| 170 | }; | 186 | }; |
| 171 | static struct vexpress_hwmon_type vexpress_hwmon_energy = { | 187 | static struct vexpress_hwmon_type vexpress_hwmon_energy = { |
