diff options
author | Pawel Moll <pawel.moll@arm.com> | 2014-04-23 13:27:04 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-04-24 09:01:59 -0400 |
commit | 52feaca5d685c07a4bc9812d16d84f5f7991bfe7 (patch) | |
tree | e08ee3ccbcc7b74c2f6bd5fb9c16509017e26df4 /drivers | |
parent | a798c10faf62a505d24e5f6213fbaf904a39623f (diff) |
hwmon: (vexpress) Use legal hwmon device names
The driver used to directly us a DT 'compatible' property for
the 'name' attribute of the hwmon devices. Unfortunately it
contains '-' which is illegal in this context. It messes up
libsensors and thus every application using it.
Fixed by providing equivalent (and simpler) name strings.
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/vexpress.c | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c index d867e6bb2be1..7f9690560f40 100644 --- a/drivers/hwmon/vexpress.c +++ b/drivers/hwmon/vexpress.c | |||
@@ -27,15 +27,15 @@ | |||
27 | struct vexpress_hwmon_data { | 27 | struct vexpress_hwmon_data { |
28 | struct device *hwmon_dev; | 28 | struct device *hwmon_dev; |
29 | struct vexpress_config_func *func; | 29 | struct vexpress_config_func *func; |
30 | const char *name; | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | static ssize_t vexpress_hwmon_name_show(struct device *dev, | 33 | static ssize_t vexpress_hwmon_name_show(struct device *dev, |
33 | struct device_attribute *dev_attr, char *buffer) | 34 | struct device_attribute *dev_attr, char *buffer) |
34 | { | 35 | { |
35 | const char *compatible = of_get_property(dev->of_node, "compatible", | 36 | struct vexpress_hwmon_data *data = dev_get_drvdata(dev); |
36 | NULL); | ||
37 | 37 | ||
38 | return sprintf(buffer, "%s\n", compatible); | 38 | return sprintf(buffer, "%s\n", data->name); |
39 | } | 39 | } |
40 | 40 | ||
41 | static ssize_t vexpress_hwmon_label_show(struct device *dev, | 41 | static ssize_t vexpress_hwmon_label_show(struct device *dev, |
@@ -94,6 +94,11 @@ struct attribute *vexpress_hwmon_attrs_##_name[] = { \ | |||
94 | NULL \ | 94 | NULL \ |
95 | } | 95 | } |
96 | 96 | ||
97 | struct vexpress_hwmon_type { | ||
98 | const char *name; | ||
99 | const struct attribute_group **attr_groups; | ||
100 | }; | ||
101 | |||
97 | #if !defined(CONFIG_REGULATOR_VEXPRESS) | 102 | #if !defined(CONFIG_REGULATOR_VEXPRESS) |
98 | static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); | 103 | static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); |
99 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show, | 104 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show, |
@@ -102,6 +107,13 @@ static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input); | |||
102 | static struct attribute_group vexpress_hwmon_group_volt = { | 107 | static struct attribute_group vexpress_hwmon_group_volt = { |
103 | .attrs = vexpress_hwmon_attrs_volt, | 108 | .attrs = vexpress_hwmon_attrs_volt, |
104 | }; | 109 | }; |
110 | static struct vexpress_hwmon_type vexpress_hwmon_volt = { | ||
111 | .name = "vexpress_volt", | ||
112 | .attr_groups = (const struct attribute_group *[]) { | ||
113 | &vexpress_hwmon_group_volt, | ||
114 | NULL, | ||
115 | }, | ||
116 | }; | ||
105 | #endif | 117 | #endif |
106 | 118 | ||
107 | static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); | 119 | static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); |
@@ -111,6 +123,13 @@ static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input); | |||
111 | static struct attribute_group vexpress_hwmon_group_amp = { | 123 | static struct attribute_group vexpress_hwmon_group_amp = { |
112 | .attrs = vexpress_hwmon_attrs_amp, | 124 | .attrs = vexpress_hwmon_attrs_amp, |
113 | }; | 125 | }; |
126 | static struct vexpress_hwmon_type vexpress_hwmon_amp = { | ||
127 | .name = "vexpress_amp", | ||
128 | .attr_groups = (const struct attribute_group *[]) { | ||
129 | &vexpress_hwmon_group_amp, | ||
130 | NULL | ||
131 | }, | ||
132 | }; | ||
114 | 133 | ||
115 | static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); | 134 | static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); |
116 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show, | 135 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show, |
@@ -119,6 +138,13 @@ static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input); | |||
119 | static struct attribute_group vexpress_hwmon_group_temp = { | 138 | static struct attribute_group vexpress_hwmon_group_temp = { |
120 | .attrs = vexpress_hwmon_attrs_temp, | 139 | .attrs = vexpress_hwmon_attrs_temp, |
121 | }; | 140 | }; |
141 | static struct vexpress_hwmon_type vexpress_hwmon_temp = { | ||
142 | .name = "vexpress_temp", | ||
143 | .attr_groups = (const struct attribute_group *[]) { | ||
144 | &vexpress_hwmon_group_temp, | ||
145 | NULL | ||
146 | }, | ||
147 | }; | ||
122 | 148 | ||
123 | static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); | 149 | static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); |
124 | static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show, | 150 | static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show, |
@@ -127,6 +153,13 @@ static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input); | |||
127 | static struct attribute_group vexpress_hwmon_group_power = { | 153 | static struct attribute_group vexpress_hwmon_group_power = { |
128 | .attrs = vexpress_hwmon_attrs_power, | 154 | .attrs = vexpress_hwmon_attrs_power, |
129 | }; | 155 | }; |
156 | static struct vexpress_hwmon_type vexpress_hwmon_power = { | ||
157 | .name = "vexpress_power", | ||
158 | .attr_groups = (const struct attribute_group *[]) { | ||
159 | &vexpress_hwmon_group_power, | ||
160 | NULL | ||
161 | }, | ||
162 | }; | ||
130 | 163 | ||
131 | static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); | 164 | static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); |
132 | static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show, | 165 | static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show, |
@@ -135,26 +168,33 @@ static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input); | |||
135 | static struct attribute_group vexpress_hwmon_group_energy = { | 168 | static struct attribute_group vexpress_hwmon_group_energy = { |
136 | .attrs = vexpress_hwmon_attrs_energy, | 169 | .attrs = vexpress_hwmon_attrs_energy, |
137 | }; | 170 | }; |
171 | static struct vexpress_hwmon_type vexpress_hwmon_energy = { | ||
172 | .name = "vexpress_energy", | ||
173 | .attr_groups = (const struct attribute_group *[]) { | ||
174 | &vexpress_hwmon_group_energy, | ||
175 | NULL | ||
176 | }, | ||
177 | }; | ||
138 | 178 | ||
139 | static struct of_device_id vexpress_hwmon_of_match[] = { | 179 | static struct of_device_id vexpress_hwmon_of_match[] = { |
140 | #if !defined(CONFIG_REGULATOR_VEXPRESS) | 180 | #if !defined(CONFIG_REGULATOR_VEXPRESS) |
141 | { | 181 | { |
142 | .compatible = "arm,vexpress-volt", | 182 | .compatible = "arm,vexpress-volt", |
143 | .data = &vexpress_hwmon_group_volt, | 183 | .data = &vexpress_hwmon_volt, |
144 | }, | 184 | }, |
145 | #endif | 185 | #endif |
146 | { | 186 | { |
147 | .compatible = "arm,vexpress-amp", | 187 | .compatible = "arm,vexpress-amp", |
148 | .data = &vexpress_hwmon_group_amp, | 188 | .data = &vexpress_hwmon_amp, |
149 | }, { | 189 | }, { |
150 | .compatible = "arm,vexpress-temp", | 190 | .compatible = "arm,vexpress-temp", |
151 | .data = &vexpress_hwmon_group_temp, | 191 | .data = &vexpress_hwmon_temp, |
152 | }, { | 192 | }, { |
153 | .compatible = "arm,vexpress-power", | 193 | .compatible = "arm,vexpress-power", |
154 | .data = &vexpress_hwmon_group_power, | 194 | .data = &vexpress_hwmon_power, |
155 | }, { | 195 | }, { |
156 | .compatible = "arm,vexpress-energy", | 196 | .compatible = "arm,vexpress-energy", |
157 | .data = &vexpress_hwmon_group_energy, | 197 | .data = &vexpress_hwmon_energy, |
158 | }, | 198 | }, |
159 | {} | 199 | {} |
160 | }; | 200 | }; |
@@ -165,6 +205,7 @@ static int vexpress_hwmon_probe(struct platform_device *pdev) | |||
165 | int err; | 205 | int err; |
166 | const struct of_device_id *match; | 206 | const struct of_device_id *match; |
167 | struct vexpress_hwmon_data *data; | 207 | struct vexpress_hwmon_data *data; |
208 | const struct vexpress_hwmon_type *type; | ||
168 | 209 | ||
169 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 210 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
170 | if (!data) | 211 | if (!data) |
@@ -174,12 +215,14 @@ static int vexpress_hwmon_probe(struct platform_device *pdev) | |||
174 | match = of_match_device(vexpress_hwmon_of_match, &pdev->dev); | 215 | match = of_match_device(vexpress_hwmon_of_match, &pdev->dev); |
175 | if (!match) | 216 | if (!match) |
176 | return -ENODEV; | 217 | return -ENODEV; |
218 | type = match->data; | ||
219 | data->name = type->name; | ||
177 | 220 | ||
178 | data->func = vexpress_config_func_get_by_dev(&pdev->dev); | 221 | data->func = vexpress_config_func_get_by_dev(&pdev->dev); |
179 | if (!data->func) | 222 | if (!data->func) |
180 | return -ENODEV; | 223 | return -ENODEV; |
181 | 224 | ||
182 | err = sysfs_create_group(&pdev->dev.kobj, match->data); | 225 | err = sysfs_create_groups(&pdev->dev.kobj, type->attr_groups); |
183 | if (err) | 226 | if (err) |
184 | goto error; | 227 | goto error; |
185 | 228 | ||