Skip to content

Commit cd96620

Browse files
David BrownellLinus Torvalds
authored andcommitted
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>
1 parent 7d9f99e commit cd96620

9 files changed

Lines changed: 74 additions & 66 deletions

File tree

‎drivers/rtc/class.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ static DEFINE_IDR(rtc_idr);
2323
static DEFINE_MUTEX(idr_lock);
2424
struct class *rtc_class;
2525

26-
static void rtc_device_release(struct class_device *class_dev)
26+
static void rtc_device_release(struct device *dev)
2727
{
28-
struct rtc_device *rtc = to_rtc_device(class_dev);
28+
struct rtc_device *rtc = to_rtc_device(dev);
2929
mutex_lock(&idr_lock);
3030
idr_remove(&rtc_idr, rtc->id);
3131
mutex_unlock(&idr_lock);
@@ -73,18 +73,18 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
7373
rtc->ops = ops;
7474
rtc->owner = owner;
7575
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;
7979

8080
mutex_init(&rtc->ops_lock);
8181
spin_lock_init(&rtc->irq_lock);
8282
spin_lock_init(&rtc->irq_task_lock);
8383

8484
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);
8686

87-
err = class_device_register(&rtc->class_dev);
87+
err = device_register(&rtc->dev);
8888
if (err)
8989
goto exit_kfree;
9090

@@ -93,7 +93,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
9393
rtc_proc_add_device(rtc);
9494

9595
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);
9797

9898
return rtc;
9999

@@ -120,18 +120,18 @@ EXPORT_SYMBOL_GPL(rtc_device_register);
120120
*/
121121
void rtc_device_unregister(struct rtc_device *rtc)
122122
{
123-
if (class_device_get(&rtc->class_dev) != NULL) {
123+
if (get_device(&rtc->dev) != NULL) {
124124
mutex_lock(&rtc->ops_lock);
125125
/* remove innards of this RTC, then disable it, before
126126
* letting any rtc_class_open() users access it again
127127
*/
128128
rtc_sysfs_del_device(rtc);
129129
rtc_dev_del_device(rtc);
130130
rtc_proc_del_device(rtc);
131-
class_device_unregister(&rtc->class_dev);
131+
device_unregister(&rtc->dev);
132132
rtc->ops = NULL;
133133
mutex_unlock(&rtc->ops_lock);
134-
class_device_put(&rtc->class_dev);
134+
put_device(&rtc->dev);
135135
}
136136
}
137137
EXPORT_SYMBOL_GPL(rtc_device_unregister);

‎drivers/rtc/hctosys.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ static int __init rtc_hctosys(void)
4646

4747
do_settimeofday(&tv);
4848

49-
dev_info(rtc->class_dev.dev,
49+
dev_info(rtc->dev.parent,
5050
"setting the system clock to "
5151
"%d-%02d-%02d %02d:%02d:%02d (%u)\n",
5252
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
5353
tm.tm_hour, tm.tm_min, tm.tm_sec,
5454
(unsigned int) tv.tv_sec);
5555
}
5656
else
57-
dev_err(rtc->class_dev.dev,
57+
dev_err(rtc->dev.parent,
5858
"hctosys: invalid date/time\n");
5959
}
6060
else
61-
dev_err(rtc->class_dev.dev,
61+
dev_err(rtc->dev.parent,
6262
"hctosys: unable to read the hardware clock\n");
6363

6464
rtc_class_close(rtc);

‎drivers/rtc/interface.c‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
2727
err = -EINVAL;
2828
else {
2929
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);
3131
}
3232

3333
mutex_unlock(&rtc->ops_lock);
@@ -52,7 +52,7 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
5252
else if (!rtc->ops->set_time)
5353
err = -EINVAL;
5454
else
55-
err = rtc->ops->set_time(rtc->class_dev.dev, tm);
55+
err = rtc->ops->set_time(rtc->dev.parent, tm);
5656

5757
mutex_unlock(&rtc->ops_lock);
5858
return err;
@@ -70,11 +70,11 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
7070
if (!rtc->ops)
7171
err = -ENODEV;
7272
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);
7474
else if (rtc->ops->read_time && rtc->ops->set_time) {
7575
struct rtc_time new, old;
7676

77-
err = rtc->ops->read_time(rtc->class_dev.dev, &old);
77+
err = rtc->ops->read_time(rtc->dev.parent, &old);
7878
if (err == 0) {
7979
rtc_time_to_tm(secs, &new);
8080

@@ -86,7 +86,7 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
8686
*/
8787
if (!((old.tm_hour == 23 && old.tm_min == 59) ||
8888
(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,
9090
&new);
9191
}
9292
}
@@ -113,7 +113,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
113113
err = -EINVAL;
114114
else {
115115
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);
117117
}
118118

119119
mutex_unlock(&rtc->ops_lock);
@@ -134,7 +134,7 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
134134
else if (!rtc->ops->set_alarm)
135135
err = -EINVAL;
136136
else
137-
err = rtc->ops->set_alarm(rtc->class_dev.dev, alarm);
137+
err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
138138

139139
mutex_unlock(&rtc->ops_lock);
140140
return err;
@@ -167,22 +167,22 @@ EXPORT_SYMBOL_GPL(rtc_update_irq);
167167

168168
struct rtc_device *rtc_class_open(char *name)
169169
{
170-
struct class_device *class_dev_tmp;
170+
struct device *dev;
171171
struct rtc_device *rtc = NULL;
172172

173173
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);
179179
break;
180180
}
181181
}
182182

