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: Denis 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Denis V. Lunev 2008-04-29 01:02:35 -07:00 committed by Linus Torvalds
parent 1b50221738
commit c7705f3449
12 changed files with 33 additions and 68 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -180,6 +180,7 @@ static ssize_t zoran_write(struct file *file, const char __user *buffer,
}
static const struct file_operations zoran_operations = {
.owner = THIS_MODULE,
.open = zoran_open,
.read = seq_read,
.write = zoran_write,
@ -195,10 +196,8 @@ zoran_proc_init (struct zoran *zr)
char name[8];
snprintf(name, 7, "zoran%d", zr->id);
if ((zr->zoran_proc = create_proc_entry(name, 0, NULL))) {
zr->zoran_proc->data = zr;
zr->zoran_proc->owner = THIS_MODULE;
zr->zoran_proc->proc_fops = &zoran_operations;
zr->zoran_proc = proc_create_data(name, 0, NULL, &zoran_operations, zr);
if (zr->zoran_proc != NULL) {
dprintk(2,
KERN_INFO
"%s: procfs entry /proc/%s allocated. data=%p\n",

View file

@ -1893,13 +1893,11 @@ static int i2o_proc_create_entries(struct proc_dir_entry *dir,
struct proc_dir_entry *tmp;
while (i2o_pe->name) {
tmp = create_proc_entry(i2o_pe->name, i2o_pe->mode, dir);
tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir,
i2o_pe->fops, data);
if (!tmp)
return -1;
tmp->data = data;
tmp->proc_fops = i2o_pe->fops;
i2o_pe++;
}

View file

@ -210,13 +210,10 @@ static int hdpu_cpustate_probe(struct platform_device *pdev)
return ret;
}
proc_de = create_proc_entry("sky_cpustate", 0666, NULL);
proc_de = proc_create("sky_cpustate", 0666, NULL, &proc_cpustate);
if (!proc_de) {
printk(KERN_WARNING "sky_cpustate: "
"Unable to create proc entry\n");
} else {
proc_de->proc_fops = &proc_cpustate;
proc_de->owner = THIS_MODULE;
}
printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n");

View file

@ -102,22 +102,17 @@ static int hdpu_nexus_probe(struct platform_device *pdev)
printk(KERN_ERR "sky_nexus: Could not map slot id\n");
}
hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, NULL);
if (!hdpu_slot_id)
hdpu_slot_id = proc_create("sky_slot_id", 0666, NULL, &proc_slot_id);
if (!hdpu_slot_id) {
printk(KERN_WARNING "sky_nexus: "
"Unable to create proc dir entry: sky_slot_id\n");
} else {
hdpu_slot_id->proc_fops = &proc_slot_id;
hdpu_slot_id->owner = THIS_MODULE;
}
hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, NULL);
hdpu_chassis_id = proc_create("sky_chassis_id", 0666, NULL,
&proc_chassis_id);
if (!hdpu_chassis_id)
printk(KERN_WARNING "sky_nexus: "
"Unable to create proc dir entry: sky_chassis_id\n");
} else {
hdpu_chassis_id->proc_fops = &proc_chassis_id;
hdpu_chassis_id->owner = THIS_MODULE;
}
return 0;

View file

@ -293,6 +293,7 @@ static int proc_bus_pci_release(struct inode *inode, struct file *file)
#endif /* HAVE_PCI_MMAP */
static const struct file_operations proc_bus_pci_operations = {
.owner = THIS_MODULE,
.llseek = proc_bus_pci_lseek,
.read = proc_bus_pci_read,
.write = proc_bus_pci_write,
@ -406,11 +407,10 @@ int pci_proc_attach_device(struct pci_dev *dev)
}
sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
e = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir);
e = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir,
&proc_bus_pci_operations, dev);
if (!e)
return -ENOMEM;
e->proc_fops = &proc_bus_pci_operations;
e->data = dev;
e->size = dev->cfg_size;
dev->procent = e;
@ -462,6 +462,7 @@ static int proc_bus_pci_dev_open(struct inode *inode, struct file *file)
return seq_open(file, &proc_bus_pci_devices_op);
}
static const struct file_operations proc_bus_pci_dev_operations = {
.owner = THIS_MODULE,
.open = proc_bus_pci_dev_open,
.read = seq_read,
.llseek = seq_lseek,
@ -470,12 +471,10 @@ static const struct file_operations proc_bus_pci_dev_operations = {
static int __init pci_proc_init(void)
{
struct proc_dir_entry *entry;
struct pci_dev *dev = NULL;
proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
entry = create_proc_entry("devices", 0, proc_bus_pci_dir);
if (entry)
entry->proc_fops = &proc_bus_pci_dev_operations;
proc_create("devices", 0, proc_bus_pci_dir,
&proc_bus_pci_dev_operations);
proc_initialized = 1;
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
pci_proc_attach_device(dev);

View file

@ -85,6 +85,7 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
}
static const struct file_operations isapnp_proc_bus_file_operations = {
.owner = THIS_MODULE,
.llseek = isapnp_proc_bus_lseek,
.read = isapnp_proc_bus_read,
};
@ -102,12 +103,10 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
return -ENOMEM;
}
sprintf(name, "%02x", dev->number);
e = dev->procent = create_proc_entry(name, S_IFREG | S_IRUGO, de);
e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de,
&isapnp_proc_bus_file_operations, dev);
if (!e)
return -ENOMEM;
e->proc_fops = &isapnp_proc_bus_file_operations;
e->owner = THIS_MODULE;
e->data = dev;
e->size = 256;
return 0;
}

View file

@ -108,12 +108,10 @@ void rtc_proc_add_device(struct rtc_device *rtc)
if (rtc->id == 0) {
struct proc_dir_entry *ent;
ent = create_proc_entry("driver/rtc", 0, NULL);
if (ent) {
ent->proc_fops = &rtc_proc_fops;
ent = proc_create_data("driver/rtc", 0, NULL,
&rtc_proc_fops, rtc);
if (ent)
ent->owner = rtc->owner;
ent->data = rtc;
}
}
}