diff options
| author | Dave Jones <davej@tetrachloride.(none)> | 2002-12-30 08:06:22 -0100 |
|---|---|---|
| committer | Dave Jones <davej@tetrachloride.(none)> | 2002-12-30 08:06:22 -0100 |
| commit | 3b1b68d9bbe97dbdb8da3b9647838bb90ea408f3 (patch) | |
| tree | ef33b8acae4a1e197148ed68897cfdbde1c58aa5 | |
| parent | b55d39b2e06021717d248351a86b7366116ef117 (diff) | |
| parent | bec7aa00ffe5b1270837b965fdfe80be3e8e6e2e (diff) | |
Merge tetrachloride.(none):/mnt/stuff/kernel/2.5/bk-linus
into tetrachloride.(none):/mnt/stuff/kernel/2.5/agpgart
120 files changed, 703 insertions, 1396 deletions
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig index dc780d28f1c4..ddaf6c1e0b16 100644 --- a/arch/i386/Kconfig +++ b/arch/i386/Kconfig @@ -43,13 +43,13 @@ choice default PC config PC - bool PC + bool "IBM PC (and compatible)" help Choose this option if your computer is a standard PC or compatible. config VOYAGER - bool "NCR Voyager Architecture" - ---help--- + bool "NCR Voyager" + help Voyager is a MCA based 32 way capable SMP architecture proprietary to NCR Corp. Machine classes 345x/35xx/4100/51xx are voyager based. @@ -58,9 +58,35 @@ config VOYAGER If you do not specifically know you have a Voyager based machine, say N here otherwise the kernel you build will not be bootable. +config X86_NUMAQ + bool "IBM/Sequent NUMAQ" + help + This option is used for getting Linux to run on a (IBM/Sequent) NUMA + multiquad box. This changes the way that processors are bootstrapped, + and uses Clustered Logical APIC addressing mode instead of Flat Logical. + You will need a new lynxer.elf file to flash your firmware with - send + email to Martin.Bligh@us.ibm.com + +config X86_SUMMIT + bool "IBM x440 (Summit/EXA)" + help + This option is needed for IBM systems that use the Summit/EXA chipset. + In particular, it is needed for the x440. + + If you don't have one of these computers, you should say N here. + # Visual Workstation support is utterly broken. # If you want to see it working mail an VW540 to hch@infradead.org 8) -#bool 'SGI Visual Workstation support' CONFIG_VISWS +#config X86_VISWS +# bool "SGI 320/540 (Visual Workstation)" +# help +# The SGI Visual Workstation series is an IA32-based workstation +# based on SGI systems chips with some legacy PC hardware attached. +# +# Say Y here to create a kernel to run on the SGI 320 or 540. +# +# A kernel compiled for the Visual Workstation will not run on PCs +# and vice versa. See <file:Documentation/sgi-visws.txt> for details. endchoice @@ -430,33 +456,9 @@ config NR_CPUS This is purely to save memory - each supported CPU adds approximately eight kilobytes to the kernel image. -config X86_NUMA - bool "Multi-node NUMA system support" - depends on SMP - -#Platform Choices -config X86_NUMAQ - bool "Multiquad (IBM/Sequent) NUMAQ support" - depends on X86_NUMA - help - This option is used for getting Linux to run on a (IBM/Sequent) NUMA - multiquad box. This changes the way that processors are bootstrapped, - and uses Clustered Logical APIC addressing mode instead of Flat Logical. - You will need a new lynxer.elf file to flash your firmware with - send - email to Martin.Bligh@us.ibm.com - -config X86_SUMMIT - bool "IBM x440 (Summit/EXA) support" - depends on X86_NUMA - help - This option is needed for IBM systems that use the Summit/EXA chipset. - In particular, it is needed for the x440. - - If you don't have one of these computers, you should say N here. - config CLUSTERED_APIC bool - depends on X86_NUMA && (X86_NUMAQ || X86_SUMMIT) + depends on X86_NUMAQ || X86_SUMMIT default y # Common NUMA Features diff --git a/arch/i386/kernel/ioport.c b/arch/i386/kernel/ioport.c index d80fd0b70284..a795bafc6f17 100644 --- a/arch/i386/kernel/ioport.c +++ b/arch/i386/kernel/ioport.c @@ -14,6 +14,7 @@ #include <linux/smp_lock.h> #include <linux/stddef.h> #include <linux/slab.h> +#include <linux/thread_info.h> /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */ static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value) @@ -122,5 +123,7 @@ asmlinkage int sys_iopl(unsigned long unused) return -EPERM; } regs->eflags = (regs->eflags & 0xffffcfff) | (level << 12); + /* Make sure we return the long way (not sysenter) */ + set_thread_flag(TIF_SIGPENDING); return 0; } diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index fb5baa1754cc..be74791bdbe7 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -269,6 +269,7 @@ static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m) BUG(); } +#if 0 static void __init MP_translation_info (struct mpc_config_translation *m) { printk("Translation: record %d, type %d, quad %d, global %d, local %d\n", mpc_record, m->trans_type, m->trans_quad, m->trans_global, m->trans_local); @@ -327,6 +328,7 @@ static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, \ } } } +#endif /* * Read/parse the MPC diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index f5e6bb394864..1c9c7d17dcc5 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c @@ -558,8 +558,11 @@ asmlinkage int sys_execve(struct pt_regs regs) if (IS_ERR(filename)) goto out; error = do_execve(filename, (char **) regs.ecx, (char **) regs.edx, ®s); - if (error == 0) + if (error == 0) { current->ptrace &= ~PT_DTRACE; + /* Make sure we don't return using sysenter.. */ + set_thread_flag(TIF_SIGPENDING); + } putname(filename); out: return error; diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 4f0b998e9496..7c08f768281c 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c @@ -596,12 +596,14 @@ static inline void inquire_remote_apic(int apicid) } #endif -static int __init wakeup_secondary_via_NMI(int logical_apicid) +#ifdef WAKE_SECONDARY_VIA_NMI /* - * Poke the other CPU in the eye to wake it up. Remember that the normal + * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this * won't ... remember to clear down the APIC, etc later. */ +static int __init +wakeup_secondary_cpu(int logical_apicid, unsigned long start_eip) { unsigned long send_status = 0, accept_status = 0; int timeout, maxlvt; @@ -643,8 +645,11 @@ static int __init wakeup_secondary_via_NMI(int logical_apicid) return (send_status | accept_status); } +#endif /* WAKE_SECONDARY_VIA_NMI */ -static int __init wakeup_secondary_via_INIT(int phys_apicid, unsigned long start_eip) +#ifdef WAKE_SECONDARY_VIA_INIT +static int __init +wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) { unsigned long send_status = 0, accept_status = 0; int maxlvt, timeout, num_starts, j; @@ -766,6 +771,7 @@ static int __init wakeup_secondary_via_INIT(int phys_apicid, unsigned long start return (send_status | accept_status); } +#endif /* WAKE_SECONDARY_VIA_INIT */ extern unsigned long cpu_initialized; diff --git a/arch/sparc/vmlinux.lds.S b/arch/sparc/vmlinux.lds.S index e0610ed2df4c..a9343f993144 100644 --- a/arch/sparc/vmlinux.lds.S +++ b/arch/sparc/vmlinux.lds.S @@ -48,6 +48,9 @@ SECTIONS __setup_start = .; .init.setup : { *(.init.setup) } __setup_end = .; + __start___param = .; + __param : { *(__param) } + __stop___param = .; __initcall_start = .; .initcall.init : { *(.initcall1.init) diff --git a/crypto/api.c b/crypto/api.c index 626437fb5dea..64886f4d6335 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -29,8 +29,7 @@ static inline int crypto_alg_get(struct crypto_alg *alg) static inline void crypto_alg_put(struct crypto_alg *alg) { - if (alg->cra_module) - __MOD_DEC_USE_COUNT(alg->cra_module); + module_put(alg->cra_module); } struct crypto_alg *crypto_alg_lookup(const char *name) diff --git a/drivers/Makefile b/drivers/Makefile index 07c756c046b8..a6ce89683e2c 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -38,8 +38,6 @@ obj-$(CONFIG_GAMEPORT) += input/gameport/ obj-$(CONFIG_SERIO) += input/serio/ obj-$(CONFIG_I2O) += message/ obj-$(CONFIG_I2C) += i2c/ -obj-$(CONFIG_I2C_MAINBOARD) += i2c/busses/ -obj-$(CONFIG_SENSORS) += i2c/chips/ obj-$(CONFIG_PHONE) += telephony/ obj-$(CONFIG_MD) += md/ obj-$(CONFIG_BT) += bluetooth/ diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 98a62d7c7a6b..c133b454b2fb 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -168,15 +168,13 @@ retry: best = p->range; *part = dev - p->dev; if (p->lock && p->lock(dev, data) < 0) { - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); continue; } read_unlock(&gendisk_lock); disk = probe(dev, part, data); /* Currently ->owner protects _only_ ->probe() itself. */ - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); if (disk) return disk; goto retry; diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c index 3c1161767acf..0b19343f6969 100644 --- a/drivers/block/paride/paride.c +++ b/drivers/block/paride/paride.c @@ -175,8 +175,7 @@ void pi_release(PIA * pi) #endif /* !CONFIG_PARPORT */ if (pi->proto->release_proto) pi->proto->release_proto(pi); - if (pi->proto->owner) - __MOD_DEC_USE_COUNT(pi->proto->owner); + module_put(pi->proto->owner); } EXPORT_SYMBOL(pi_release); @@ -238,7 +237,6 @@ int pi_register(PIP * pr) printk("paride: protocol table full\n"); return 0; } - MOD_INC_USE_COUNT; protocols[k] = pr; pr->index = k; printk("paride: %s registered as protocol %d\n", pr->name, k); @@ -256,7 +254,6 @@ void pi_unregister(PIP * pr) return; } protocols[pr->index] = 0; - MOD_DEC_USE_COUNT; } EXPORT_SYMBOL(pi_unregister); @@ -392,14 +389,13 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode, if (!proto) continue; /* still racy */ - if (proto->owner) - __MOD_INC_USE_COUNT(proto->owner); + if (!try_module_get(proto->owner)) + continue; pi->proto = proto; pi->private = 0; if (proto->init_proto && proto->init_proto(pi) < 0) { pi->proto = NULL; - if (proto->owner) - __MOD_DEC_USE_COUNT(proto->owner); + module_put(proto->owner); continue; } if (delay == -1) @@ -432,8 +428,7 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode, } if (pi->proto->release_proto) pi->proto->release_proto(pi); - if (proto->owner) - __MOD_DEC_USE_COUNT(proto->owner); + module_put(proto->owner); } if (!pi->port) { diff --git a/drivers/char/busmouse.c b/drivers/char/busmouse.c index 29362e24aa4c..85baa0cdf51b 100644 --- a/drivers/char/busmouse.c +++ b/drivers/char/busmouse.c @@ -175,8 +175,7 @@ static int busmouse_release(struct inode *inode, struct file *file) if (--mse->active == 0) { if (mse->ops->release) ret = mse->ops->release(inode, file); - if (mse->ops->owner) - __MOD_DEC_USE_COUNT(mse->ops->owner); + module_put(mse->ops->owner); mse->ready = 0; } unlock_kernel(); @@ -207,8 +206,8 @@ static int busmouse_open(struct inode *inode, struct file *file) ret = 0; if (mse->ops->open) { ret = mse->ops->open(inode, file); - if (ret && mse->ops->owner) - __MOD_DEC_USE_COUNT(mse->ops->owner); + if (ret) + module_put(mse->ops->owner); } if (ret) diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 0e97b489d17b..e7ed88e4ac02 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -27,15 +27,6 @@ #include <asm/io.h> #include <asm/pgalloc.h> -#ifdef CONFIG_I2C_MAINBOARD -extern void i2c_mainboard_init_all(void); -#endif -#ifdef CONFIG_SENSORS -extern void sensors_init_all(void); -#endif -#ifdef CONFIG_I2C -extern int i2c_init_all(void); -#endif #ifdef CONFIG_FB extern void fbmem_init(void); #endif @@ -708,12 +699,6 @@ int __init chr_dev_init(void) printk("unable to get major %d for memory devs\n", MEM_MAJOR); memory_devfs_register(); rand_initialize(); -#ifdef CONFIG_I2C - i2c_init_all(); -#endif -#ifdef CONFIG_I2C_MAINBOARD - i2c_mainboard_init_all(); -#endif #if defined (CONFIG_FB) fbmem_init(); #endif @@ -728,10 +713,6 @@ int __init chr_dev_init(void) #if defined(CONFIG_S390_TAPE) && defined(CONFIG_S390_TAPE_CHAR) tapechar_init(); #endif -#ifdef CONFIG_SENSORS - sensors_init_all(); -#endif - return 0; } diff --git a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c index b03104c8edd1..5e4c1748b7d1 100644 --- a/drivers/hotplug/pci_hotplug_core.c +++ b/drivers/hotplug/pci_hotplug_core.c @@ -561,19 +561,19 @@ static void fs_remove_file (struct dentry *dentry) up(&parent->d_inode->i_sem); } +/* yuck, WFT is this? */ #define GET_STATUS(name,type) \ static int get_##name (struct hotplug_slot *slot, type *value) \ { \ struct hotplug_slot_ops *ops = slot->ops; \ int retval = 0; \ - if (ops->owner) \ - __MOD_INC_USE_COUNT(ops->owner); \ - if (ops->get_##name) \ - retval = ops->get_##name (slot, value); \ - else \ - *value = slot->info->name; \ - if (ops->owner) \ - __MOD_DEC_USE_COUNT(ops->owner); \ + if (try_module_get(ops->owner)) { \ + if (ops->get_##name) \ + retval = ops->get_##name (slot, value); \ + else \ + *value = slot->info->name; \ + module_put(ops->owner); \ + } \ return retval; \ } @@ -665,21 +665,19 @@ static ssize_t power_write_file (struct file *file, const char *ubuff, size_t co case 0: if (!slot->ops->disable_slot) break; - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->disable_slot(slot); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->disable_slot(slot); + module_put(slot->ops->owner); + } break; case 1: if (!slot->ops->enable_slot) break; - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->enable_slot(slot); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->enable_slot(slot); + module_put(slot->ops->owner); + } break; default: @@ -773,11 +771,10 @@ static ssize_t attention_write_file (struct file *file, const char *ubuff, size_ dbg (" - attention = %d\n", attention); if (slot->ops->set_attention_status) { - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->set_attention_status(slot, attention); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->set_attention_status(slot, attention); + module_put(slot->ops->owner); + } } exit: @@ -1011,11 +1008,10 @@ static ssize_t test_write_file (struct file *file, const char *ubuff, size_t cou dbg ("test = %d\n", test); if (slot->ops->hardware_test) { - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->hardware_test(slot, test); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->hardware_test(slot, test); + module_put(slot->ops->owner); + } } exit: diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 206f7c5f2ed4..ab26300729b2 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -166,8 +166,6 @@ config I2C_IBM_OCP_ADAP tristate "IBM on-chip I2C Adapter" depends on I2C_IBM_OCP_ALGO -# This is needed for automatic patch generation: sensors code starts here -# This is needed for automatic patch generation: sensors code ends here config I2C_CHARDEV tristate "I2C device interface" depends on I2C diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 924e971081b7..69595aa670e9 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -18,6 +18,4 @@ obj-$(CONFIG_ITE_I2C_ADAP) += i2c-adap-ite.o obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o obj-$(CONFIG_SCx200_ACB) += scx200_acb.o obj-$(CONFIG_I2C_PROC) += i2c-proc.o - -# This is needed for automatic patch generation: sensors code starts here -# This is needed for automatic patch generation: sensors code ends here +obj-y += busses/ chips/ diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index b6bf9ee09ff2..8750653989a9 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -5,22 +5,9 @@ menu "I2C Hardware Sensors Mainboard support" -config I2C_MAINBOARD - bool "Hardware sensors mainboard support" - depends on EXPERIMENTAL && I2C && I2C_PROC - help - Many modern mainboards have some kind of I2C interface integrated. This - is often in the form of a SMBus, or System Management Bus, which is - basically the same as I2C but which uses only a subset of the I2C - protocol. - - You will also want the latest user-space utilties: you can find them - in the lm_sensors package, which you can download at - http://www.lm-sensors.nu - config I2C_AMD756 tristate " AMD 756/766" - depends on I2C_MAINBOARD + depends on I2C && I2C_PROC help If you say yes to this option, support will be included for the AMD 756/766/768 mainboard I2C interfaces. @@ -37,7 +24,7 @@ config I2C_AMD756 config I2C_AMD8111 tristate " AMD 8111" - depends on I2C_MAINBOARD + depends on I2C && I2C_PROC help If you say yes to this option, support will be included for the AMD 8111 mainboard I2C interfaces. diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 75d4babc375c..181b1d97e0a9 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -2,6 +2,5 @@ # Makefile for the kernel hardware sensors bus drivers. # -obj-$(CONFIG_I2C_MAINBOARD) += i2c-mainboard.o obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index db08bdc56430..aba96ef80719 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -27,6 +27,7 @@ /* 2002-04-08: Added nForce support. (Csaba Halasz) 2002-10-03: Fixed nForce PnP I/O port. (Michael Steil) + 2002-12-28: Rewritten into something that resembles a Linux driver (hch) */ /* @@ -37,43 +38,29 @@ #include <linux/version.h> #include <linux/module.h> #include <linux/pci.h> -#include <asm/io.h> #include <linux/kernel.h> #include <linux/stddef.h> #include <linux/sched.h> #include <linux/ioport.h> #include <linux/i2c.h> #include <linux/init.h> +#include <asm/io.h> -struct sd { - const unsigned short vendor; - const unsigned short device; - const unsigned short function; - const char* name; - int amdsetup:1; -}; - -static struct sd supported[] = { - {PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_740B, 3, "AMD756", 1}, - {PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7413, 3, "AMD766", 1}, - {PCI_VENDOR_ID_AMD, 0x7443, 3, "AMD768", 1}, - {PCI_VENDOR_ID_NVIDIA, 0x01B4, 1, "nVidia nForce", 0}, - {0, 0, 0} -}; +#define DRV_NAME "i2c-amd756" /* AMD756 SMBus address offsets */ #define SMB_ADDR_OFFSET 0xE0 #define SMB_IOSIZE 16 -#define SMB_GLOBAL_STATUS (0x0 + amd756_smba) -#define SMB_GLOBAL_ENABLE (0x2 + amd756_smba) -#define SMB_HOST_ADDRESS (0x4 + amd756_smba) -#define SMB_HOST_DATA (0x6 + amd756_smba) -#define SMB_HOST_COMMAND (0x8 + amd756_smba) -#define SMB_HOST_BLOCK_DATA (0x9 + amd756_smba) -#define SMB_HAS_DATA (0xA + amd756_smba) -#define SMB_HAS_DEVICE_ADDRESS (0xC + amd756_smba) -#define SMB_HAS_HOST_ADDRESS (0xE + amd756_smba) -#define SMB_SNOOP_ADDRESS (0xF + amd756_smba) +#define SMB_GLOBAL_STATUS (0x0 + amd756_ioport) +#define SMB_GLOBAL_ENABLE (0x2 + amd756_ioport) +#define SMB_HOST_ADDRESS (0x4 + amd756_ioport) +#define SMB_HOST_DATA (0x6 + amd756_ioport) +#define SMB_HOST_COMMAND (0x8 + amd756_ioport) +#define SMB_HOST_BLOCK_DATA (0x9 + amd756_ioport) +#define SMB_HAS_DATA (0xA + amd756_ioport) +#define SMB_HAS_DEVICE_ADDRESS (0xC + amd756_ioport) +#define SMB_HAS_HOST_ADDRESS (0xE + amd756_ioport) +#define SMB_SNOOP_ADDRESS (0xF + amd756_ioport) /* PCI Address Constants */ @@ -98,120 +85,8 @@ static struct sd supported[] = { #define AMD756_PROCESS_CALL 0x04 #define AMD756_BLOCK_DATA 0x05 -/* insmod parameters */ - -int __init i2c_amd756_init(void); -void __exit i2c_amd756_exit(void); -static int amd756_cleanup(void); - -static int amd756_setup(void); -static s32 amd756_access(struct i2c_adapter *adap, u16 addr, - unsigned short flags, char read_write, - u8 command, int size, union i2c_smbus_data *data); -static void amd756_do_pause(unsigned int amount); -static void amd756_abort(void); -static int amd756_transaction(void); -static void amd756_inc(struct i2c_adapter *adapter); -static void amd756_dec(struct i2c_adapter *adapter); -static u32 amd756_func(struct i2c_adapter *adapter); - -static struct i2c_algorithm smbus_algorithm = { - /* name */ "Non-I2C SMBus adapter", - /* id */ I2C_ALGO_SMBUS, - /* master_xfer */ NULL, - /* smbus_access */ amd756_access, - /* slave;_send */ NULL, - /* slave_rcv */ NULL, - /* algo_control */ NULL, - /* functionality */ amd756_func, -}; - -static struct i2c_adapter amd756_adapter = { - "unset", - I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756, - &smbus_algorithm, - NULL, - amd756_inc, - amd756_dec, - NULL, - NULL, -}; - -static int __initdata amd756_initialized; -static struct sd *amd756_sd = NULL; -static unsigned short amd756_smba = 0; -int amd756_setup(void) -{ - unsigned char temp; - struct sd *currdev; - struct pci_dev *AMD756_dev = NULL; - - if (pci_present() == 0) { - return -ENODEV; - } - - /* Look for a supported chip */ - for(currdev = supported; currdev->vendor; ) { - AMD756_dev = pci_find_device(currdev->vendor, - currdev->device, AMD756_dev); - if (AMD756_dev != NULL) { - if (PCI_FUNC(AMD756_dev->devfn) == currdev->function) - break; - } else { - currdev++; - } - } - - if (AMD756_dev == NULL) { - printk - ("i2c-amd756.o: Error: No AMD756 or compatible device detected!\n"); - return -ENODEV; - } - printk(KERN_INFO "i2c-amd756.o: Found %s SMBus controller.\n", currdev->name); - - if (currdev->amdsetup) - { - pci_read_config_byte(AMD756_dev, SMBGCFG, &temp); - if ((temp & 128) == 0) { - printk("i2c-amd756.o: Error: SMBus controller I/O not enabled!\n"); - return -ENODEV; - } - - /* Determine the address of the SMBus areas */ - /* Technically it is a dword but... */ - pci_read_config_word(AMD756_dev, SMBBA, &amd756_smba); - amd756_smba &= 0xff00; - amd756_smba += SMB_ADDR_OFFSET; - } else { - pci_read_config_word(AMD756_dev, SMBBANFORCE, &amd756_smba); - amd756_smba &= 0xfffc; - } - if(amd756_smba == 0) { - printk(KERN_ERR "i2c-amd756.o: Error: SMB base address uninitialized\n"); - return -ENODEV; - } - if (check_region(amd756_smba, SMB_IOSIZE)) { - printk - ("i2c-amd756.o: SMB region 0x%x already in use!\n", - amd756_smba); - return -ENODEV; - } - - /* Everything is happy, let's grab the memory and set things up. */ - request_region(amd756_smba, SMB_IOSIZE, "amd756-smbus"); - -#ifdef DEBUG - pci_read_config_byte(AMD756_dev, SMBREV, &temp); - printk("i2c-amd756.o: SMBREV = 0x%X\n", temp); - printk("i2c-amd756.o: AMD756_smba = 0x%X\n", amd756_smba); -#endif /* DEBUG */ - - /* store struct sd * for future reference */ - amd756_sd = currdev; - - return 0; -} +static unsigned short amd756_ioport = 0; /* SMBUS event = I/O 28-29 bit 11 @@ -220,7 +95,7 @@ int amd756_setup(void) */ /* Internally used pause function */ -void amd756_do_pause(unsigned int amount) +static void amd756_do_pause(unsigned int amount) { current->state = TASK_INTERRUPTIBLE; schedule_timeout(amount); @@ -241,33 +116,21 @@ void amd756_do_pause(unsigned int amount) #define GE_HOST_STC (1 << 3) #define GE_ABORT (1 << 5) -void amd756_abort(void) -{ - printk("i2c-amd756.o: Sending abort.\n"); - outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); - amd756_do_pause(100); - outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); -} -int amd756_transaction(void) +static int amd756_transaction(void) { int temp; int result = 0; int timeout = 0; -#ifdef DEBUG - printk - ("i2c-amd756.o: Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", - inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), - inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); -#endif + pr_debug(DRV_NAME + ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", + inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), + inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); /* Make sure the SMBus host is ready to start transmitting */ if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) { -#ifdef DEBUG - printk - ("i2c-amd756.o: SMBus busy (%04x). Waiting... \n", temp); -#endif + pr_debug(DRV_NAME ": SMBus busy (%04x). Waiting... \n", temp); do { amd756_do_pause(1); temp = inw_p(SMB_GLOBAL_STATUS); @@ -275,9 +138,8 @@ int amd756_transaction(void) (timeout++ < MAX_TIMEOUT)); /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { - printk("i2c-amd756.o: Busy wait timeout! (%04x)\n", temp); - amd756_abort(); - return -1; + pr_debug(DRV_NAME ": Busy wait timeout (%04x)\n", temp); + goto abort; } timeout = 0; } @@ -293,64 +155,63 @@ int amd756_transaction(void) /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { - printk("i2c-amd756.o: Completion timeout!\n"); - amd756_abort (); - return -1; + pr_debug(DRV_NAME ": Completion timeout!\n"); + goto abort; } if (temp & GS_PRERR_STS) { result = -1; -#ifdef DEBUG - printk("i2c-amd756.o: SMBus Protocol error (no response)!\n"); -#endif + pr_debug(DRV_NAME ": SMBus Protocol error (no response)!\n"); } if (temp & GS_COL_STS) { result = -1; - printk("i2c-amd756.o: SMBus collision!\n"); + printk(KERN_WARNING DRV_NAME " SMBus collision!\n"); } if (temp & GS_TO_STS) { result = -1; -#ifdef DEBUG - printk("i2c-amd756.o: SMBus protocol timeout!\n"); -#endif - } -#ifdef DEBUG - if (temp & GS_HCYC_STS) { - printk("i2c-amd756.o: SMBus protocol success!\n"); + pr_debug(DRV_NAME ": SMBus protocol timeout!\n"); } -#endif + + if (temp & GS_HCYC_STS) + pr_debug(DRV_NAME " SMBus protocol success!\n"); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); #ifdef DEBUG if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) { - printk - ("i2c-amd756.o: Failed reset at end of transaction (%04x)\n", - temp); + pr_debug(DRV_NAME + ": Failed reset at end of transaction (%04x)\n", temp); } - printk - ("i2c-amd756.o: Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", - inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), - inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); + + pr_debug(DRV_NAME + ": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", + inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), + inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); #endif return result; + + abort: + printk(KERN_WARNING DRV_NAME ": Sending abort.\n"); + outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); + amd756_do_pause(100); + outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); + return -1; } /* Return -1 on error. */ -s32 amd756_access(struct i2c_adapter * adap, u16 addr, +static s32 amd756_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data * data) { int i, len; - /** TODO: Should I supporte the 10-bit transfers? */ + /** TODO: Should I supporte the 10-bit transfers? */ switch (size) { case I2C_SMBUS_PROC_CALL: - printk - ("i2c-amd756.o: I2C_SMBUS_PROC_CALL not supported!\n"); + pr_debug(DRV_NAME ": I2C_SMBUS_PROC_CALL not supported!\n"); /* TODO: Well... It is supported, I'm just not sure what to do here... */ return -1; case I2C_SMBUS_QUICK: @@ -435,92 +296,140 @@ s32 amd756_access(struct i2c_adapter * adap, u16 addr, return 0; } -void amd756_inc(struct i2c_adapter *adapter) +static void amd756_inc(struct i2c_adapter *adapter) { MOD_INC_USE_COUNT; } -void amd756_dec(struct i2c_adapter *adapter) +static void amd756_dec(struct i2c_adapter *adapter) { MOD_DEC_USE_COUNT; } -u32 amd756_func(struct i2c_adapter *adapter) +static u32 amd756_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL; } -int __init i2c_amd756_init(void) +static struct i2c_algorithm smbus_algorithm = { + .name = "Non-I2C SMBus adapter", + .id = I2C_ALGO_SMBUS, + .smbus_xfer = amd756_access, + .functionality = amd756_func, +}; + +static struct i2c_adapter amd756_adapter = { + .name = "unset", + .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756, + .algo = &smbus_algorithm, + .inc_use = amd756_inc, + .dec_use = amd756_dec, +}; + +enum chiptype { AMD756, AMD766, AMD768, NFORCE }; + +static struct pci_device_id amd756_ids[] __devinitdata = { + {PCI_VENDOR_ID_AMD, 0x740B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD756 }, + {PCI_VENDOR_ID_AMD, 0x7413, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD766 }, + {PCI_VENDOR_ID_AMD, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD768 }, + {PCI_VENDOR_ID_NVIDIA, 0x01B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE }, + { 0, } +}; + +static int __devinit amd756_probe(struct pci_dev *pdev, + const struct pci_device_id *id) { - int res; -#ifdef DEBUG -/* PE- It might be good to make this a permanent part of the code! */ - if (amd756_initialized) { - printk - ("i2c-amd756.o: Oops, amd756_init called a second time!\n"); - return -EBUSY; + int nforce = (id->driver_data == NFORCE), error; + u8 temp; + + if (amd756_ioport) { + printk(KERN_ERR DRV_NAME ": Only one device supported. " + "(you have a strange motherboard, btw..)\n"); + return -ENODEV; } -#endif - amd756_initialized = 0; - if ((res = amd756_setup())) { - printk - ("i2c-amd756.o: AMD756 or compatible device not detected, module not inserted.\n"); - amd756_cleanup(); - return res; + + if (nforce) { + if (PCI_FUNC(pdev->devfn) != 1) + return -ENODEV; + + pci_read_config_word(pdev, SMBBANFORCE, &amd756_ioport); + amd756_ioport &= 0xfffc; + } else { /* amd */ + if (PCI_FUNC(pdev->devfn) != 3) + return -ENODEV; + + pci_read_config_byte(pdev, SMBGCFG, &temp); + if ((temp & 128) == 0) { + printk(KERN_ERR DRV_NAME + ": Error: SMBus controller I/O not enabled!\n"); + return -ENODEV; + } + + /* Determine the address of the SMBus areas */ + /* Technically it is a dword but... */ + pci_read_config_word(pdev, SMBBA, &amd756_ioport); + amd756_ioport &= 0xff00; + amd756_ioport += SMB_ADDR_OFFSET; } - amd756_initialized++; - sprintf(amd756_adapter.name, "SMBus %s adapter at %04x", - amd756_sd->name, amd756_smba); - if ((res = i2c_add_adapter(&amd756_adapter))) { - printk - ("i2c-amd756.o: Adapter registration failed, module not inserted.\n"); - amd756_cleanup(); - return res; + + if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { + printk(KERN_ERR DRV_NAME + ": SMB region 0x%x already in use!\n", amd756_ioport); + return -ENODEV; } - amd756_initialized++; - printk("i2c-amd756.o: %s bus detected and initialized\n", - amd756_sd->name); + +#ifdef DEBUG + pci_read_config_byte(pdev, SMBREV, &temp); + printk(KERN_DEBUG DRV_NAME ": SMBREV = 0x%X\n", temp); + printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport); +#endif + + sprintf(amd756_adapter.name, + "SMBus AMD75x adapter at %04x", amd756_ioport); + + error = i2c_add_adapter(&amd756_adapter); + if (error) { + printk(KERN_ERR DRV_NAME + ": Adapter registration failed, module not inserted.\n"); + goto out_err; + } + return 0; + + out_err: + release_region(amd756_ioport, SMB_IOSIZE); + return error; } -void __exit i2c_amd756_exit(void) +static void __devexit amd756_remove(struct pci_dev *dev) { - amd756_cleanup(); + i2c_del_adapter(&amd756_adapter); + release_region(amd756_ioport, SMB_IOSIZE); } -static int amd756_cleanup(void) +static struct pci_driver amd756_driver = { + .name = "amd75x smbus", + .id_table = amd756_ids, + .probe = amd756_probe, + .remove = __devexit_p(amd756_remove), +}; + +static int __init amd756_init(void) { - int res; - if (amd756_initialized >= 2) { - if ((res = i2c_del_adapter(&amd756_adapter))) { - printk - ("i2c-amd756.o: i2c_del_adapter failed, module not removed\n"); - return res; - } else - amd756_initialized--; - } - if (amd756_initialized >= 1) { - release_region(amd756_smba, SMB_IOSIZE); - amd756_initialized--; - } - return 0; + return pci_module_init(&amd756_driver); } -EXPORT_NO_SYMBOLS; - -#ifdef MODULE +static void __exit amd756_exit(void) +{ + pci_unregister_driver(&amd756_driver); +} MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>"); MODULE_DESCRIPTION("AMD756/766/768/nVidia nForce SMBus driver"); - -#ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); -#endif - -#endif /* MODULE */ -module_init(i2c_amd756_init) -module_exit(i2c_amd756_exit) +module_init(amd756_init) +module_exit(amd756_exit) diff --git a/drivers/i2c/busses/i2c-mainboard.c b/drivers/i2c/busses/i2c-mainboard.c deleted file mode 100644 index 5c58598bd399..000000000000 --- a/drivers/i2c/busses/i2c-mainboard.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - i2c-mainboard.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* Not configurable as a module */ - -#include <linux/init.h> - -extern int i2c_amd756_init(void); - -int __init i2c_mainboard_init_all(void) -{ -#ifdef CONFIG_I2C_AMD756 - i2c_amd756_init(); -#endif - - return 0; -} diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 19ade539d2ac..405db21a3a32 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig @@ -5,22 +5,9 @@ menu "I2C Hardware Sensors Chip support" -config SENSORS - bool "Hardware sensors chip support" - depends on EXPERIMENTAL && I2C && I2C_PROC - help - Many modern mainboards have some kind of I2C interface integrated. - This is often in the form of a SMBus, or System Management Bus, which - is basically the same as I2C but which uses only a subset of the I2C - protocol. - - You will also want the latest user-space utilties: you can find them - in the lm_sensors package, which you can download at - http://www.lm-sensors.nu - config SENSORS_ADM1021 tristate " Analog Devices ADM1021 and compatibles" - depends on SENSORS + depends on I2C && I2C_PROC help If you say yes here you get support for Analog Devices ADM1021 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, @@ -37,7 +24,7 @@ config SENSORS_ADM1021 config SENSORS_LM75 tristate " National Semiconductors LM75 and compatibles" - depends on SENSORS + depends on I2C && I2C_PROC help If you say yes here you get support for National Semiconductor LM75 sensor chips and clones: Dallas Semi DS75 and DS1775, TelCon @@ -51,4 +38,3 @@ config SENSORS_LM75 http://www.lm-sensors.nu endmenu - diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 0bb64d68a61e..835c8db87b4f 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile @@ -2,6 +2,5 @@ # Makefile for the kernel hardware sensors chip drivers. # -obj-$(CONFIG_SENSORS) += sensors.o obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o obj-$(CONFIG_SENSORS_LM75) += lm75.o diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index 54a76b9a0309..abab348e5b1b 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -26,7 +26,6 @@ #include <linux/sensors.h> #include <linux/init.h> -MODULE_LICENSE("GPL"); /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; @@ -108,10 +107,6 @@ struct adm1021_data { remote_temp_offset, remote_temp_offset_prec; }; -int __init sensors_adm1021_init(void); -void __exit sensors_adm1021_exit(void); -static int adm1021_cleanup(void); - static int adm1021_attach_adapter(struct i2c_adapter *adapter); static int adm1021_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind); @@ -178,9 +173,6 @@ static ctl_table adm1021_max_dir_table_template[] = { {0} }; -/* Used by init/cleanup */ -static int __initdata adm1021_initialized = 0; - /* I choose here for semi-static allocation. Complete dynamic allocation could also be used; the code needed for this would probably take more memory than the datastructure takes now. */ @@ -585,46 +577,21 @@ void adm1021_alarms(struct i2c_client *client, int operation, int ctl_name, } } -int __init sensors_adm1021_init(void) +static int __init sensors_adm1021_init(void) { - int res; - printk("adm1021.o version %s (%s)\n", LM_VERSION, LM_DATE); - adm1021_initialized = 0; - if ((res = i2c_add_driver(&adm1021_driver))) { - printk - ("adm1021.o: Driver registration failed, module not inserted.\n"); - adm1021_cleanup(); - return res; - } - adm1021_initialized++; - return 0; + return i2c_add_driver(&adm1021_driver); } -void __exit sensors_adm1021_exit(void) +static void __exit sensors_adm1021_exit(void) { - adm1021_cleanup(); -} - -static int adm1021_cleanup(void) -{ - int res; - - if (adm1021_initialized >= 1) { - if ((res = i2c_del_driver(&adm1021_driver))) { - printk - ("adm1021.o: Driver deregistration failed, module not removed.\n"); - return res; - } - adm1021_initialized--; - } - - return 0; + i2c_del_driver(&adm1021_driver); } MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); MODULE_DESCRIPTION("adm1021 driver"); +MODULE_LICENSE("GPL"); MODULE_PARM(read_only, "i"); MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index f7a516b82703..83b08f63c421 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -25,7 +25,6 @@ #include <linux/sensors.h> #include <linux/init.h> -MODULE_LICENSE("GPL"); /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; @@ -66,10 +65,6 @@ struct lm75_data { u16 temp, temp_os, temp_hyst; /* Register values */ }; -int __init sensors_lm75_init(void); -void __exit sensors_lm75_exit(void); -static int lm75_cleanup(void); - static int lm75_attach_adapter(struct i2c_adapter *adapter); static int lm75_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind); @@ -110,9 +105,6 @@ static ctl_table lm75_dir_table_template[] = { {0} }; -/* Used by init/cleanup */ -static int __initdata lm75_initialized = 0; - static int lm75_id = 0; int lm75_attach_adapter(struct i2c_adapter *adapter) @@ -188,10 +180,7 @@ int lm75_detect(struct i2c_adapter *adapter, int address, type_name = "lm75"; client_name = "LM75 chip"; } else { -#ifdef DEBUG - printk("lm75.o: Internal error: unknown kind (%d)?!?", - kind); -#endif + pr_debug("lm75.o: Internal error: unknown kind (%d)?!?", kind); goto error1; } @@ -314,10 +303,7 @@ void lm75_update_client(struct i2c_client *client) if ((jiffies - data->last_updated > HZ + HZ / 2) || (jiffies < data->last_updated) || !data->valid) { - -#ifdef DEBUG - printk("Starting lm75 update\n"); -#endif + pr_debug("Starting lm75 update\n"); data->temp = lm75_read_value(client, LM75_REG_TEMP); data->temp_os = lm75_read_value(client, LM75_REG_TEMP_OS); @@ -359,45 +345,17 @@ void lm75_temp(struct i2c_client *client, int operation, int ctl_name, int __init sensors_lm75_init(void) { - int res; - - printk("lm75.o version %s (%s)\n", LM_VERSION, LM_DATE); - lm75_initialized = 0; - if ((res = i2c_add_driver(&lm75_driver))) { - printk - ("lm75.o: Driver registration failed, module not inserted.\n"); - lm75_cleanup(); - return res; - } - lm75_initialized++; - return 0; -} - -void __exit sensors_lm75_exit(void) -{ - lm75_cleanup(); + return i2c_add_driver(&lm75_driver); } -static int lm75_cleanup(void) +static void __exit sensors_lm75_exit(void) { - int res; - - if (lm75_initialized >= 1) { - if ((res = i2c_del_driver(&lm75_driver))) { - printk - ("lm75.o: Driver deregistration failed, module not removed.\n"); - return res; - } - lm75_initialized--; - } - - return 0; + i2c_del_driver(&lm75_driver); } -EXPORT_NO_SYMBOLS; - MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); MODULE_DESCRIPTION("LM75 driver"); +MODULE_LICENSE("GPL"); module_init(sensors_lm75_init); module_exit(sensors_lm75_exit); diff --git a/drivers/i2c/chips/sensors.c b/drivers/i2c/chips/sensors.c deleted file mode 100644 index 0733c474753b..000000000000 --- a/drivers/i2c/chips/sensors.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - sensors.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* Not configurable as a module */ - -#include <linux/init.h> - -extern int sensors_adm1021_init(void); -extern int sensors_lm75_init(void); - -int __init sensors_init_all(void) -{ -#ifdef CONFIG_SENSORS_ADM1021 - sensors_adm1021_init(); -#endif -#ifdef CONFIG_SENSORS_LM75 - sensors_lm75_init(); -#endif - return 0; -} diff --git a/drivers/i2c/i2c-adap-ite.c b/drivers/i2c/i2c-adap-ite.c index 46ba5149995b..9e2904c0f5e8 100644 --- a/drivers/i2c/i2c-adap-ite.c +++ b/drivers/i2c/i2c-adap-ite.c @@ -160,19 +160,17 @@ static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs) */ static int iic_hw_resrc_init(void) { - if (check_region(gpi.iic_base, ITE_IIC_IO_SIZE) < 0 ) { - return -ENODEV; - } else { - request_region(gpi.iic_base, ITE_IIC_IO_SIZE, - "i2c (i2c bus adapter)"); - } - if (gpi.iic_irq > 0) { - if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0) { - gpi.iic_irq = 0; - } else - DEB3(printk("Enabled IIC IRQ %d\n", gpi.iic_irq)); - enable_irq(gpi.iic_irq); - } + if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c")) + return -ENODEV; + + if (gpi.iic_irq <= 0) + return 0; + + if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0) + gpi.iic_irq = 0; + else + enable_irq(gpi.iic_irq); + return 0; } diff --git a/drivers/i2c/i2c-algo-bit.c b/drivers/i2c/i2c-algo-bit.c index 60d6da9c9eaf..9551f0d27e6f 100644 --- a/drivers/i2c/i2c-algo-bit.c +++ b/drivers/i2c/i2c-algo-bit.c @@ -605,18 +605,9 @@ int i2c_bit_del_bus(struct i2c_adapter *adap) return 0; } -int __init i2c_algo_bit_init (void) -{ - printk(KERN_INFO "i2c-algo-bit.o: i2c bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); - return 0; -} - - - EXPORT_SYMBOL(i2c_bit_add_bus); EXPORT_SYMBOL(i2c_bit_del_bus); -#ifdef MODULE MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); MODULE_LICENSE("GPL"); @@ -629,13 +620,3 @@ MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck"); MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus"); MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol"); - -int init_module(void) -{ - return i2c_algo_bit_init(); -} - -void cleanup_module(void) -{ -} -#endif diff --git a/drivers/i2c/i2c-algo-pcf.c b/drivers/i2c/i2c-algo-pcf.c index 407656271ce5..000b34a84d4c 100644 --- a/drivers/i2c/i2c-algo-pcf.c +++ b/drivers/i2c/i2c-algo-pcf.c @@ -520,17 +520,9 @@ int i2c_pcf_del_bus(struct i2c_adapter *adap) return 0; } -int __init i2c_algo_pcf_init (void) -{ - printk(KERN_INFO "i2c-algo-pcf.o: i2c pcf8584 algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); - return 0; -} - - EXPORT_SYMBOL(i2c_pcf_add_bus); EXPORT_SYMBOL(i2c_pcf_del_bus); -#ifdef MODULE MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); MODULE_LICENSE("GPL"); @@ -541,14 +533,3 @@ MODULE_PARM(i2c_debug,"i"); MODULE_PARM_DESC(pcf_scan, "Scan for active chips on the bus"); MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol"); - - -int init_module(void) -{ - return i2c_algo_pcf_init(); -} - -void cleanup_module(void) -{ -} -#endif diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 01af09b5120f..4ddcb6a26401 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -56,8 +56,8 @@ /* ----- global variables -------------------------------------------------- */ /**** lock for writing to global variables: the adapter & driver list */ -struct semaphore adap_lock; -struct semaphore driver_lock; +DECLARE_MUTEX(adap_lock); +DECLARE_MUTEX(driver_lock); /**** adapter list */ static struct i2c_adapter *adapters[I2C_ADAP_MAX]; @@ -76,11 +76,6 @@ static int i2c_debug; */ #ifdef CONFIG_PROC_FS - -int __init i2cproc_init(void); -void __exit i2cproc_exit(void); -static int i2cproc_cleanup(void); - static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count, loff_t *ppos); static int read_bus_i2c(char *buf, char **start, off_t offset, int len, @@ -91,14 +86,6 @@ static int read_bus_i2c(char *buf, char **start, off_t offset, int len, static struct file_operations i2cproc_operations = { .read = i2cproc_bus_read, }; - -static int i2cproc_initialized = 0; - -#else /* undef CONFIG_PROC_FS */ - -#define i2cproc_init() 0 -#define i2cproc_cleanup() 0 - #endif /* CONFIG_PROC_FS */ @@ -136,8 +123,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) init_MUTEX(&adap->lock); #ifdef CONFIG_PROC_FS - - if (i2cproc_initialized) { + { char name[8]; struct proc_dir_entry *proc_entry; @@ -155,7 +141,6 @@ int i2c_add_adapter(struct i2c_adapter *adap) proc_entry->owner = THIS_MODULE; adap->inode = proc_entry->low_ino; } - #endif /* def CONFIG_PROC_FS */ /* inform drivers of new adapters */ @@ -234,10 +219,10 @@ int i2c_del_adapter(struct i2c_adapter *adap) } } #ifdef CONFIG_PROC_FS - if (i2cproc_initialized) { + { char name[8]; sprintf(name,"i2c-%d", i); - remove_proc_entry(name,proc_bus); + remove_proc_entry(name, proc_bus); } #endif /* def CONFIG_PROC_FS */ @@ -681,41 +666,30 @@ ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count, return -ENOENT; } -int i2cproc_init(void) +static int i2cproc_init(void) { struct proc_dir_entry *proc_bus_i2c; - i2cproc_initialized = 0; - - if (! proc_bus) { - printk(KERN_ERR "i2c-core.o: /proc/bus/ does not exist"); - i2cproc_cleanup(); - return -ENOENT; - } proc_bus_i2c = create_proc_entry("i2c",0,proc_bus); if (!proc_bus_i2c) { printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c"); - i2cproc_cleanup(); return -ENOENT; } + proc_bus_i2c->read_proc = &read_bus_i2c; proc_bus_i2c->owner = THIS_MODULE; - i2cproc_initialized += 2; return 0; } -int i2cproc_cleanup(void) +static void __exit i2cproc_cleanup(void) { - if (i2cproc_initialized >= 1) { - remove_proc_entry("i2c",proc_bus); - i2cproc_initialized -= 2; - } - return 0; + remove_proc_entry("i2c",proc_bus); } - +module_init(i2cproc_init); +module_exit(i2cproc_cleanup); #endif /* def CONFIG_PROC_FS */ /* ---------------------------------------------------- @@ -1440,120 +1414,6 @@ int i2c_check_functionality (struct i2c_adapter *adap, u32 func) return (func & adap_func) == func; } - -static int __init i2c_init(void) -{ - printk(KERN_INFO "i2c-core.o: i2c core module version %s (%s)\n", I2C_VERSION, I2C_DATE); - memset(adapters,0,sizeof(adapters)); - memset(drivers,0,sizeof(drivers)); - adap_count=0; - driver_count=0; - - init_MUTEX(&adap_lock); - init_MUTEX(&driver_lock); - - i2cproc_init(); - - return 0; -} - -void __exit i2c_exit(void) -{ - i2cproc_cleanup(); -} - -#ifndef MODULE -#ifdef CONFIG_I2C_CHARDEV - extern int i2c_dev_init(void); -#endif -#ifdef CONFIG_I2C_ALGOBIT - extern int i2c_algo_bit_init(void); -#endif -#ifdef CONFIG_I2C_PHILIPSPAR - extern int i2c_bitlp_init(void); -#endif -#ifdef CONFIG_I2C_ELV - extern int i2c_bitelv_init(void); -#endif -#ifdef CONFIG_I2C_VELLEMAN - extern int i2c_bitvelle_init(void); -#endif -#ifdef CONFIG_I2C_BITVIA - extern int i2c_bitvia_init(void); -#endif - -#ifdef CONFIG_I2C_ALGOPCF - extern int i2c_algo_pcf_init(void); -#endif -#ifdef CONFIG_I2C_ELEKTOR - extern int i2c_pcfisa_init(void); -#endif - -#ifdef CONFIG_I2C_ALGO8XX - extern int i2c_algo_8xx_init(void); -#endif -#ifdef CONFIG_I2C_RPXLITE - extern int i2c_rpx_init(void); -#endif -#ifdef CONFIG_I2C_PROC - extern int sensors_init(void); -#endif - -/* This is needed for automatic patch generation: sensors code starts here */ -/* This is needed for automatic patch generation: sensors code ends here */ - -int __init i2c_init_all(void) -{ - /* --------------------- global ----- */ - i2c_init(); - -#ifdef CONFIG_I2C_CHARDEV - i2c_dev_init(); -#endif - /* --------------------- bit -------- */ -#ifdef CONFIG_I2C_ALGOBIT - i2c_algo_bit_init(); -#endif -#ifdef CONFIG_I2C_PHILIPSPAR - i2c_bitlp_init(); -#endif -#ifdef CONFIG_I2C_ELV - i2c_bitelv_init(); -#endif -#ifdef CONFIG_I2C_VELLEMAN - i2c_bitvelle_init(); -#endif - - /* --------------------- pcf -------- */ -#ifdef CONFIG_I2C_ALGOPCF - i2c_algo_pcf_init(); -#endif -#ifdef CONFIG_I2C_ELEKTOR - i2c_pcfisa_init(); -#endif - - /* --------------------- 8xx -------- */ -#ifdef CONFIG_I2C_ALGO8XX - i2c_algo_8xx_init(); -#endif -#ifdef CONFIG_I2C_RPXLITE - i2c_rpx_init(); -#endif - - /* -------------- proc interface ---- */ -#ifdef CONFIG_I2C_PROC - sensors_init(); -#endif -/* This is needed for automatic patch generation: sensors code starts here */ -/* This is needed for automatic patch generation: sensors code ends here */ - - return 0; -} - -#endif - - - EXPORT_SYMBOL(i2c_add_adapter); EXPORT_SYMBOL(i2c_del_adapter); EXPORT_SYMBOL(i2c_add_driver); @@ -1594,9 +1454,7 @@ EXPORT_SYMBOL(i2c_check_functionality); MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_DESCRIPTION("I2C-Bus main module"); -MODULE_PARM(i2c_debug, "i"); -MODULE_PARM_DESC(i2c_debug,"debug level"); MODULE_LICENSE("GPL"); -module_init(i2c_init); -module_exit(i2c_exit); +MODULE_PARM(i2c_debug, "i"); +MODULE_PARM_DESC(i2c_debug,"debug level"); diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index a2c539a5d269..a702cc953dc7 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -48,10 +48,6 @@ #include <linux/i2c.h> #include <linux/i2c-dev.h> -int __init i2c_dev_init(void); -void __exit i2c_dev_exit(void); -static int dev_cleanup(void); - /* struct file_operations changed too often in the 2.1 series for nice code */ static ssize_t i2cdev_read (struct file *file, char *buf, size_t count, @@ -437,19 +433,6 @@ static int i2cdev_command(struct i2c_client *client, unsigned int cmd, return -1; } -static int dev_cleanup(void) -{ - int res; - - if ((res = i2c_del_driver(&i2cdev_driver))) { - printk(KERN_ERR "i2c-dev.o: Driver deregistration failed, " - "module not removed.\n"); - } - - devfs_remove("i2c"); - unregister_chrdev(I2C_MAJOR,"i2c"); -} - int __init i2c_dev_init(void) { int res; @@ -471,13 +454,13 @@ int __init i2c_dev_init(void) return 0; } -void __exit i2c_dev_exit(void) +static void __exit i2c_dev_exit(void) { - dev_cleanup(); + i2c_del_driver(&i2cdev_driver); + devfs_remove("i2c"); + unregister_chrdev(I2C_MAJOR,"i2c"); } -EXPORT_NO_SYMBOLS; - MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_DESCRIPTION("I2C /dev entries driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/i2c/i2c-elektor.c b/drivers/i2c/i2c-elektor.c index d6c37f8bdd05..f142e72e9b75 100644 --- a/drivers/i2c/i2c-elektor.c +++ b/drivers/i2c/i2c-elektor.c @@ -142,11 +142,11 @@ static void pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) { static int pcf_isa_init(void) { if (!mmapped) { - if (check_region(base, 2) < 0 ) { - printk(KERN_ERR "i2c-elektor.o: requested I/O region (0x%X:2) is in use.\n", base); + if (!request_region(base, 2, "i2c (isa bus adapter)")) + printk(KERN_ERR + "i2c-elektor.o: requested I/O region (0x%X:2) " + "is in use.\n", base); return -ENODEV; - } else { - request_region(base, 2, "i2c (isa bus adapter)"); } } if (irq > 0) { @@ -159,19 +159,6 @@ static int pcf_isa_init(void) return 0; } - -static void pcf_isa_exit(void) -{ - if (irq > 0) { - disable_irq(irq); - free_irq(irq, 0); - } - if (!mmapped) { - release_region(base , 2); - } -} - - static int pcf_isa_reg(struct i2c_client *client) { return 0; @@ -223,7 +210,7 @@ static struct i2c_adapter pcf_isa_ops = { .client_unregister = pcf_isa_unreg, }; -int __init i2c_pcfisa_init(void) +static int __init i2c_pcfisa_init(void) { #ifdef __alpha__ /* check to see we have memory mapped PCF8584 connected to the @@ -281,23 +268,39 @@ int __init i2c_pcfisa_init(void) } init_waitqueue_head(&pcf_wait); - if (pcf_isa_init() == 0) { - if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) { - pcf_isa_exit(); - return -ENODEV; - } - } else { + if (pcf_isa_init()) return -ENODEV; - } + if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) + goto fail; printk(KERN_ERR "i2c-elektor.o: found device at %#x.\n", base); return 0; + + fail: + if (irq > 0) { + disable_irq(irq); + free_irq(irq, 0); + } + + if (!mmapped) + release_region(base , 2); + return -ENODEV; } -EXPORT_NO_SYMBOLS; +static void i2c_pcfisa_exit(void) +{ + i2c_pcf_del_bus(&pcf_isa_ops); + + if (irq > 0) { + disable_irq(irq); + free_irq(irq, 0); + } + + if (!mmapped) + release_region(base , 2); +} -#ifdef MODULE MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter"); MODULE_LICENSE("GPL"); @@ -309,15 +312,5 @@ MODULE_PARM(own, "i"); MODULE_PARM(mmapped, "i"); MODULE_PARM(i2c_debug, "i"); -int init_module(void) -{ - return i2c_pcfisa_init(); -} - -void cleanup_module(void) -{ - i2c_pcf_del_bus(&pcf_isa_ops); - pcf_isa_exit(); -} - -#endif +module_init(i2c_pcfisa_init); +module_exit(i2c_pcfisa_exit); diff --git a/drivers/i2c/i2c-elv.c b/drivers/i2c/i2c-elv.c index c1ad9f5ed63b..a11ba27ffa2e 100644 --- a/drivers/i2c/i2c-elv.c +++ b/drivers/i2c/i2c-elv.c @@ -88,34 +88,31 @@ static int bit_elv_getsda(void *data) static int bit_elv_init(void) { - if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { - return -ENODEV; - } else { - /* test for ELV adap. */ - if (inb(base+1) & 0x80) { /* BUSY should be high */ - DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); - return -ENODEV; - } else { - outb(0x0c,base+2); /* SLCT auf low */ - udelay(400); - if ( !(inb(base+1) && 0x10) ) { - outb(0x04,base+2); - DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); - return -ENODEV; - } - } - request_region(base,(base == 0x3bc)? 3 : 8, - "i2c (ELV adapter)"); - PortData = 0; - bit_elv_setsda((void*)base,1); - bit_elv_setscl((void*)base,1); + if (!request_region(base, (base == 0x3bc) ? 3 : 8, + "i2c (ELV adapter)")) + return -ENODEV; + + if (inb(base+1) & 0x80) { /* BUSY should be high */ + DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); + goto fail; + } + + outb(0x0c,base+2); /* SLCT auf low */ + udelay(400); + if (!(inb(base+1) && 0x10)) { + outb(0x04,base+2); + DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); + goto fail; } + + PortData = 0; + bit_elv_setsda((void*)base,1); + bit_elv_setscl((void*)base,1); return 0; -} -static void __exit bit_elv_exit(void) -{ - release_region( base , (base == 0x3bc)? 3 : 8 ); +fail: + release_region(base , (base == 0x3bc) ? 3 : 8); + return -ENODEV; } static int bit_elv_reg(struct i2c_client *client) @@ -166,7 +163,7 @@ static struct i2c_adapter bit_elv_ops = { bit_elv_unreg, }; -int __init i2c_bitelv_init(void) +static int __init i2c_bitelv_init(void) { printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); if (base==0) { @@ -192,24 +189,17 @@ int __init i2c_bitelv_init(void) return 0; } +static void __exit i2c_bitelv_exit(void) +{ + i2c_bit_del_bus(&bit_elv_ops); + release_region(base , (base == 0x3bc) ? 3 : 8); +} -#ifdef MODULE MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter"); MODULE_LICENSE("GPL"); - MODULE_PARM(base, "i"); -int init_module(void) -{ - return i2c_bitelv_init(); -} - -void cleanup_module(void) -{ - i2c_bit_del_bus(&bit_elv_ops); - bit_elv_exit(); -} - -#endif +module_init(i2c_bitelv_init); +module_exit(i2c_bitelv_exit); diff --git a/drivers/i2c/i2c-frodo.c b/drivers/i2c/i2c-frodo.c index de38a02e29de..634a4ac46457 100644 --- a/drivers/i2c/i2c-frodo.c +++ b/drivers/i2c/i2c-frodo.c @@ -96,8 +96,6 @@ static int __init i2c_frodo_init (void) return (i2c_bit_add_bus (&frodo_ops)); } -EXPORT_NO_SYMBOLS; - static void __exit i2c_frodo_exit (void) { i2c_bit_del_bus (&frodo_ops); @@ -105,12 +103,7 @@ static void __exit i2c_frodo_exit (void) MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>"); MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo"); - -#ifdef MODULE_LICENSE MODULE_LICENSE ("GPL"); -#endif /* #ifdef MODULE_LICENSE */ - -EXPORT_NO_SYMBOLS; module_init (i2c_frodo_init); module_exit (i2c_frodo_exit); diff --git a/drivers/i2c/i2c-philips-par.c b/drivers/i2c/i2c-philips-par.c index c26e74304724..be9a49f146b8 100644 --- a/drivers/i2c/i2c-philips-par.c +++ b/drivers/i2c/i2c-philips-par.c @@ -297,14 +297,5 @@ MODULE_LICENSE("GPL"); MODULE_PARM(type, "i"); -#ifdef MODULE -int init_module(void) -{ - return i2c_bitlp_init(); -} - -void cleanup_module(void) -{ - i2c_bitlp_exit(); -} -#endif +module_init(i2c_bitlp_init); +module_exit(i2c_bitlp_exit); diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index 2f26eab8d882..2273dbf684f9 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -40,10 +40,6 @@ #define THIS_MODULE NULL #endif -int __init sensors_init(void); -void __exit i2c_proc_exit(void); -static int proc_cleanup(void); - static int i2c_create_name(char **name, const char *prefix, struct i2c_adapter *adapter, int addr); static int i2c_parse_reals(int *nrels, void *buffer, int bufsize, @@ -92,7 +88,6 @@ static ctl_table i2c_proc[] = { static struct ctl_table_header *i2c_proc_header; -static int i2c_initialized; /* This returns a nice name for a new directory; for example lm78-isa-0310 (for a LM78 chip on the ISA bus at port 0x310), or lm75-i2c-3-4e (for @@ -648,6 +643,7 @@ int i2c_detect(struct i2c_adapter *adapter, I2C_FUNC_SMBUS_QUICK)) return -1; for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { + /* XXX: WTF is going on here??? */ if ((is_isa && check_region(addr, 1)) || (!is_isa && i2c_check_addr(adapter, addr))) continue; @@ -848,10 +844,9 @@ int i2c_detect(struct i2c_adapter *adapter, return 0; } -int __init sensors_init(void) +static int __init i2c_proc_init(void) { printk(KERN_INFO "i2c-proc.o version %s (%s)\n", I2C_VERSION, I2C_DATE); - i2c_initialized = 0; if (! (i2c_proc_header = register_sysctl_table(i2c_proc, 0))) { @@ -859,22 +854,12 @@ int __init sensors_init(void) return -EPERM; } i2c_proc_header->ctl_table->child->de->owner = THIS_MODULE; - i2c_initialized++; return 0; } -void __exit i2c_proc_exit(void) -{ - proc_cleanup(); -} - -static int proc_cleanup(void) +static void __exit i2c_proc_exit(void) { - if (i2c_initialized >= 1) { - unregister_sysctl_table(i2c_proc_header); - i2c_initialized--; - } - return 0; + unregister_sysctl_table(i2c_proc_header); } EXPORT_SYMBOL(i2c_deregister_entry); @@ -887,5 +872,5 @@ MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); MODULE_DESCRIPTION("i2c-proc driver"); MODULE_LICENSE("GPL"); -module_init(sensors_init); +module_init(i2c_proc_init); module_exit(i2c_proc_exit); diff --git a/drivers/i2c/i2c-rpx.c b/drivers/i2c/i2c-rpx.c index af9a6368c3c2..a449ae9c8724 100644 --- a/drivers/i2c/i2c-rpx.c +++ b/drivers/i2c/i2c-rpx.c @@ -126,11 +126,8 @@ void __exit i2c_rpx_exit(void) i2c_8xx_del_bus(&rpx_ops); } -#ifdef MODULE MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards"); module_init(i2c_rpx_init); module_exit(i2c_rpx_exit); -#endif - diff --git a/drivers/i2c/i2c-velleman.c b/drivers/i2c/i2c-velleman.c index 71d8934a94a1..9ae1a20cc868 100644 --- a/drivers/i2c/i2c-velleman.c +++ b/drivers/i2c/i2c-velleman.c @@ -102,12 +102,6 @@ static int bit_velle_init(void) return 0; } -static void __exit bit_velle_exit(void) -{ - release_region( base , (base == 0x3bc)? 3 : 8 ); -} - - static int bit_velle_reg(struct i2c_client *client) { return 0; @@ -157,7 +151,7 @@ static struct i2c_adapter bit_velle_ops = { bit_velle_unreg, }; -int __init i2c_bitvelle_init(void) +static int __init i2c_bitvelle_init(void) { printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); if (base==0) { @@ -183,22 +177,17 @@ int __init i2c_bitvelle_init(void) return 0; } -#ifdef MODULE +static void __exit i2c_bitvelle_exit(void) +{ + i2c_bit_del_bus(&bit_velle_ops); + release_region(base, (base == 0x3bc) ? 3 : 8); +} + MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter"); MODULE_LICENSE("GPL"); MODULE_PARM(base, "i"); -int init_module(void) -{ - return i2c_bitvelle_init(); -} - -void cleanup_module(void) -{ - i2c_bit_del_bus(&bit_velle_ops); - bit_velle_exit(); -} - -#endif +module_init(i2c_bitvelle_init); +module_exit(i2c_bitvelle_exit); diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 3c07fbefa9bf..0ae396abfcc1 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1336,14 +1336,12 @@ int ata_attach(ide_drive_t *drive) continue; spin_unlock(&drivers_lock); if (driver->attach(drive) == 0) { - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); drive->gendev.driver = &driver->gen_driver; return 0; } spin_lock(&drivers_lock); - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); } spin_unlock(&drivers_lock); spin_lock(&drives_lock); diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 407276e6aab3..b0babb4acc08 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c @@ -49,6 +49,14 @@ static int falconide_offsets[IDE_NR_PORTS] __initdata = { /* + * falconide_intr_lock is used to obtain access to the IDE interrupt, + * which is shared between several drivers. + */ + +int falconide_intr_lock; + + + /* * Probe for a Falcon IDE interface */ diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index 0b251ee098c1..b5e00b4b12b5 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -1135,28 +1135,19 @@ static int ieee1394_dispatch_open(struct inode *inode, struct file *file) unloading while the file is open, and will be dropped by the VFS when the file is released. */ - - if(THIS_MODULE) - __MOD_DEC_USE_COUNT((struct module*) THIS_MODULE); - - /* note that if ieee1394 is compiled into the kernel, - THIS_MODULE will be (void*) NULL, hence the if and - the cast are necessary */ - + module_put(THIS_MODULE); } else { - - /* if the open() failed, then we need to drop the - extra reference we gave to the task-specific - driver */ - - if(module) - __MOD_DEC_USE_COUNT(module); - /* point the file's f_ops back to ieee1394. The VFS will then decrement ieee1394's reference count immediately after this function returns. */ file->f_op = &ieee1394_chardev_ops; + + /* if the open() failed, then we need to drop the + extra reference we gave to the task-specific + driver */ + module_put(module); + } return retval; diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 949a9497b0b5..337124784e9c 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -91,8 +91,7 @@ capi_ctr_get(struct capi_ctr *card) static inline void capi_ctr_put(struct capi_ctr *card) { - if (card->owner) - __MOD_DEC_USE_COUNT(card->owner); + module_put(card->owner); DBG("MOD_COUNT DEC"); } diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 6bf8310ac1e9..886302cbd2b1 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -44,11 +44,11 @@ static struct tt_internal *get_target_type(const char *name) read_lock(&_lock); ti = __find_target_type(name); - - if (ti) { - if (ti->use == 0 && ti->tt.module) - __MOD_INC_USE_COUNT(ti->tt.module); - ti->use++; + if (ti && ti->use == 0) { + if (try_module_get(ti->tt.module)) + ti->use++; + else + ti = NULL; } read_unlock(&_lock); @@ -86,8 +86,8 @@ void dm_put_target_type(struct target_type *t) struct tt_internal *ti = (struct tt_internal *) t; read_lock(&_lock); - if (--ti->use == 0 && ti->tt.module) - __MOD_DEC_USE_COUNT(ti->tt.module); + if (--ti->use == 0) + module_put(ti->tt.module); if (ti->use < 0) BUG(); diff --git a/drivers/media/dvb/dvb-core/dvb_i2c.c b/drivers/media/dvb/dvb-core/dvb_i2c.c index e9a48ba1af9f..9eefbf4513d1 100644 --- a/drivers/media/dvb/dvb-core/dvb_i2c.c +++ b/drivers/media/dvb/dvb-core/dvb_i2c.c @@ -63,18 +63,11 @@ int register_i2c_client (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) { - if (dev->owner) { - if (!MOD_CAN_QUERY(dev->owner)) - return; - - __MOD_INC_USE_COUNT(dev->owner); - } - - if (dev->attach (i2c) == 0) { - register_i2c_client (i2c, dev); - } else { - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + if (try_module_get(dev->owner)) { + if (dev->attach(i2c) == 0) + register_i2c_client(i2c, dev); + else + module_put(dev->owner); } } @@ -82,10 +75,8 @@ void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) { - dev->detach (i2c); - - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + dev->detach(i2c); + module_put(dev->owner); } diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 1abef42a5896..bcc26db53c6a 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -3158,8 +3158,7 @@ static int reset_camera(struct cam_data *cam) static void put_cam(struct cpia_camera_ops* ops) { - if (ops->owner) - __MOD_DEC_USE_COUNT(ops->owner); + module_put(ops->owner); } /* ------------------------- V4L interface --------------------- */ diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c index da5512cd14e3..efdd7ee41d34 100644 --- a/drivers/mtd/chips/chipreg.c +++ b/drivers/mtd/chips/chipreg.c @@ -71,15 +71,13 @@ struct mtd_info *do_map_probe(char *name, struct map_info *map) return NULL; ret = drv->probe(map); -#ifdef CONFIG_MODULES + /* We decrease the use count here. It may have been a probe-only module, which is no longer required from this point, having given us a handle on (and increased the use count of) the actual driver code. */ - if(drv->module) - __MOD_DEC_USE_COUNT(drv->module); -#endif + module_put(drv->module); if (ret) return ret; diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index a73fe2c3db70..a27737026547 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c @@ -502,8 +502,7 @@ errout_stop: errout_free: sirdev_free_buffers(dev); errout_dec: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); return -EAGAIN; } @@ -533,11 +532,7 @@ static int sirdev_close(struct net_device *ndev) drv->stop_dev(dev); sirdev_free_buffers(dev); - - lock_kernel(); - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); - unlock_kernel(); + module_put(drv->owner); out: dev->speed = 0; diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c index 6384215dc27e..cf7a17a002d3 100644 --- a/drivers/net/irda/sir_dongle.c +++ b/drivers/net/irda/sir_dongle.c @@ -121,8 +121,7 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type) out_reject: dev->dongle_drv = NULL; - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); out_unlock: up(&dongle_list_lock); return err; @@ -137,9 +136,7 @@ int sirdev_put_dongle(struct sir_dev *dev) drv->close(dev); /* close this dongle instance */ dev->dongle_drv = NULL; /* unlink the dongle driver */ - - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner);/* decrement driver's module refcount */ + module_put(drv->owner);/* decrement driver's module refcount */ } return 0; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4363f2c188c3..2c14942cbb00 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -257,7 +257,6 @@ struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_de int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass) { unsigned int buses; - unsigned short cr; struct pci_bus *child; int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 6f0cfa5c66bc..8eedee623a04 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1757,8 +1757,7 @@ dasd_release(struct inode *inp, struct file *filp) } if (atomic_dec_return(&device->open_count) == 0) { invalidate_buffers(inp->i_rdev); - if (device->discipline->owner) - __MOD_DEC_USE_COUNT(device->discipline->owner); + module_put(device->discipline->owner); } return 0; } diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index def999eb4334..9047d68fb20a 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -115,7 +115,7 @@ dasd_ioctl(struct inode *inp, struct file *filp, if (try_inc_mod_count(ioctl->owner) != 0) continue; rc = ioctl->handler(bdev, no, data); - __MOD_DEC_USE_COUNT(ioctl->owner); + module_put(ioctl->owner); } else rc = ioctl->handler(bdev, no, data); return rc; diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c index 23c48e2e6381..af71fadf2f52 100644 --- a/drivers/s390/char/tape_core.c +++ b/drivers/s390/char/tape_core.c @@ -857,8 +857,7 @@ tape_release(struct tape_device *device) spin_lock(get_ccwdev_lock(device->cdev)); if (device->tape_state == TS_IN_USE) tape_state_set(device, TS_UNUSED); - if (device->discipline->owner) - __MOD_DEC_USE_COUNT(device->discipline->owner); + module_put(device->discipline->owner); spin_unlock(get_ccwdev_lock(device->cdev)); return 0; } diff --git a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c index ffeacdf56718..f8d8fa5adfb6 100644 --- a/drivers/scsi/fcal.c +++ b/drivers/scsi/fcal.c @@ -138,10 +138,14 @@ int __init fcal_detect(Scsi_Host_Template *tpnt) continue; } + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + nfcals++; - if (fc->module) __MOD_INC_USE_COUNT(fc->module); - fcal = (struct fcal *)host->hostdata; fc->fcp_register(fc, TYPE_SCSI_FCP, 0); @@ -193,7 +197,7 @@ int fcal_release(struct Scsi_Host *host) struct fcal *fcal = (struct fcal *)host->hostdata; fc_channel *fc = fcal->fc; - if (fc->module) __MOD_DEC_USE_COUNT(fc->module); + module_put(fc->module); fc->fcp_register(fc, TYPE_SCSI_FCP, 1); FCALND((" releasing fcal.\n")); diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c index 84024bc0adb9..3c3452557f8b 100644 --- a/drivers/scsi/pluto.c +++ b/drivers/scsi/pluto.c @@ -232,10 +232,14 @@ int __init pluto_detect(Scsi_Host_Template *tpnt) continue; } + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + nplutos++; - if (fc->module) __MOD_INC_USE_COUNT(fc->module); - pluto = (struct pluto *)host->hostdata; host->max_id = inq->targets; diff --git a/drivers/serial/core.c b/drivers/serial/core.c index 4e6c1a543e55..4e4c736318bb 100644 --- a/drivers/serial/core.c +++ b/drivers/serial/core.c @@ -396,7 +396,7 @@ uart_get_divisor(struct uart_port *port, struct termios *termios, baud = uart_get_baud_rate(port, termios); quot = uart_calculate_quot(port, baud); if (quot) - break; + return quot; /* * Oops, the quotient was zero. Try again with @@ -1294,8 +1294,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) wake_up_interruptible(&info->open_wait); done: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); } static void uart_wait_until_sent(struct tty_struct *tty, int timeout) @@ -1665,8 +1664,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) return retval; out: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); fail: return retval; } diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 272b32873d7e..6d3c093afa1d 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -3278,19 +3278,23 @@ request_decompressor(struct usb_ov511 *ov) err("Unknown bridge"); } - if (ov->decomp_ops) { - if (!ov->decomp_ops->owner) { - ov->decomp_ops = NULL; - unlock_kernel(); - return -ENOSYS; - } - __MOD_INC_USE_COUNT(ov->decomp_ops->owner); - unlock_kernel(); - return 0; - } else { - unlock_kernel(); - return -ENOSYS; + if (!ov->decomp_ops) + goto nosys; + + if (!ov->decomp_ops->owner) { + ov->decomp_ops = NULL; + goto nosys; } + + if (!try_module_get(ov->decomp_ops->owner)) + goto nosys; + + unlock_kernel(); + return 0; + + nosys: + unlock_kernel(); + return -ENOSYS; } /* Unlocks decompression module and nulls ov->decomp_ops. Safe to call even @@ -3306,8 +3310,8 @@ release_decompressor(struct usb_ov511 *ov) lock_kernel(); - if (ov->decomp_ops && ov->decomp_ops->owner) { - __MOD_DEC_USE_COUNT(ov->decomp_ops->owner); + if (ov->decomp_ops) { + module_put(ov->decomp_ops->owner); released = 1; } diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index 6620d403ba9c..4c81b621ff76 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -730,6 +730,7 @@ EXPORT_SYMBOL(usbvideo_SayAndWait); /* ******************************************************************** */ +/* XXX: this piece of crap really wants some error handling.. */ static void usbvideo_ClientIncModCount(struct uvd *uvd) { if (uvd == NULL) { @@ -744,7 +745,10 @@ static void usbvideo_ClientIncModCount(struct uvd *uvd) err("%s: uvd->handle->md_module == NULL", __FUNCTION__); return; } - __MOD_INC_USE_COUNT(uvd->handle->md_module); + if (!try_module_get(uvd->handle->md_module)) { + err("%s: try_module_get() == 0", __FUNCTION__); + return; + } } static void usbvideo_ClientDecModCount(struct uvd *uvd) @@ -761,7 +765,7 @@ static void usbvideo_ClientDecModCount(struct uvd *uvd) err("%s: uvd->handle->md_module == NULL", __FUNCTION__); return; } - __MOD_DEC_USE_COUNT(uvd->handle->md_module); + module_put(uvd->handle->md_module); } int usbvideo_register( diff --git a/drivers/video/aty128fb.c b/drivers/video/aty128fb.c index 69f2d8d618c3..5545dbdb50ac 100644 --- a/drivers/video/aty128fb.c +++ b/drivers/video/aty128fb.c @@ -1415,7 +1415,7 @@ aty128fb_setup(char *options) } #endif #ifdef CONFIG_ALL_PPC - /* vmode and cmode depreciated */ + /* vmode and cmode deprecated */ if (!strncmp(this_opt, "vmode:", 6)) { unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX) diff --git a/fs/block_dev.c b/fs/block_dev.c index e6fc5b1984e3..2e0b69ff70a1 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -623,8 +623,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * } } else { put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); if (bdev->bd_contains == bdev) { if (bdev->bd_disk->fops->open) { ret = bdev->bd_disk->fops->open(inode, file); @@ -651,8 +650,7 @@ out_first: blkdev_put(bdev->bd_contains, BDEV_RAW); bdev->bd_contains = NULL; put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); out: up(&bdev->bd_sem); unlock_kernel(); @@ -723,9 +721,10 @@ int blkdev_put(struct block_device *bdev, int kind) } if (!bdev->bd_openers) { struct module *owner = disk->fops->owner; + put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); + bdev->bd_disk = NULL; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; if (bdev != bdev->bd_contains) { diff --git a/fs/dquot.c b/fs/dquot.c index 5da20a7049ce..8781f7201a87 100644 --- a/fs/dquot.c +++ b/fs/dquot.c @@ -111,8 +111,7 @@ static struct quota_format_type *find_quota_format(int id) static void put_quota_format(struct quota_format_type *fmt) { - if (fmt->qf_owner) - __MOD_DEC_USE_COUNT(fmt->qf_owner); + module_put(fmt->qf_owner); } /* diff --git a/fs/exec.c b/fs/exec.c index 1699f5bdf92e..901b8e12388f 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -102,8 +102,7 @@ int unregister_binfmt(struct linux_binfmt * fmt) static inline void put_binfmt(struct linux_binfmt * fmt) { - if (fmt->module) - __MOD_DEC_USE_COUNT(fmt->module); + module_put(fmt->module); } /* @@ -1108,14 +1107,18 @@ out_file: return retval; } -void set_binfmt(struct linux_binfmt *new) +int set_binfmt(struct linux_binfmt *new) { struct linux_binfmt *old = current->binfmt; - if (new && new->module) - __MOD_INC_USE_COUNT(new->module); + + if (new) { + if (!try_module_get(new->module)) + return -1; + } current->binfmt = new; - if (old && old->module) - __MOD_DEC_USE_COUNT(old->module); + if (old) + module_put(old->module); + return 0; } #define CORENAME_MAX_SIZE 64 diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 0fa6fcfe61b0..d2f5935ef972 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -694,8 +694,6 @@ static journal_t * journal_init_common (void) journal_t *journal; int err; - MOD_INC_USE_COUNT; - journal = jbd_kmalloc(sizeof(*journal), GFP_KERNEL); if (!journal) goto fail; @@ -724,7 +722,6 @@ static journal_t * journal_init_common (void) } return journal; fail: - MOD_DEC_USE_COUNT; return NULL; } @@ -1131,7 +1128,6 @@ void journal_destroy (journal_t *journal) unlock_journal(journal); kfree(journal); - MOD_DEC_USE_COUNT; } diff --git a/fs/libfs.c b/fs/libfs.c index 813bc9046bcd..e3d30987c919 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -6,6 +6,15 @@ #include <linux/pagemap.h> #include <linux/smp_lock.h> +int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ + struct inode *inode = dentry->d_inode; + generic_fillattr(inode, stat); + stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + return 0; +} + int simple_statfs(struct super_block *sb, struct statfs *buf) { buf->f_type = sb->s_magic; diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c index 0af5e08cb950..3ea711688341 100644 --- a/fs/nls/nls_base.c +++ b/fs/nls/nls_base.c @@ -245,8 +245,7 @@ struct nls_table *load_nls(char *charset) void unload_nls(struct nls_table *nls) { - if (nls->owner) - __MOD_DEC_USE_COUNT(nls->owner); + module_put(nls->owner); } wchar_t charset2uni[256] = { diff --git a/fs/partitions/check.c b/fs/partitions/check.c index da216ea3efa6..b1d436feb241 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -565,8 +565,7 @@ char *partition_name(dev_t dev) dname->name = NULL; if (hd) { dname->name = disk_name(hd, part, dname->namebuf); - if (hd->fops->owner) - __MOD_DEC_USE_COUNT(hd->fops->owner); + module_put(hd->fops->owner); put_disk(hd); } if (!dname->name) { diff --git a/fs/proc/array.c b/fs/proc/array.c index 2fa25e95712d..4dae164bc85a 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -513,8 +513,9 @@ static int proc_pid_maps_get_line (char *buf, struct vm_area_struct *map) return len; } -ssize_t proc_pid_read_maps (struct task_struct *task, struct file * file, char * buf, - size_t count, loff_t *ppos) +#ifdef CONFIG_MMU +ssize_t proc_pid_read_maps(struct task_struct *task, struct file *file, + char *buf, size_t count, loff_t *ppos) { struct mm_struct *mm; struct vm_area_struct * map; @@ -597,3 +598,4 @@ out_free1: out: return retval; } +#endif /* CONFIG_MMU */ diff --git a/fs/proc/base.c b/fs/proc/base.c index ac19cc676195..9fa201bb6f9e 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -75,7 +75,9 @@ static struct pid_entry base_stuff[] = { E(PROC_PID_CMDLINE, "cmdline", S_IFREG|S_IRUGO), E(PROC_PID_STAT, "stat", S_IFREG|S_IRUGO), E(PROC_PID_STATM, "statm", S_IFREG|S_IRUGO), +#ifdef CONFIG_MMU E(PROC_PID_MAPS, "maps", S_IFREG|S_IRUGO), +#endif E(PROC_PID_MEM, "mem", S_IFREG|S_IRUSR|S_IWUSR), E(PROC_PID_CWD, "cwd", S_IFLNK|S_IRWXUGO), E(PROC_PID_ROOT, "root", S_IFLNK|S_IRWXUGO), @@ -98,7 +100,6 @@ static inline int proc_type(struct inode *inode) return PROC_I(inode)->type; } -ssize_t proc_pid_read_maps(struct task_struct*,struct file*,char*,size_t,loff_t*); int proc_pid_stat(struct task_struct*,char*); int proc_pid_status(struct task_struct*,char*); int proc_pid_statm(struct task_struct*,char*); @@ -321,6 +322,9 @@ static int proc_permission(struct inode *inode, int mask) return proc_check_root(inode); } +#ifdef CONFIG_MMU +extern ssize_t proc_pid_read_maps(struct task_struct *, struct file *, + char *, size_t, loff_t *); static ssize_t pid_maps_read(struct file * file, char * buf, size_t count, loff_t *ppos) { @@ -335,6 +339,7 @@ static ssize_t pid_maps_read(struct file * file, char * buf, static struct file_operations proc_maps_operations = { .read = pid_maps_read, }; +#endif /* CONFIG_MMU */ extern struct seq_operations mounts_op; static int mounts_open(struct inode *inode, struct file *file) @@ -1023,10 +1028,11 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry) inode->i_fop = &proc_info_file_operations; ei->op.proc_read = proc_pid_statm; break; +#ifdef CONFIG_MMU case PROC_PID_MAPS: inode->i_fop = &proc_maps_operations; break; - +#endif case PROC_PID_MEM: inode->i_op = &proc_mem_inode_operations; inode->i_fop = &proc_mem_operations; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 9f8ac09e12ce..15418ab4f490 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -40,6 +40,7 @@ static struct super_operations ramfs_ops; static struct address_space_operations ramfs_aops; static struct file_operations ramfs_file_operations; +static struct inode_operations ramfs_file_inode_operations; static struct inode_operations ramfs_dir_inode_operations; static struct backing_dev_info ramfs_backing_dev_info = { @@ -66,6 +67,7 @@ static struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev init_special_inode(inode, mode, dev); break; case S_IFREG: + inode->i_op = &ramfs_file_inode_operations; inode->i_fop = &ramfs_file_operations; break; case S_IFDIR: @@ -114,7 +116,6 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode) return ramfs_mknod(dir, dentry, mode | S_IFREG, 0); } - static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname) { struct inode *inode; @@ -147,6 +148,10 @@ static struct file_operations ramfs_file_operations = { .sendfile = generic_file_sendfile, }; +static struct inode_operations ramfs_file_inode_operations = { + .getattr = simple_getattr, +}; + static struct inode_operations ramfs_dir_inode_operations = { .create = ramfs_create, .lookup = simple_lookup, diff --git a/include/asm-arm/arch-arc/io.h b/include/asm-arm/arch-arc/io.h index 11c9ce687ab4..5aab0c88953f 100644 --- a/include/asm-arm/arch-arc/io.h +++ b/include/asm-arm/arch-arc/io.h @@ -246,7 +246,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) /* diff --git a/include/asm-arm/arch-cl7500/io.h b/include/asm-arm/arch-cl7500/io.h index 376ca94ebb9c..16a926084d5f 100644 --- a/include/asm-arm/arch-cl7500/io.h +++ b/include/asm-arm/arch-cl7500/io.h @@ -236,7 +236,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) #endif diff --git a/include/asm-arm/arch-rpc/io.h b/include/asm-arm/arch-rpc/io.h index cb39453f5c9f..3a1c18ad63bb 100644 --- a/include/asm-arm/arch-rpc/io.h +++ b/include/asm-arm/arch-rpc/io.h @@ -238,7 +238,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) #define insb(p,d,l) __raw_readsb(__ioaddr(p),d,l) diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h index c936883e5f0e..38682a28d121 100644 --- a/include/asm-arm/memory.h +++ b/include/asm-arm/memory.h @@ -44,7 +44,7 @@ static inline void *phys_to_virt(unsigned long x) /* * Virtual <-> DMA view memory address translations * Again, these are *only* valid on the kernel direct mapped RAM - * memory. Use of these is *depreciated*. + * memory. Use of these is *deprecated*. */ #define virt_to_bus(x) (__virt_to_bus((unsigned long)(x))) #define bus_to_virt(x) ((void *)(__bus_to_virt((unsigned long)(x)))) @@ -109,7 +109,7 @@ static inline void *phys_to_virt(unsigned long x) #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) /* - * We should really eliminate virt_to_bus() here - it's depreciated. + * We should really eliminate virt_to_bus() here - it's deprecated. */ #define page_to_bus(page) (virt_to_bus(page_address(page))) diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h index 38f4ba0ecc67..f3319e9b4f29 100644 --- a/include/asm-arm/setup.h +++ b/include/asm-arm/setup.h @@ -68,7 +68,7 @@ struct tag_ramdisk { /* describes where the compressed ramdisk image lives (virtual address) */ /* * this one accidentally used virtual addresses - as such, - * its depreciated. + * it's deprecated. */ #define ATAG_INITRD 0x54410005 diff --git a/include/asm-i386/mach-default/mach_apic.h b/include/asm-i386/mach-default/mach_apic.h index a24df01ffe2e..905bc7a1284d 100644 --- a/include/asm-i386/mach-default/mach_apic.h +++ b/include/asm-i386/mach-default/mach_apic.h @@ -73,8 +73,7 @@ static inline int mpc_apic_id(struct mpc_config_processor *m, int quad) return (m->mpc_apicid); } -#define wakeup_secondary_cpu(apicid, start_eip) \ - wakeup_secondary_via_INIT(apicid, start_eip) +#define WAKE_SECONDARY_VIA_INIT static inline void setup_portio_remap(void) { diff --git a/include/asm-i386/mach-numaq/mach_apic.h b/include/asm-i386/mach-numaq/mach_apic.h index be8eacb32aa0..94d2f5f28275 100644 --- a/include/asm-i386/mach-numaq/mach_apic.h +++ b/include/asm-i386/mach-numaq/mach_apic.h @@ -69,8 +69,7 @@ static inline int mpc_apic_id(struct mpc_config_processor *m, int quad) return logical_apicid; } -#define wakeup_secondary_cpu(apicid, start_eip) \ - wakeup_secondary_via_NMI(apicid) +#define WAKE_SECONDARY_VIA_NMI static inline void setup_portio_remap(void) { diff --git a/include/asm-i386/mach-numaq/mach_mpparse.h b/include/asm-i386/mach-numaq/mach_mpparse.h index ddda81a724a8..f15b7b9ae1e8 100644 --- a/include/asm-i386/mach-numaq/mach_mpparse.h +++ b/include/asm-i386/mach-numaq/mach_mpparse.h @@ -1,9 +1,6 @@ #ifndef __ASM_MACH_MPPARSE_H #define __ASM_MACH_MPPARSE_H -static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, - unsigned short oemsize); - static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, struct mpc_config_translation *translation) { diff --git a/include/asm-i386/mach-summit/mach_apic.h b/include/asm-i386/mach-summit/mach_apic.h index 2de1e9fea7cd..bf601c3368ad 100644 --- a/include/asm-i386/mach-summit/mach_apic.h +++ b/include/asm-i386/mach-summit/mach_apic.h @@ -54,8 +54,7 @@ static inline unsigned long apicid_to_phys_cpu_present(int apicid) return (1ul << apicid); } -#define wakeup_secondary_cpu(apicid, start_eip) \ - wakeup_secondary_via_INIT(apicid, start_eip) +#define WAKE_SECONDARY_VIA_INIT static inline void setup_portio_remap(void) { diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h index 01cdbdc7a32b..6ee68de9408b 100644 --- a/include/asm-i386/processor.h +++ b/include/asm-i386/processor.h @@ -395,31 +395,17 @@ struct thread_struct { unsigned long *ts_io_bitmap; }; -#define INIT_THREAD { \ - { { 0, 0 } , }, \ - 0, \ - 0, 0, 0, 0, \ - { [0 ... 7] = 0 }, /* debugging registers */ \ - 0, 0, 0, \ - { { 0, }, }, /* 387 state */ \ - 0,0,0,0,0, \ - NULL, /* io permissions */ \ +#define INIT_THREAD { \ + .vm86_info = NULL, \ + .ts_io_bitmap = NULL, \ } -#define INIT_TSS { \ - 0,0, /* back_link, __blh */ \ - sizeof(init_stack) + (long) &init_stack, /* esp0 */ \ - __KERNEL_DS, 0, /* ss0 */ \ - 0,0,0,0,0,0, /* stack1, stack2 */ \ - 0, /* cr3 */ \ - 0,0, /* eip,eflags */ \ - 0,0,0,0, /* eax,ecx,edx,ebx */ \ - 0,0,0,0, /* esp,ebp,esi,edi */ \ - 0,0,0,0,0,0, /* es,cs,ss */ \ - 0,0,0,0,0,0, /* ds,fs,gs */ \ - GDT_ENTRY_LDT,0, /* ldt */ \ - 0, INVALID_IO_BITMAP_OFFSET, /* tace, bitmap */ \ - {~0, } /* ioperm */ \ +#define INIT_TSS { \ + .esp0 = sizeof(init_stack) + (long)&init_stack, \ + .ss0 = __KERNEL_DS, \ + .ldt = GDT_ENTRY_LDT, \ + .bitmap = INVALID_IO_BITMAP_OFFSET, \ + .io_bitmap = { [ 0 ... IO_BITMAP_SIZE ] = ~0 }, \ } static inline void load_esp0(struct tss_struct *tss, unsigned long esp0) diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h index 05bdac770eed..377038170a0b 100644 --- a/include/asm-i386/uaccess.h +++ b/include/asm-i386/uaccess.h @@ -189,7 +189,7 @@ do { \ case 1: __put_user_asm(x,ptr,retval,"b","b","iq"); break; \ case 2: __put_user_asm(x,ptr,retval,"w","w","ir"); break; \ case 4: __put_user_asm(x,ptr,retval,"l","","ir"); break; \ - case 8: __put_user_u64(x,ptr,retval); break; \ + case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break; \ default: __put_user_bad(); \ } \ } while (0) diff --git a/include/asm-m68k/ide.h b/include/asm-m68k/ide.h index 6b451e47441c..621be3adc24a 100644 --- a/include/asm-m68k/ide.h +++ b/include/asm-m68k/ide.h @@ -144,19 +144,19 @@ static __inline__ void ide_init_default_hwifs(void) #define ATA_ARCH_ACK_INTR -#ifdef CONFIG_ATARI +#ifdef CONFIG_BLK_DEV_FALCON_IDE #define ATA_ARCH_LOCK -extern int ide_intr_lock; +extern int falconide_intr_lock; static __inline__ void ide_release_lock (void) { if (MACH_IS_ATARI) { - if (ide_intr_lock == 0) { + if (falconide_intr_lock == 0) { printk("ide_release_lock: bug\n"); return; } - ide_intr_lock = 0; + falconide_intr_lock = 0; stdma_release(); } } @@ -164,14 +164,14 @@ static __inline__ void ide_release_lock (void) static __inline__ void ide_get_lock(void (*handler)(int, void *, struct pt_regs *), void *data) { if (MACH_IS_ATARI) { - if (ide_intr_lock == 0) { + if (falconide_intr_lock == 0) { if (in_interrupt() > 0) panic( "Falcon IDE hasn't ST-DMA lock in interrupt" ); stdma_lock(handler, data); - ide_intr_lock = 1; + falconide_intr_lock = 1; } } } -#endif /* CONFIG_ATARI */ +#endif /* CONFIG_BLK_DEV_FALCON_IDE */ #endif /* __KERNEL__ */ #endif /* _M68K_IDE_H */ diff --git a/include/linux/ax25.h b/include/linux/ax25.h index 6dfc8fc9116d..56c11f0dbd80 100644 --- a/include/linux/ax25.h +++ b/include/linux/ax25.h @@ -85,7 +85,7 @@ struct ax25_ctl_struct { }; /* this will go away. Please do not export to user land */ -struct ax25_info_struct_depreciated { +struct ax25_info_struct_deprecated { unsigned int n2, n2count; unsigned int t1, t1timer; unsigned int t2, t2timer; diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index ae1b454395b5..bd929e344d75 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -58,13 +58,7 @@ extern int copy_strings(int argc,char ** argv,struct linux_binprm *bprm); extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); extern void compute_creds(struct linux_binprm *binprm); extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); -extern void set_binfmt(struct linux_binfmt *new); - - -#if 0 -/* this went away now */ -#define change_ldt(a,b) setup_arg_pages(a,b) -#endif +extern int set_binfmt(struct linux_binfmt *new); #endif /* __KERNEL__ */ #endif /* _LINUX_BINFMTS_H */ diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 51cfdb71594b..f88889740949 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -21,9 +21,9 @@ * and then gcc will emit a warning for each usage of the function. */ #if __GNUC__ >= 3 -#define deprecated __attribute__((deprecated)) +#define __deprecated __attribute__((deprecated)) #else -#define deprecated +#define __deprecated #endif /* This macro obfuscates arithmetic on a variable address so that gcc diff --git a/include/linux/fs.h b/include/linux/fs.h index 500cb3ac421e..6c3188b991e6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -983,13 +983,13 @@ struct super_block *get_sb_pseudo(struct file_system_type *, char *, /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \ (((fops) && (fops)->owner) \ - ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \ + ? (try_inc_mod_count((fops)->owner) ? (fops) : NULL) \ : (fops)) #define fops_put(fops) \ do { \ if ((fops) && (fops)->owner) \ - __MOD_DEC_USE_COUNT((fops)->owner); \ + module_put((fops)->owner); \ } while(0) extern int register_filesystem(struct file_system_type *); @@ -1300,6 +1300,7 @@ extern int dcache_dir_open(struct inode *, struct file *); extern int dcache_dir_close(struct inode *, struct file *); extern loff_t dcache_dir_lseek(struct file *, loff_t, int); extern int dcache_readdir(struct file *, void *, filldir_t); +extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int simple_statfs(struct super_block *, struct statfs *); extern int simple_link(struct dentry *, struct inode *, struct dentry *); extern int simple_unlink(struct inode *, struct dentry *); diff --git a/include/linux/init.h b/include/linux/init.h index 46b1ef190c52..b7c6363478aa 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -147,14 +147,13 @@ struct obs_kernel_param { #define module_init(initfn) \ static inline initcall_t __inittest(void) \ { return initfn; } \ - int __initfn(void) __attribute__((alias(#initfn))); + int init_module(void) __attribute__((alias(#initfn))); /* This is only required if you want to be unloadable. */ #define module_exit(exitfn) \ static inline exitcall_t __exittest(void) \ { return exitfn; } \ - void __exitfn(void) __attribute__((alias(#exitfn))); - + void cleanup_module(void) __attribute__((alias(#exitfn))); #define __setup(str,func) /* nothing */ #endif diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 7c48dfa36962..edd1eadb98b8 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -108,7 +108,7 @@ extern struct resource * __request_region(struct resource *, unsigned long start #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) -extern int deprecated __check_region(struct resource *, unsigned long, unsigned long); +extern int __deprecated __check_region(struct resource *, unsigned long, unsigned long); extern void __release_region(struct resource *, unsigned long, unsigned long); #define get_ioport_list(buf) get_resource_list(&ioport_resource, buf, PAGE_SIZE) diff --git a/include/linux/module.h b/include/linux/module.h index 2392edcc3307..3a411c8c6575 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -40,12 +40,11 @@ struct kernel_symbol char name[MODULE_NAME_LEN]; }; -#ifdef MODULE +/* These are either module local, or the kernel's dummy ones. */ +extern int init_module(void); +extern void cleanup_module(void); -#ifdef KBUILD_MODNAME -static const char __module_name[MODULE_NAME_LEN] __attribute__((section(".gnu.linkonce.modname"))) = \ - __stringify(KBUILD_MODNAME); -#endif +#ifdef MODULE /* For replacement modutils, use an alias not a pointer. */ #define MODULE_GENERIC_TABLE(gtype,name) \ @@ -56,9 +55,6 @@ static const struct gtype##_id * __module_##gtype##_table \ extern const struct gtype##_id __mod_##gtype##_table \ __attribute__ ((unused, alias(__stringify(name)))) -/* This is magically filled in by the linker, but THIS_MODULE must be - a constant so it works in initializers. */ -extern struct module __this_module; #define THIS_MODULE (&__this_module) #else /* !MODULE */ @@ -176,7 +172,7 @@ struct module /* The command line arguments (may be mangled). People like keeping pointers to this stuff */ - char args[0]; + char *args; }; /* FIXME: It'd be nice to isolate modules during init, too, so they @@ -289,6 +285,19 @@ static inline const char *module_address_lookup(unsigned long addr, } #endif /* CONFIG_MODULES */ +#if defined(MODULE) && defined(KBUILD_MODNAME) +/* We make the linker do some of the work. */ +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = __stringify(KBUILD_MODNAME), + .symbols = { .owner = &__this_module }, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; +#endif /* MODULE && KBUILD_MODNAME */ + /* For archs to search exception tables */ extern struct list_head extables; extern spinlock_t modlist_lock; @@ -296,9 +305,20 @@ extern spinlock_t modlist_lock; #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ -#define __MOD_INC_USE_COUNT(mod) \ - do { __unsafe(mod); (void)try_module_get(mod); } while(0) -#define __MOD_DEC_USE_COUNT(mod) module_put(mod) +static inline void __deprecated __MOD_INC_USE_COUNT(struct module *module) +{ + __unsafe(module); + /* + * Yes, we ignore the retval here, that's why it's deprecated. + */ + try_module_get(module); +} + +static inline void __deprecated __MOD_DEC_USE_COUNT(struct module *module) +{ + module_put(module); +} + #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE) struct obsolete_modparm { @@ -319,14 +339,21 @@ struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \ /* People do this inside their init routines, when the module isn't "live" yet. They should no longer be doing that, but meanwhile... */ +static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module) +{ + __unsafe(module); + #if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE) -#define MOD_INC_USE_COUNT \ - do { __unsafe(THIS_MODULE); local_inc(&THIS_MODULE->ref[get_cpu()].count); put_cpu(); } while (0) + local_inc(&module->ref[get_cpu()].count); + put_cpu(); #else -#define MOD_INC_USE_COUNT \ - do { __unsafe(THIS_MODULE); (void)try_module_get(THIS_MODULE); } while (0) + try_module_get(module); #endif -#define MOD_DEC_USE_COUNT module_put(THIS_MODULE) +} +#define MOD_INC_USE_COUNT \ + _MOD_INC_USE_COUNT(THIS_MODULE) +#define MOD_DEC_USE_COUNT \ + __MOD_DEC_USE_COUNT(THIS_MODULE) #define try_inc_mod_count(mod) try_module_get(mod) #define EXPORT_NO_SYMBOLS extern int module_dummy_usage; @@ -342,13 +369,6 @@ extern int module_dummy_usage; && __mod_between((p),(n),(m)->module_init,(m)->init_size)) \ || __mod_between((p),(n),(m)->module_core,(m)->core_size)) -/* Old-style "I'll just call it init_module and it'll be run at - insert". Use module_init(myroutine) instead. */ -#ifdef MODULE -#define init_module(voidarg) __initfn(void) -#define cleanup_module(voidarg) __exitfn(void) -#endif - /* * The exception and symbol tables, and the lock * to protect them. diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 92a1bc154e8e..e52553263640 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -39,7 +39,7 @@ struct kparam_string { writable. */ #define __module_param_call(prefix, name, set, get, arg, perm) \ static char __param_str_##name[] __initdata = prefix #name; \ - static struct kernel_param __param_##name \ + static struct kernel_param const __param_##name \ __attribute__ ((unused,__section__ ("__param"))) \ = { __param_str_##name, perm, set, get, arg } diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h index 94ffed22315b..ad8dfcbda17d 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h @@ -81,10 +81,7 @@ static inline void map_destroy(struct mtd_info *mtd) if (map->fldrv->destroy) map->fldrv->destroy(mtd); -#ifdef CONFIG_MODULES - if (map->fldrv->module) - __MOD_DEC_USE_COUNT(map->fldrv->module); -#endif + module_put(map->fldrv->module); kfree(mtd); } diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index ae5bfe3e10fb..52d38241e91e 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -224,8 +224,7 @@ static inline struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) static inline void put_mtd_device(struct mtd_info *mtd) { - if (mtd->module) - __MOD_DEC_USE_COUNT(mtd->module); + module_put(mtd->module); } diff --git a/include/linux/personality.h b/include/linux/personality.h index ca5d403e49ff..33802c8eeedb 100644 --- a/include/linux/personality.h +++ b/include/linux/personality.h @@ -107,22 +107,4 @@ struct exec_domain { #define set_personality(pers) \ ((current->personality == pers) ? 0 : __set_personality(pers)) -/* - * Load an execution domain. - */ -#define get_exec_domain(ep) \ -do { \ - if (ep != NULL && ep->module != NULL) \ - __MOD_INC_USE_COUNT(ep->module); \ -} while (0) - -/* - * Unload an execution domain. - */ -#define put_exec_domain(ep) \ -do { \ - if (ep != NULL && ep->module != NULL) \ - __MOD_DEC_USE_COUNT(ep->module); \ -} while (0) - #endif /* _LINUX_PERSONALITY_H */ diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index e0b31f7f5243..162a5c23e606 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -172,7 +172,7 @@ __set_personality(u_long personality) fsp = copy_fs_struct(current->fs); if (fsp == NULL) { - put_exec_domain(ep); + module_put(ep->module); return -ENOMEM;; } @@ -194,10 +194,7 @@ __set_personality(u_long personality) current_thread_info()->exec_domain = ep; set_fs_altroot(); - put_exec_domain(oep); - - printk(KERN_DEBUG "[%s:%d]: set personality to %lx\n", - current->comm, current->pid, personality); + module_put(oep->module); return 0; } diff --git a/kernel/exit.c b/kernel/exit.c index 5e7fcdaa6221..6adea537242a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -664,9 +664,9 @@ fake_volatile: if (current->leader) disassociate_ctty(1); - put_exec_domain(tsk->thread_info->exec_domain); - if (tsk->binfmt && tsk->binfmt->module) - __MOD_DEC_USE_COUNT(tsk->binfmt->module); + module_put(tsk->thread_info->exec_domain->module); + if (tsk->binfmt) + module_put(tsk->binfmt->module); tsk->exit_code = code; exit_notify(); diff --git a/kernel/fork.c b/kernel/fork.c index b8771509f285..6f7298827344 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -743,10 +743,11 @@ static struct task_struct *copy_process(unsigned long clone_flags, if (nr_threads >= max_threads) goto bad_fork_cleanup_count; - get_exec_domain(p->thread_info->exec_domain); + if (!try_module_get(p->thread_info->exec_domain->module)) + goto bad_fork_cleanup_count; - if (p->binfmt && p->binfmt->module) - __MOD_INC_USE_COUNT(p->binfmt->module); + if (p->binfmt && !try_module_get(p->binfmt->module)) + goto bad_fork_cleanup_put_domain; #ifdef CONFIG_PREEMPT /* @@ -958,9 +959,10 @@ bad_fork_cleanup_security: bad_fork_cleanup: if (p->pid > 0) free_pidmap(p->pid); - put_exec_domain(p->thread_info->exec_domain); - if (p->binfmt && p->binfmt->module) - __MOD_DEC_USE_COUNT(p->binfmt->module); + if (p->binfmt) + module_put(p->binfmt->module); +bad_fork_cleanup_put_domain: + module_put(p->thread_info->exec_domain->module); bad_fork_cleanup_count: atomic_dec(&p->user->processes); free_uid(p->user); diff --git a/kernel/intermodule.c b/kernel/intermodule.c index a6cd1d08afa4..9228ca4fe035 100644 --- a/kernel/intermodule.c +++ b/kernel/intermodule.c @@ -166,7 +166,7 @@ void inter_module_put(const char *im_name) ime = list_entry(tmp, struct inter_module_entry, list); if (strcmp(ime->im_name, im_name) == 0) { if (ime->owner) - __MOD_DEC_USE_COUNT(ime->owner); + module_put(ime->owner); spin_unlock(&ime_lock); return; } diff --git a/kernel/ksyms.c b/kernel/ksyms.c index f634f12d4bef..cd49778dd1f3 100644 --- a/kernel/ksyms.c +++ b/kernel/ksyms.c @@ -299,6 +299,7 @@ EXPORT_SYMBOL(dcache_dir_open); EXPORT_SYMBOL(dcache_dir_close); EXPORT_SYMBOL(dcache_dir_lseek); EXPORT_SYMBOL(dcache_readdir); +EXPORT_SYMBOL(simple_getattr); EXPORT_SYMBOL(simple_statfs); EXPORT_SYMBOL(simple_lookup); EXPORT_SYMBOL(simple_dir_operations); diff --git a/kernel/module.c b/kernel/module.c index 2209ab07e733..4b789cf97f5d 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -60,6 +60,13 @@ struct sizes unsigned long core_size; }; +/* Stub function for modules which don't have an initfn */ +int init_module(void) +{ + return 0; +} +EXPORT_SYMBOL(init_module); + /* Find a symbol, return value and the symbol group */ static unsigned long __find_symbol(const char *name, struct kernel_symbol_group **group) @@ -357,6 +364,12 @@ static inline int try_force(unsigned int flags) } #endif /* CONFIG_MODULE_FORCE_UNLOAD */ +/* Stub function for modules which don't have an exitfn */ +void cleanup_module(void) +{ +} +EXPORT_SYMBOL(cleanup_module); + asmlinkage long sys_delete_module(const char *name_user, unsigned int flags) { @@ -406,7 +419,8 @@ sys_delete_module(const char *name_user, unsigned int flags) } /* If it has an init func, it must have an exit func to unload */ - if ((mod->init && !mod->exit) || mod->unsafe) { + if ((mod->init != init_module && mod->exit == cleanup_module) + || mod->unsafe) { forced = try_force(flags); if (!forced) { /* This module can't be removed */ @@ -453,8 +467,7 @@ sys_delete_module(const char *name_user, unsigned int flags) destroy: /* Final destruction now noone is using it. */ - if (mod->exit) - mod->exit(); + mod->exit(); free_module(mod); out: @@ -474,7 +487,7 @@ static void print_unload_info(struct seq_file *m, struct module *mod) if (mod->unsafe) seq_printf(m, " [unsafe]"); - if (mod->init && !mod->exit) + if (mod->init != init_module && mod->exit == cleanup_module) seq_printf(m, " [permanent]"); seq_printf(m, "\n"); @@ -708,15 +721,15 @@ static void free_module(struct module *mod) list_del(&mod->extable.list); spin_unlock_irq(&modlist_lock); - /* These may be NULL, but that's OK */ - module_free(mod, mod->module_init); - module_free(mod, mod->module_core); - /* Module unload stuff */ module_unload_free(mod); - /* Finally, free the module structure */ - module_free(mod, mod); + /* This may be NULL, but that's OK */ + module_free(mod, mod->module_init); + kfree(mod->args); + + /* Finally, free the core (containing the module structure) */ + module_free(mod, mod->module_core); } void *__symbol_get(const char *symbol) @@ -771,27 +784,6 @@ static void *copy_section(const char *name, return dest; } -/* Look for the special symbols */ -static int grab_private_symbols(Elf_Shdr *sechdrs, - unsigned int symbolsec, - const char *strtab, - struct module *mod) -{ - Elf_Sym *sym = (void *)sechdrs[symbolsec].sh_offset; - unsigned int i; - - for (i = 1; i < sechdrs[symbolsec].sh_size/sizeof(*sym); i++) { - if (symbol_is("__initfn", strtab + sym[i].st_name)) - mod->init = (void *)sym[i].st_value; -#ifdef CONFIG_MODULE_UNLOAD - if (symbol_is("__exitfn", strtab + sym[i].st_name)) - mod->exit = (void *)sym[i].st_value; -#endif - } - - return 0; -} - /* Deal with the given section */ static int handle_section(const char *name, Elf_Shdr *sechdrs, @@ -810,9 +802,6 @@ static int handle_section(const char *name, case SHT_RELA: ret = apply_relocate_add(sechdrs, strtab, symindex, i, mod); break; - case SHT_SYMTAB: - ret = grab_private_symbols(sechdrs, i, strtab, mod); - break; default: DEBUGP("Ignoring section %u: %s\n", i, sechdrs[i].sh_type==SHT_NULL ? "NULL": @@ -920,9 +909,6 @@ static void simplify_symbols(Elf_Shdr *sechdrs, strtab + sym[i].st_name, mod, &ksg); - /* We fake up "__this_module" */ - if (symbol_is("__this_module", strtab+sym[i].st_name)) - sym[i].st_value = (unsigned long)mod; } } } @@ -964,9 +950,9 @@ static struct module *load_module(void *umod, { Elf_Ehdr *hdr; Elf_Shdr *sechdrs; - char *secstrings; + char *secstrings, *args; unsigned int i, symindex, exportindex, strindex, setupindex, exindex, - modnameindex, obsparmindex; + modindex, obsparmindex; long arglen; unsigned long common_length; struct sizes sizes, used; @@ -1007,7 +993,7 @@ static struct module *load_module(void *umod, exportindex = setupindex = obsparmindex = 0; /* And these should exist, but gcc whinges if we don't init them */ - symindex = strindex = exindex = modnameindex = 0; + symindex = strindex = exindex = modindex = 0; /* Find where important sections are */ for (i = 1; i < hdr->e_shnum; i++) { @@ -1015,21 +1001,19 @@ static struct module *load_module(void *umod, /* Internal symbols */ DEBUGP("Symbol table in section %u\n", i); symindex = i; + /* Strings */ + strindex = sechdrs[i].sh_link; + DEBUGP("String table found in section %u\n", strindex); } else if (strcmp(secstrings+sechdrs[i].sh_name, - ".gnu.linkonce.modname") == 0) { - /* This module's name */ - DEBUGP("Module name in section %u\n", i); - modnameindex = i; + ".gnu.linkonce.this_module") == 0) { + /* The module struct */ + DEBUGP("Module in section %u\n", i); + modindex = i; } else if (strcmp(secstrings+sechdrs[i].sh_name, "__ksymtab") == 0) { /* Exported symbols. */ DEBUGP("EXPORT table in section %u\n", i); exportindex = i; - } else if (strcmp(secstrings + sechdrs[i].sh_name, ".strtab") - == 0) { - /* Strings */ - DEBUGP("String table found in section %u\n", i); - strindex = i; } else if (strcmp(secstrings+sechdrs[i].sh_name, "__param") == 0) { /* Setup parameter info */ @@ -1058,39 +1042,35 @@ static struct module *load_module(void *umod, #endif } - if (!modnameindex) { - DEBUGP("Module has no name!\n"); + if (!modindex) { + printk(KERN_WARNING "No module found in object\n"); err = -ENOEXEC; goto free_hdr; } + mod = (void *)hdr + sechdrs[modindex].sh_offset; - /* Now allocate space for the module proper, and copy name and args. */ + /* Now copy in args */ err = strlen_user(uargs); if (err < 0) goto free_hdr; arglen = err; - mod = module_alloc(sizeof(*mod) + arglen+1); - if (!mod) { + args = kmalloc(arglen+1, GFP_KERNEL); + if (!args) { err = -ENOMEM; goto free_hdr; } - memset(mod, 0, sizeof(*mod) + arglen+1); - if (copy_from_user(mod->args, uargs, arglen) != 0) { + if (copy_from_user(args, uargs, arglen+1) != 0) { err = -EFAULT; goto free_mod; } - strncpy(mod->name, (char *)hdr + sechdrs[modnameindex].sh_offset, - sizeof(mod->name)-1); if (find_module(mod->name)) { err = -EEXIST; goto free_mod; } - mod->symbols.owner = mod; mod->state = MODULE_STATE_COMING; - module_unload_init(mod); /* How much space will we need? (Common area in first) */ common_length = read_commons(hdr, &sechdrs[symindex]); @@ -1139,6 +1119,9 @@ static struct module *load_module(void *umod, if (IS_ERR(ptr)) goto cleanup; sechdrs[i].sh_offset = (unsigned long)ptr; + /* Have we just copied __this_module across? */ + if (i == modindex) + mod = ptr; } else { sechdrs[i].sh_offset += (unsigned long)hdr; } @@ -1147,6 +1130,9 @@ static struct module *load_module(void *umod, if (used.init_size > mod->init_size || used.core_size > mod->core_size) BUG(); + /* Now we've moved module, initialize linked lists, etc. */ + module_unload_init(mod); + /* Fix up syms, so that st_value is a pointer to location. */ simplify_symbols(sechdrs, symindex, strindex, mod->module_core, mod); @@ -1183,6 +1169,7 @@ static struct module *load_module(void *umod, if (err < 0) goto cleanup; + mod->args = args; if (obsparmindex) { err = obsolete_params(mod->name, mod->args, (struct obsolete_modparm *) @@ -1215,7 +1202,7 @@ static struct module *load_module(void *umod, free_core: module_free(mod, mod->module_core); free_mod: - module_free(mod, mod); + kfree(args); free_hdr: vfree(hdr); if (err < 0) return ERR_PTR(err); @@ -1266,7 +1253,7 @@ sys_init_module(void *umod, up(&module_mutex); /* Start the module */ - ret = mod->init ? mod->init() : 0; + ret = mod->init(); if (ret < 0) { /* Init routine failed: abort. Try to protect us from buggy refcounters. */ diff --git a/kernel/resource.c b/kernel/resource.c index 7e23211ac0a9..83d04826245d 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -237,7 +237,7 @@ struct resource * __request_region(struct resource *parent, unsigned long start, return res; } -int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) +int __deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) { struct resource * res; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 82a847128a31..1eedb5ed6cb2 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1786,7 +1786,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) warned=1; } - if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_depreciated))) { + if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_deprecated))) { res = -EFAULT; break; } diff --git a/net/core/dev.c b/net/core/dev.c index e48cb774fe0f..97e772ff5f82 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -703,8 +703,7 @@ int dev_open(struct net_device *dev) ret = dev->open(dev); if (ret) { clear_bit(__LINK_STATE_START, &dev->state); - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + module_put(dev->owner); } } } else { @@ -829,16 +828,14 @@ int dev_close(struct net_device *dev) #endif /* - * Tell people we are down + * Tell people we are down */ notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev); /* * Drop the module refcount */ - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); - + module_put(dev->owner); return 0; } diff --git a/net/ipv4/xfrm_policy.c b/net/ipv4/xfrm_policy.c index d21d597e7be1..fe30556f78d6 100644 --- a/net/ipv4/xfrm_policy.c +++ b/net/ipv4/xfrm_policy.c @@ -200,8 +200,7 @@ struct xfrm_type *xfrm_get_type(u8 proto) void xfrm_put_type(struct xfrm_type *type) { - if (type->owner) - __MOD_DEC_USE_COUNT(type->owner); + module_put(type->owner); } static inline unsigned long make_jiffies(long secs) diff --git a/net/rxrpc/call.c b/net/rxrpc/call.c index 6bba546eece7..a0e81b58191d 100644 --- a/net/rxrpc/call.c +++ b/net/rxrpc/call.c @@ -435,7 +435,7 @@ void rxrpc_put_call(struct rxrpc_call *call) rxrpc_put_message(msg); } - if (call->owner) __MOD_DEC_USE_COUNT(call->owner); + module_put(call->owner); down_write(&rxrpc_calls_sem); list_del(&call->call_link); diff --git a/sound/core/control.c b/sound/core/control.c index 6dce340429ff..7de5256c19fc 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -40,12 +40,6 @@ typedef struct _snd_kctl_ioctl { static DECLARE_RWSEM(snd_ioctl_rwsem); static LIST_HEAD(snd_control_ioctls); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int snd_ctl_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev)); @@ -88,7 +82,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) return 0; __error: - dec_mod_count(card->module); + module_put(card->module); __error2: snd_card_file_remove(card, file); __error1: @@ -135,7 +129,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file) up_write(&card->controls_rwsem); snd_ctl_empty_read_queue(ctl); snd_magic_kfree(ctl); - dec_mod_count(card->module); + module_put(card->module); snd_card_file_remove(card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/info.c b/sound/core/info.c index 808f46456976..0ae2541810a6 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -36,12 +36,6 @@ * */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_info_check_reserved_words(const char *str) { static char *reserved[] = @@ -407,7 +401,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) return 0; __error: - dec_mod_count(entry->module); + module_put(entry->module); __error1: #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; @@ -450,7 +444,7 @@ static int snd_info_entry_release(struct inode *inode, struct file *file) data->file_private_data); break; } - dec_mod_count(entry->module); + module_put(entry->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 0d6aecd9016c..088bf5ea33c1 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -34,12 +34,6 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Mixer OSS emulation for ALSA."); MODULE_LICENSE("GPL"); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int snd_mixer_oss_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev)); @@ -82,7 +76,7 @@ static int snd_mixer_oss_release(struct inode *inode, struct file *file) if (file->private_data) { fmixer = (snd_mixer_oss_file_t *) file->private_data; - dec_mod_count(fmixer->card->module); + module_put(fmixer->card->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index c6e18a7e0d0a..4febec2769c2 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -71,12 +71,6 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_pcm_oss_plugin_clear(snd_pcm_substream_t *substream) { snd_pcm_runtime_t *runtime = substream->runtime; @@ -1617,7 +1611,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) return err; __error: - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); __error2: snd_card_file_remove(pcm->card, file); __error1: @@ -1644,7 +1638,7 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) snd_pcm_oss_release_file(pcm_oss_file); up(&pcm->open_mutex); wake_up(&pcm->open_wait); - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 773d3a10c567..57f2a9c0f4a2 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -76,14 +76,6 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - - - int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info) { snd_pcm_runtime_t * runtime; @@ -1833,7 +1825,7 @@ int snd_pcm_open(struct inode *inode, struct file *file) return err; __error: - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); __error2: snd_card_file_remove(pcm->card, file); __error1: @@ -1863,7 +1855,7 @@ int snd_pcm_release(struct inode *inode, struct file *file) snd_pcm_release_file(pcm_file); up(&pcm->open_mutex); wake_up(&pcm->open_wait); - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 18dc962f094d..a03924780f93 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -58,12 +58,6 @@ snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; static DECLARE_MUTEX(register_mutex); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static inline unsigned short snd_rawmidi_file_flags(struct file *file) { switch (file->f_mode & (FMODE_READ | FMODE_WRITE)) { @@ -345,7 +339,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, snd_rawmidi_done_buffer(output); kfree(output); } - dec_mod_count(rmidi->card->module); + module_put(rmidi->card->module); up(&rmidi->open_mutex); __error1: #ifdef LINUX_2_2 @@ -504,7 +498,7 @@ int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; } up(&rmidi->open_mutex); - dec_mod_count(rmidi->card->module); + module_put(rmidi->card->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 9cc61a3cd426..837ef15abb69 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -83,12 +83,6 @@ static spinlock_t register_lock = SPIN_LOCK_UNLOCKED; static seq_oss_synth_t *get_synthdev(seq_oss_devinfo_t *dp, int dev); static void reset_channels(seq_oss_synthinfo_t *info); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * global initialization */ @@ -245,7 +239,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) continue; } if (rec->oper.open(&info->arg, rec->private_data) < 0) { - dec_mod_count(rec->oper.owner); + module_put(rec->oper.owner); snd_use_lock_free(&rec->use_lock); continue; } @@ -322,7 +316,7 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp) if (rec->opened) { debug_printk(("synth %d closed\n", i)); rec->oper.close(&info->arg); - dec_mod_count(rec->oper.owner); + module_put(rec->oper.owner); rec->opened--; } snd_use_lock_free(&rec->use_lock); diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 8f5d7ed2b4d8..14943f8fecb8 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -55,12 +55,6 @@ much elements are in array. */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* return pointer to port structure - port is locked if found */ client_port_t *snd_seq_port_use_ptr(client_t *client, int num) { @@ -413,7 +407,7 @@ static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_ if (grp->open && (port->callback_all || grp->count == 1)) { err = grp->open(port->private_data, info); if (err < 0) { - dec_mod_count(port->owner); + module_put(port->owner); grp->count--; } } @@ -438,7 +432,7 @@ static int unsubscribe_port(client_t *client, client_port_t *port, if (send_ack && client->type == USER_CLIENT) snd_seq_client_notify_subscription(port->addr.client, port->addr.port, info, SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED); - dec_mod_count(port->owner); + module_put(port->owner); return err; } diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index d4fcb6aa085c..0719b6ad0ee8 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -53,12 +53,6 @@ MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); MODULE_DESCRIPTION("Virtual Raw MIDI client on Sequencer"); MODULE_LICENSE("GPL"); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * initialize an event record */ @@ -303,7 +297,7 @@ static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE; - dec_mod_count(rdev->card->module); + module_put(rdev->card->module); return 0; } @@ -331,7 +325,7 @@ static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); rdev->flags &= ~SNDRV_VIRMIDI_USE; - dec_mod_count(rdev->card->module); + module_put(rdev->card->module); return 0; } diff --git a/sound/core/timer.c b/sound/core/timer.c index e16dfdda8a95..1b571b00728d 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -80,12 +80,6 @@ static int snd_timer_dev_unregister(snd_device_t *device); static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * create a timer instance with the given owner string. * when timer is not NULL, increments the module counter @@ -325,7 +319,7 @@ int snd_timer_close(snd_timer_instance_t * timeri) kfree(timeri->owner); kfree(timeri); if (timer && timer->card) - dec_mod_count(timer->card->module); + module_put(timer->card->module); return 0; } diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 2651522d72e5..c622456c6136 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -35,12 +35,6 @@ int use_internal_drums = 0; MODULE_PARM(use_internal_drums, "i"); MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_opl3_synth_use_inc(opl3_t * opl3) { if (!try_inc_mod_count(opl3->card->module)) @@ -51,7 +45,7 @@ int snd_opl3_synth_use_inc(opl3_t * opl3) void snd_opl3_synth_use_dec(opl3_t * opl3) { - dec_mod_count(opl3->card->module); + module_put(opl3->card->module); } int snd_opl3_synth_setup(opl3_t * opl3) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 04fa4a649ab6..a3473afd0118 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -39,12 +39,6 @@ MODULE_LICENSE("GPL"); static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_gus_use_inc(snd_gus_card_t * gus) { MOD_INC_USE_COUNT; @@ -57,7 +51,7 @@ int snd_gus_use_inc(snd_gus_card_t * gus) void snd_gus_use_dec(snd_gus_card_t * gus) { - dec_mod_count(gus->card->module); + module_put(gus->card->module); MOD_DEC_USE_COUNT; } diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 75aaca8a9fb9..817b6d807a86 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -33,13 +33,6 @@ #define FX_MSB_TRANSFER 0x02 /* transfer after DSP MSB byte written */ #define FX_AUTO_INCR 0x04 /* auto-increment DSP address after transfer */ -static inline void -dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int wavefront_fx_idle (snd_wavefront_t *dev) @@ -164,7 +157,7 @@ int snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) { - dec_mod_count(hw->card->module); + module_put(hw->card->module); MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 5f0058dc08ca..f3e26ef9473f 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -233,13 +233,6 @@ static wavefront_command wavefront_commands[] = { { 0x00 } }; -static inline void -dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static const char * wavefront_errorstr (int errnum) @@ -1623,7 +1616,7 @@ int snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) { - dec_mod_count(hw->card->module); + module_put(hw->card->module); MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/oss/audio.c b/sound/oss/audio.c index 74e3c282c14f..91101d990e49 100644 --- a/sound/oss/audio.c +++ b/sound/oss/audio.c @@ -88,19 +88,20 @@ int audio_open(int dev, struct file *file) return -ENXIO; driver = audio_devs[dev]->d; - if (driver->owner) - __MOD_INC_USE_COUNT(driver->owner); + + if (!try_module_get(driver->owner)) + return -ENODEV; if ((ret = DMAbuf_open(dev, mode)) < 0) goto error_1; if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) + goto error_2; if ((ret = coprocessor->open(coprocessor->devc, COPR_PCM)) < 0) { printk(KERN_WARNING "Sound: Can't access coprocessor device\n"); - goto error_2; + goto error_3; } } @@ -119,14 +120,14 @@ int audio_open(int dev, struct file *file) * Clean-up stack: this is what needs (un)doing if * we can't open the audio device ... */ + error_3: + module_put(coprocessor->owner); + error_2: - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); DMAbuf_release(dev, mode); error_1: - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); return ret; } @@ -200,14 +201,11 @@ void audio_release(int dev, struct file *file) if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) { coprocessor->close(coprocessor->devc, COPR_PCM); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } DMAbuf_release(dev, mode); - if (audio_devs[dev]->d->owner) - __MOD_DEC_USE_COUNT (audio_devs[dev]->d->owner); + module_put(audio_devs[dev]->d->owner); } static void translate_bytes(const unsigned char *table, unsigned char *buff, int n) diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c index 58b330ecad1f..30f8c7f67971 100644 --- a/sound/oss/midibuf.c +++ b/sound/oss/midibuf.c @@ -170,8 +170,7 @@ int MIDIbuf_open(int dev, struct file *file) * Interrupts disabled. Be careful */ - if (midi_devs[dev]->owner) - __MOD_INC_USE_COUNT (midi_devs[dev]->owner); + module_put(midi_devs[dev]->owner); if ((err = midi_devs[dev]->open(dev, mode, midi_input_intr, midi_output_intr)) < 0) @@ -254,8 +253,7 @@ void MIDIbuf_release(int dev, struct file *file) midi_in_buf[dev] = NULL; midi_out_buf[dev] = NULL; - if (midi_devs[dev]->owner) - __MOD_DEC_USE_COUNT (midi_devs[dev]->owner); + module_put(midi_devs[dev]->owner); } int MIDIbuf_write(int dev, struct file *file, const char *buf, int count) diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c index a8817a2d8d02..c8d9d59ef915 100644 --- a/sound/oss/mpu401.c +++ b/sound/oss/mpu401.c @@ -498,8 +498,10 @@ static int mpu401_open(int dev, int mode, if ( (coprocessor = midi_devs[dev]->coproc) != NULL ) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) { + mpu401_close(dev); + return err; + } if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) { @@ -537,9 +539,7 @@ static void mpu401_close(int dev) coprocessor = midi_devs[dev]->coproc; if (coprocessor) { coprocessor->close(coprocessor->devc, COPR_MIDI); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } devc->opened = 0; } @@ -838,8 +838,8 @@ static int mpu_synth_open(int dev, int mode) coprocessor = midi_devs[midi_dev]->coproc; if (coprocessor) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) + return err; if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) { @@ -876,9 +876,7 @@ static void mpu_synth_close(int dev) coprocessor = midi_devs[midi_dev]->coproc; if (coprocessor) { coprocessor->close(coprocessor->devc, COPR_MIDI); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } devc->opened = 0; devc->mode = 0; diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 860e21734e9e..8a2f0055f1ac 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c @@ -1041,8 +1041,8 @@ int sequencer_open(int dev, struct file *file) if (synth_devs[i]==NULL) continue; - if (synth_devs[i]->owner) - __MOD_INC_USE_COUNT (synth_devs[i]->owner); + if (!try_module_get(synth_devs[i]->owner)) + continue; if ((tmp = synth_devs[i]->open(i, mode)) < 0) { @@ -1072,8 +1072,8 @@ int sequencer_open(int dev, struct file *file) for (i = 0; i < max_mididev; i++) if (!midi_opened[i] && midi_devs[i]) { - if (midi_devs[i]->owner) - __MOD_INC_USE_COUNT (midi_devs[i]->owner); + if (!try_module_get(midi_devs[i]->owner)) + continue; if ((retval = midi_devs[i]->open(i, mode, sequencer_midi_input, sequencer_midi_output)) >= 0) @@ -1084,9 +1084,8 @@ int sequencer_open(int dev, struct file *file) } if (seq_mode == SEQ_2) { - if (tmr->owner) - __MOD_INC_USE_COUNT (tmr->owner); - tmr->open(tmr_no, seq_mode); + if (try_module_get(tmr->owner)) + tmr->open(tmr_no, seq_mode); } init_waitqueue_head(&seq_sleeper); @@ -1169,8 +1168,7 @@ void sequencer_release(int dev, struct file *file) { synth_devs[i]->close(i); - if (synth_devs[i]->owner) - __MOD_DEC_USE_COUNT (synth_devs[i]->owner); + module_put(synth_devs[i]->owner); if (synth_devs[i]->midi_dev) midi_opened[synth_devs[i]->midi_dev] = 0; @@ -1181,15 +1179,13 @@ void sequencer_release(int dev, struct file *file) { if (midi_opened[i]) { midi_devs[i]->close(i); - if (midi_devs[i]->owner) - __MOD_DEC_USE_COUNT (midi_devs[i]->owner); + module_put(midi_devs[i]->owner); } } if (seq_mode == SEQ_2) { tmr->close(tmr_no); - if (tmr->owner) - __MOD_DEC_USE_COUNT (tmr->owner); + module_put(tmr->owner); } if (obsolete_api_used) diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index 4d29d0ec11a5..89988a1b3814 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c @@ -222,9 +222,9 @@ static int sound_open(struct inode *inode, struct file *file) } if (dev && (dev >= num_mixers || mixer_devs[dev] == NULL)) return -ENXIO; - - if (mixer_devs[dev]->owner) - __MOD_INC_USE_COUNT (mixer_devs[dev]->owner); + + if (!try_module_get(mixer_devs[dev]->owner)) + return -ENXIO; break; case SND_DEV_SEQ: @@ -261,9 +261,7 @@ static int sound_release(struct inode *inode, struct file *file) DEB(printk("sound_release(dev=%d)\n", dev)); switch (dev & 0x0f) { case SND_DEV_CTL: - dev >>= 4; - if (mixer_devs[dev]->owner) - __MOD_DEC_USE_COUNT (mixer_devs[dev]->owner); + module_put(mixer_devs[dev >> 4]->owner); break; case SND_DEV_SEQ: diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 3175511d87f9..0dd6ef8c376c 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -61,12 +61,6 @@ static snd_midi_op_t emux_ops = { /* */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * Initialise the EMUX Synth by creating a client and registering * a series of ports. @@ -283,7 +277,7 @@ snd_emux_inc_count(snd_emux_t *emu) if (!try_inc_mod_count(emu->ops.owner)) goto __error; if (!try_inc_mod_count(emu->card->module)) { - dec_mod_count(emu->ops.owner); + module_put(emu->ops.owner); __error: emu->used--; return 0; @@ -298,11 +292,11 @@ snd_emux_inc_count(snd_emux_t *emu) void snd_emux_dec_count(snd_emux_t *emu) { - dec_mod_count(emu->ops.owner); + module_put(emu->ops.owner); emu->used--; if (emu->used <= 0) snd_emux_terminate_all(emu); - dec_mod_count(emu->card->module); + module_put(emu->card->module); } |
