@@ -21,7 +21,6 @@ static ssize_t rtc_sysfs_show_name(struct class_device *dev, char *buf)
2121{
2222 return sprintf (buf , "%s\n" , to_rtc_device (dev )-> name );
2323}
24- static CLASS_DEVICE_ATTR (name , S_IRUGO , rtc_sysfs_show_name , NULL) ;
2524
2625static ssize_t rtc_sysfs_show_date (struct class_device * dev , char * buf )
2726{
@@ -36,7 +35,6 @@ static ssize_t rtc_sysfs_show_date(struct class_device *dev, char *buf)
3635
3736 return retval ;
3837}
39- static CLASS_DEVICE_ATTR (date , S_IRUGO , rtc_sysfs_show_date , NULL) ;
4038
4139static ssize_t rtc_sysfs_show_time (struct class_device * dev , char * buf )
4240{
@@ -51,7 +49,6 @@ static ssize_t rtc_sysfs_show_time(struct class_device *dev, char *buf)
5149
5250 return retval ;
5351}
54- static CLASS_DEVICE_ATTR (time , S_IRUGO , rtc_sysfs_show_time , NULL) ;
5552
5653static ssize_t rtc_sysfs_show_since_epoch (struct class_device * dev , char * buf )
5754{
@@ -67,21 +64,15 @@ static ssize_t rtc_sysfs_show_since_epoch(struct class_device *dev, char *buf)
6764
6865 return retval ;
6966}
70- static CLASS_DEVICE_ATTR (since_epoch , S_IRUGO , rtc_sysfs_show_since_epoch , NULL) ;
71-
72- static struct attribute * rtc_attrs [] = {
73- & class_device_attr_name .attr ,
74- & class_device_attr_date .attr ,
75- & class_device_attr_time .attr ,
76- & class_device_attr_since_epoch .attr ,
77- NULL ,
78- };
7967
80- static struct attribute_group rtc_attr_group = {
81- .attrs = rtc_attrs ,
68+ static struct class_device_attribute rtc_attrs [] = {
69+ __ATTR (name , S_IRUGO , rtc_sysfs_show_name , NULL ),
70+ __ATTR (date , S_IRUGO , rtc_sysfs_show_date , NULL ),
71+ __ATTR (time , S_IRUGO , rtc_sysfs_show_time , NULL ),
72+ __ATTR (since_epoch , S_IRUGO , rtc_sysfs_show_since_epoch , NULL ),
73+ { },
8274};
8375
84-
8576static ssize_t
8677rtc_sysfs_show_wakealarm (struct class_device * dev , char * buf )
8778{
@@ -157,71 +148,39 @@ static const CLASS_DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR,
157148 * suspend-to-disk. So: no attribute unless that side effect is possible.
158149 * (Userspace may disable that mechanism later.)
159150 */
160- static inline int rtc_does_wakealarm (struct class_device * class_dev )
151+ static inline int rtc_does_wakealarm (struct rtc_device * rtc )
161152{
162- struct rtc_device * rtc ;
163-
164- if (!device_can_wakeup (class_dev -> dev ))
153+ if (!device_can_wakeup (rtc -> class_dev .dev ))
165154 return 0 ;
166- rtc = to_rtc_device (class_dev );
167155 return rtc -> ops -> set_alarm != NULL ;
168156}
169157
170158
171- static int rtc_sysfs_add_device (struct class_device * class_dev ,
172- struct class_interface * class_intf )
159+ void rtc_sysfs_add_device (struct rtc_device * rtc )
173160{
174161 int err ;
175162
176- dev_dbg (class_dev -> dev , "rtc intf: sysfs\n" );
163+ /* not all RTCs support both alarms and wakeup */
164+ if (!rtc_does_wakealarm (rtc ))
165+ return ;
177166
178- err = sysfs_create_group (& class_dev -> kobj , & rtc_attr_group );
167+ err = class_device_create_file (& rtc -> class_dev ,
168+ & class_device_attr_wakealarm );
179169 if (err )
180- dev_err (class_dev -> dev , "failed to create %s\n" ,
181- "sysfs attributes" );
182- else if (rtc_does_wakealarm (class_dev )) {
183- /* not all RTCs support both alarms and wakeup */
184- err = class_device_create_file (class_dev ,
185- & class_device_attr_wakealarm );
186- if (err ) {
187- dev_err (class_dev -> dev , "failed to create %s\n" ,
188- "alarm attribute" );
189- sysfs_remove_group (& class_dev -> kobj , & rtc_attr_group );
190- }
191- }
192-
193- return err ;
170+ dev_err (rtc -> class_dev .dev , "failed to create "
171+ "alarm attribute, %d" ,
172+ err );
194173}
195174
196- static void rtc_sysfs_remove_device (struct class_device * class_dev ,
197- struct class_interface * class_intf )
175+ void rtc_sysfs_del_device (struct rtc_device * rtc )
198176{
199- if (rtc_does_wakealarm (class_dev ))
200- class_device_remove_file (class_dev ,
177+ /* REVISIT did we add it successfully? */
178+ if (rtc_does_wakealarm (rtc ))
179+ class_device_remove_file (& rtc -> class_dev ,
201180 & class_device_attr_wakealarm );
202- sysfs_remove_group (& class_dev -> kobj , & rtc_attr_group );
203- }
204-
205- /* interface registration */
206-
207- static struct class_interface rtc_sysfs_interface = {
208- .add = & rtc_sysfs_add_device ,
209- .remove = & rtc_sysfs_remove_device ,
210- };
211-
212- static int __init rtc_sysfs_init (void )
213- {
214- return rtc_interface_register (& rtc_sysfs_interface );
215181}
216182
217- static void __exit rtc_sysfs_exit ( void )
183+ void __init rtc_sysfs_init ( struct class * rtc_class )
218184{
219- class_interface_unregister ( & rtc_sysfs_interface ) ;
185+ rtc_class -> class_dev_attrs = rtc_attrs ;
220186}
221-
222- subsys_initcall (rtc_sysfs_init );
223- module_exit (rtc_sysfs_exit );
224-
225- MODULE_AUTHOR ("Alessandro Zummo <a.zummo@towertech.it>" );
226- MODULE_DESCRIPTION ("RTC class sysfs interface" );
227- MODULE_LICENSE ("GPL" );
0 commit comments