diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-24 18:05:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-24 18:39:04 -0400 |
commit | eb375597e2d456499bfa427fb398ab36bdc837e5 (patch) | |
tree | 3aa3de301a777131209b624734e491046fd94933 /drivers/misc | |
parent | e017a84b9397f50e22ba219d0b2875bf48a6573f (diff) |
c2port: convert class code to use dev_groups
The dev_attrs field of struct class is going away soon, dev_groups
should be used instead. This converts the c2port class code to use the
correct field.
Cc: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/c2port/core.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index a3b8370c7dea..abe6e251e368 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c | |||
@@ -311,6 +311,7 @@ static ssize_t c2port_show_name(struct device *dev, | |||
311 | 311 | ||
312 | return sprintf(buf, "%s\n", c2dev->name); | 312 | return sprintf(buf, "%s\n", c2dev->name); |
313 | } | 313 | } |
314 | static DEVICE_ATTR(name, 0444, c2port_show_name, NULL); | ||
314 | 315 | ||
315 | static ssize_t c2port_show_flash_blocks_num(struct device *dev, | 316 | static ssize_t c2port_show_flash_blocks_num(struct device *dev, |
316 | struct device_attribute *attr, char *buf) | 317 | struct device_attribute *attr, char *buf) |
@@ -320,6 +321,7 @@ static ssize_t c2port_show_flash_blocks_num(struct device *dev, | |||
320 | 321 | ||
321 | return sprintf(buf, "%d\n", ops->blocks_num); | 322 | return sprintf(buf, "%d\n", ops->blocks_num); |
322 | } | 323 | } |
324 | static DEVICE_ATTR(flash_blocks_num, 0444, c2port_show_flash_blocks_num, NULL); | ||
323 | 325 | ||
324 | static ssize_t c2port_show_flash_block_size(struct device *dev, | 326 | static ssize_t c2port_show_flash_block_size(struct device *dev, |
325 | struct device_attribute *attr, char *buf) | 327 | struct device_attribute *attr, char *buf) |
@@ -329,6 +331,7 @@ static ssize_t c2port_show_flash_block_size(struct device *dev, | |||
329 | 331 | ||
330 | return sprintf(buf, "%d\n", ops->block_size); | 332 | return sprintf(buf, "%d\n", ops->block_size); |
331 | } | 333 | } |
334 | static DEVICE_ATTR(flash_block_size, 0444, c2port_show_flash_block_size, NULL); | ||
332 | 335 | ||
333 | static ssize_t c2port_show_flash_size(struct device *dev, | 336 | static ssize_t c2port_show_flash_size(struct device *dev, |
334 | struct device_attribute *attr, char *buf) | 337 | struct device_attribute *attr, char *buf) |
@@ -338,18 +341,18 @@ static ssize_t c2port_show_flash_size(struct device *dev, | |||
338 | 341 | ||
339 | return sprintf(buf, "%d\n", ops->blocks_num * ops->block_size); | 342 | return sprintf(buf, "%d\n", ops->blocks_num * ops->block_size); |
340 | } | 343 | } |
344 | static DEVICE_ATTR(flash_size, 0444, c2port_show_flash_size, NULL); | ||
341 | 345 | ||
342 | static ssize_t c2port_show_access(struct device *dev, | 346 | static ssize_t access_show(struct device *dev, struct device_attribute *attr, |
343 | struct device_attribute *attr, char *buf) | 347 | char *buf) |
344 | { | 348 | { |
345 | struct c2port_device *c2dev = dev_get_drvdata(dev); | 349 | struct c2port_device *c2dev = dev_get_drvdata(dev); |
346 | 350 | ||
347 | return sprintf(buf, "%d\n", c2dev->access); | 351 | return sprintf(buf, "%d\n", c2dev->access); |
348 | } | 352 | } |
349 | 353 | ||
350 | static ssize_t c2port_store_access(struct device *dev, | 354 | static ssize_t access_store(struct device *dev, struct device_attribute *attr, |
351 | struct device_attribute *attr, | 355 | const char *buf, size_t count) |
352 | const char *buf, size_t count) | ||
353 | { | 356 | { |
354 | struct c2port_device *c2dev = dev_get_drvdata(dev); | 357 | struct c2port_device *c2dev = dev_get_drvdata(dev); |
355 | struct c2port_ops *ops = c2dev->ops; | 358 | struct c2port_ops *ops = c2dev->ops; |
@@ -375,6 +378,7 @@ static ssize_t c2port_store_access(struct device *dev, | |||
375 | 378 | ||
376 | return count; | 379 | return count; |
377 | } | 380 | } |
381 | static DEVICE_ATTR_RW(access); | ||
378 | 382 | ||
379 | static ssize_t c2port_store_reset(struct device *dev, | 383 | static ssize_t c2port_store_reset(struct device *dev, |
380 | struct device_attribute *attr, | 384 | struct device_attribute *attr, |
@@ -395,6 +399,7 @@ static ssize_t c2port_store_reset(struct device *dev, | |||
395 | 399 | ||
396 | return count; | 400 | return count; |
397 | } | 401 | } |
402 | static DEVICE_ATTR(reset, 0200, NULL, c2port_store_reset); | ||
398 | 403 | ||
399 | static ssize_t __c2port_show_dev_id(struct c2port_device *dev, char *buf) | 404 | static ssize_t __c2port_show_dev_id(struct c2port_device *dev, char *buf) |
400 | { | 405 | { |
@@ -431,6 +436,7 @@ static ssize_t c2port_show_dev_id(struct device *dev, | |||
431 | 436 | ||
432 | return ret; | 437 | return ret; |
433 | } | 438 | } |
439 | static DEVICE_ATTR(dev_id, 0444, c2port_show_dev_id, NULL); | ||
434 | 440 | ||
435 | static ssize_t __c2port_show_rev_id(struct c2port_device *dev, char *buf) | 441 | static ssize_t __c2port_show_rev_id(struct c2port_device *dev, char *buf) |
436 | { | 442 | { |
@@ -467,6 +473,7 @@ static ssize_t c2port_show_rev_id(struct device *dev, | |||
467 | 473 | ||
468 | return ret; | 474 | return ret; |
469 | } | 475 | } |
476 | static DEVICE_ATTR(rev_id, 0444, c2port_show_rev_id, NULL); | ||
470 | 477 | ||
471 | static ssize_t c2port_show_flash_access(struct device *dev, | 478 | static ssize_t c2port_show_flash_access(struct device *dev, |
472 | struct device_attribute *attr, char *buf) | 479 | struct device_attribute *attr, char *buf) |
@@ -536,6 +543,8 @@ static ssize_t c2port_store_flash_access(struct device *dev, | |||
536 | 543 | ||
537 | return count; | 544 | return count; |
538 | } | 545 | } |
546 | static DEVICE_ATTR(flash_access, 0644, c2port_show_flash_access, | ||
547 | c2port_store_flash_access); | ||
539 | 548 | ||
540 | static ssize_t __c2port_write_flash_erase(struct c2port_device *dev) | 549 | static ssize_t __c2port_write_flash_erase(struct c2port_device *dev) |
541 | { | 550 | { |
@@ -616,6 +625,7 @@ static ssize_t c2port_store_flash_erase(struct device *dev, | |||
616 | 625 | ||
617 | return count; | 626 | return count; |
618 | } | 627 | } |
628 | static DEVICE_ATTR(flash_erase, 0200, NULL, c2port_store_flash_erase); | ||
619 | 629 | ||
620 | static ssize_t __c2port_read_flash_data(struct c2port_device *dev, | 630 | static ssize_t __c2port_read_flash_data(struct c2port_device *dev, |
621 | char *buffer, loff_t offset, size_t count) | 631 | char *buffer, loff_t offset, size_t count) |
@@ -850,22 +860,20 @@ static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj, | |||
850 | /* | 860 | /* |
851 | * Class attributes | 861 | * Class attributes |
852 | */ | 862 | */ |
853 | 863 | static struct attribute *c2port_attrs[] = { | |
854 | static struct device_attribute c2port_attrs[] = { | 864 | &dev_attr_name.attr, |
855 | __ATTR(name, 0444, c2port_show_name, NULL), | 865 | &dev_attr_flash_blocks_num.attr, |
856 | __ATTR(flash_blocks_num, 0444, c2port_show_flash_blocks_num, NULL), | 866 | &dev_attr_flash_block_size.attr, |
857 | __ATTR(flash_block_size, 0444, c2port_show_flash_block_size, NULL), | 867 | &dev_attr_flash_size.attr, |
858 | __ATTR(flash_size, 0444, c2port_show_flash_size, NULL), | 868 | &dev_attr_access.attr, |
859 | __ATTR(access, 0644, c2port_show_access, c2port_store_access), | 869 | &dev_attr_reset.attr, |
860 | __ATTR(reset, 0200, NULL, c2port_store_reset), | 870 | &dev_attr_dev_id.attr, |
861 | __ATTR(dev_id, 0444, c2port_show_dev_id, NULL), | 871 | &dev_attr_rev_id.attr, |
862 | __ATTR(rev_id, 0444, c2port_show_rev_id, NULL), | 872 | &dev_attr_flash_access.attr, |
863 | 873 | &dev_attr_flash_erase.attr, | |
864 | __ATTR(flash_access, 0644, c2port_show_flash_access, | 874 | NULL, |
865 | c2port_store_flash_access), | ||
866 | __ATTR(flash_erase, 0200, NULL, c2port_store_flash_erase), | ||
867 | __ATTR_NULL, | ||
868 | }; | 875 | }; |
876 | ATTRIBUTE_GROUPS(c2port); | ||
869 | 877 | ||
870 | static struct bin_attribute c2port_bin_attrs[] = { | 878 | static struct bin_attribute c2port_bin_attrs[] = { |
871 | { | 879 | { |
@@ -979,7 +987,7 @@ static int __init c2port_init(void) | |||
979 | printk(KERN_ERR "c2port: failed to allocate class\n"); | 987 | printk(KERN_ERR "c2port: failed to allocate class\n"); |
980 | return PTR_ERR(c2port_class); | 988 | return PTR_ERR(c2port_class); |
981 | } | 989 | } |
982 | c2port_class->dev_attrs = c2port_attrs; | 990 | c2port_class->dev_groups = c2port_groups; |
983 | c2port_class->dev_bin_attrs = c2port_bin_attrs; | 991 | c2port_class->dev_bin_attrs = c2port_bin_attrs; |
984 | 992 | ||
985 | return 0; | 993 | return 0; |