Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd966209 authored by David Brownell's avatar David Brownell Committed by Linus Torvalds
Browse files

rtc: remove rest of class_device



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

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Acked-By: default avatarAlessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7d9f99ec
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -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);
@@ -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;

@@ -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;

@@ -120,7 +120,7 @@ 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
@@ -128,10 +128,10 @@ void rtc_device_unregister(struct rtc_device *rtc)
		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);
+3 −3
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ 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,
@@ -54,11 +54,11 @@ static int __init rtc_hctosys(void)
				(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);
+17 −17
Original line number Diff line number Diff line
@@ -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);
@@ -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;
@@ -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);

@@ -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);
		}
	}
@@ -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);
@@ -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;
@@ -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;
		}
	}
@@ -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);

@@ -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;
}
@@ -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;
	}
+6 −6
Original line number Diff line number Diff line
@@ -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);

@@ -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);
@@ -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"
@@ -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);

@@ -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);

@@ -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);


+7 −7
Original line number Diff line number Diff line
@@ -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;
@@ -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) &&
@@ -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;
	}
@@ -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;
@@ -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);
@@ -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
@@ -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);
}

Loading