diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-24 18:05:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-20 19:59:00 -0400 |
commit | a749245168ccda07b4200a8d55e2042679b7ecd4 (patch) | |
tree | 0c632f0ea1cdcc310fe84b981785da3fd709dd7b /drivers/hid/hid-roccat-pyra.c | |
parent | 6853152689d47b4a1eb9f38a25a18f3f8b7a60de (diff) |
hid: roccat-pyra: convert class code to use bin_attrs in groups
Now that attribute groups support binary attributes, use them instead of
the dev_bin_attrs field in struct class, as that is going away soon.
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hid/hid-roccat-pyra.c')
-rw-r--r-- | drivers/hid/hid-roccat-pyra.c | 140 |
1 files changed, 62 insertions, 78 deletions
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 7960d507ad9a..5a6dbbeee790 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
@@ -156,7 +156,8 @@ PYRA_SYSFS_W(thingy, THINGY) \ | |||
156 | PYRA_SYSFS_R(thingy, THINGY) | 156 | PYRA_SYSFS_R(thingy, THINGY) |
157 | 157 | ||
158 | #define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \ | 158 | #define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \ |
159 | { \ | 159 | PYRA_SYSFS_RW(thingy, THINGY); \ |
160 | static struct bin_attribute bin_attr_##thingy = { \ | ||
160 | .attr = { .name = #thingy, .mode = 0660 }, \ | 161 | .attr = { .name = #thingy, .mode = 0660 }, \ |
161 | .size = PYRA_SIZE_ ## THINGY, \ | 162 | .size = PYRA_SIZE_ ## THINGY, \ |
162 | .read = pyra_sysfs_read_ ## thingy, \ | 163 | .read = pyra_sysfs_read_ ## thingy, \ |
@@ -164,24 +165,25 @@ PYRA_SYSFS_R(thingy, THINGY) | |||
164 | } | 165 | } |
165 | 166 | ||
166 | #define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \ | 167 | #define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \ |
167 | { \ | 168 | PYRA_SYSFS_R(thingy, THINGY); \ |
169 | static struct bin_attribute bin_attr_##thingy = { \ | ||
168 | .attr = { .name = #thingy, .mode = 0440 }, \ | 170 | .attr = { .name = #thingy, .mode = 0440 }, \ |
169 | .size = PYRA_SIZE_ ## THINGY, \ | 171 | .size = PYRA_SIZE_ ## THINGY, \ |
170 | .read = pyra_sysfs_read_ ## thingy, \ | 172 | .read = pyra_sysfs_read_ ## thingy, \ |
171 | } | 173 | } |
172 | 174 | ||
173 | #define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \ | 175 | #define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \ |
174 | { \ | 176 | PYRA_SYSFS_W(thingy, THINGY); \ |
177 | static struct bin_attribute bin_attr_##thingy = { \ | ||
175 | .attr = { .name = #thingy, .mode = 0220 }, \ | 178 | .attr = { .name = #thingy, .mode = 0220 }, \ |
176 | .size = PYRA_SIZE_ ## THINGY, \ | 179 | .size = PYRA_SIZE_ ## THINGY, \ |
177 | .write = pyra_sysfs_write_ ## thingy \ | 180 | .write = pyra_sysfs_write_ ## thingy \ |
178 | } | 181 | } |
179 | 182 | ||
180 | PYRA_SYSFS_W(control, CONTROL) | 183 | PYRA_BIN_ATTRIBUTE_W(control, CONTROL); |
181 | PYRA_SYSFS_RW(info, INFO) | 184 | PYRA_BIN_ATTRIBUTE_RW(info, INFO); |
182 | PYRA_SYSFS_RW(profile_settings, PROFILE_SETTINGS) | 185 | PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS); |
183 | PYRA_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) | 186 | PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS); |
184 | PYRA_SYSFS_R(settings, SETTINGS) | ||
185 | 187 | ||
186 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, | 188 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, |
187 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 189 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
@@ -221,6 +223,25 @@ static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, | |||
221 | PYRA_COMMAND_PROFILE_BUTTONS); | 223 | PYRA_COMMAND_PROFILE_BUTTONS); |
222 | } | 224 | } |
223 | 225 | ||
226 | #define PROFILE_ATTR(number) \ | ||
227 | static struct bin_attribute bin_attr_profile##number##_settings = { \ | ||
228 | .attr = { .name = "profile##number##_settings", .mode = 0440 }, \ | ||
229 | .size = PYRA_SIZE_PROFILE_SETTINGS, \ | ||
230 | .read = pyra_sysfs_read_profilex_settings, \ | ||
231 | .private = &profile_numbers[number-1], \ | ||
232 | }; \ | ||
233 | static struct bin_attribute bin_attr_profile##number##_buttons = { \ | ||
234 | .attr = { .name = "profile##number##_buttons", .mode = 0440 }, \ | ||
235 | .size = PYRA_SIZE_PROFILE_BUTTONS, \ | ||
236 | .read = pyra_sysfs_read_profilex_buttons, \ | ||
237 | .private = &profile_numbers[number-1], \ | ||
238 | }; | ||
239 | PROFILE_ATTR(1); | ||
240 | PROFILE_ATTR(2); | ||
241 | PROFILE_ATTR(3); | ||
242 | PROFILE_ATTR(4); | ||
243 | PROFILE_ATTR(5); | ||
244 | |||
224 | static ssize_t pyra_sysfs_write_settings(struct file *fp, | 245 | static ssize_t pyra_sysfs_write_settings(struct file *fp, |
225 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 246 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
226 | loff_t off, size_t count) | 247 | loff_t off, size_t count) |
@@ -258,6 +279,11 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
258 | return PYRA_SIZE_SETTINGS; | 279 | return PYRA_SIZE_SETTINGS; |
259 | } | 280 | } |
260 | 281 | ||
282 | PYRA_SYSFS_R(settings, SETTINGS); | ||
283 | static struct bin_attribute bin_attr_settings = | ||
284 | __BIN_ATTR(settings, (S_IWUSR | S_IRUGO), | ||
285 | pyra_sysfs_read_settings, pyra_sysfs_write_settings, | ||
286 | PYRA_SIZE_SETTINGS); | ||
261 | 287 | ||
262 | static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, | 288 | static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, |
263 | struct device_attribute *attr, char *buf) | 289 | struct device_attribute *attr, char *buf) |
@@ -314,75 +340,34 @@ static struct attribute *pyra_attrs[] = { | |||
314 | &dev_attr_startup_profile.attr, | 340 | &dev_attr_startup_profile.attr, |
315 | NULL, | 341 | NULL, |
316 | }; | 342 | }; |
317 | ATTRIBUTE_GROUPS(pyra); | 343 | |
318 | 344 | static struct bin_attribute *pyra_bin_attributes[] = { | |
319 | static struct bin_attribute pyra_bin_attributes[] = { | 345 | &bin_attr_control, |
320 | PYRA_BIN_ATTRIBUTE_W(control, CONTROL), | 346 | &bin_attr_info, |
321 | PYRA_BIN_ATTRIBUTE_RW(info, INFO), | 347 | &bin_attr_profile_settings, |
322 | PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), | 348 | &bin_attr_profile_buttons, |
323 | PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), | 349 | &bin_attr_settings, |
324 | PYRA_BIN_ATTRIBUTE_RW(settings, SETTINGS), | 350 | &bin_attr_profile1_settings, |
325 | { | 351 | &bin_attr_profile2_settings, |
326 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 352 | &bin_attr_profile3_settings, |
327 | .size = PYRA_SIZE_PROFILE_SETTINGS, | 353 | &bin_attr_profile4_settings, |
328 | .read = pyra_sysfs_read_profilex_settings, | 354 | &bin_attr_profile5_settings, |
329 | .private = &profile_numbers[0] | 355 | &bin_attr_profile1_buttons, |
330 | }, | 356 | &bin_attr_profile2_buttons, |
331 | { | 357 | &bin_attr_profile3_buttons, |
332 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 358 | &bin_attr_profile4_buttons, |
333 | .size = PYRA_SIZE_PROFILE_SETTINGS, | 359 | &bin_attr_profile5_buttons, |
334 | .read = pyra_sysfs_read_profilex_settings, | 360 | NULL, |
335 | .private = &profile_numbers[1] | 361 | }; |
336 | }, | 362 | |
337 | { | 363 | static const struct attribute_group pyra_group = { |
338 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 364 | .attrs = pyra_attrs, |
339 | .size = PYRA_SIZE_PROFILE_SETTINGS, | 365 | .bin_attrs = pyra_bin_attributes, |
340 | .read = pyra_sysfs_read_profilex_settings, | 366 | }; |
341 | .private = &profile_numbers[2] | 367 | |
342 | }, | 368 | static const struct attribute_group *pyra_groups[] = { |
343 | { | 369 | &pyra_group, |
344 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 370 | NULL, |
345 | .size = PYRA_SIZE_PROFILE_SETTINGS, | ||
346 | .read = pyra_sysfs_read_profilex_settings, | ||
347 | .private = &profile_numbers[3] | ||
348 | }, | ||
349 | { | ||
350 | .attr = { .name = "profile5_settings", .mode = 0440 }, | ||
351 | .size = PYRA_SIZE_PROFILE_SETTINGS, | ||
352 | .read = pyra_sysfs_read_profilex_settings, | ||
353 | .private = &profile_numbers[4] | ||
354 | }, | ||
355 | { | ||
356 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | ||
357 | .size = PYRA_SIZE_PROFILE_BUTTONS, | ||
358 | .read = pyra_sysfs_read_profilex_buttons, | ||
359 | .private = &profile_numbers[0] | ||
360 | }, | ||
361 | { | ||
362 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | ||
363 | .size = PYRA_SIZE_PROFILE_BUTTONS, | ||
364 | .read = pyra_sysfs_read_profilex_buttons, | ||
365 | .private = &profile_numbers[1] | ||
366 | }, | ||
367 | { | ||
368 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | ||
369 | .size = PYRA_SIZE_PROFILE_BUTTONS, | ||
370 | .read = pyra_sysfs_read_profilex_buttons, | ||
371 | .private = &profile_numbers[2] | ||
372 | }, | ||
373 | { | ||
374 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | ||
375 | .size = PYRA_SIZE_PROFILE_BUTTONS, | ||
376 | .read = pyra_sysfs_read_profilex_buttons, | ||
377 | .private = &profile_numbers[3] | ||
378 | }, | ||
379 | { | ||
380 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | ||
381 | .size = PYRA_SIZE_PROFILE_BUTTONS, | ||
382 | .read = pyra_sysfs_read_profilex_buttons, | ||
383 | .private = &profile_numbers[4] | ||
384 | }, | ||
385 | __ATTR_NULL | ||
386 | }; | 371 | }; |
387 | 372 | ||
388 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, | 373 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, |
@@ -605,7 +590,6 @@ static int __init pyra_init(void) | |||
605 | if (IS_ERR(pyra_class)) | 590 | if (IS_ERR(pyra_class)) |
606 | return PTR_ERR(pyra_class); | 591 | return PTR_ERR(pyra_class); |
607 | pyra_class->dev_groups = pyra_groups; | 592 | pyra_class->dev_groups = pyra_groups; |
608 | pyra_class->dev_bin_attrs = pyra_bin_attributes; | ||
609 | 593 | ||
610 | retval = hid_register_driver(&pyra_driver); | 594 | retval = hid_register_driver(&pyra_driver); |
611 | if (retval) | 595 | if (retval) |