浏览代码

usb: 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>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
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>
Denis V. Lunev 17 年之前
父节点
当前提交
cdefa185dd
共有 3 个文件被更改,包括 5 次插入23 次删除
  1. 2 9
      drivers/usb/gadget/at91_udc.c
  2. 2 5
      drivers/usb/gadget/omap_udc.c
  3. 1 9
      drivers/usb/host/sl811-hcd.c

+ 2 - 9
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 = {
 static const struct file_operations proc_ops = {
+	.owner		= THIS_MODULE,
 	.open		= proc_udc_open,
 	.open		= proc_udc_open,
 	.read		= seq_read,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
 	.llseek		= seq_lseek,
@@ -239,15 +240,7 @@ static const struct file_operations proc_ops = {
 
 
 static void create_debug_file(struct at91_udc *udc)
 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)
 static void remove_debug_file(struct at91_udc *udc)

+ 2 - 5
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 = {
 static const struct file_operations proc_ops = {
+	.owner		= THIS_MODULE,
 	.open		= proc_udc_open,
 	.open		= proc_udc_open,
 	.read		= seq_read,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
 	.llseek		= seq_lseek,
@@ -2512,11 +2513,7 @@ static const struct file_operations proc_ops = {
 
 
 static void create_proc_file(void)
 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)
 static void remove_proc_file(void)

+ 1 - 9
drivers/usb/host/sl811-hcd.c

@@ -1506,15 +1506,7 @@ static const char proc_filename[] = "driver/sl811h";
 
 
 static void create_debug_file(struct sl811 *sl811)
 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)
 static void remove_debug_file(struct sl811 *sl811)