Commit cd9662094edf4173e87f0452e57e4eacc228f8ff

Authored by David Brownell
Committed by Linus Torvalds
1 parent 7d9f99eccc

rtc: remove rest of class_device

Finish converting the RTC framework so it no longer uses class_device.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-By: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 9 changed files with 74 additions and 66 deletions Side-by-side Diff

... ... @@ -23,9 +23,9 @@
23 23 static DEFINE_MUTEX(idr_lock);
24 24 struct class *rtc_class;
25 25  
26   -static void rtc_device_release(struct class_device *class_dev)
  26 +static void rtc_device_release(struct device *dev)
27 27 {
28   - struct rtc_device *rtc = to_rtc_device(class_dev);
  28 + struct rtc_device *rtc = to_rtc_device(dev);
29 29 mutex_lock(&idr_lock);
30 30 idr_remove(&rtc_idr, rtc->id);
31 31 mutex_unlock(&idr_lock);
32 32  
33 33  
... ... @@ -73,18 +73,18 @@
73 73 rtc->ops = ops;
74 74 rtc->owner = owner;
75 75 rtc->max_user_freq = 64;
76   - rtc->class_dev.dev = dev;
77   - rtc->class_dev.class = rtc_class;
78   - rtc->class_dev.release = rtc_device_release;
  76 + rtc->dev.parent = dev;
  77 + rtc->dev.class = rtc_class;
  78 + rtc->dev.release = rtc_device_release;
79 79  
80 80 mutex_init(&rtc->ops_lock);
81 81 spin_lock_init(&rtc->irq_lock);
82 82 spin_lock_init(&rtc->irq_task_lock);
83 83  
84 84 strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
85   - snprintf(rtc->class_dev.class_id, BUS_ID_SIZE, "rtc%d", id);
  85 + snprintf(rtc->dev.bus_id, BUS_ID_SIZE, "rtc%d", id);
86 86  
87   - err = class_device_register(&rtc->class_dev);
  87 + err = device_register(&rtc->dev);
88 88 if (err)
89 89 goto exit_kfree;
90 90  
... ... @@ -93,7 +93,7 @@
93 93 rtc_proc_add_device(rtc);
94 94  
95 95 dev_info(dev, "rtc core: registered %s as %s\n",
96   - rtc->name, rtc->class_dev.class_id);
  96 + rtc->name, rtc->dev.bus_id);