183183
if (rtc) {
184184
if (!try_module_get(rtc->owner)) {
185-
class_device_put(class_dev_tmp);
185+
put_device(dev);
186186
rtc = NULL;
187187
}
188188
}
@@ -195,7 +195,7 @@ EXPORT_SYMBOL_GPL(rtc_class_open);
195195
void rtc_class_close(struct rtc_device *rtc)
196196
{
197197
module_put(rtc->owner);
198-
class_device_put(&rtc->class_dev);
198+
put_device(&rtc->dev);
199199
}
200200
EXPORT_SYMBOL_GPL(rtc_class_close);
201201

@@ -241,7 +241,7 @@ int rtc_irq_set_state(struct rtc_device *rtc, struct rtc_task *task, int enabled
241241
spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
242242

243243
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);
245245

246246
return err;
247247
}
@@ -261,7 +261,7 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
261261
spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
262262

263263
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);
265265
if (err == 0)
266266
rtc->irq_freq = freq;
267267
}

‎drivers/rtc/rtc-cmos.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
434434
goto cleanup0;
435435
}
436436
}
437-
rename_region(ports, cmos_rtc.rtc->class_dev.class_id);
437+
rename_region(ports, cmos_rtc.rtc->dev.bus_id);
438438

439439
spin_lock_irq(&rtc_lock);
440440

@@ -470,7 +470,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
470470

471471
if (is_valid_irq(rtc_irq))
472472
retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,
473-
cmos_rtc.rtc->class_dev.class_id,
473+
cmos_rtc.rtc->dev.bus_id,
474474
cmos_rtc.rtc);
475475
if (retval < 0) {
476476
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
@@ -483,7 +483,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
483483
*/
484484

485485
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,
487487
is_valid_irq(rtc_irq)
488488
? (cmos_rtc.mon_alrm
489489
? "year"
@@ -525,7 +525,7 @@ static void __exit cmos_do_remove(struct device *dev)
525525
rename_region(cmos->iomem, NULL);
526526

527527
if (is_valid_irq(cmos->irq))
528-
free_irq(cmos->irq, &cmos_rtc.rtc->class_dev);
528+
free_irq(cmos->irq, cmos_rtc.rtc);
529529

530530
rtc_device_unregister(cmos_rtc.rtc);
531531

@@ -564,7 +564,7 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg)
564564
*/
565565

566566
pr_debug("%s: suspend%s, ctrl %02x\n",
567-
cmos_rtc.rtc->class_dev.class_id,
567+
cmos_rtc.rtc->dev.bus_id,
568568
(tmp & RTC_AIE) ? ", alarm may wake" : "",
569569
tmp);
570570

@@ -595,7 +595,7 @@ static int cmos_resume(struct device *dev)
595595
}
596596

597597
pr_debug("%s: resume, ctrl %02x\n",
598-
cmos_rtc.rtc->class_dev.class_id,
598+
cmos_rtc.rtc->dev.bus_id,
599599
cmos->suspend_ctrl);
600600

