aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-29 04:02:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:22 -0400
commita95609cb0283a23e519e607ff9fc2a4aa77e2532 (patch)
tree053d411aa27dafead6326a70d0ca3482bd2d0494 /drivers
parentcf7acfab032ff262f42954328cdfd20a5d9aaaac (diff)
netdev: use non-racy method for proc entries creation
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: Jeff Garzik <jgarzik@pobox.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bonding/bond_main.c9
-rw-r--r--drivers/net/ibmveth.c9
-rw-r--r--drivers/net/irda/vlsi_ir.c5
-rw-r--r--drivers/net/pppoe.c4
-rw-r--r--drivers/net/pppol2tp.c4
-rw-r--r--drivers/net/wireless/airo.c84
6 files changed, 43 insertions, 72 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6e91b4b7aabb..6425603bc379 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3282,17 +3282,14 @@ static int bond_create_proc_entry(struct bonding *bond)
3282 struct net_device *bond_dev = bond->dev; 3282 struct net_device *bond_dev = bond->dev;
3283 3283
3284 if (bond_proc_dir) { 3284 if (bond_proc_dir) {
3285 bond->proc_entry = create_proc_entry(bond_dev->name, 3285 bond->proc_entry = proc_create_data(bond_dev->name,
3286 S_IRUGO, 3286 S_IRUGO, bond_proc_dir,
3287 bond_proc_dir); 3287 &bond_info_fops, bond);
3288 if (bond->proc_entry == NULL) { 3288 if (bond->proc_entry == NULL) {
3289 printk(KERN_WARNING DRV_NAME 3289 printk(KERN_WARNING DRV_NAME
3290 ": Warning: Cannot create /proc/net/%s/%s\n", 3290 ": Warning: Cannot create /proc/net/%s/%s\n",
3291 DRV_NAME, bond_dev->name); 3291 DRV_NAME, bond_dev->name);
3292 } else { 3292 } else {
3293 bond->proc_entry->data = bond;
3294 bond->proc_entry->proc_fops = &bond_info_fops;
3295 bond->proc_entry->owner = THIS_MODULE;
3296 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ); 3293 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
3297 } 3294 }
3298 } 3295 }
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index ce4fc2ec2fe4..00527805e4f1 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1302,13 +1302,10 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
1302 if (ibmveth_proc_dir) { 1302 if (ibmveth_proc_dir) {
1303 char u_addr[10]; 1303 char u_addr[10];
1304 sprintf(u_addr, "%x", adapter->vdev->unit_address); 1304 sprintf(u_addr, "%x", adapter->vdev->unit_address);
1305 entry = create_proc_entry(u_addr, S_IFREG, ibmveth_proc_dir); 1305 entry = proc_create_data(u_addr, S_IFREG, ibmveth_proc_dir,
1306 if (!entry) { 1306 &ibmveth_proc_fops, adapter);
1307 if (!entry)
1307 ibmveth_error_printk("Cannot create adapter proc entry"); 1308 ibmveth_error_printk("Cannot create adapter proc entry");
1308 } else {
1309 entry->data = (void *) adapter;
1310 entry->proc_fops = &ibmveth_proc_fops;
1311 }
1312 } 1309 }
1313 return; 1310 return;
1314} 1311}
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index acd082a96a4f..d15e00b8591e 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1674,13 +1674,12 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1674 if (vlsi_proc_root != NULL) { 1674 if (vlsi_proc_root != NULL) {
1675 struct proc_dir_entry *ent; 1675 struct proc_dir_entry *ent;
1676 1676
1677 ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root); 1677 ent = proc_create_data(ndev->name, S_IFREG|S_IRUGO,
1678 vlsi_proc_root, VLSI_PROC_FOPS, ndev);
1678 if (!ent) { 1679 if (!ent) {
1679 IRDA_WARNING("%s: failed to create proc entry\n", 1680 IRDA_WARNING("%s: failed to create proc entry\n",
1680 __FUNCTION__); 1681 __FUNCTION__);
1681 } else { 1682 } else {
1682 ent->data = ndev;
1683 ent->proc_fops = VLSI_PROC_FOPS;
1684 ent->size = 0; 1683 ent->size = 0;
1685 } 1684 }
1686 idev->proc_entry = ent; 1685 idev->proc_entry = ent;
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 4fad4ddb3504..58a26a47af29 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -1052,11 +1052,9 @@ static int __init pppoe_proc_init(void)
1052{ 1052{
1053 struct proc_dir_entry *p; 1053 struct proc_dir_entry *p;
1054 1054
1055 p = create_proc_entry("pppoe", S_IRUGO, init_net.proc_net); 1055 p = proc_net_fops_create(&init_net, "pppoe", S_IRUGO, &pppoe_seq_fops);
1056 if (!p) 1056 if (!p)
1057 return -ENOMEM; 1057 return -ENOMEM;
1058
1059 p->proc_fops = &pppoe_seq_fops;
1060 return 0; 1058 return 0;
1061} 1059}
1062#else /* CONFIG_PROC_FS */ 1060#else /* CONFIG_PROC_FS */
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 3d10ca050b79..244d7830c92a 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -2469,12 +2469,12 @@ static int __init pppol2tp_init(void)
2469 goto out_unregister_pppol2tp_proto; 2469 goto out_unregister_pppol2tp_proto;
2470 2470
2471#ifdef CONFIG_PROC_FS 2471#ifdef CONFIG_PROC_FS
2472 pppol2tp_proc = create_proc_entry("pppol2tp", 0, init_net.proc_net); 2472 pppol2tp_proc = proc_net_fops_create(&init_net, "pppol2tp", 0,
2473 &pppol2tp_proc_fops);
2473 if (!pppol2tp_proc) { 2474 if (!pppol2tp_proc) {
2474 err = -ENOMEM; 2475 err = -ENOMEM;
2475 goto out_unregister_pppox_proto; 2476 goto out_unregister_pppox_proto;
2476 } 2477 }
2477 pppol2tp_proc->proc_fops = &pppol2tp_proc_fops;
2478#endif /* CONFIG_PROC_FS */ 2478#endif /* CONFIG_PROC_FS */
2479 printk(KERN_INFO "PPPoL2TP kernel driver, %s\n", 2479 printk(KERN_INFO "PPPoL2TP kernel driver, %s\n",
2480 PPPOL2TP_DRV_VERSION); 2480 PPPOL2TP_DRV_VERSION);
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 6c395fcece58..d263eee2652a 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4347,24 +4347,28 @@ static int proc_config_open( struct inode *inode, struct file *file );
4347static int proc_wepkey_open( struct inode *inode, struct file *file ); 4347static int proc_wepkey_open( struct inode *inode, struct file *file );
4348 4348
4349static const struct file_operations proc_statsdelta_ops = { 4349static const struct file_operations proc_statsdelta_ops = {
4350 .owner = THIS_MODULE,
4350 .read = proc_read, 4351 .read = proc_read,
4351 .open = proc_statsdelta_open, 4352 .open = proc_statsdelta_open,
4352 .release = proc_close 4353 .release = proc_close
4353}; 4354};
4354 4355
4355static const struct file_operations proc_stats_ops = { 4356static const struct file_operations proc_stats_ops = {
4357 .owner = THIS_MODULE,
4356 .read = proc_read, 4358 .read = proc_read,
4357 .open = proc_stats_open, 4359 .open = proc_stats_open,
4358 .release = proc_close 4360 .release = proc_close
4359}; 4361};
4360 4362
4361static const struct file_operations proc_status_ops = { 4363static const struct file_operations proc_status_ops = {
4364 .owner = THIS_MODULE,
4362 .read = proc_read, 4365 .read = proc_read,
4363 .open = proc_status_open, 4366 .open = proc_status_open,
4364 .release = proc_close 4367 .release = proc_close
4365}; 4368};
4366 4369
4367static const struct file_operations proc_SSID_ops = { 4370static const struct file_operations proc_SSID_ops = {
4371 .owner = THIS_MODULE,
4368 .read = proc_read, 4372 .read = proc_read,
4369 .write = proc_write, 4373 .write = proc_write,
4370 .open = proc_SSID_open, 4374 .open = proc_SSID_open,
@@ -4372,6 +4376,7 @@ static const struct file_operations proc_SSID_ops = {
4372}; 4376};
4373 4377
4374static const struct file_operations proc_BSSList_ops = { 4378static const struct file_operations proc_BSSList_ops = {
4379 .owner = THIS_MODULE,
4375 .read = proc_read, 4380 .read = proc_read,
4376 .write = proc_write, 4381 .write = proc_write,
4377 .open = proc_BSSList_open, 4382 .open = proc_BSSList_open,
@@ -4379,6 +4384,7 @@ static const struct file_operations proc_BSSList_ops = {
4379}; 4384};
4380 4385
4381static const struct file_operations proc_APList_ops = { 4386static const struct file_operations proc_APList_ops = {
4387 .owner = THIS_MODULE,
4382 .read = proc_read, 4388 .read = proc_read,
4383 .write = proc_write, 4389 .write = proc_write,
4384 .open = proc_APList_open, 4390 .open = proc_APList_open,
@@ -4386,6 +4392,7 @@ static const struct file_operations proc_APList_ops = {
4386}; 4392};
4387 4393
4388static const struct file_operations proc_config_ops = { 4394static const struct file_operations proc_config_ops = {
4395 .owner = THIS_MODULE,
4389 .read = proc_read, 4396 .read = proc_read,
4390 .write = proc_write, 4397 .write = proc_write,
4391 .open = proc_config_open, 4398 .open = proc_config_open,
@@ -4393,6 +4400,7 @@ static const struct file_operations proc_config_ops = {
4393}; 4400};
4394 4401
4395static const struct file_operations proc_wepkey_ops = { 4402static const struct file_operations proc_wepkey_ops = {
4403 .owner = THIS_MODULE,
4396 .read = proc_read, 4404 .read = proc_read,
4397 .write = proc_write, 4405 .write = proc_write,
4398 .open = proc_wepkey_open, 4406 .open = proc_wepkey_open,
@@ -4411,10 +4419,6 @@ struct proc_data {
4411 void (*on_close) (struct inode *, struct file *); 4419 void (*on_close) (struct inode *, struct file *);
4412}; 4420};
4413 4421
4414#ifndef SETPROC_OPS
4415#define SETPROC_OPS(entry, ops) (entry)->proc_fops = &(ops)
4416#endif
4417
4418static int setup_proc_entry( struct net_device *dev, 4422static int setup_proc_entry( struct net_device *dev,
4419 struct airo_info *apriv ) { 4423 struct airo_info *apriv ) {
4420 struct proc_dir_entry *entry; 4424 struct proc_dir_entry *entry;
@@ -4430,100 +4434,76 @@ static int setup_proc_entry( struct net_device *dev,
4430 apriv->proc_entry->owner = THIS_MODULE; 4434 apriv->proc_entry->owner = THIS_MODULE;
4431 4435
4432 /* Setup the StatsDelta */ 4436 /* Setup the StatsDelta */
4433 entry = create_proc_entry("StatsDelta", 4437 entry = proc_create_data("StatsDelta",
4434 S_IFREG | (S_IRUGO&proc_perm), 4438 S_IFREG | (S_IRUGO&proc_perm),
4435 apriv->proc_entry); 4439 apriv->proc_entry, &proc_statsdelta_ops, dev);
4436 if (!entry) 4440 if (!entry)
4437 goto fail_stats_delta; 4441 goto fail_stats_delta;
4438 entry->uid = proc_uid; 4442 entry->uid = proc_uid;
4439 entry->gid = proc_gid; 4443 entry->gid = proc_gid;
4440 entry->data = dev;
4441 entry->owner = THIS_MODULE;
4442 SETPROC_OPS(entry, proc_statsdelta_ops);
4443 4444
4444 /* Setup the Stats */ 4445 /* Setup the Stats */
4445 entry = create_proc_entry("Stats", 4446 entry = proc_create_data("Stats",
4446 S_IFREG | (S_IRUGO&proc_perm), 4447 S_IFREG | (S_IRUGO&proc_perm),
4447 apriv->proc_entry); 4448 apriv->proc_entry, &proc_stats_ops, dev);
4448 if (!entry) 4449 if (!entry)
4449 goto fail_stats; 4450 goto fail_stats;
4450 entry->uid = proc_uid; 4451 entry->uid = proc_uid;
4451 entry->gid = proc_gid; 4452 entry->gid = proc_gid;
4452 entry->data = dev;
4453 entry->owner = THIS_MODULE;
4454 SETPROC_OPS(entry, proc_stats_ops);
4455 4453
4456 /* Setup the Status */ 4454 /* Setup the Status */
4457 entry = create_proc_entry("Status", 4455 entry = proc_create_data("Status",
4458 S_IFREG | (S_IRUGO&proc_perm), 4456 S_IFREG | (S_IRUGO&proc_perm),
4459 apriv->proc_entry); 4457 apriv->proc_entry, &proc_status_ops, dev);
4460 if (!entry) 4458 if (!entry)
4461 goto fail_status; 4459 goto fail_status;
4462 entry->uid = proc_uid; 4460 entry->uid = proc_uid;
4463 entry->gid = proc_gid; 4461 entry->gid = proc_gid;
4464 entry->data = dev;
4465 entry->owner = THIS_MODULE;
4466 SETPROC_OPS(entry, proc_status_ops);
4467 4462
4468 /* Setup the Config */ 4463 /* Setup the Config */
4469 entry = create_proc_entry("Config", 4464 entry = proc_create_data("Config",
4470 S_IFREG | proc_perm, 4465 S_IFREG | proc_perm,
4471 apriv->proc_entry); 4466 apriv->proc_entry, &proc_config_ops, dev);
4472 if (!entry) 4467 if (!entry)
4473 goto fail_config; 4468 goto fail_config;
4474 entry->uid = proc_uid; 4469 entry->uid = proc_uid;
4475 entry->gid = proc_gid; 4470 entry->gid = proc_gid;
4476 entry->data = dev;
4477 entry->owner = THIS_MODULE;
4478 SETPROC_OPS(entry, proc_config_ops);
4479 4471
4480 /* Setup the SSID */ 4472 /* Setup the SSID */
4481 entry = create_proc_entry("SSID", 4473 entry = proc_create_data("SSID",
4482 S_IFREG | proc_perm, 4474 S_IFREG | proc_perm,
4483 apriv->proc_entry); 4475 apriv->proc_entry, &proc_SSID_ops, dev);
4484 if (!entry) 4476 if (!entry)
4485 goto fail_ssid; 4477 goto fail_ssid;
4486 entry->uid = proc_uid; 4478 entry->uid = proc_uid;
4487 entry->gid = proc_gid; 4479 entry->gid = proc_gid;
4488 entry->data = dev;
4489 entry->owner = THIS_MODULE;
4490 SETPROC_OPS(entry, proc_SSID_ops);
4491 4480
4492 /* Setup the APList */ 4481 /* Setup the APList */
4493 entry = create_proc_entry("APList", 4482 entry = proc_create_data("APList",
4494 S_IFREG | proc_perm, 4483 S_IFREG | proc_perm,
4495 apriv->proc_entry); 4484 apriv->proc_entry, &proc_APList_ops, dev);
4496 if (!entry) 4485 if (!entry)
4497 goto fail_aplist; 4486 goto fail_aplist;
4498 entry->uid = proc_uid; 4487 entry->uid = proc_uid;
4499 entry->gid = proc_gid; 4488 entry->gid = proc_gid;
4500 entry->data = dev;
4501 entry->owner = THIS_MODULE;
4502 SETPROC_OPS(entry, proc_APList_ops);
4503 4489
4504 /* Setup the BSSList */ 4490 /* Setup the BSSList */
4505 entry = create_proc_entry("BSSList", 4491 entry = proc_create_data("BSSList",
4506 S_IFREG | proc_perm, 4492 S_IFREG | proc_perm,
4507 apriv->proc_entry); 4493 apriv->proc_entry, &proc_BSSList_ops, dev);
4508 if (!entry) 4494 if (!entry)
4509 goto fail_bsslist; 4495 goto fail_bsslist;
4510 entry->uid = proc_uid; 4496 entry->uid = proc_uid;
4511 entry->gid = proc_gid; 4497 entry->gid = proc_gid;
4512 entry->data = dev;
4513 entry->owner = THIS_MODULE;
4514 SETPROC_OPS(entry, proc_BSSList_ops);
4515 4498
4516 /* Setup the WepKey */ 4499 /* Setup the WepKey */
4517 entry = create_proc_entry("WepKey", 4500 entry = proc_create_data("WepKey",
4518 S_IFREG | proc_perm, 4501 S_IFREG | proc_perm,
4519 apriv->proc_entry); 4502 apriv->proc_entry, &proc_wepkey_ops, dev);
4520 if (!entry) 4503 if (!entry)
4521 goto fail_wepkey; 4504 goto fail_wepkey;
4522 entry->uid = proc_uid; 4505 entry->uid = proc_uid;
4523 entry->gid = proc_gid; 4506 entry->gid = proc_gid;
4524 entry->data = dev;
4525 entry->owner = THIS_MODULE;
4526 SETPROC_OPS(entry, proc_wepkey_ops);
4527 4507
4528 return 0; 4508 return 0;
4529 4509