97 97  
98 98 return rtc;
99 99  
... ... @@ -120,7 +120,7 @@
120 120 */
121 121 void rtc_device_unregister(struct rtc_device *rtc)
122 122 {
123   - if (class_device_get(&rtc->class_dev) != NULL) {
  123 + if (get_device(&rtc->dev) != NULL) {
124 124 mutex_lock(&rtc->ops_lock);
125 125 /* remove innards of this RTC, then disable it, before
126 126 * letting any rtc_class_open() users access it again
127 127  
... ... @@ -128,10 +128,10 @@
128 128 rtc_sysfs_del_device(rtc);
129 129 rtc_dev_del_device(rtc);
130 130 rtc_proc_del_device(rtc);
131   - class_device_unregister(&rtc->class_dev);
  131 + device_unregister(&rtc->dev);
132 132 rtc->ops = NULL;
133 133 mutex_unlock(&rtc->ops_lock);
134   - class_device_put(&rtc->class_dev);
  134 + put_device(&rtc->dev);
135 135 }
136 136 }
137 137 EXPORT_SYMBOL_GPL(rtc_device_unregister);
drivers/rtc/hctosys.c
... ... @@ -46,7 +46,7 @@
46 46  
47 47 do_settimeofday(&tv);
48 48  
49   - dev_info(rtc->class_dev.dev,
  49 + dev_info(rtc->dev.parent,
50 50 "setting the system clock to "
51 51 "%d-%02d-%02d %02d:%02d:%02d (%u)\n",
52 52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
53 53  
... ... @@ -54,11 +54,11 @@
54 54 (unsigned int) tv.tv_sec);
55 55 }
56 56 else
57   - dev_err(rtc->class_dev.dev,
  57 + dev_err(rtc->dev.parent,
58 58 "hctosys: invalid date/time\n");
59 59 }
60 60 else
61   - dev_err(rtc->class_dev.dev,
  61 + dev_err(rtc->dev.parent,
62 62 "hctosys: unable to read the hardware clock\n");
63 63  
64 64 rtc_class_close(rtc);
drivers/rtc/interface.c
... ... @@ -27,7 +27,7 @@
27 27 err = -EINVAL;
28 28 else {
29 29 memset(tm, 0, sizeof(struct rtc_time));
30   - err = rtc->ops->read_time(rtc->class_dev.dev, tm);
  30 + err = rtc->ops->read_time(rtc->dev.parent, tm);
31 31 }
32 32  
33 33 mutex_unlock(&rtc->ops_lock);
... ... @@ -52,7 +52,7 @@
52 52 else if (!rtc->ops->set_time)
53 53 err = -EINVAL;
54 54 else
55   - err = rtc->ops->set_time(rtc->class_dev.dev, tm);
  55 + err = rtc->ops->set_time(rtc->dev.parent, tm);
56 56  
57 57 mutex_unlock(&rtc->ops_lock);
58 58 return err;
59 59  
... ... @@ -70,11 +70,11 @@
70 70 if (!rtc->ops)
71 71 err = -ENODEV;
72 72 else if (rtc->ops->set_mmss)
73   - err = rtc->ops->set_mmss(rtc->class_dev.dev, secs);
  73 + err = rtc->ops->set_mmss(rtc->dev.parent, secs);
74 74 else if (rtc->ops->read_time && rtc->ops->set_time) {
75 75 struct rtc_time new, old;
76 76  
77   - err = rtc->ops->read_time(rtc->class_dev.dev, &old);
  77 + err = rtc->ops->read_time(rtc->dev.parent, &old);
78 78 if (err == 0) {
79 79 rtc_time_to_tm(secs, &new);
80 80  
... ... @@ -86,7 +86,7 @@
86 86 */
87 87 if (!((old.tm_hour == 23 && old.tm_min == 59) ||
88 88 (new.tm_hour == 23 && new.tm_min == 59)))
89   - err = rtc->ops->set_time(rtc->class_dev.dev,
  89 + err = rtc->ops->set_time(rtc->dev.parent,
90 90 &new);
91 91 }
92 92 }
... ... @@ -113,7 +113,7 @@
113 113 err = -EINVAL;
114 114 else {
115 115 memset(alarm, 0, sizeof(struct rtc_wkalrm));
116   - err = rtc->ops->read_alarm(rtc->class_dev.dev, alarm);
  116 + err = rtc->ops->read_alarm(rtc->dev.parent, alarm);
117 117 }
118 118  
119 119 mutex_unlock(&rtc->ops_lock);
... ... @@ -134,7 +134,7 @@
134 134 else if (!rtc->ops->set_alarm)
135 135 err = -EINVAL;
136 136 else
137   - err = rtc->ops->set_alarm(rtc->class_dev.dev, alarm);
  137 + err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
138 138  
139 139 mutex_unlock(&rtc->ops_lock);
140 140 return err;
141 141  
142 142  
... ... @@ -167,22 +167,22 @@
167 167  
168 168 struct rtc_device *rtc_class_open(char *name)
169 169 {
170   - struct class_device *class_dev_tmp;
  170 + struct device *dev;
171 171 struct rtc_device *rtc = NULL;
172 172  
173 173 down(&rtc_class->sem);
174   - list_for_each_entry(class_dev_tmp, &rtc_class->children, node) {
175   - if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) {
176   - class_dev_tmp = class_device_get(class_dev_tmp);
177   - if (class_dev_tmp)
178   - rtc = to_rtc_device(class_dev_tmp);
  174 + list_for_each_entry(dev, &rtc_class->devices, node) {
  175 + if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0) {
  176 + dev = get_device(dev);
  177 + if (dev)
  178 + rtc = to_rtc_device(dev);
179 179 break;
180 180 }
181 181 }
182 182  
183 183 if (rtc) {
184 184 if (!try_module_get(rtc->owner)) {
185   - class_device_put(class_dev_tmp);
  185 + put_device(dev);
186 186 rtc = NULL;
187 187 }
188 188 }
... ... @@ -195,7 +195,7 @@
195 195 void rtc_class_close(struct rtc_device *rtc)
196 196 {
197 197 module_put(rtc->owner);
198   - class_device_put(&rtc->class_dev);
  198 + put_device(&rtc->dev);
199 199 }
200 200 EXPORT_SYMBOL_GPL(rtc_class_close);
201 201  
... ... @@ -241,7 +241,7 @@
241 241 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
242 242  
243 243 if (err == 0)
244   - err = rtc->ops->irq_set_state(rtc->class_dev.dev, enabled);
  244 + err = rtc->ops->irq_set_state(rtc->dev.parent, enabled);
245 245  
246 246 return err;
247 247 }
... ... @@ -261,7 +261,7 @@
261 261 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
262 262  
263 263 if (err == 0) {
264   - err = rtc->ops->irq_set_freq(rtc->class_dev.dev, freq);
  264 + err = rtc->ops->irq_set_freq(rtc->dev.parent, freq);
265 265 if (err == 0)
266 266 rtc->irq_freq = freq;
267 267 }
drivers/rtc/rtc-cmos.c
... ... @@ -434,7 +434,7 @@
434 434 goto cleanup0;
435 435 }
436 436 }
437   - rename_region(ports, cmos_rtc.rtc->class_dev.class_id);
  437 + rename_region(ports, cmos_rtc.rtc->dev.bus_id);
