Skip to content

Commit

Permalink
rtc: remove rest of class_device
Browse files Browse the repository at this point in the history
Finish converting the RTC framework so it no longer uses class_device.

Signed-off-by: David Brownell <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Acked-By: Alessandro Zummo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
David Brownell authored and Linus Torvalds committed May 8, 2007
1 parent 7d9f99e commit cd96620
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 66 deletions.
22 changes: 11 additions & 11 deletions drivers/rtc/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ static DEFINE_IDR(rtc_idr);
static DEFINE_MUTEX(idr_lock);
struct class *rtc_class;

static void rtc_device_release(struct class_device *class_dev)
static void rtc_device_release(struct device *dev)
{
struct rtc_device *rtc = to_rtc_device(class_dev);
struct rtc_device *rtc = to_rtc_device(dev);
mutex_lock(&idr_lock);
idr_remove(&rtc_idr, rtc->id);
mutex_unlock(&idr_lock);
Expand Down Expand Up @@ -73,18 +73,18 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
rtc->ops = ops;
rtc->owner = owner;
rtc->max_user_freq = 64;
rtc->class_dev.dev = dev;
rtc->class_dev.class = rtc_class;
rtc->class_dev.release = rtc_device_release;
rtc->dev.parent = dev;
rtc->dev.class = rtc_class;
rtc->dev.release = rtc_device_release;

mutex_init(&rtc->ops_lock);
spin_lock_init(&rtc->irq_lock);
spin_lock_init(&rtc->irq_task_lock);

strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
snprintf(rtc->class_dev.class_id, BUS_ID_SIZE, "rtc%d", id);
snprintf(rtc->dev.bus_id, BUS_ID_SIZE, "rtc%d", id);

err = class_device_register(&rtc->class_dev);
err = device_register(&rtc->dev);
if (err)
goto exit_kfree;

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

dev_info(dev, "rtc core: registered %s as %s\n",
rtc->name, rtc->class_dev.class_id);
rtc->name, rtc->dev.bus_id);

return rtc;

Expand All @@ -120,18 +120,18 @@ EXPORT_SYMBOL_GPL(rtc_device_register);
*/
void rtc_device_unregister(struct rtc_device *rtc)
{
if (class_device_get(&rtc->class_dev) != NULL) {
if (get_device(&rtc->dev) != NULL) {
mutex_lock(&rtc->ops_lock);
/* remove innards of this RTC, then disable it, before
* letting any rtc_class_open() users access it again
*/
rtc_sysfs_del_device(rtc);
rtc_dev_del_device(rtc);
rtc_proc_del_device(rtc);
class_device_unregister(&rtc->class_dev);
device_unregister(&rtc->dev);
rtc->ops = NULL;
mutex_unlock(&rtc->ops_lock);
class_device_put(&rtc->class_dev);
put_device(&rtc->dev);
}
}
EXPORT_SYMBOL_GPL(rtc_device_unregister);
Expand Down
6 changes: 3 additions & 3 deletions drivers/rtc/hctosys.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ static int __init rtc_hctosys(void)

do_settimeofday(&tv);

dev_info(rtc->class_dev.dev,
dev_info(rtc->dev.parent,
"setting the system clock to "
"%d-%02d-%02d %02d:%02d:%02d (%u)\n",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
(unsigned int) tv.tv_sec);
}
else
dev_err(rtc->class_dev.dev,
dev_err(rtc->dev.parent,
"hctosys: invalid date/time\n");
}
else
dev_err(rtc->class_dev.dev,
dev_err(rtc->dev.parent,
"hctosys: unable to read the hardware clock\n");

rtc_class_close(rtc);
Expand Down
34 changes: 17 additions & 17 deletions drivers/rtc/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
err = -EINVAL;
else {
memset(tm, 0, sizeof(struct rtc_time));
err = rtc->ops->read_time(rtc->class_dev.dev, tm);
err = rtc->ops->read_time(rtc->dev.parent, tm);
}

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

mutex_unlock(&rtc->ops_lock);
return err;
Expand All @@ -70,11 +70,11 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
if (!rtc->ops)
err = -ENODEV;
else if (rtc->ops->set_mmss)
err = rtc->ops->set_mmss(rtc->class_dev.dev, secs);
err = rtc->ops->set_mmss(rtc->dev.parent, secs);
else if (rtc->ops->read_time && rtc->ops->set_time) {
struct rtc_time new, old;

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

Expand All @@ -86,7 +86,7 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
*/
if (!((old.tm_hour == 23 && old.tm_min == 59) ||
(new.tm_hour == 23 && new.tm_min == 59)))
err = rtc->ops->set_time(rtc->class_dev.dev,
err = rtc->ops->set_time(rtc->dev.parent,
&new);
}
}
Expand All @@ -113,7 +113,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
err = -EINVAL;
else {
memset(alarm, 0, sizeof(struct rtc_wkalrm));
err = rtc->ops->read_alarm(rtc->class_dev.dev, alarm);
err = rtc->ops->read_alarm(rtc->dev.parent, alarm);
}

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

mutex_unlock(&rtc->ops_lock);
return err;
Expand Down Expand Up @@ -167,22 +167,22 @@ EXPORT_SYMBOL_GPL(rtc_update_irq);

struct rtc_device *rtc_class_open(char *name)
{
struct class_device *class_dev_tmp;
struct device *dev;
struct rtc_device *rtc = NULL;

down(&rtc_class->sem);
list_for_each_entry(class_dev_tmp, &rtc_class->children, node) {
if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) {
class_dev_tmp = class_device_get(class_dev_tmp);
if (class_dev_tmp)
rtc = to_rtc_device(class_dev_tmp);
list_for_each_entry(dev, &rtc_class->devices, node) {
if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0) {
dev = get_device(dev);
if (dev)
rtc = to_rtc_device(dev);
break;
}
}

if (rtc) {
if (!try_module_get(rtc->owner)) {
class_device_put(class_dev_tmp);
put_device(dev);
rtc = NULL;
}
}
Expand All @@ -195,7 +195,7 @@ EXPORT_SYMBOL_GPL(rtc_class_open);
void rtc_class_close(struct rtc_device *rtc)
{
module_put(rtc->owner);
class_device_put(&rtc->class_dev);
put_device(&rtc->dev);
}
EXPORT_SYMBOL_GPL(rtc_class_close);

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

if (err == 0)
err = rtc->ops->irq_set_state(rtc->class_dev.dev, enabled);
err = rtc->ops->irq_set_state(rtc->dev.parent, enabled);

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

if (err == 0) {
err = rtc->ops->irq_set_freq(rtc->class_dev.dev, freq);
err = rtc->ops->irq_set_freq(rtc->dev.parent, freq);
if (err == 0)
rtc->irq_freq = freq;
}
Expand Down
12 changes: 6 additions & 6 deletions drivers/rtc/rtc-cmos.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
goto cleanup0;
}
}
rename_region(ports, cmos_rtc.rtc->class_dev.class_id);
rename_region(ports, cmos_rtc.rtc->dev.bus_id);

spin_lock_irq(&rtc_lock);

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

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

pr_info("%s: alarms up to one %s%s\n",
cmos_rtc.rtc->class_dev.class_id,
cmos_rtc.rtc->dev.bus_id,
is_valid_irq(rtc_irq)
? (cmos_rtc.mon_alrm
? "year"
Expand Down Expand Up @@ -525,7 +525,7 @@ static void __exit cmos_do_remove(struct device *dev)
rename_region(cmos->iomem, NULL);

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

rtc_device_unregister(cmos_rtc.rtc);

Expand Down Expand Up @@ -564,7 +564,7 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg)
*/

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

Expand Down Expand Up @@ -595,7 +595,7 @@ static int cmos_resume(struct device *dev)
}

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


Expand Down
14 changes: 7 additions & 7 deletions drivers/rtc/rtc-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)

