27
27
struct vexpress_hwmon_data {
28
28
struct device * hwmon_dev ;
29
29
struct regmap * reg ;
30
- const char * name ;
31
30
};
32
31
33
- static ssize_t vexpress_hwmon_name_show (struct device * dev ,
34
- struct device_attribute * dev_attr , char * buffer )
35
- {
36
- struct vexpress_hwmon_data * data = dev_get_drvdata (dev );
37
-
38
- return sprintf (buffer , "%s\n" , data -> name );
39
- }
40
-
41
32
static ssize_t vexpress_hwmon_label_show (struct device * dev ,
42
33
struct device_attribute * dev_attr , char * buffer )
43
34
{
@@ -95,16 +86,6 @@ static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
95
86
return attr -> mode ;
96
87
}
97
88
98
- static DEVICE_ATTR (name , S_IRUGO , vexpress_hwmon_name_show , NULL) ;
99
-
100
- #define VEXPRESS_HWMON_ATTRS (_name , _label_attr , _input_attr ) \
101
- struct attribute *vexpress_hwmon_attrs_##_name[] = { \
102
- &dev_attr_name.attr, \
103
- &dev_attr_##_label_attr.attr, \
104
- &sensor_dev_attr_##_input_attr.dev_attr.attr, \
105
- NULL \
106
- }
107
-
108
89
struct vexpress_hwmon_type {
109
90
const char * name ;
110
91
const struct attribute_group * * attr_groups ;
@@ -114,7 +95,11 @@ struct vexpress_hwmon_type {
114
95
static DEVICE_ATTR (in1_label , S_IRUGO , vexpress_hwmon_label_show , NULL) ;
115
96
static SENSOR_DEVICE_ATTR (in1_input , S_IRUGO , vexpress_hwmon_u32_show ,
116
97
NULL, 1000 ) ;
117
- static VEXPRESS_HWMON_ATTRS (volt , in1_label , in1_input ) ;
98
+ static struct attribute * vexpress_hwmon_attrs_volt [] = {
99
+ & dev_attr_in1_label .attr ,
100
+ & sensor_dev_attr_in1_input .dev_attr .attr ,
101
+ NULL
102
+ };
118
103
static struct attribute_group vexpress_hwmon_group_volt = {
119
104
.is_visible = vexpress_hwmon_attr_is_visible ,
120
105
.attrs = vexpress_hwmon_attrs_volt ,
@@ -131,7 +116,11 @@ static struct vexpress_hwmon_type vexpress_hwmon_volt = {
131
116
static DEVICE_ATTR (curr1_label , S_IRUGO , vexpress_hwmon_label_show , NULL) ;
132
117
static SENSOR_DEVICE_ATTR (curr1_input , S_IRUGO , vexpress_hwmon_u32_show ,
133
118
NULL, 1000 ) ;
134
- static VEXPRESS_HWMON_ATTRS (amp , curr1_label , curr1_input ) ;
119
+ static struct attribute * vexpress_hwmon_attrs_amp [] = {
120
+ & dev_attr_curr1_label .attr ,
121
+ & sensor_dev_attr_curr1_input .dev_attr .attr ,
122
+ NULL
123
+ };
135
124
static struct attribute_group vexpress_hwmon_group_amp = {
136
125
.is_visible = vexpress_hwmon_attr_is_visible ,
137
126
.attrs = vexpress_hwmon_attrs_amp ,
@@ -147,7 +136,11 @@ static struct vexpress_hwmon_type vexpress_hwmon_amp = {
147
136
static DEVICE_ATTR (temp1_label , S_IRUGO , vexpress_hwmon_label_show , NULL) ;
148
137
static SENSOR_DEVICE_ATTR (temp1_input , S_IRUGO , vexpress_hwmon_u32_show ,
149
138
NULL, 1000 ) ;
150
- static VEXPRESS_HWMON_ATTRS (temp , temp1_label , temp1_input ) ;
139
+ static struct attribute * vexpress_hwmon_attrs_temp [] = {
140
+ & dev_attr_temp1_label .attr ,
141
+ & sensor_dev_attr_temp1_input .dev_attr .attr ,
142
+ NULL
143
+ };
151
144
static struct attribute_group vexpress_hwmon_group_temp = {
152
145
.is_visible = vexpress_hwmon_attr_is_visible ,
153
146
.attrs = vexpress_hwmon_attrs_temp ,
@@ -163,7 +156,11 @@ static struct vexpress_hwmon_type vexpress_hwmon_temp = {
163
156
static DEVICE_ATTR (power1_label , S_IRUGO , vexpress_hwmon_label_show , NULL) ;
164
157
static SENSOR_DEVICE_ATTR (power1_input , S_IRUGO , vexpress_hwmon_u32_show ,
165
158
NULL, 1 ) ;
166
- static VEXPRESS_HWMON_ATTRS (power , power1_label , power1_input ) ;
159
+ static struct attribute * vexpress_hwmon_attrs_power [] = {
160
+ & dev_attr_power1_label .attr ,
161
+ & sensor_dev_attr_power1_input .dev_attr .attr ,
162
+ NULL
163
+ };
167
164
static struct attribute_group vexpress_hwmon_group_power = {
168
165
.is_visible = vexpress_hwmon_attr_is_visible ,
169
166
.attrs = vexpress_hwmon_attrs_power ,
@@ -179,7 +176,11 @@ static struct vexpress_hwmon_type vexpress_hwmon_power = {
179
176
static DEVICE_ATTR (energy1_label , S_IRUGO , vexpress_hwmon_label_show , NULL) ;
180
177
static SENSOR_DEVICE_ATTR (energy1_input , S_IRUGO , vexpress_hwmon_u64_show ,
181
178
NULL, 1 ) ;
182
- static VEXPRESS_HWMON_ATTRS (energy , energy1_label , energy1_input ) ;
179
+ static struct attribute * vexpress_hwmon_attrs_energy [] = {
180
+ & dev_attr_energy1_label .attr ,
181
+ & sensor_dev_attr_energy1_input .dev_attr .attr ,
182
+ NULL
183
+ };
183
184
static struct attribute_group vexpress_hwmon_group_energy = {
184
185
.is_visible = vexpress_hwmon_attr_is_visible ,
185
186
.attrs = vexpress_hwmon_attrs_energy ,
@@ -218,7 +219,6 @@ MODULE_DEVICE_TABLE(of, vexpress_hwmon_of_match);
218
219
219
220
static int vexpress_hwmon_probe (struct platform_device * pdev )
220
221
{
221
- int err ;
222
222
const struct of_device_id * match ;
223
223
struct vexpress_hwmon_data * data ;
224
224
const struct vexpress_hwmon_type * type ;
@@ -232,45 +232,19 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
232
232
if (!match )
233
233
return - ENODEV ;
234
234
type = match -> data ;
235
- data -> name = type -> name ;
236
235
237
236
data -> reg = devm_regmap_init_vexpress_config (& pdev -> dev );
238
237
if (IS_ERR (data -> reg ))
239
238
return PTR_ERR (data -> reg );
240
239
241
- err = sysfs_create_groups (& pdev -> dev .kobj , type -> attr_groups );
242
- if (err )
243
- goto error ;
244
-
245
- data -> hwmon_dev = hwmon_device_register (& pdev -> dev );
246
- if (IS_ERR (data -> hwmon_dev )) {
247
- err = PTR_ERR (data -> hwmon_dev );
248
- goto error ;
249
- }
250
-
251
- return 0 ;
252
-
253
- error :
254
- sysfs_remove_group (& pdev -> dev .kobj , match -> data );
255
- return err ;
256
- }
257
-
258
- static int vexpress_hwmon_remove (struct platform_device * pdev )
259
- {
260
- struct vexpress_hwmon_data * data = platform_get_drvdata (pdev );
261
- const struct of_device_id * match ;
262
-
263
- hwmon_device_unregister (data -> hwmon_dev );
264
-
265
- match = of_match_device (vexpress_hwmon_of_match , & pdev -> dev );
266
- sysfs_remove_group (& pdev -> dev .kobj , match -> data );
240
+ data -> hwmon_dev = devm_hwmon_device_register_with_groups (& pdev -> dev ,
241
+ type -> name , data , type -> attr_groups );
267
242
268
- return 0 ;
243
+ return PTR_ERR_OR_ZERO ( data -> hwmon_dev ) ;
269
244
}
270
245
271
246
static struct platform_driver vexpress_hwmon_driver = {
272
247
.probe = vexpress_hwmon_probe ,
273
- .remove = vexpress_hwmon_remove ,
274
248
.driver = {
275
249
.name = DRVNAME ,
276
250
.owner = THIS_MODULE ,
0 commit comments