1515static void * bgrt_image ;
1616static struct kobject * bgrt_kobj ;
1717
18- static ssize_t version_show (struct device * dev ,
19- struct device_attribute * attr , char * buf )
20- {
21- return snprintf (buf , PAGE_SIZE , "%d\n" , bgrt_tab .version );
22- }
23- static DEVICE_ATTR_RO (version );
24-
25- static ssize_t status_show (struct device * dev ,
26- struct device_attribute * attr , char * buf )
27- {
28- return snprintf (buf , PAGE_SIZE , "%d\n" , bgrt_tab .status );
29- }
30- static DEVICE_ATTR_RO (status );
31-
32- static ssize_t type_show (struct device * dev ,
33- struct device_attribute * attr , char * buf )
34- {
35- return snprintf (buf , PAGE_SIZE , "%d\n" , bgrt_tab .image_type );
36- }
37- static DEVICE_ATTR_RO (type );
38-
39- static ssize_t xoffset_show (struct device * dev ,
40- struct device_attribute * attr , char * buf )
41- {
42- return snprintf (buf , PAGE_SIZE , "%d\n" , bgrt_tab .image_offset_x );
43- }
44- static DEVICE_ATTR_RO (xoffset );
45-
46- static ssize_t yoffset_show (struct device * dev ,
47- struct device_attribute * attr , char * buf )
48- {
49- return snprintf (buf , PAGE_SIZE , "%d\n" , bgrt_tab .image_offset_y );
50- }
51- static DEVICE_ATTR_RO (yoffset );
18+ #define BGRT_SHOW (_name , _member ) \
19+ static ssize_t _name##_show(struct kobject *kobj, \
20+ struct kobj_attribute *attr, char *buf) \
21+ { \
22+ return sysfs_emit(buf, "%d\n", bgrt_tab._member); \
23+ } \
24+ struct kobj_attribute bgrt_attr_##_name = __ATTR_RO(_name)
25+
26+ BGRT_SHOW (version , version );
27+ BGRT_SHOW (status , status );
28+ BGRT_SHOW (type , image_type );
29+ BGRT_SHOW (xoffset , image_offset_x );
30+ BGRT_SHOW (yoffset , image_offset_y );
5231
5332static ssize_t image_read (struct file * file , struct kobject * kobj ,
5433 struct bin_attribute * attr , char * buf , loff_t off , size_t count )
@@ -60,11 +39,11 @@ static ssize_t image_read(struct file *file, struct kobject *kobj,
6039static BIN_ATTR_RO (image , 0 ) ; /* size gets filled in later */
6140
6241static struct attribute * bgrt_attributes [] = {
63- & dev_attr_version .attr ,
64- & dev_attr_status .attr ,
65- & dev_attr_type .attr ,
66- & dev_attr_xoffset .attr ,
67- & dev_attr_yoffset .attr ,
42+ & bgrt_attr_version .attr ,
43+ & bgrt_attr_status .attr ,
44+ & bgrt_attr_type .attr ,
45+ & bgrt_attr_xoffset .attr ,
46+ & bgrt_attr_yoffset .attr ,
6847 NULL ,
6948};
7049
0 commit comments