Commit 6bc8a393 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/jgarzik/irda-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents 2511765d 3c8b5914
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* vlsi_ir.c: VLSI82C147 PCI IrDA controller driver for Linux * vlsi_ir.c: VLSI82C147 PCI IrDA controller driver for Linux
* *
* Copyright (c) 2001-2002 Martin Diehl * Copyright (c) 2001-2003 Martin Diehl
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
...@@ -28,7 +28,7 @@ MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>"); ...@@ -28,7 +28,7 @@ MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
#define DRIVER_NAME "vlsi_ir" #define DRIVER_NAME "vlsi_ir"
#define DRIVER_VERSION "v0.4" #define DRIVER_VERSION "v0.4a"
/********************************************************/ /********************************************************/
...@@ -149,6 +149,9 @@ static void vlsi_ring_debug(struct vlsi_ring *r) ...@@ -149,6 +149,9 @@ static void vlsi_ring_debug(struct vlsi_ring *r)
/********************************************************/ /********************************************************/
/* needed regardless of CONFIG_PROC_FS */
static struct proc_dir_entry *vlsi_proc_root = NULL;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int vlsi_proc_pdev(struct pci_dev *pdev, char *buf, int len) static int vlsi_proc_pdev(struct pci_dev *pdev, char *buf, int len)
...@@ -394,8 +397,6 @@ static int vlsi_proc_print(struct net_device *ndev, char *buf, int len) ...@@ -394,8 +397,6 @@ static int vlsi_proc_print(struct net_device *ndev, char *buf, int len)
return out - buf; return out - buf;
} }
static struct proc_dir_entry *vlsi_proc_root = NULL;
struct vlsi_proc_data { struct vlsi_proc_data {
int size; int size;
char *data; char *data;
...@@ -494,11 +495,18 @@ static int vlsi_proc_release(struct inode *inode, struct file *file) ...@@ -494,11 +495,18 @@ static int vlsi_proc_release(struct inode *inode, struct file *file)
} }
static struct file_operations vlsi_proc_fops = { static struct file_operations vlsi_proc_fops = {
/* protect individual procdir file entry against rmmod */
.owner = THIS_MODULE,
.open = vlsi_proc_open, .open = vlsi_proc_open,
.llseek = vlsi_proc_lseek, .llseek = vlsi_proc_lseek,
.read = vlsi_proc_read, .read = vlsi_proc_read,
.release = vlsi_proc_release, .release = vlsi_proc_release,
}; };
#define VLSI_PROC_FOPS (&vlsi_proc_fops)
#else /* CONFIG_PROC_FS */
#define VLSI_PROC_FOPS NULL
#endif #endif
/********************************************************/ /********************************************************/
...@@ -1800,8 +1808,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1800,8 +1808,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_freedev; goto out_freedev;
} }
#ifdef CONFIG_PROC_FS if (vlsi_proc_root != NULL) {
{
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root); ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root);
...@@ -1810,11 +1817,11 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1810,11 +1817,11 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_unregister; goto out_unregister;
} }
ent->data = ndev; ent->data = ndev;
ent->proc_fops = &vlsi_proc_fops; ent->proc_fops = VLSI_PROC_FOPS;
ent->size = 0; ent->size = 0;
idev->proc_entry = ent; idev->proc_entry = ent;
} } else
#endif idev->proc_entry = NULL;
printk(KERN_INFO "%s: registered device %s\n", drivername, ndev->name); printk(KERN_INFO "%s: registered device %s\n", drivername, ndev->name);
...@@ -1851,12 +1858,10 @@ static void __devexit vlsi_irda_remove(struct pci_dev *pdev) ...@@ -1851,12 +1858,10 @@ static void __devexit vlsi_irda_remove(struct pci_dev *pdev)
down(&idev->sem); down(&idev->sem);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
pci_disable_device(pdev); pci_disable_device(pdev);
#ifdef CONFIG_PROC_FS
if (idev->proc_entry) { if (idev->proc_entry) {
remove_proc_entry(ndev->name, vlsi_proc_root); remove_proc_entry(ndev->name, vlsi_proc_root);
idev->proc_entry = NULL; idev->proc_entry = NULL;
} }
#endif
up(&idev->sem); up(&idev->sem);
unregister_netdev(ndev); unregister_netdev(ndev);
...@@ -1993,9 +1998,7 @@ static struct pci_driver vlsi_irda_driver = { ...@@ -1993,9 +1998,7 @@ static struct pci_driver vlsi_irda_driver = {
#endif #endif
}; };
#ifdef CONFIG_PROC_FS
#define PROC_DIR ("driver/" DRIVER_NAME) #define PROC_DIR ("driver/" DRIVER_NAME)
#endif
static int __init vlsi_mod_init(void) static int __init vlsi_mod_init(void)
{ {
...@@ -2025,18 +2028,23 @@ static int __init vlsi_mod_init(void) ...@@ -2025,18 +2028,23 @@ static int __init vlsi_mod_init(void)
sirpulse = !!sirpulse; sirpulse = !!sirpulse;
#ifdef CONFIG_PROC_FS /* create_proc_entry returns NULL if !CONFIG_PROC_FS.
* Failure to create the procfs entry is handled like running
* without procfs - it's not required for the driver to work.
*/
vlsi_proc_root = create_proc_entry(PROC_DIR, S_IFDIR, 0); vlsi_proc_root = create_proc_entry(PROC_DIR, S_IFDIR, 0);
if (!vlsi_proc_root) if (vlsi_proc_root) {
return -ENOMEM; /* protect registered procdir against module removal.
#endif * Because we are in the module init path there's no race
* window after create_proc_entry (and no barrier needed).
*/
vlsi_proc_root->owner = THIS_MODULE;
}
ret = pci_module_init(&vlsi_irda_driver); ret = pci_module_init(&vlsi_irda_driver);
#ifdef CONFIG_PROC_FS if (ret && vlsi_proc_root)
if (ret)
remove_proc_entry(PROC_DIR, 0); remove_proc_entry(PROC_DIR, 0);
#endif
return ret; return ret;
} }
...@@ -2044,6 +2052,7 @@ static int __init vlsi_mod_init(void) ...@@ -2044,6 +2052,7 @@ static int __init vlsi_mod_init(void)
static void __exit vlsi_mod_exit(void) static void __exit vlsi_mod_exit(void)
{ {
pci_unregister_driver(&vlsi_irda_driver); pci_unregister_driver(&vlsi_irda_driver);
if (vlsi_proc_root)
remove_proc_entry(PROC_DIR, 0); remove_proc_entry(PROC_DIR, 0);
} }
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* *
* vlsi_ir.h: VLSI82C147 PCI IrDA controller driver for Linux * vlsi_ir.h: VLSI82C147 PCI IrDA controller driver for Linux
* *
* Version: 0.4 * Version: 0.4a
* *
* Copyright (c) 2001-2002 Martin Diehl * Copyright (c) 2001-2003 Martin Diehl
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
...@@ -730,9 +730,7 @@ typedef struct vlsi_irda_dev { ...@@ -730,9 +730,7 @@ typedef struct vlsi_irda_dev {
u32 cfg_space[64/sizeof(u32)]; u32 cfg_space[64/sizeof(u32)];
u8 resume_ok; u8 resume_ok;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_entry; struct proc_dir_entry *proc_entry;
#endif
} vlsi_irda_dev_t; } vlsi_irda_dev_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment