diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-20 00:50:28 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-20 00:50:28 -0400 |
commit | 975b53cc903033b7ac30a37e06452394d6734018 (patch) | |
tree | b33381b8a7c303602851474e1168787cf8dae03b /drivers/hid/hid-roccat-kovaplus.c | |
parent | 0f1947f3561e7e6df7164cf1e0f14f541ddc29bd (diff) |
hid: roccat-kovaplus: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hid/hid-roccat-kovaplus.c')
-rw-r--r-- | drivers/hid/hid-roccat-kovaplus.c | 137 |
1 files changed, 54 insertions, 83 deletions
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index ae630221f896..8a0f2993411f 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c | |||
@@ -197,31 +197,25 @@ KOVAPLUS_SYSFS_W(thingy, THINGY) \ | |||
197 | KOVAPLUS_SYSFS_R(thingy, THINGY) | 197 | KOVAPLUS_SYSFS_R(thingy, THINGY) |
198 | 198 | ||
199 | #define KOVAPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ | 199 | #define KOVAPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ |
200 | { \ | 200 | KOVAPLUS_SYSFS_RW(thingy, THINGY); \ |
201 | static struct bin_attribute bin_attr_##thingy = { \ | ||
201 | .attr = { .name = #thingy, .mode = 0660 }, \ | 202 | .attr = { .name = #thingy, .mode = 0660 }, \ |
202 | .size = KOVAPLUS_SIZE_ ## THINGY, \ | 203 | .size = KOVAPLUS_SIZE_ ## THINGY, \ |
203 | .read = kovaplus_sysfs_read_ ## thingy, \ | 204 | .read = kovaplus_sysfs_read_ ## thingy, \ |
204 | .write = kovaplus_sysfs_write_ ## thingy \ | 205 | .write = kovaplus_sysfs_write_ ## thingy \ |
205 | } | 206 | } |
206 | 207 | ||
207 | #define KOVAPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \ | ||
208 | { \ | ||
209 | .attr = { .name = #thingy, .mode = 0440 }, \ | ||
210 | .size = KOVAPLUS_SIZE_ ## THINGY, \ | ||
211 | .read = kovaplus_sysfs_read_ ## thingy, \ | ||
212 | } | ||
213 | |||
214 | #define KOVAPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ | 208 | #define KOVAPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ |
215 | { \ | 209 | KOVAPLUS_SYSFS_W(thingy, THINGY); \ |
210 | static struct bin_attribute bin_attr_##thingy = { \ | ||
216 | .attr = { .name = #thingy, .mode = 0220 }, \ | 211 | .attr = { .name = #thingy, .mode = 0220 }, \ |
217 | .size = KOVAPLUS_SIZE_ ## THINGY, \ | 212 | .size = KOVAPLUS_SIZE_ ## THINGY, \ |
218 | .write = kovaplus_sysfs_write_ ## thingy \ | 213 | .write = kovaplus_sysfs_write_ ## thingy \ |
219 | } | 214 | } |
220 | 215 | KOVAPLUS_BIN_ATTRIBUTE_W(control, CONTROL); | |
221 | KOVAPLUS_SYSFS_W(control, CONTROL) | 216 | KOVAPLUS_BIN_ATTRIBUTE_RW(info, INFO); |
222 | KOVAPLUS_SYSFS_RW(info, INFO) | 217 | KOVAPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS); |
223 | KOVAPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS) | 218 | KOVAPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS); |
224 | KOVAPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) | ||
225 | 219 | ||
226 | static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp, | 220 | static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp, |
227 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 221 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
@@ -261,6 +255,25 @@ static ssize_t kovaplus_sysfs_read_profilex_buttons(struct file *fp, | |||
261 | KOVAPLUS_COMMAND_PROFILE_BUTTONS); | 255 | KOVAPLUS_COMMAND_PROFILE_BUTTONS); |
262 | } | 256 | } |
263 | 257 | ||
258 | #define PROFILE_ATTR(number) \ | ||
259 | static struct bin_attribute bin_attr_profile##number##_settings = { \ | ||
260 | .attr = { .name = "profile##number##_settings", .mode = 0440 }, \ | ||
261 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, \ | ||
262 | .read = kovaplus_sysfs_read_profilex_settings, \ | ||
263 | .private = &profile_numbers[number-1], \ | ||
264 | }; \ | ||
265 | static struct bin_attribute bin_attr_profile##number##_buttons = { \ | ||
266 | .attr = { .name = "profile##number##_buttons", .mode = 0440 }, \ | ||
267 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, \ | ||
268 | .read = kovaplus_sysfs_read_profilex_buttons, \ | ||
269 | .private = &profile_numbers[number-1], \ | ||
270 | }; | ||
271 | PROFILE_ATTR(1); | ||
272 | PROFILE_ATTR(2); | ||
273 | PROFILE_ATTR(3); | ||
274 | PROFILE_ATTR(4); | ||
275 | PROFILE_ATTR(5); | ||
276 | |||
264 | static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, | 277 | static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, |
265 | struct device_attribute *attr, char *buf) | 278 | struct device_attribute *attr, char *buf) |
266 | { | 279 | { |
@@ -372,74 +385,33 @@ static struct attribute *kovaplus_attrs[] = { | |||
372 | &dev_attr_actual_sensitivity_y.attr, | 385 | &dev_attr_actual_sensitivity_y.attr, |
373 | NULL, | 386 | NULL, |
374 | }; | 387 | }; |
375 | ATTRIBUTE_GROUPS(kovaplus); | 388 | |
376 | 389 | static struct bin_attribute *kovaplus_bin_attributes[] = { | |
377 | static struct bin_attribute kovaplus_bin_attributes[] = { | 390 | &bin_attr_control, |
378 | KOVAPLUS_BIN_ATTRIBUTE_W(control, CONTROL), | 391 | &bin_attr_info, |
379 | KOVAPLUS_BIN_ATTRIBUTE_RW(info, INFO), | 392 | &bin_attr_profile_settings, |
380 | KOVAPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), | 393 | &bin_attr_profile_buttons, |
381 | KOVAPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), | 394 | &bin_attr_profile1_settings, |
382 | { | 395 | &bin_attr_profile2_settings, |
383 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 396 | &bin_attr_profile3_settings, |
384 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, | 397 | &bin_attr_profile4_settings, |
385 | .read = kovaplus_sysfs_read_profilex_settings, | 398 | &bin_attr_profile5_settings, |
386 | .private = &profile_numbers[0] | 399 | &bin_attr_profile1_buttons, |
387 | }, | 400 | &bin_attr_profile2_buttons, |
388 | { | 401 | &bin_attr_profile3_buttons, |
389 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 402 | &bin_attr_profile4_buttons, |
390 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, | 403 | &bin_attr_profile5_buttons, |
391 | .read = kovaplus_sysfs_read_profilex_settings, | 404 | NULL, |
392 | .private = &profile_numbers[1] | 405 | }; |
393 | }, | 406 | |
394 | { | 407 | static const struct attribute_group kovaplus_group = { |
395 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 408 | .attrs = kovaplus_attrs, |
396 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, | 409 | .bin_attrs = kovaplus_bin_attributes, |
397 | .read = kovaplus_sysfs_read_profilex_settings, | 410 | }; |
398 | .private = &profile_numbers[2] | 411 | |
399 | }, | 412 | static const struct attribute_group *kovaplus_groups[] = { |
400 | { | 413 | &kovaplus_group, |
401 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 414 | NULL, |
402 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, | ||
403 | .read = kovaplus_sysfs_read_profilex_settings, | ||
404 | .private = &profile_numbers[3] | ||
405 | }, | ||
406 | { | ||
407 | .attr = { .name = "profile5_settings", .mode = 0440 }, | ||
408 | .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, | ||
409 | .read = kovaplus_sysfs_read_profilex_settings, | ||
410 | .private = &profile_numbers[4] | ||
411 | }, | ||
412 | { | ||
413 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | ||
414 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, | ||
415 | .read = kovaplus_sysfs_read_profilex_buttons, | ||
416 | .private = &profile_numbers[0] | ||
417 | }, | ||
418 | { | ||
419 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | ||
420 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, | ||
421 | .read = kovaplus_sysfs_read_profilex_buttons, | ||
422 | .private = &profile_numbers[1] | ||
423 | }, | ||
424 | { | ||
425 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | ||
426 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, | ||
427 | .read = kovaplus_sysfs_read_profilex_buttons, | ||
428 | .private = &profile_numbers[2] | ||
429 | }, | ||
430 | { | ||
431 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | ||
432 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, | ||
433 | .read = kovaplus_sysfs_read_profilex_buttons, | ||
434 | .private = &profile_numbers[3] | ||
435 | }, | ||
436 | { | ||
437 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | ||
438 | .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, | ||
439 | .read = kovaplus_sysfs_read_profilex_buttons, | ||
440 | .private = &profile_numbers[4] | ||
441 | }, | ||
442 | __ATTR_NULL | ||
443 | }; | 415 | }; |
444 | 416 | ||
445 | static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev, | 417 | static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev, |
@@ -668,7 +640,6 @@ static int __init kovaplus_init(void) | |||
668 | if (IS_ERR(kovaplus_class)) | 640 | if (IS_ERR(kovaplus_class)) |
669 | return PTR_ERR(kovaplus_class); | 641 | return PTR_ERR(kovaplus_class); |
670 | kovaplus_class->dev_groups = kovaplus_groups; | 642 | kovaplus_class->dev_groups = kovaplus_groups; |
671 | kovaplus_class->dev_bin_attrs = kovaplus_bin_attributes; | ||
672 | 643 | ||
673 | retval = hid_register_driver(&kovaplus_driver); | 644 | retval = hid_register_driver(&kovaplus_driver); |
674 | if (retval) | 645 | if (retval) |