@@ -311,6 +311,7 @@ static ssize_t c2port_show_name(struct device *dev,
311311
312312 return sprintf (buf , "%s\n" , c2dev -> name );
313313}
314+ static DEVICE_ATTR (name , 0444 , c2port_show_name , NULL) ;
314315
315316static ssize_t c2port_show_flash_blocks_num (struct device * dev ,
316317 struct device_attribute * attr , char * buf )
@@ -320,6 +321,7 @@ static ssize_t c2port_show_flash_blocks_num(struct device *dev,
320321
321322 return sprintf (buf , "%d\n" , ops -> blocks_num );
322323}
324+ static DEVICE_ATTR (flash_blocks_num , 0444 , c2port_show_flash_blocks_num , NULL) ;
323325
324326static ssize_t c2port_show_flash_block_size (struct device * dev ,
325327 struct device_attribute * attr , char * buf )
@@ -329,6 +331,7 @@ static ssize_t c2port_show_flash_block_size(struct device *dev,
329331
330332 return sprintf (buf , "%d\n" , ops -> block_size );
331333}
334+ static DEVICE_ATTR (flash_block_size , 0444 , c2port_show_flash_block_size , NULL) ;
332335
333336static ssize_t c2port_show_flash_size (struct device * dev ,
334337 struct device_attribute * attr , char * buf )
@@ -338,18 +341,18 @@ static ssize_t c2port_show_flash_size(struct device *dev,
338341
339342 return sprintf (buf , "%d\n" , ops -> blocks_num * ops -> block_size );
340343}
344+ static DEVICE_ATTR (flash_size , 0444 , c2port_show_flash_size , NULL) ;
341345
342- static ssize_t c2port_show_access (struct device * dev ,
343- struct device_attribute * attr , char * buf )
346+ static ssize_t access_show (struct device * dev , struct device_attribute * attr ,
347+ char * buf )
344348{
345349 struct c2port_device * c2dev = dev_get_drvdata (dev );
346350
347351 return sprintf (buf , "%d\n" , c2dev -> access );
348352}
349353
350- static ssize_t c2port_store_access (struct device * dev ,
351- struct device_attribute * attr ,
352- const char * buf , size_t count )
354+ static ssize_t access_store (struct device * dev , struct device_attribute * attr ,
355+ const char * buf , size_t count )
353356{
354357 struct c2port_device * c2dev = dev_get_drvdata (dev );
355358 struct c2port_ops * ops = c2dev -> ops ;
@@ -375,6 +378,7 @@ static ssize_t c2port_store_access(struct device *dev,
375378
376379 return count ;
377380}
381+ static DEVICE_ATTR_RW (access );
378382
379383static ssize_t c2port_store_reset (struct device * dev ,
380384 struct device_attribute * attr ,
@@ -395,6 +399,7 @@ static ssize_t c2port_store_reset(struct device *dev,
395399
396400 return count ;
397401}
402+ static DEVICE_ATTR (reset , 0200 , NULL, c2port_store_reset ) ;
398403
399404static ssize_t __c2port_show_dev_id (struct c2port_device * dev , char * buf )
400405{
@@ -431,6 +436,7 @@ static ssize_t c2port_show_dev_id(struct device *dev,
431436
432437 return ret ;
433438}
439+ static DEVICE_ATTR (dev_id , 0444 , c2port_show_dev_id , NULL) ;
434440
435441static ssize_t __c2port_show_rev_id (struct c2port_device * dev , char * buf )
436442{
@@ -467,6 +473,7 @@ static ssize_t c2port_show_rev_id(struct device *dev,
467473
468474 return ret ;
469475}
476+ static DEVICE_ATTR (rev_id , 0444 , c2port_show_rev_id , NULL) ;
470477
471478static ssize_t c2port_show_flash_access (struct device * dev ,
472479 struct device_attribute * attr , char * buf )
@@ -536,6 +543,8 @@ static ssize_t c2port_store_flash_access(struct device *dev,
536543
537544 return count ;
538545}
546+ static DEVICE_ATTR (flash_access , 0644 , c2port_show_flash_access ,
547+ c2port_store_flash_access ) ;
539548
540549static ssize_t __c2port_write_flash_erase (struct c2port_device * dev )
541550{
@@ -616,6 +625,7 @@ static ssize_t c2port_store_flash_erase(struct device *dev,
616625
617626 return count ;
618627}
628+ static DEVICE_ATTR (flash_erase , 0200 , NULL, c2port_store_flash_erase ) ;
619629
620630static ssize_t __c2port_read_flash_data (struct c2port_device * dev ,
621631 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,
850860/*
851861 * Class attributes
852862 */
853-
854- static struct device_attribute c2port_attrs [] = {
855- __ATTR (name , 0444 , c2port_show_name , NULL ),
856- __ATTR (flash_blocks_num , 0444 , c2port_show_flash_blocks_num , NULL ),
857- __ATTR (flash_block_size , 0444 , c2port_show_flash_block_size , NULL ),
858- __ATTR (flash_size , 0444 , c2port_show_flash_size , NULL ),
859- __ATTR (access , 0644 , c2port_show_access , c2port_store_access ),
860- __ATTR (reset , 0200 , NULL , c2port_store_reset ),
861- __ATTR (dev_id , 0444 , c2port_show_dev_id , NULL ),
862- __ATTR (rev_id , 0444 , c2port_show_rev_id , NULL ),
863-
864- __ATTR (flash_access , 0644 , c2port_show_flash_access ,
865- c2port_store_flash_access ),
866- __ATTR (flash_erase , 0200 , NULL , c2port_store_flash_erase ),
867- __ATTR_NULL ,
863+ static struct attribute * c2port_attrs [] = {
864+ & dev_attr_name .attr ,
865+ & dev_attr_flash_blocks_num .attr ,
866+ & dev_attr_flash_block_size .attr ,
867+ & dev_attr_flash_size .attr ,
868+ & dev_attr_access .attr ,
869+ & dev_attr_reset .attr ,
870+ & dev_attr_dev_id .attr ,
871+ & dev_attr_rev_id .attr ,
872+ & dev_attr_flash_access .attr ,
873+ & dev_attr_flash_erase .attr ,
874+ NULL ,
868875};
876+ ATTRIBUTE_GROUPS (c2port );
869877
870878static struct bin_attribute c2port_bin_attrs [] = {
871879 {
@@ -979,7 +987,7 @@ static int __init c2port_init(void)
979987 printk (KERN_ERR "c2port: failed to allocate class\n" );
980988 return PTR_ERR (c2port_class );
981989 }
982- c2port_class -> dev_attrs = c2port_attrs ;
990+ c2port_class -> dev_groups = c2port_groups ;
983991 c2port_class -> dev_bin_attrs = c2port_bin_attrs ;
984992
985993 return 0 ;
0 commit comments