file->private_data = rtc;

err = ops->open ? ops->open(rtc->class_dev.dev) : 0;
err = ops->open ? ops->open(rtc->dev.parent) : 0;
if (err == 0) {
spin_lock_irq(&rtc->irq_lock);
rtc->irq_data = 0;
Expand Down Expand Up @@ -180,7 +180,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (ret == 0) {
/* Check for any data updates */
if (rtc->ops->read_callback)
data = rtc->ops->read_callback(rtc->class_dev.dev,
data = rtc->ops->read_callback(rtc->dev.parent,
data);

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

/* try the driver's ioctl interface */
if (ops->ioctl) {
err = ops->ioctl(rtc->class_dev.dev, cmd, arg);
err = ops->ioctl(rtc->dev.parent, cmd, arg);
if (err != -ENOIOCTLCMD)
return err;
}
Expand Down Expand Up @@ -371,7 +371,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
clear_uie(rtc);
#endif
if (rtc->ops->release)
rtc->ops->release(rtc->class_dev.dev);
rtc->ops->release(rtc->dev.parent);

mutex_unlock(&rtc->char_lock);
return 0;
Expand Down Expand Up @@ -406,7 +406,7 @@ void rtc_dev_add_device(struct rtc_device *rtc)
return;
}

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

mutex_init(&rtc->char_lock);
spin_lock_init(&rtc->irq_lock);
Expand All @@ -419,7 +419,7 @@ void rtc_dev_add_device(struct rtc_device *rtc)
cdev_init(&rtc->char_dev, &rtc_dev_fops);
rtc->char_dev.owner = rtc->owner;

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

void rtc_dev_del_device(struct rtc_device *rtc)
{
if (rtc->class_dev.devt)
if (rtc->dev.devt)
cdev_del(&rtc->char_dev);
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/rtc/rtc-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
goto fail;
}
platform_set_drvdata(pdev, rtc);
class_set_devdata(&rtc->class_dev, mem);
dev_set_devdata(&rtc->dev, mem);

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

/* handle periodic and alarm irqs */
if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED,
rtc->class_dev.class_id, &rtc->class_dev)) {
rtc->dev.bus_id, rtc)) {
pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
pdev->name, omap_rtc_timer);
goto fail0;
}
if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
rtc->class_dev.class_id, &rtc->class_dev)) {
rtc->dev.bus_id, rtc)) {
pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
pdev->name, omap_rtc_alarm);
goto fail1;
Expand Down Expand Up @@ -481,7 +481,7 @@ static int __devexit omap_rtc_remove(struct platform_device *pdev)
free_irq(omap_rtc_timer, rtc);
free_irq(omap_rtc_alarm, rtc);

release_resource(class_get_devdata(&rtc->class_dev));
release_resource(dev_get_devdata(&rtc->dev));
rtc_device_unregister(rtc);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
seq_printf(seq, "24hr\t\t: yes\n");

if (ops->proc)
ops->proc(rtc->class_dev.dev, seq);
ops->proc(rtc->dev.parent, seq);

return 0;
}
Expand Down
Loading

0 comments on commit cd96620

Please sign in to comment.