601601

‎drivers/rtc/rtc-dev.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
3434

3535
file->private_data = rtc;
3636

37-
err = ops->open ? ops->open(rtc->class_dev.dev) : 0;
37+
err = ops->open ? ops->open(rtc->dev.parent) : 0;
3838
if (err == 0) {
3939
spin_lock_irq(&rtc->irq_lock);
4040
rtc->irq_data = 0;
@@ -180,7 +180,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
180180
if (ret == 0) {
181181
/* Check for any data updates */
182182
if (rtc->ops->read_callback)
183-
data = rtc->ops->read_callback(rtc->class_dev.dev,
183+
data = rtc->ops->read_callback(rtc->dev.parent,
184184
data);
185185

186186
if (sizeof(int) != sizeof(long) &&
@@ -251,7 +251,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
251251

252252
/* try the driver's ioctl interface */
253253
if (ops->ioctl) {
254-
err = ops->ioctl(rtc->class_dev.dev, cmd, arg);
254+
err = ops->ioctl(rtc->dev.parent, cmd, arg);
255255
if (err != -ENOIOCTLCMD)
256256
return err;
257257
}
@@ -371,7 +371,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
371371
clear_uie(rtc);
372372
#endif
373373
if (rtc->ops->release)
374-
rtc->ops->release(rtc->class_dev.dev);
374+
rtc->ops->release(rtc->dev.parent);
375375

376376
mutex_unlock(&rtc->char_lock);
377377
return 0;
@@ -406,7 +406,7 @@ void rtc_dev_add_device(struct rtc_device *rtc)
406406
return;
407407
}
408408

409-
rtc->class_dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
409+
rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
410410

411411
mutex_init(&rtc->char_lock);
412412
spin_lock_init(&rtc->irq_lock);
@@ -419,7 +419,7 @@ void rtc_dev_add_device(struct rtc_device *rtc)
419419
cdev_init(&rtc->char_dev, &rtc_dev_fops);
420420
rtc->char_dev.owner = rtc->owner;
421421

422-
if (cdev_add(&rtc->char_dev, rtc->class_dev.devt, 1))
422+
if (cdev_add(&rtc->char_dev, rtc->dev.devt, 1))
423423
printk(KERN_WARNING "%s: failed to add char device %d:%d\n",
424424
rtc->name, MAJOR(rtc_devt), rtc->id);
425425
else
@@ -429,7 +429,7 @@ void rtc_dev_add_device(struct rtc_device *rtc)
429429

430430
void rtc_dev_del_device(struct rtc_device *rtc)
431431
{
432-
if (rtc->class_dev.devt)
432+
if (rtc->dev.devt)
433433
cdev_del(&rtc->char_dev);
434434
}
435435

‎drivers/rtc/rtc-omap.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
399399
goto fail;
400400
}
401401
platform_set_drvdata(pdev, rtc);
402-
class_set_devdata(&rtc->class_dev, mem);
402+
dev_set_devdata(&rtc->dev, mem);
403403

404404
/* clear pending irqs, and set 1/second periodic,
405405
* which we'll use instead of update irqs
@@ -418,13 +418,13 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
418418

419419
/* handle periodic and alarm irqs */
420420
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)) {
422422
pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
423423
pdev->name, omap_rtc_timer);
424424
goto fail0;
425425
}
426426
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)) {
428428
pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
429429
pdev->name, omap_rtc_alarm);
430430
goto fail1;
@@ -481,7 +481,7 @@ static int __devexit omap_rtc_remove(struct platform_device *pdev)
481481
free_irq(omap_rtc_timer, rtc);
482482
free_irq(omap_rtc_alarm, rtc);
483483

484-
release_resource(class_get_devdata(&rtc->class_dev));
484+
release_resource(dev_get_devdata(&rtc->dev));
485485
rtc_device_unregister(rtc);
486486
return 0;
487487
}

‎drivers/rtc/rtc-proc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
7474
seq_printf(seq, "24hr\t\t: yes\n");
7575

7676
if (ops->proc)
77-
ops->proc(rtc->class_dev.dev, seq);
77+
ops->proc(rtc->dev.parent, seq);
7878

7979
return 0;
8080
}

0 commit comments

Comments
 (0)