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

Commit 59cacb8d authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

rtc/proc: switch to proc_create_single_data



And stop trying to get a reference on the submodule, procfs code deals
with release after an unloaded module and thus removed proc entry.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 004fd11d
Loading
Loading
Loading
Loading
+2 −31
Original line number Diff line number Diff line
@@ -107,40 +107,11 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
	return 0;
}

static int rtc_proc_open(struct inode *inode, struct file *file)
{
	int ret;
	struct rtc_device *rtc = PDE_DATA(inode);

	if (!try_module_get(rtc->owner))
		return -ENODEV;

	ret = single_open(file, rtc_proc_show, rtc);
	if (ret)
		module_put(rtc->owner);
	return ret;
}

static int rtc_proc_release(struct inode *inode, struct file *file)
{
	int res = single_release(inode, file);
	struct rtc_device *rtc = PDE_DATA(inode);

	module_put(rtc->owner);
	return res;
}

static const struct file_operations rtc_proc_fops = {
	.open		= rtc_proc_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= rtc_proc_release,
};

void rtc_proc_add_device(struct rtc_device *rtc)
{
	if (is_rtc_hctosys(rtc))
		proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc);
		proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
				rtc);
}

void rtc_proc_del_device(struct rtc_device *rtc)