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

Commit c7705f34 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by Linus Torvalds
Browse files

drivers: use non-racy method for proc entries creation (2)



Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Peter Osterlund <petero2@telia.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Neil Brown <neilb@suse.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Alessandro 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 1b502217
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -2744,7 +2744,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
	int i;
	int ret = 0;
	char b[BDEVNAME_SIZE];
	struct proc_dir_entry *proc;
	struct block_device *bdev;

	if (pd->pkt_dev == dev) {
@@ -2788,11 +2787,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
		goto out_mem;
	}

	proc = create_proc_entry(pd->name, 0, pkt_proc);
	if (proc) {
		proc->data = pd;
		proc->proc_fops = &pkt_proc_fops;
	}
	proc_create_data(pd->name, 0, pkt_proc, &pkt_proc_fops, pd);
	DPRINTK(DRIVER_NAME": writer %s mapped to %s\n", pd->name, bdevname(bdev, b));
	return 0;

+3 −7
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ static int proc_viocd_open(struct inode *inode, struct file *file)
}

static const struct file_operations proc_viocd_operations = {
	.owner		= THIS_MODULE,
	.open		= proc_viocd_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
@@ -679,7 +680,6 @@ static struct vio_driver viocd_driver = {

static int __init viocd_init(void)
{
	struct proc_dir_entry *e;
	int ret = 0;

	if (!firmware_has_feature(FW_FEATURE_ISERIES))
@@ -719,12 +719,8 @@ static int __init viocd_init(void)
	if (ret)
		goto out_free_info;

	e = create_proc_entry("iSeries/viocd", S_IFREG|S_IRUGO, NULL);
	if (e) {
		e->owner = THIS_MODULE;
		e->proc_fops = &proc_viocd_operations;
	}

	proc_create("iSeries/viocd", S_IFREG|S_IRUGO, NULL,
		    &proc_viocd_operations);
	return 0;

out_free_info:
+2 −5
Original line number Diff line number Diff line
@@ -822,6 +822,7 @@ static int ide_drivers_open(struct inode *inode, struct file *file)
}

static const struct file_operations ide_drivers_operations = {
	.owner		= THIS_MODULE,
	.open		= ide_drivers_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
@@ -830,16 +831,12 @@ static const struct file_operations ide_drivers_operations = {

void proc_ide_create(void)
{
	struct proc_dir_entry *entry;

	proc_ide_root = proc_mkdir("ide", NULL);

	if (!proc_ide_root)
		return;

	entry = create_proc_entry("drivers", 0, proc_ide_root);
	if (entry)
		entry->proc_fops = &ide_drivers_operations;
	proc_create("drivers", 0, proc_ide_root, &ide_drivers_operations);
}

void proc_ide_destroy(void)
+4 −8
Original line number Diff line number Diff line
@@ -904,20 +904,16 @@ static int __init input_proc_init(void)

	proc_bus_input_dir->owner = THIS_MODULE;

	entry = create_proc_entry("devices", 0, proc_bus_input_dir);
	entry = proc_create("devices", 0, proc_bus_input_dir,
			    &input_devices_fileops);
	if (!entry)
		goto fail1;

	entry->owner = THIS_MODULE;
	entry->proc_fops = &input_devices_fileops;

	entry = create_proc_entry("handlers", 0, proc_bus_input_dir);
	entry = proc_create("handlers", 0, proc_bus_input_dir,
			    &input_handlers_fileops);
	if (!entry)
		goto fail2;

	entry->owner = THIS_MODULE;
	entry->proc_fops = &input_handlers_fileops;

	return 0;

 fail2:	remove_proc_entry("devices", proc_bus_input_dir);
+1 −5
Original line number Diff line number Diff line
@@ -5947,13 +5947,9 @@ static struct notifier_block md_notifier = {

static void md_geninit(void)
{
	struct proc_dir_entry *p;

	dprintk("md: sizeof(mdp_super_t) = %d\n", (int)sizeof(mdp_super_t));

	p = create_proc_entry("mdstat", S_IRUGO, NULL);
	if (p)
		p->proc_fops = &md_seq_fops;
	proc_create("mdstat", S_IRUGO, NULL, &md_seq_fops);
}

static int __init md_init(void)
Loading