438 438  
439 439 spin_lock_irq(&rtc_lock);
440 440  
... ... @@ -470,7 +470,7 @@
470 470  
471 471 if (is_valid_irq(rtc_irq))
472 472 retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,
473   - cmos_rtc.rtc->class_dev.class_id,
  473 + cmos_rtc.rtc->dev.bus_id,
474 474 cmos_rtc.rtc);
475 475 if (retval < 0) {
476 476 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
... ... @@ -483,7 +483,7 @@
483 483 */
484 484  
485 485 pr_info("%s: alarms up to one %s%s\n",
486   - cmos_rtc.rtc->class_dev.class_id,
  486 + cmos_rtc.rtc->dev.bus_id,
487 487 is_valid_irq(rtc_irq)
488 488 ? (cmos_rtc.mon_alrm
489 489 ? "year"
... ... @@ -525,7 +525,7 @@
525 525 rename_region(cmos->iomem, NULL);
526 526  
527 527 if (is_valid_irq(cmos->irq))
528   - free_irq(cmos->irq, &cmos_rtc.rtc->class_dev);
  528 + free_irq(cmos->irq, cmos_rtc.rtc);
529 529  
530 530 rtc_device_unregister(cmos_rtc.rtc);
531 531  
... ... @@ -564,7 +564,7 @@
564 564 */
565 565  
566 566 pr_debug("%s: suspend%s, ctrl %02x\n",
567   - cmos_rtc.rtc->class_dev.class_id,
  567 + cmos_rtc.rtc->dev.bus_id,
568 568 (tmp & RTC_AIE) ? ", alarm may wake" : "",
569 569 tmp);
570 570  
... ... @@ -595,7 +595,7 @@
595 595 }
596 596  
597 597 pr_debug("%s: resume, ctrl %02x\n",
598   - cmos_rtc.rtc->class_dev.class_id,
  598 + cmos_rtc.rtc->dev.bus_id,
599 599 cmos->suspend_ctrl);
600 600  
601 601  
drivers/rtc/rtc-dev.c
... ... @@ -34,7 +34,7 @@
34 34  
35 35 file->private_data = rtc;
36 36  
37   - err = ops->open ? ops->open(rtc->class_dev.dev) : 0;
  37 + err = ops->open ? ops->open(rtc->dev.parent) : 0;
38 38 if (err == 0) {
39 39 spin_lock_irq(&rtc->irq_lock);
40 40 rtc->irq_data = 0;
... ... @@ -180,7 +180,7 @@
180 180 if (ret == 0) {
181 181 /* Check for any data updates */
182 182 if (rtc->ops->read_callback)
183   - data = rtc->ops->read_callback(rtc->class_dev.dev,
  183 + data = rtc->ops->read_callback(rtc->dev.parent,
184 184 data);
185 185  
186 186 if (sizeof(int) != sizeof(long) &&
... ... @@ -251,7 +251,7 @@
251 251  
252 252 /* try the driver's ioctl interface */
253 253 if (ops->ioctl) {
254   - err = ops->ioctl(rtc->class_dev.dev, cmd, arg);
  254 + err = ops->ioctl(rtc->dev.parent, cmd, arg);
255 255 if (err != -ENOIOCTLCMD)
256 256 return err;
257 257 }
... ... @@ -371,7 +371,7 @@
371 371 clear_uie(rtc);
372 372 #endif
373 373 if (rtc->ops->release)
374   - rtc->ops->release(rtc->class_dev.dev);
  374 + rtc->ops->release(rtc->dev.parent);
375 375  
376 376 mutex_unlock(&rtc->char_lock);
377 377 return 0;
... ... @@ -406,7 +406,7 @@
406 406 return;
407 407 }
408 408  
409   - rtc->class_dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
  409 + rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
410 410  
411 411 mutex_init(&rtc->char_lock);
412 412 spin_lock_init(&rtc->irq_lock);
... ... @@ -419,7 +419,7 @@
419 419 cdev_init(&rtc->char_dev, &rtc_dev_fops);
420 420 rtc->char_dev.owner = rtc->owner;
421 421  
422   - if (cdev_add(&rtc->char_dev, rtc->class_dev.devt, 1))
  422 + if (cdev_add(&rtc->char_dev, rtc->dev.devt, 1))
423 423 printk(KERN_WARNING "%s: failed to add char device %d:%d\n",
424 424 rtc->name, MAJOR(rtc_devt), rtc->id);
425 425 else
... ... @@ -429,7 +429,7 @@
429 429  
430 430 void rtc_dev_del_device(struct rtc_device *rtc)
431 431 {
432   - if (rtc->class_dev.devt)
  432 + if (rtc->dev.devt)
433 433 cdev_del(&rtc->char_dev);
434 434 }
435 435  
drivers/rtc/rtc-omap.c
... ... @@ -399,7 +399,7 @@
399 399 goto fail;
400 400 }
401 401 platform_set_drvdata(pdev, rtc);
402   - class_set_devdata(&rtc->class_dev, mem);
  402 + dev_set_devdata(&rtc->dev, mem);
403 403  
404 404 /* clear pending irqs, and set 1/second periodic,
405 405 * which we'll use instead of update irqs
406 406  
... ... @@ -418,13 +418,13 @@
418 418  
419 419 /* handle periodic and alarm irqs */
420 420 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED,
421   - rtc->class_dev.class_id, &rtc->class_dev)) {
  421 + rtc->dev.bus_id, rtc)) {
422 422 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
423 423 pdev->name, omap_rtc_timer);
424 424 goto fail0;
425 425 }
426 426 if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
427   - rtc->class_dev.class_id, &rtc->class_dev)) {
  427 + rtc->dev.bus_id, rtc)) {
428 428 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
429 429 pdev->name, omap_rtc_alarm);
430 430 goto fail1;
... ... @@ -481,7 +481,7 @@
481 481 free_irq(omap_rtc_timer, rtc);
482 482 free_irq(omap_rtc_alarm, rtc);
483 483  
484   - release_resource(class_get_devdata(&rtc->class_dev));
  484 + release_resource(dev_get_devdata(&rtc->dev));
