[PATCH 15/29] usb: use non-racy method for proc entries creation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Denis V. Lunev
Date: Tuesday, April 8, 2008 - 4:19 am

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>
---
 drivers/usb/gadget/at91_udc.c |   11 ++---------
 drivers/usb/gadget/omap_udc.c |    7 ++-----
 drivers/usb/host/sl811-hcd.c  |   10 +---------
 3 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 6ba0ca5..3fdff1e 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -231,6 +231,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations proc_ops = {
+	.owner		= THIS_MODULE,
 	.open		= proc_udc_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
@@ -239,15 +240,7 @@ static const struct file_operations proc_ops = {
 
 static void create_debug_file(struct at91_udc *udc)
 {
-	struct proc_dir_entry *pde;
-
-	pde = create_proc_entry (debug_filename, 0, NULL);
-	udc->pde = pde;
-	if (pde == NULL)
-		return;
-
-	pde->proc_fops = &proc_ops;
-	pde->data = udc;
+	udc->pde = proc_create_data(debug_filename, 0, NULL, &proc_ops, udc);
 }
 
 static void remove_debug_file(struct at91_udc *udc)
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 49de9d7..ab0d5eb 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2504,6 +2504,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations proc_ops = {
+	.owner		= THIS_MODULE,
 	.open		= proc_udc_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
@@ -2512,11 +2513,7 @@ static const struct file_operations proc_ops = {
 
 static void create_proc_file(void)
 {
-	struct proc_dir_entry *pde;
-
-	pde = create_proc_entry (proc_filename, 0, NULL);
-	if (pde)
-		pde->proc_fops = &proc_ops;
+	proc_create(proc_filename, 0, NULL, &proc_ops);
 }
 
 static void remove_proc_file(void)
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index ec349d4..7397d37 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1505,15 +1505,7 @@ static const char proc_filename[] = "driver/sl811h";
 
 static void create_debug_file(struct sl811 *sl811)
 {
-	struct proc_dir_entry *pde;
-
-	pde = create_proc_entry(proc_filename, 0, NULL);
-	if (pde == NULL)
-		return;
-
-	pde->proc_fops = &proc_ops;
-	pde->data = sl811;
-	sl811->pde = pde;
+	sl811->pde = proc_create_data(proc_filename, 0, NULL, &proc_ops, sl811);
 }
 
 static void remove_debug_file(struct sl811 *sl811)
-- 
1.5.3.rc5

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/29] proc entries creation race, Denis V. Lunev, (Tue Apr 8, 4:18 am)
[PATCH 15/29] usb: use non-racy method for proc entries cr ..., Denis V. Lunev, (Tue Apr 8, 4:19 am)
[patch, -git] isdn: hysdn_procconf.c build fix, Ingo Molnar, (Wed Apr 30, 10:57 am)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Andrew Morton, (Wed Apr 30, 11:10 am)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Ingo Molnar, (Wed Apr 30, 11:30 am)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Andrew Morton, (Wed Apr 30, 11:47 am)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Denis V. Lunev, (Wed Apr 30, 12:03 pm)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Andrew Morton, (Wed Apr 30, 12:14 pm)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Harvey Harrison, (Wed Apr 30, 12:24 pm)
Re: [patch, -git] isdn: hysdn_procconf.c build fix, Alexey Dobriyan, (Wed Apr 30, 2:21 pm)