diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-20 00:50:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-20 00:50:27 -0400 |
commit | eb3156e0a6cdde402cdf3bcc7e2ecc98d7ac5c49 (patch) | |
tree | b3e47b8da871075fdb4b5c1e1215d61c83928b33 | |
parent | 080795482566ecaf599bfa8cb5656ff13ca4a4ce (diff) |
hid: roccat-koneplus: 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>
-rw-r--r-- | drivers/hid/hid-roccat-koneplus.c | 153 |
1 files changed, 66 insertions, 87 deletions
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 11906b4b42b2..db4d8b6a2542 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c | |||
@@ -156,7 +156,8 @@ KONEPLUS_SYSFS_W(thingy, THINGY) \ | |||
156 | KONEPLUS_SYSFS_R(thingy, THINGY) | 156 | KONEPLUS_SYSFS_R(thingy, THINGY) |
157 | 157 | ||
158 | #define KONEPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ | 158 | #define KONEPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ |
159 | { \ | 159 | KONEPLUS_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 = KONEPLUS_SIZE_ ## THINGY, \ | 162 | .size = KONEPLUS_SIZE_ ## THINGY, \ |
162 | .read = koneplus_sysfs_read_ ## thingy, \ | 163 | .read = koneplus_sysfs_read_ ## thingy, \ |
@@ -164,28 +165,29 @@ KONEPLUS_SYSFS_R(thingy, THINGY) | |||
164 | } | 165 | } |
165 | 166 | ||
166 | #define KONEPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \ | 167 | #define KONEPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \ |
167 | { \ | 168 | KONEPLUS_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 = KONEPLUS_SIZE_ ## THINGY, \ | 171 | .size = KONEPLUS_SIZE_ ## THINGY, \ |
170 | .read = koneplus_sysfs_read_ ## thingy, \ | 172 | .read = koneplus_sysfs_read_ ## thingy, \ |
171 | } | 173 | } |
172 | 174 | ||
173 | #define KONEPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ | 175 | #define KONEPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ |
174 | { \ | 176 | KONEPLUS_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 = KONEPLUS_SIZE_ ## THINGY, \ | 179 | .size = KONEPLUS_SIZE_ ## THINGY, \ |
177 | .write = koneplus_sysfs_write_ ## thingy \ | 180 | .write = koneplus_sysfs_write_ ## thingy \ |
178 | } | 181 | } |
179 | 182 | KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL); | |
180 | KONEPLUS_SYSFS_W(control, CONTROL) | 183 | KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK); |
181 | KONEPLUS_SYSFS_RW(info, INFO) | 184 | KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO); |
182 | KONEPLUS_SYSFS_W(talk, TALK) | 185 | KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE); |
183 | KONEPLUS_SYSFS_W(macro, MACRO) | 186 | KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO); |
184 | KONEPLUS_SYSFS_RW(sensor, SENSOR) | 187 | KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR); |
185 | KONEPLUS_SYSFS_RW(tcu, TCU) | 188 | KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU); |
186 | KONEPLUS_SYSFS_R(tcu_image, TCU_IMAGE) | 189 | KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS); |
187 | KONEPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS) | 190 | KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS); |
188 | KONEPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) | ||
189 | 191 | ||
190 | static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, | 192 | static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, |
191 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 193 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
@@ -225,6 +227,25 @@ static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, | |||
225 | KONEPLUS_COMMAND_PROFILE_BUTTONS); | 227 | KONEPLUS_COMMAND_PROFILE_BUTTONS); |
226 | } | 228 | } |
227 | 229 | ||
230 | #define PROFILE_ATTR(number) \ | ||
231 | static struct bin_attribute bin_attr_profile##number##_settings = { \ | ||
232 | .attr = { .name = "profile##number##_settings", .mode = 0440 }, \ | ||
233 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, \ | ||
234 | .read = koneplus_sysfs_read_profilex_settings, \ | ||
235 | .private = &profile_numbers[number-1], \ | ||
236 | }; \ | ||
237 | static struct bin_attribute bin_attr_profile##number##_buttons = { \ | ||
238 | .attr = { .name = "profile##number##_buttons", .mode = 0440 }, \ | ||
239 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, \ | ||
240 | .read = koneplus_sysfs_read_profilex_buttons, \ | ||
241 | .private = &profile_numbers[number-1], \ | ||
242 | }; | ||
243 | PROFILE_ATTR(1); | ||
244 | PROFILE_ATTR(2); | ||
245 | PROFILE_ATTR(3); | ||
246 | PROFILE_ATTR(4); | ||
247 | PROFILE_ATTR(5); | ||
248 | |||
228 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, | 249 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, |
229 | struct device_attribute *attr, char *buf) | 250 | struct device_attribute *attr, char *buf) |
230 | { | 251 | { |
@@ -308,79 +329,38 @@ static struct attribute *koneplus_attrs[] = { | |||
308 | &dev_attr_firmware_version.attr, | 329 | &dev_attr_firmware_version.attr, |
309 | NULL, | 330 | NULL, |
310 | }; | 331 | }; |
311 | ATTRIBUTE_GROUPS(koneplus); | 332 | |
312 | 333 | static struct bin_attribute *koneplus_bin_attributes[] = { | |
313 | static struct bin_attribute koneplus_bin_attributes[] = { | 334 | &bin_attr_control, |
314 | KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL), | 335 | &bin_attr_talk, |
315 | KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO), | 336 | &bin_attr_macro, |
316 | KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK), | 337 | &bin_attr_tcu_image, |
317 | KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO), | 338 | &bin_attr_info, |
318 | KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR), | 339 | &bin_attr_sensor, |
319 | KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU), | 340 | &bin_attr_tcu, |
320 | KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE), | 341 | &bin_attr_profile_settings, |
321 | KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), | 342 | &bin_attr_profile_buttons, |
322 | KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), | 343 | &bin_attr_profile1_settings, |
323 | { | 344 | &bin_attr_profile2_settings, |
324 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 345 | &bin_attr_profile3_settings, |
325 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, | 346 | &bin_attr_profile4_settings, |
326 | .read = koneplus_sysfs_read_profilex_settings, | 347 | &bin_attr_profile5_settings, |
327 | .private = &profile_numbers[0] | 348 | &bin_attr_profile1_buttons, |
328 | }, | 349 | &bin_attr_profile2_buttons, |
329 | { | 350 | &bin_attr_profile3_buttons, |
330 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 351 | &bin_attr_profile4_buttons, |
331 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, | 352 | &bin_attr_profile5_buttons, |
332 | .read = koneplus_sysfs_read_profilex_settings, | 353 | NULL, |
333 | .private = &profile_numbers[1] | 354 | }; |
334 | }, | 355 | |
335 | { | 356 | static const struct attribute_group koneplus_group = { |
336 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 357 | .attrs = koneplus_attrs, |
337 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, | 358 | .bin_attrs = koneplus_bin_attributes, |
338 | .read = koneplus_sysfs_read_profilex_settings, | 359 | }; |
339 | .private = &profile_numbers[2] | 360 | |
340 | }, | 361 | static const struct attribute_group *koneplus_groups[] = { |
341 | { | 362 | &koneplus_group, |
342 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 363 | NULL, |
343 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, | ||
344 | .read = koneplus_sysfs_read_profilex_settings, | ||
345 | .private = &profile_numbers[3] | ||
346 | }, | ||
347 | { | ||
348 | .attr = { .name = "profile5_settings", .mode = 0440 }, | ||
349 | .size = KONEPLUS_SIZE_PROFILE_SETTINGS, | ||
350 | .read = koneplus_sysfs_read_profilex_settings, | ||
351 | .private = &profile_numbers[4] | ||
352 | }, | ||
353 | { | ||
354 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | ||
355 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, | ||
356 | .read = koneplus_sysfs_read_profilex_buttons, | ||
357 | .private = &profile_numbers[0] | ||
358 | }, | ||
359 | { | ||
360 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | ||
361 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, | ||
362 | .read = koneplus_sysfs_read_profilex_buttons, | ||
363 | .private = &profile_numbers[1] | ||
364 | }, | ||
365 | { | ||
366 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | ||
367 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, | ||
368 | .read = koneplus_sysfs_read_profilex_buttons, | ||
369 | .private = &profile_numbers[2] | ||
370 | }, | ||
371 | { | ||
372 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | ||
373 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, | ||
374 | .read = koneplus_sysfs_read_profilex_buttons, | ||
375 | .private = &profile_numbers[3] | ||
376 | }, | ||
377 | { | ||
378 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | ||
379 | .size = KONEPLUS_SIZE_PROFILE_BUTTONS, | ||
380 | .read = koneplus_sysfs_read_profilex_buttons, | ||
381 | .private = &profile_numbers[4] | ||
382 | }, | ||
383 | __ATTR_NULL | ||
384 | }; | 364 | }; |
385 | 365 | ||
386 | static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, | 366 | static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, |
@@ -577,7 +557,6 @@ static int __init koneplus_init(void) | |||
577 | if (IS_ERR(koneplus_class)) | 557 | if (IS_ERR(koneplus_class)) |
578 | return PTR_ERR(koneplus_class); | 558 | return PTR_ERR(koneplus_class); |
579 | koneplus_class->dev_groups = koneplus_groups; | 559 | koneplus_class->dev_groups = koneplus_groups; |
580 | koneplus_class->dev_bin_attrs = koneplus_bin_attributes; | ||
581 | 560 | ||
582 | retval = hid_register_driver(&koneplus_driver); | 561 | retval = hid_register_driver(&koneplus_driver); |
583 | if (retval) | 562 | if (retval) |