485 485 rtc_device_unregister(rtc);
486 486 return 0;
487 487 }
drivers/rtc/rtc-proc.c
... ... @@ -74,7 +74,7 @@
74 74 seq_printf(seq, "24hr\t\t: yes\n");
75 75  
76 76 if (ops->proc)
77   - ops->proc(rtc->class_dev.dev, seq);
  77 + ops->proc(rtc->dev.parent, seq);
78 78  
79 79 return 0;
80 80 }
drivers/rtc/rtc-sysfs.c
... ... @@ -17,12 +17,16 @@
17 17  
18 18 /* device attributes */
19 19  
20   -static ssize_t rtc_sysfs_show_name(struct class_device *dev, char *buf)
  20 +static ssize_t
  21 +rtc_sysfs_show_name(struct device *dev, struct device_attribute *attr,
  22 + char *buf)
21 23 {
22 24 return sprintf(buf, "%s\n", to_rtc_device(dev)->name);
23 25 }
24 26  
25   -static ssize_t rtc_sysfs_show_date(struct class_device *dev, char *buf)
  27 +static ssize_t
  28 +rtc_sysfs_show_date(struct device *dev, struct device_attribute *attr,
  29 + char *buf)
26 30 {
27 31 ssize_t retval;
28 32 struct rtc_time tm;
... ... @@ -36,7 +40,9 @@
36 40 return retval;
37 41 }
38 42  
39   -static ssize_t rtc_sysfs_show_time(struct class_device *dev, char *buf)
  43 +static ssize_t
  44 +rtc_sysfs_show_time(struct device *dev, struct device_attribute *attr,
  45 + char *buf)
40 46 {
41 47 ssize_t retval;
42 48 struct rtc_time tm;
... ... @@ -50,7 +56,9 @@
50 56 return retval;
51 57 }
52 58  
53   -static ssize_t rtc_sysfs_show_since_epoch(struct class_device *dev, char *buf)
  59 +static ssize_t
  60 +rtc_sysfs_show_since_epoch(struct device *dev, struct device_attribute *attr,
  61 + char *buf)
54 62 {
55 63 ssize_t retval;
56 64 struct rtc_time tm;
... ... @@ -65,7 +73,7 @@
65 73 return retval;
66 74 }
67 75  
68   -static struct class_device_attribute rtc_attrs[] = {
  76 +static struct device_attribute rtc_attrs[] = {
69 77 __ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL),
70 78 __ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL),
71 79 __ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL),
... ... @@ -74,7 +82,8 @@
74 82 };
75 83  
76 84 static ssize_t
77   -rtc_sysfs_show_wakealarm(struct class_device *dev, char *buf)
  85 +rtc_sysfs_show_wakealarm(struct device *dev, struct device_attribute *attr,
  86 + char *buf)
78 87 {
79 88 ssize_t retval;
80 89 unsigned long alarm;
... ... @@ -98,7 +107,8 @@
98 107 }
99 108  
100 109 static ssize_t
101   -rtc_sysfs_set_wakealarm(struct class_device *dev, const char *buf, size_t n)
  110 +rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
  111 + const char *buf, size_t n)
102 112 {
103 113 ssize_t retval;
104 114 unsigned long now, alarm;
... ... @@ -139,7 +149,7 @@
139 149 retval = rtc_set_alarm(rtc, &alm);
140 150 return (retval < 0) ? retval : n;
141 151 }
142   -static const CLASS_DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR,
  152 +static DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR,
143 153 rtc_sysfs_show_wakealarm, rtc_sysfs_set_wakealarm);
144 154  
145 155  
... ... @@ -150,7 +160,7 @@
150 160 */
151 161 static inline int rtc_does_wakealarm(struct rtc_device *rtc)
152 162 {
153   - if (!device_can_wakeup(rtc->class_dev.dev))
  163 + if (!device_can_wakeup(rtc->dev.parent))
154 164 return 0;
155 165 return rtc->ops->set_alarm != NULL;
156 166 }
157 167  
... ... @@ -164,10 +174,9 @@
164 174 if (!rtc_does_wakealarm(rtc))
165 175 return;
166 176  
167   - err = class_device_create_file(&rtc->class_dev,
168   - &class_device_attr_wakealarm);
  177 + err = device_create_file(&rtc->dev, &dev_attr_wakealarm);
169 178 if (err)
170   - dev_err(rtc->class_dev.dev, "failed to create "
  179 + dev_err(rtc->dev.parent, "failed to create "
171 180 "alarm attribute, %d",
172 181 err);
173 182 }
174 183  
... ... @@ -176,12 +185,11 @@
176 185 {
177 186 /* REVISIT did we add it successfully? */
178 187 if (rtc_does_wakealarm(rtc))
179   - class_device_remove_file(&rtc->class_dev,
180   - &class_device_attr_wakealarm);
  188 + device_remove_file(&rtc->dev, &dev_attr_wakealarm);
181 189 }
182 190  
183 191 void __init rtc_sysfs_init(struct class *rtc_class)
184 192 {
185   - rtc_class->class_dev_attrs = rtc_attrs;
  193 + rtc_class->dev_attrs = rtc_attrs;
186 194 }
... ... @@ -136,7 +136,7 @@
136 136  
137 137 struct rtc_device
138 138 {
139   - struct class_device class_dev;
  139 + struct device dev;
140 140 struct module *owner;
141 141  
142 142 int id;
... ... @@ -168,7 +168,7 @@
168 168 unsigned int uie_timer_active:1;
169 169 #endif
170 170 };
171   -#define to_rtc_device(d) container_of(d, struct rtc_device, class_dev)
  171 +#define to_rtc_device(d) container_of(d, struct rtc_device, dev)
172 172  
173 173 extern struct rtc_device *rtc_device_register(const char *name,
174 174 struct device *dev,