diff options
| author | Dave Jones <davej@halogen.(none)> | 2002-12-30 23:08:22 +0000 |
|---|---|---|
| committer | Dave Jones <davej@halogen.(none)> | 2002-12-30 23:08:22 +0000 |
| commit | 1f46ead556d590cbb585ecaebe8ac1871d3c6dab (patch) | |
| tree | 680083ed2d1564b17306d6cfee9d2b1a3c973f29 /drivers | |
| parent | 05ae9880250d5ffe81f9385a83b8d4e73ca5c4c0 (diff) | |
| parent | 43fb68dc00a8ab0b728e27c2a8fd4033d2ba0932 (diff) | |
Merge halogen.(none):/home/davej/src/kernel/2.5/bk-linus
into halogen.(none):/home/davej/src/kernel/2.5/agpgart
Diffstat (limited to 'drivers')
70 files changed, 595 insertions, 980 deletions
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index 115078c60d4c..05ed2e52c190 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -14,6 +14,7 @@ #include <linux/string.h> #include <linux/mc146818rtc.h> #include <linux/init.h> +#include <linux/bcd.h> #include "pcf8583.h" diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index e84ceeb85eeb..cdb4fe6d5b4f 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -16,6 +16,7 @@ #include <linux/device.h> #include <linux/suspend.h> #include <linux/seq_file.h> +#include <linux/bcd.h> #include <asm/uaccess.h> #include <asm/acpi.h> diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index c133b454b2fb..c7541b2fe264 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -160,7 +160,7 @@ retry: read_unlock(&gendisk_lock); return NULL; } - if (!try_inc_mod_count(p->owner)) + if (!try_module_get(p->owner)) continue; owner = p->owner; data = p->data; @@ -422,7 +422,7 @@ struct gendisk *get_disk(struct gendisk *disk) if (!disk->fops) return NULL; owner = disk->fops->owner; - if (owner && !try_inc_mod_count(owner)) + if (owner && !try_module_get(owner)) return NULL; return to_disk(kobject_get(&disk->kobj)); } diff --git a/drivers/char/busmouse.c b/drivers/char/busmouse.c index 85baa0cdf51b..c574177b5418 100644 --- a/drivers/char/busmouse.c +++ b/drivers/char/busmouse.c @@ -200,7 +200,7 @@ static int busmouse_open(struct inode *inode, struct file *file) if (!mse || !mse->ops) /* shouldn't happen, but... */ goto end; - if (mse->ops->owner && !try_inc_mod_count(mse->ops->owner)) + if (!try_module_get(mse->ops->owner)) goto end; ret = 0; diff --git a/drivers/char/dz.c b/drivers/char/dz.c index f67afe1e21ba..db281901522d 100644 --- a/drivers/char/dz.c +++ b/drivers/char/dz.c @@ -1425,9 +1425,9 @@ int __init dz_init(void) printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line, info->port, SERIAL); - tty_register_devfs(&serial_driver, 0, + tty_register_device(&serial_driver, serial_driver.minor_start + info->line); - tty_register_devfs(&callout_driver, 0, + tty_register_device(&callout_driver, callout_driver.minor_start + info->line); } diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 7b9b42bc2729..b3fe12431691 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -279,7 +279,7 @@ int __init hvc_init(void) for (i = 0; i < hvc_driver.num; i++) { hvc_struct[i].lock = SPIN_LOCK_UNLOCKED; hvc_struct[i].index = i; - tty_register_devfs(&hvc_driver, 0, hvc_driver.minor_start + i); + tty_register_device(&hvc_driver, hvc_driver.minor_start + i); } if (tty_register_driver(&hvc_driver)) diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index c43a7f6e569b..1fbc0eb7fb79 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -899,11 +899,11 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) { if ( pB->i2eChannelMap[box] & (1 << j) ) { - tty_register_devfs(&ip2_tty_driver, - 0, j + ABS_BIGGEST_BOX * + tty_register_device(&ip2_tty_driver, + j + ABS_BIGGEST_BOX * (box+i*ABS_MAX_BOXES)); - tty_register_devfs(&ip2_callout_driver, - 0, j + ABS_BIGGEST_BOX * + tty_register_device(&ip2_callout_driver, + j + ABS_BIGGEST_BOX * (box+i*ABS_MAX_BOXES)); } } diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index dc050fbf9baf..34304a4dcb7f 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -48,10 +48,6 @@ #define IS_CONSOLE_DEV(dev) (kdev_val(dev) == __mkdev(TTY_MAJOR,0)) #define IS_SYSCONS_DEV(dev) (kdev_val(dev) == __mkdev(TTYAUX_MAJOR,1)) -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - /* number of characters left in xmit buffer before select has we have room */ #define WAKEUP_CHARS 256 @@ -725,16 +721,18 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, if (tty->real_raw) { spin_lock_irqsave(&tty->read_lock, cpuflags); - i = MIN(count, MIN(N_TTY_BUF_SIZE - tty->read_cnt, - N_TTY_BUF_SIZE - tty->read_head)); + i = min(N_TTY_BUF_SIZE - tty->read_cnt, + N_TTY_BUF_SIZE - tty->read_head); + i = min(count, i); memcpy(tty->read_buf + tty->read_head, cp, i); tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); tty->read_cnt += i; cp += i; count -= i; - i = MIN(count, MIN(N_TTY_BUF_SIZE - tty->read_cnt, - N_TTY_BUF_SIZE - tty->read_head)); + i = min(N_TTY_BUF_SIZE - tty->read_cnt, + N_TTY_BUF_SIZE - tty->read_head); + i = min(count, i); memcpy(tty->read_buf + tty->read_head, cp, i); tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); tty->read_cnt += i; @@ -915,7 +913,8 @@ static inline int copy_from_read_buf(struct tty_struct *tty, retval = 0; spin_lock_irqsave(&tty->read_lock, flags); - n = MIN(*nr, MIN(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail)); + n = min(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail); + n = min((ssize_t)*nr, n); spin_unlock_irqrestore(&tty->read_lock, flags); if (n) { mb(); diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 9ae96fac0835..5c23c6b2ec63 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -64,8 +64,6 @@ static struct termios *pts_termios_locked[UNIX98_NR_MAJORS][NR_PTYS]; static struct pty_struct ptm_state[UNIX98_NR_MAJORS][NR_PTYS]; #endif -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - static void pty_close(struct tty_struct * tty, struct file * filp) { if (!tty) @@ -97,7 +95,7 @@ static void pty_close(struct tty_struct * tty, struct file * filp) } } #endif - tty_unregister_devfs (&tty->link->driver, minor(tty->device)); + tty_unregister_device (&tty->link->driver, minor(tty->device)); tty_vhangup(tty->link); } } @@ -156,7 +154,7 @@ static int pty_write(struct tty_struct * tty, int from_user, n = count; if (!n) break; - n = MIN(n, PTY_BUF_SIZE); + n = min(n, PTY_BUF_SIZE); n -= copy_from_user(temp_buffer, buf, n); if (!n) { if (!c) @@ -307,6 +305,7 @@ static void pty_flush_buffer(struct tty_struct *tty) } } +extern void tty_register_devfs (struct tty_driver *driver, unsigned int flags, unsigned minor); static int pty_open(struct tty_struct *tty, struct file * filp) { int retval; diff --git a/drivers/char/random.c b/drivers/char/random.c index 5bb5d2929005..48f0b8202da5 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -660,14 +660,16 @@ void batch_entropy_store(u32 a, u32 b, int num) batch_entropy_credit[batch_head] = num; new = (batch_head+1) & (batch_max-1); - if (new != batch_tail) { + if ((unsigned)(new - batch_tail) >= (unsigned)(batch_max / 2)) { /* * Schedule it for the next timer tick: */ schedule_delayed_work(&batch_work, 1); batch_head = new; - } else { + } else if (new == batch_tail) { DEBUG_ENT("batch entropy buffer full\n"); + } else { + batch_head = new; } } diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 75dffcb2b48c..1e5f4c6ec5a1 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -72,6 +72,7 @@ #include <linux/spinlock.h> #include <linux/sysctl.h> #include <linux/wait.h> +#include <linux/bcd.h> #include <asm/current.h> #include <asm/uaccess.h> diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 4d94c4de5c46..d39c31afe0e4 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -90,6 +90,7 @@ #include <linux/init.h> #include <linux/module.h> #include <linux/smp_lock.h> +#include <linux/device.h> #include <asm/uaccess.h> #include <asm/system.h> @@ -158,13 +159,6 @@ extern void tx3912_console_init(void); extern void tx3912_rs_init(void); extern void hvc_console_init(void); -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a) < (b) ? (b) : (a)) -#endif - static struct tty_struct *alloc_tty_struct(void) { struct tty_struct *tty; @@ -713,7 +707,7 @@ static inline ssize_t do_tty_write( unlock_kernel(); } else { for (;;) { - unsigned long size = MAX(PAGE_SIZE*2,16384); + unsigned long size = max((unsigned long)PAGE_SIZE*2, 16384UL); if (size > count) size = count; lock_kernel(); @@ -1351,7 +1345,7 @@ retry_open: set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ minor -= driver->minor_start; devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start)); - tty_register_devfs(&pts_driver[major], DEVFS_FL_DEFAULT, + tty_register_device(&pts_driver[major], pts_driver[major].minor_start + minor); noctty = 1; goto init_dev_done; @@ -2038,9 +2032,6 @@ void tty_default_put_char(struct tty_struct *tty, unsigned char ch) tty->driver.write(tty, 0, &ch, 1); } -/* - * Register a tty device described by <driver>, with minor number <minor>. - */ void tty_register_devfs (struct tty_driver *driver, unsigned int flags, unsigned minor) { #ifdef CONFIG_DEVFS_FS @@ -2077,8 +2068,21 @@ void tty_unregister_devfs (struct tty_driver *driver, unsigned minor) devfs_remove(driver->name, minor-driver->minor_start+driver->name_base); } -EXPORT_SYMBOL(tty_register_devfs); -EXPORT_SYMBOL(tty_unregister_devfs); +/* + * Register a tty device described by <driver>, with minor number <minor>. + */ +void tty_register_device (struct tty_driver *driver, unsigned minor) +{ + tty_register_devfs(driver, 0, minor); +} + +void tty_unregister_device (struct tty_driver *driver, unsigned minor) +{ + tty_unregister_devfs(driver, minor); +} + +EXPORT_SYMBOL(tty_register_device); +EXPORT_SYMBOL(tty_unregister_device); /* * Called by a tty driver to register itself. @@ -2104,7 +2108,7 @@ int tty_register_driver(struct tty_driver *driver) if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) { for(i = 0; i < driver->num; i++) - tty_register_devfs(driver, 0, driver->minor_start + i); + tty_register_device(driver, driver->minor_start + i); } proc_tty_register_driver(driver); return error; @@ -2159,7 +2163,7 @@ int tty_unregister_driver(struct tty_driver *driver) driver->termios_locked[i] = NULL; kfree(tp); } - tty_unregister_devfs(driver, driver->minor_start + i); + tty_unregister_device(driver, driver->minor_start + i); } proc_tty_unregister_driver(driver); return 0; @@ -2261,12 +2265,19 @@ static struct tty_driver dev_console_driver; extern int vty_init(void); #endif +struct device_class tty_devclass = { + .name = "tty", +}; +EXPORT_SYMBOL(tty_devclass); + /* * Ok, now we can initialize the rest of the tty devices and can count * on memory allocations, interrupts etc.. */ void __init tty_init(void) { + devclass_register(&tty_devclass); + /* * dev_tty_driver and dev_console_driver are actually magic * devices which get redirected at open time. Nevertheless, diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 0be0bd218bfc..0920a11c3683 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -2646,7 +2646,7 @@ static void __init con_init_devfs (void) int i; for (i = 0; i < console_driver.num; i++) - tty_register_devfs (&console_driver, DEVFS_FL_DEFAULT, + tty_register_device (&console_driver, console_driver.minor_start + i); } diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index aba96ef80719..b2627572924e 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -296,17 +296,6 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, return 0; } -static void amd756_inc(struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -static void amd756_dec(struct i2c_adapter *adapter) -{ - - MOD_DEC_USE_COUNT; -} - static u32 amd756_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | @@ -322,11 +311,10 @@ static struct i2c_algorithm smbus_algorithm = { }; static struct i2c_adapter amd756_adapter = { + .owner = THIS_MODULE, .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 }; diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index ac2f741d3843..eff6dd081745 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c @@ -320,16 +320,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, return 0; } -void amd8111_inc(struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -void amd8111_dec(struct i2c_adapter *adapter) -{ - MOD_DEC_USE_COUNT; -} - u32 amd8111_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | @@ -368,12 +358,11 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ return -1; } + smbus->adapter.owner = THIS_MODULE; sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base); smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111; smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo_data = smbus; - smbus->adapter.inc_use = amd8111_inc; - smbus->adapter.dec_use = amd8111_dec; if (i2c_add_adapter(&smbus->adapter)) { printk(KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n"); diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index abab348e5b1b..19c4fed60425 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -23,9 +23,20 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/sensors.h> +#include <linux/i2c-proc.h> #include <linux/init.h> +/* Registers */ +#define ADM1021_SYSCTL_TEMP 1200 +#define ADM1021_SYSCTL_REMOTE_TEMP 1201 +#define ADM1021_SYSCTL_DIE_CODE 1202 +#define ADM1021_SYSCTL_ALARMS 1203 + +#define ADM1021_ALARM_TEMP_HIGH 0x40 +#define ADM1021_ALARM_TEMP_LOW 0x20 +#define ADM1021_ALARM_RTEMP_HIGH 0x10 +#define ADM1021_ALARM_RTEMP_LOW 0x08 +#define ADM1021_ALARM_RTEMP_NA 0x04 /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; @@ -114,8 +125,6 @@ static void adm1021_init_client(struct i2c_client *client); static int adm1021_detach_client(struct i2c_client *client); static int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg); -static void adm1021_inc_use(struct i2c_client *client); -static void adm1021_dec_use(struct i2c_client *client); static int adm1021_read_value(struct i2c_client *client, u8 reg); static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value); @@ -136,14 +145,13 @@ static int read_only = 0; /* This is the driver that will be inserted */ static struct i2c_driver adm1021_driver = { - /* name */ "ADM1021, MAX1617 sensor driver", - /* id */ I2C_DRIVERID_ADM1021, - /* flags */ I2C_DF_NOTIFY, - /* attach_adapter */ &adm1021_attach_adapter, - /* detach_client */ &adm1021_detach_client, - /* command */ &adm1021_command, - /* inc_use */ &adm1021_inc_use, - /* dec_use */ &adm1021_dec_use + .owner = THIS_MODULE, + .name = "ADM1021, MAX1617 sensor driver", + .id = I2C_DRIVERID_ADM1021, + .flags = I2C_DF_NOTIFY, + .attach_adapter = adm1021_attach_adapter, + .detach_client = adm1021_detach_client, + .command = adm1021_command, }; /* These files are created for each detected adm1021. This is just a template; @@ -375,16 +383,6 @@ int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; } -void adm1021_inc_use(struct i2c_client *client) -{ - MOD_INC_USE_COUNT; -} - -void adm1021_dec_use(struct i2c_client *client) -{ - MOD_DEC_USE_COUNT; -} - /* All registers are byte-sized */ int adm1021_read_value(struct i2c_client *client, u8 reg) { @@ -478,8 +476,9 @@ void adm1021_temp(struct i2c_client *client, int operation, int ctl_name, void adm1021_remote_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { -int prec=0; struct adm1021_data *data = client->data; + int prec = 0; + if (operation == SENSORS_PROC_REAL_INFO) if (data->type == adm1023) { *nrels_mag = 3; } else { *nrels_mag = 0; } diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index 83b08f63c421..e628f4418420 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -22,10 +22,12 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/sensors.h> +#include <linux/i2c-proc.h> #include <linux/init.h> +#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ + /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; static unsigned short normal_i2c_range[] = { 0x48, 0x4f, SENSORS_I2C_END }; @@ -72,8 +74,6 @@ static void lm75_init_client(struct i2c_client *client); static int lm75_detach_client(struct i2c_client *client); static int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg); -static void lm75_inc_use(struct i2c_client *client); -static void lm75_dec_use(struct i2c_client *client); static u16 swap_bytes(u16 val); static int lm75_read_value(struct i2c_client *client, u8 reg); static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); @@ -84,14 +84,12 @@ static void lm75_update_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { - /* name */ "LM75 sensor chip driver", - /* id */ I2C_DRIVERID_LM75, - /* flags */ I2C_DF_NOTIFY, - /* attach_adapter */ &lm75_attach_adapter, - /* detach_client */ &lm75_detach_client, - /* command */ &lm75_command, - /* inc_use */ &lm75_inc_use, - /* dec_use */ &lm75_dec_use + .name = "LM75 sensor chip driver", + .id = I2C_DRIVERID_LM75, + .flags = I2C_DF_NOTIFY, + .attach_adapter = lm75_attach_adapter, + .detach_client = lm75_detach_client, + .command = lm75_command, }; /* These files are created for each detected LM75. This is just a template; @@ -221,24 +219,11 @@ int lm75_detect(struct i2c_adapter *adapter, int address, int lm75_detach_client(struct i2c_client *client) { - int err; - -#ifdef MODULE - if (MOD_IN_USE) - return -EBUSY; -#endif - - i2c_deregister_entry(((struct lm75_data *) (client->data))-> - sysctl_id); - - if ((err = i2c_detach_client(client))) { - printk - ("lm75.o: Client deregistration failed, client not detached.\n"); - return err; - } + struct lm75_data *data = client->data; + i2c_deregister_entry(data->sysctl_id); + i2c_detach_client(client); kfree(client); - return 0; } @@ -247,16 +232,6 @@ int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; } -void lm75_inc_use(struct i2c_client *client) -{ - MOD_INC_USE_COUNT; -} - -void lm75_dec_use(struct i2c_client *client) -{ - MOD_DEC_USE_COUNT; -} - u16 swap_bytes(u16 val) { return (val >> 8) | (val << 8); diff --git a/drivers/i2c/i2c-adap-ite.c b/drivers/i2c/i2c-adap-ite.c index 9e2904c0f5e8..2c7b5103806c 100644 --- a/drivers/i2c/i2c-adap-ite.c +++ b/drivers/i2c/i2c-adap-ite.c @@ -184,35 +184,6 @@ static void iic_ite_release(void) release_region(gpi.iic_base , 2); } - -static int iic_ite_reg(struct i2c_client *client) -{ - return 0; -} - - -static int iic_ite_unreg(struct i2c_client *client) -{ - return 0; -} - - -static void iic_ite_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - - -static void iic_ite_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -228,14 +199,10 @@ static struct i2c_algo_iic_data iic_ite_data = { }; static struct i2c_adapter iic_ite_ops = { - "ITE IIC adapter", - I2C_HW_I_IIC, - NULL, - &iic_ite_data, - iic_ite_inc_use, - iic_ite_dec_use, - iic_ite_reg, - iic_ite_unreg, + .owner = THIS_MODULE, + .name = "ITE IIC adapter", + .id = I2C_HW_I_IIC, + .algo_data = &iic_ite_data, }; /* Called when the module is loaded. This function starts the diff --git a/drivers/i2c/i2c-algo-bit.c b/drivers/i2c/i2c-algo-bit.c index 9551f0d27e6f..73b9f304493c 100644 --- a/drivers/i2c/i2c-algo-bit.c +++ b/drivers/i2c/i2c-algo-bit.c @@ -529,14 +529,11 @@ static u32 bit_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_bit_algo = { - "Bit-shift algorithm", - I2C_ALGO_BIT, - bit_xfer, - NULL, - NULL, /* slave_xmit */ - NULL, /* slave_recv */ - algo_control, /* ioctl */ - bit_func, /* functionality */ + .name = "Bit-shift algorithm", + .id = I2C_ALGO_BIT, + .master_xfer = bit_xfer, + .algo_control = algo_control, + .functionality = bit_func, }; /* @@ -581,11 +578,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) printk("\n"); } -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif i2c_add_adapter(adap); - return 0; } @@ -599,9 +592,6 @@ int i2c_bit_del_bus(struct i2c_adapter *adap) DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",adap->name)); -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif return 0; } diff --git a/drivers/i2c/i2c-algo-ibm_ocp.c b/drivers/i2c/i2c-algo-ibm_ocp.c index 77380200a2ef..3b345d2e9d78 100644 --- a/drivers/i2c/i2c-algo-ibm_ocp.c +++ b/drivers/i2c/i2c-algo-ibm_ocp.c @@ -877,7 +877,7 @@ static struct i2c_algorithm iic_algo = { // // Description: Register bus structure // -int i2c_iic_add_bus(struct i2c_adapter *adap) +int i2c_ocp_add_bus(struct i2c_adapter *adap) { struct i2c_algo_iic_data *iic_adap = adap->algo_data; @@ -912,7 +912,7 @@ int i2c_iic_add_bus(struct i2c_adapter *adap) // // Done // -int i2c_iic_del_bus(struct i2c_adapter *adap) +int i2c_ocp_del_bus(struct i2c_adapter *adap) { int res; if ((res = i2c_del_adapter(adap)) < 0) @@ -942,8 +942,8 @@ void i2c_algo_iic_exit(void) } -EXPORT_SYMBOL(i2c_iic_add_bus); -EXPORT_SYMBOL(i2c_iic_del_bus); +EXPORT_SYMBOL(i2c_ocp_add_bus); +EXPORT_SYMBOL(i2c_ocp_del_bus); // // The MODULE_* macros resolve to nothing if MODULES is not defined diff --git a/drivers/i2c/i2c-algo-ibm_ocp.h b/drivers/i2c/i2c-algo-ibm_ocp.h index e32e5af81b38..5a4e588f19ae 100644 --- a/drivers/i2c/i2c-algo-ibm_ocp.h +++ b/drivers/i2c/i2c-algo-ibm_ocp.h @@ -49,7 +49,7 @@ struct i2c_algo_iic_data { #define I2C_IIC_ADAP_MAX 16 -int i2c_iic_add_bus(struct i2c_adapter *); -int i2c_iic_del_bus(struct i2c_adapter *); +int i2c_ocp_add_bus(struct i2c_adapter *); +int i2c_ocp_del_bus(struct i2c_adapter *); #endif /* I2C_ALGO_IIC_H */ diff --git a/drivers/i2c/i2c-algo-pcf.c b/drivers/i2c/i2c-algo-pcf.c index 000b34a84d4c..ffa237cfa2f4 100644 --- a/drivers/i2c/i2c-algo-pcf.c +++ b/drivers/i2c/i2c-algo-pcf.c @@ -474,10 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) return i; } -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif - i2c_add_adapter(adap); /* scan bus */ @@ -509,15 +505,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) int i2c_pcf_del_bus(struct i2c_adapter *adap) { - int res; - if ((res = i2c_del_adapter(adap)) < 0) - return res; - DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: adapter unregistered: %s\n",adap->name)); - -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif - return 0; + return i2c_del_adapter(adap); } EXPORT_SYMBOL(i2c_pcf_add_bus); diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4ddcb6a26401..f9e41cc508bf 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -446,24 +446,23 @@ int i2c_detach_client(struct i2c_client *client) return 0; } -void i2c_inc_use_client(struct i2c_client *client) +static int i2c_inc_use_client(struct i2c_client *client) { - if (client->driver->inc_use != NULL) - client->driver->inc_use(client); + if (!try_module_get(client->driver->owner)) + return -ENODEV; + if (!try_module_get(client->adapter->owner)) { + module_put(client->driver->owner); + return -ENODEV; + } - if (client->adapter->inc_use != NULL) - client->adapter->inc_use(client->adapter); + return 0; } -void i2c_dec_use_client(struct i2c_client *client) +static void i2c_dec_use_client(struct i2c_client *client) { - - if (client->driver->dec_use != NULL) - client->driver->dec_use(client); - - if (client->adapter->dec_use != NULL) - client->adapter->dec_use(client->adapter); + module_put(client->driver->owner); + module_put(client->adapter->owner); } struct i2c_client *i2c_get_client(int driver_id, int adapter_id, @@ -535,20 +534,22 @@ struct i2c_client *i2c_get_client(int driver_id, int adapter_id, int i2c_use_client(struct i2c_client *client) { - if(client->flags & I2C_CLIENT_ALLOW_USE) { - if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + if (!i2c_inc_use_client(client)) + return -ENODEV; + + if (client->flags & I2C_CLIENT_ALLOW_USE) { + if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + client->usage_count++; + else if (client->usage_count > 0) + goto busy; + else client->usage_count++; - else { - if(client->usage_count > 0) - return -EBUSY; - else - client->usage_count++; - } } - i2c_inc_use_client(client); - return 0; + busy: + i2c_dec_use_client(client); + return -EBUSY; } int i2c_release_client(struct i2c_client *client) @@ -1420,8 +1421,6 @@ EXPORT_SYMBOL(i2c_add_driver); EXPORT_SYMBOL(i2c_del_driver); EXPORT_SYMBOL(i2c_attach_client); EXPORT_SYMBOL(i2c_detach_client); -EXPORT_SYMBOL(i2c_inc_use_client); -EXPORT_SYMBOL(i2c_dec_use_client); EXPORT_SYMBOL(i2c_get_client); EXPORT_SYMBOL(i2c_use_client); EXPORT_SYMBOL(i2c_release_client); diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index a702cc953dc7..14d0081b98fe 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -138,9 +138,9 @@ static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count, struct inode *inode = file->f_dentry->d_inode; #endif /* DEBUG */ - if(count > 8192) + if (count > 8192) count = 8192; - + /* copy user space data to kernel space. */ tmp = kmalloc(count,GFP_KERNEL); if (tmp==NULL) @@ -364,8 +364,10 @@ int i2cdev_open (struct inode *inode, struct file *file) client->adapter = i2cdev_adaps[minor]; file->private_data = client; - if (i2cdev_adaps[minor]->inc_use) - i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]); + if (!try_module_get(i2cdev_adaps[minor]->owner)) { + kfree(client); + return -ENODEV; + } #ifdef DEBUG printk(KERN_DEBUG "i2c-dev.o: opened i2c-%d\n",minor); @@ -381,10 +383,7 @@ static int i2cdev_release (struct inode *inode, struct file *file) #ifdef DEBUG printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor); #endif - lock_kernel(); - if (i2cdev_adaps[minor]->dec_use) - i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]); - unlock_kernel(); + module_put(i2cdev_adaps[minor]->owner); return 0; } diff --git a/drivers/i2c/i2c-elektor.c b/drivers/i2c/i2c-elektor.c index f142e72e9b75..66ef1a818de2 100644 --- a/drivers/i2c/i2c-elektor.c +++ b/drivers/i2c/i2c-elektor.c @@ -38,7 +38,6 @@ #include <linux/i2c.h> #include <linux/i2c-algo-pcf.h> -#include <linux/i2c-elektor.h> #include <asm/io.h> #include <asm/irq.h> @@ -142,7 +141,7 @@ static void pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) { static int pcf_isa_init(void) { if (!mmapped) { - if (!request_region(base, 2, "i2c (isa bus adapter)")) + 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); @@ -159,32 +158,6 @@ static int pcf_isa_init(void) return 0; } -static int pcf_isa_reg(struct i2c_client *client) -{ - return 0; -} - - -static int pcf_isa_unreg(struct i2c_client *client) -{ - return 0; -} - -static void pcf_isa_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void pcf_isa_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -201,13 +174,10 @@ static struct i2c_algo_pcf_data pcf_isa_data = { }; static struct i2c_adapter pcf_isa_ops = { + .owner = THIS_MODULE, .name = "PCF8584 ISA adapter", .id = I2C_HW_P_ELEK, .algo_data = &pcf_isa_data, - .inc_use = pcf_isa_inc_use, - .dec_use = pcf_isa_dec_use, - .client_register = pcf_isa_reg, - .client_unregister = pcf_isa_unreg, }; static int __init i2c_pcfisa_init(void) diff --git a/drivers/i2c/i2c-elv.c b/drivers/i2c/i2c-elv.c index a11ba27ffa2e..b4c74e564813 100644 --- a/drivers/i2c/i2c-elv.c +++ b/drivers/i2c/i2c-elv.c @@ -115,30 +115,6 @@ fail: return -ENODEV; } -static int bit_elv_reg(struct i2c_client *client) -{ - return 0; -} - -static int bit_elv_unreg(struct i2c_client *client) -{ - return 0; -} - -static void bit_elv_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void bit_elv_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -153,14 +129,10 @@ static struct i2c_algo_bit_data bit_elv_data = { }; static struct i2c_adapter bit_elv_ops = { - "ELV Parallel port adaptor", - I2C_HW_B_ELV, - NULL, - &bit_elv_data, - bit_elv_inc_use, - bit_elv_dec_use, - bit_elv_reg, - bit_elv_unreg, + .owner = THIS_MODULE, + .name = "ELV Parallel port adaptor", + .id = I2C_HW_B_ELV, + .algo_data = &bit_elv_data, }; static int __init i2c_bitelv_init(void) diff --git a/drivers/i2c/i2c-frodo.c b/drivers/i2c/i2c-frodo.c index 634a4ac46457..80f6cffcc13f 100644 --- a/drivers/i2c/i2c-frodo.c +++ b/drivers/i2c/i2c-frodo.c @@ -61,44 +61,21 @@ static struct i2c_algo_bit_data bit_frodo_data = { .timeout = 100 }; -static int frodo_client_register (struct i2c_client *client) -{ - return (0); -} - -static int frodo_client_unregister (struct i2c_client *client) -{ - return (0); -} - -static void frodo_inc_use (struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -static void frodo_dec_use (struct i2c_adapter *adapter) -{ - MOD_DEC_USE_COUNT; -} - static struct i2c_adapter frodo_ops = { + .owner = THIS_MODULE, .name = "Frodo adapter driver", .id = I2C_HW_B_FRODO, .algo_data = &bit_frodo_data, - .inc_use = frodo_inc_use, - .dec_use = frodo_dec_use, - .client_register = frodo_client_register, - .client_unregister = frodo_client_unregister }; static int __init i2c_frodo_init (void) { - return (i2c_bit_add_bus (&frodo_ops)); + return i2c_bit_add_bus(&frodo_ops); } static void __exit i2c_frodo_exit (void) { - i2c_bit_del_bus (&frodo_ops); + i2c_bit_del_bus(&frodo_ops); } MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>"); diff --git a/drivers/i2c/i2c-philips-par.c b/drivers/i2c/i2c-philips-par.c index be9a49f146b8..ce2258a20447 100644 --- a/drivers/i2c/i2c-philips-par.c +++ b/drivers/i2c/i2c-philips-par.c @@ -129,26 +129,6 @@ static int bit_lp_getsda2(void *data) PARPORT_STATUS_BUSY) ? 0 : 1; } -static int bit_lp_reg(struct i2c_client *client) -{ - return 0; -} - -static int bit_lp_unreg(struct i2c_client *client) -{ - return 0; -} - -static void bit_lp_inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void bit_lp_dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -173,15 +153,9 @@ static struct i2c_algo_bit_data bit_lp_data2 = { }; static struct i2c_adapter bit_lp_ops = { - "Philips Parallel port adapter", - I2C_HW_B_LP, - NULL, - NULL, - bit_lp_inc_use, - bit_lp_dec_use, - bit_lp_reg, - - bit_lp_unreg, + .owner = THIS_MODULE, + .name = "Philips Parallel port adapter", + .id = I2C_HW_B_LP, }; static void i2c_parport_attach (struct parport *port) diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index 2273dbf684f9..785e9c5f3716 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -97,10 +97,21 @@ int i2c_create_name(char **name, const char *prefix, struct i2c_adapter *adapter, int addr) { char name_buffer[50]; - int id; + int id, i, end; if (i2c_is_isa_adapter(adapter)) sprintf(name_buffer, "%s-isa-%04x", prefix, addr); - else { + else if (!adapter->algo->smbus_xfer && !adapter->algo->master_xfer) { + /* dummy adapter, generate prefix */ + sprintf(name_buffer, "%s-", prefix); + end = strlen(name_buffer); + for(i = 0; i < 32; i++) { + if(adapter->algo->name[i] == ' ') + break; + name_buffer[end++] = tolower(adapter->algo->name[i]); + } + name_buffer[end] = 0; + sprintf(name_buffer + end, "-%04x", addr); + } else { if ((id = i2c_adapter_id(adapter)) < 0) return -ENOENT; sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr); @@ -210,49 +221,6 @@ void i2c_deregister_entry(int id) } } -/* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o - impossible if some process still uses it or some file in it */ -void i2c_fill_inode(struct inode *inode, int fill) -{ - if (fill) - MOD_INC_USE_COUNT; - else - MOD_DEC_USE_COUNT; -} - -/* Monitor access for /proc/sys/dev/sensors/ directories; make unloading - the corresponding module impossible if some process still uses it or - some file in it */ -void i2c_dir_fill_inode(struct inode *inode, int fill) -{ - int i; - struct i2c_client *client; - -#ifdef DEBUG - if (!inode) { - printk(KERN_ERR "i2c-proc.o: Warning: inode NULL in fill_inode()\n"); - return; - } -#endif /* def DEBUG */ - - for (i = 0; i < SENSORS_ENTRY_MAX; i++) - if (i2c_clients[i] - && (i2c_inodes[i] == inode->i_ino)) break; -#ifdef DEBUG - if (i == SENSORS_ENTRY_MAX) { - printk - (KERN_ERR "i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n", - inode->i_ino); - return; - } -#endif /* def DEBUG */ - client = i2c_clients[i]; - if (fill) - client->driver->inc_use(client); - else - client->driver->dec_use(client); -} - int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp, void *buffer, size_t * lenp) { diff --git a/drivers/i2c/i2c-rpx.c b/drivers/i2c/i2c-rpx.c index a449ae9c8724..389b738641c8 100644 --- a/drivers/i2c/i2c-rpx.c +++ b/drivers/i2c/i2c-rpx.c @@ -66,44 +66,15 @@ static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data) return 0; } -static int rpx_reg(struct i2c_client *client) -{ - return 0; -} - -static int rpx_unreg(struct i2c_client *client) -{ - return 0; -} - -static void rpx_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void rpx_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - static struct i2c_algo_8xx_data rpx_data = { .setisr = rpx_install_isr }; - static struct i2c_adapter rpx_ops = { - "m8xx", - I2C_HW_MPC8XX_EPON, - NULL, - &rpx_data, - rpx_inc_use, - rpx_dec_use, - rpx_reg, - rpx_unreg, + .owner = THIS_MODULE, + .name = "m8xx", + .id = I2C_HW_MPC8XX_EPON, + .algo_data = &rpx_data, }; int __init i2c_rpx_init(void) diff --git a/drivers/i2c/i2c-velleman.c b/drivers/i2c/i2c-velleman.c index 9ae1a20cc868..b158fc59a656 100644 --- a/drivers/i2c/i2c-velleman.c +++ b/drivers/i2c/i2c-velleman.c @@ -89,43 +89,15 @@ static int bit_velle_getsda(void *data) static int bit_velle_init(void) { - if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { - DEBE(printk(KERN_DEBUG "i2c-velleman.o: Port %#x already in use.\n", - base)); + if (!request_region(base, (base == 0x3bc) ? 3 : 8, + "i2c (Vellemann adapter)")) return -ENODEV; - } else { - request_region(base, (base == 0x3bc)? 3 : 8, - "i2c (Vellemann adapter)"); - bit_velle_setsda((void*)base,1); - bit_velle_setscl((void*)base,1); - } - return 0; -} - -static int bit_velle_reg(struct i2c_client *client) -{ - return 0; -} -static int bit_velle_unreg(struct i2c_client *client) -{ + bit_velle_setsda((void*)base,1); + bit_velle_setscl((void*)base,1); return 0; } -static void bit_velle_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void bit_velle_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -141,14 +113,10 @@ static struct i2c_algo_bit_data bit_velle_data = { }; static struct i2c_adapter bit_velle_ops = { - "Velleman K8000", - I2C_HW_B_VELLE, - NULL, - &bit_velle_data, - bit_velle_inc_use, - bit_velle_dec_use, - bit_velle_reg, - bit_velle_unreg, + .owner = THIS_MODULE, + .name = "Velleman K8000", + .id = I2C_HW_B_VELLE, + .algo_data = &bit_velle_data, }; static int __init i2c_bitvelle_init(void) diff --git a/drivers/i2c/scx200_acb.c b/drivers/i2c/scx200_acb.c index 083df8d02030..6f0575545d5a 100644 --- a/drivers/i2c/scx200_acb.c +++ b/drivers/i2c/scx200_acb.c @@ -397,26 +397,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter) I2C_FUNC_SMBUS_BLOCK_DATA; } -static int scx200_acb_reg(struct i2c_client *client) -{ - return 0; -} - -static int scx200_acb_unreg(struct i2c_client *client) -{ - return 0; -} - -static void scx200_acb_inc_use(struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -static void scx200_acb_dec_use(struct i2c_adapter *adapter) -{ - MOD_DEC_USE_COUNT; -} - /* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm scx200_acb_algorithm = { .name = "NatSemi SCx200 ACCESS.bus", @@ -479,12 +459,9 @@ static int __init scx200_acb_create(int base, int index) adapter = &iface->adapter; adapter->data = iface; sprintf(adapter->name, "SCx200 ACB%d", index); + adapter->owner = THIS_MODULE; adapter->id = I2C_ALGO_SMBUS; adapter->algo = &scx200_acb_algorithm; - adapter->inc_use = scx200_acb_inc_use; - adapter->dec_use = scx200_acb_dec_use; - adapter->client_register = scx200_acb_reg; - adapter->client_unregister = scx200_acb_unreg; init_MUTEX(&iface->sem); diff --git a/drivers/i2c/scx200_i2c.c b/drivers/i2c/scx200_i2c.c index 515e0c73d523..75d5a56cb32d 100644 --- a/drivers/i2c/scx200_i2c.c +++ b/drivers/i2c/scx200_i2c.c @@ -66,26 +66,6 @@ static int scx200_i2c_getsda(void *data) return scx200_gpio_get(sda); } -static int scx200_i2c_reg(struct i2c_client *client) -{ - return 0; -} - -static int scx200_i2c_unreg(struct i2c_client *client) -{ - return 0; -} - -static void scx200_i2c_inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void scx200_i2c_dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -101,13 +81,10 @@ static struct i2c_algo_bit_data scx200_i2c_data = { }; static struct i2c_adapter scx200_i2c_ops = { + .owner = THIS_MODULE, .name = "NatSemi SCx200 I2C", .id = I2C_HW_B_VELLE, .algo_data = &scx200_i2c_data, - .inc_use = scx200_i2c_inc_use, - .dec_use = scx200_i2c_dec_use, - .client_register = scx200_i2c_reg, - .client_unregister = scx200_i2c_unreg, }; int scx200_i2c_init(void) diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 0a3c9d65591e..fe2cd1ddb129 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/ide-tape.c Version 1.17a Jan, 2001 + * linux/drivers/ide/ide-tape.c Version 1.17b Oct, 2002 * * Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il> * @@ -291,6 +291,28 @@ * Ver 1.17a Apr 2001 Willem Riede osst@riede.org * - Get drive's actual block size from mode sense block descriptor * - Limit size of pipeline + * Ver 1.17b Oct 2002 Alan Stern <stern@rowland.harvard.edu> + * Changed IDETAPE_MIN_PIPELINE_STAGES to 1 and actually used + * it in the code! + * Actually removed aborted stages in idetape_abort_pipeline + * instead of just changing the command code. + * Made the transfer byte count for Request Sense equal to the + * actual length of the data transfer. + * Changed handling of partial data transfers: they do not + * cause DMA errors. + * Moved initiation of DMA transfers to the correct place. + * Removed reference to unallocated memory. + * Made __idetape_discard_read_pipeline return the number of + * sectors skipped, not the number of stages. + * Replaced errant kfree() calls with __idetape_kfree_stage(). + * Fixed off-by-one error in testing the pipeline length. + * Fixed handling of filemarks in the read pipeline. + * Small code optimization for MTBSF and MTBSFM ioctls. + * Don't try to unlock the door during device close if is + * already unlocked! + * Cosmetic fixes to miscellaneous debugging output messages. + * Set the minimum /proc/ide/hd?/settings values for "pipeline", + * "pipeline_min", and "pipeline_max" to 1. * * Here are some words from the first releases of hd.c, which are quoted * in ide.c and apply here as well: @@ -400,7 +422,7 @@ * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. */ -#define IDETAPE_VERSION "1.17a" +#define IDETAPE_VERSION "1.17b" #include <linux/config.h> #include <linux/module.h> @@ -577,9 +599,10 @@ typedef struct { * whenever we sense that the pipeline is empty, until we reach * the optimum value or until we reach MAX. * - * Setting the following parameter to 0 will disable the pipelined mode. + * Setting the following parameter to 0 is illegal: the pipelined mode + * cannot be disabled (calculate_speeds() divides by tape->max_stages.) */ -#define IDETAPE_MIN_PIPELINE_STAGES 200 +#define IDETAPE_MIN_PIPELINE_STAGES 1 #define IDETAPE_MAX_PIPELINE_STAGES 400 #define IDETAPE_INCREASE_STAGES_RATE 20 @@ -601,8 +624,8 @@ typedef struct { * is verified to be stable enough. This will make it much more * esthetic. */ -#define IDETAPE_DEBUG_INFO 1 -#define IDETAPE_DEBUG_LOG 1 +#define IDETAPE_DEBUG_INFO 0 +#define IDETAPE_DEBUG_LOG 0 #define IDETAPE_DEBUG_LOG_VERBOSE 0 #define IDETAPE_DEBUG_BUGS 1 @@ -1610,24 +1633,6 @@ static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_res } } -static void idetape_abort_pipeline (ide_drive_t *drive) -{ - idetape_tape_t *tape = drive->driver_data; - idetape_stage_t *stage = tape->next_stage; - -#if IDETAPE_DEBUG_LOG - if (tape->debug_level >= 4) - printk(KERN_INFO "ide-tape: %s: idetape_abort_pipeline called\n", tape->name); -#endif - while (stage) { - if (stage->rq.flags == IDETAPE_WRITE_RQ) - stage->rq.flags = IDETAPE_ABORTED_WRITE_RQ; - else if (stage->rq.flags == IDETAPE_READ_RQ) - stage->rq.flags = IDETAPE_ABORTED_READ_RQ; - stage = stage->next; - } -} - /* * idetape_active_next_stage will declare the next stage as "active". */ @@ -1672,7 +1677,7 @@ static void idetape_increase_max_pipeline_stages (ide_drive_t *drive) printk (KERN_INFO "ide-tape: Reached idetape_increase_max_pipeline_stages\n"); #endif /* IDETAPE_DEBUG_LOG */ - tape->max_stages += increase; + tape->max_stages += max(increase, 1); tape->max_stages = max(tape->max_stages, tape->min_pipeline); tape->max_stages = min(tape->max_stages, tape->max_pipeline); } @@ -1745,6 +1750,29 @@ static void idetape_remove_stage_head (ide_drive_t *drive) } } +static void idetape_abort_pipeline (ide_drive_t *drive, idetape_stage_t *last_stage) +{ + idetape_tape_t *tape = drive->driver_data; + idetape_stage_t *stage = tape->next_stage; + idetape_stage_t *nstage; + +#if IDETAPE_DEBUG_LOG + if (tape->debug_level >= 4) + printk(KERN_INFO "ide-tape: %s: idetape_abort_pipeline called\n", tape->name); +#endif + while (stage) { + nstage = stage->next; + idetape_kfree_stage(tape, stage); + --tape->nr_stages; + --tape->nr_pending_stages; + stage = nstage; + } + tape->last_stage = last_stage; + if (last_stage) + last_stage->next = NULL; + tape->next_stage = NULL; +} + /* * idetape_end_request is used to finish servicing a request, and to * insert a pending pipeline request into the main device queue. @@ -1756,6 +1784,7 @@ static int idetape_end_request (ide_drive_t *drive, int uptodate) unsigned long flags; int error; int remove_stage = 0; + idetape_stage_t *active_stage; #if ONSTREAM_DEBUG idetape_stage_t *stage; os_aux_t *aux; @@ -1780,6 +1809,7 @@ static int idetape_end_request (ide_drive_t *drive, int uptodate) /* The request was a pipelined data transfer request */ if (tape->active_data_request == rq) { + active_stage = tape->active_stage; tape->active_stage = NULL; tape->active_data_request = NULL; tape->nr_pending_stages--; @@ -1799,18 +1829,20 @@ static int idetape_end_request (ide_drive_t *drive, int uptodate) if (tape->first_frame_position == OS_DATA_ENDFRAME1) { #if ONSTREAM_DEBUG if (tape->debug_level >= 2) - printk("ide-tape: %s: skipping over config parition..\n", tape->name); + printk("ide-tape: %s: skipping over config partition.\n", tape->name); #endif tape->onstream_write_error = OS_PART_ERROR; - if (tape->waiting) + if (tape->waiting) { + rq->waiting = NULL; complete(tape->waiting); + } } } remove_stage = 1; if (error) { set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); if (error == IDETAPE_ERROR_EOD) - idetape_abort_pipeline(drive); + idetape_abort_pipeline(drive, active_stage); if (tape->onstream && !tape->raw && error == IDETAPE_ERROR_GENERAL && tape->sense.sense_key == 3) { @@ -1821,14 +1853,16 @@ static int idetape_end_request (ide_drive_t *drive, int uptodate) tape->nr_pending_stages++; tape->next_stage = tape->first_stage; rq->current_nr_sectors = rq->nr_sectors; - if (tape->waiting) + if (tape->waiting) { + rq->waiting = NULL; complete(tape->waiting); + } } } } else if (rq->flags == IDETAPE_READ_RQ) { if (error == IDETAPE_ERROR_EOD) { set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); - idetape_abort_pipeline(drive); + idetape_abort_pipeline(drive, active_stage); } } if (tape->next_stage != NULL && !tape->onstream_write_error) { @@ -1879,7 +1913,7 @@ static void idetape_create_request_sense_cmd (idetape_pc_t *pc) idetape_init_pc(pc); pc->c[0] = IDETAPE_REQUEST_SENSE_CMD; pc->c[4] = 20; - pc->request_transfer = 18; + pc->request_transfer = 20; pc->callback = &idetape_request_sense_callback; } @@ -1980,7 +2014,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) status.all = HWIF(drive)->INB(IDE_STATUS_REG); if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { - if (HWIF(drive)->ide_dma_end(drive)) { + if (HWIF(drive)->ide_dma_end(drive) || status.b.check) { /* * A DMA error is sometimes expected. For example, * if the tape is crossing a filemark during a @@ -1992,8 +2026,18 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) * actually transferred (we can't receive that * information from the DMA engine on most chipsets). */ + + /* + * On the contrary, a DMA error is never expected; + * it usually indicates a hardware error or abort. + * If the tape crosses a filemark during a READ + * command, it will issue an irq and position itself + * after the filemark (not before). Only a partial + * data transfer will occur, but no DMA error. + * (AS, 19 Apr 2001) + */ set_bit(PC_DMA_ERROR, &pc->flags); - } else if (!status.b.check) { + } else { pc->actually_transferred = pc->request_transfer; idetape_update_buffers(pc); } @@ -2029,7 +2073,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) if (status.b.check || test_bit(PC_DMA_ERROR, &pc->flags)) { /* Error detected */ #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 1) - printk(KERN_INFO "ide-tape: %s: I/O error, ", + printk(KERN_INFO "ide-tape: %s: I/O error\n", tape->name); #endif /* IDETAPE_DEBUG_LOG */ if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { @@ -2195,6 +2239,10 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) BUG(); /* Set the interrupt routine */ ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); +#ifdef CONFIG_BLK_DEV_IDEDMA + if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) /* Begin DMA, if necessary */ + (void) (HWIF(drive)->ide_dma_begin(drive)); +#endif /* Send the actual packet */ HWIF(drive)->atapi_output_bytes(drive, pc->c, 12); return ide_started; @@ -2223,8 +2271,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape /* * We will "abort" retrying a packet command in case * a legitimate error code was received (crossing a - * filemark, or DMA error in the end of media, for - * example). + * filemark, or end of the media, for example). */ if (!test_bit(PC_ABORT, &pc->flags)) { if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD && @@ -2249,7 +2296,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape } #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 2) - printk(KERN_INFO "ide-tape: Retry number - %d\n", pc->retries); + printk(KERN_INFO "ide-tape: Retry number - %d, cmd = %02X\n", pc->retries, pc->c[0]); #endif /* IDETAPE_DEBUG_LOG */ pc->retries++; @@ -2275,10 +2322,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape OUT_BYTE(bcount.b.high, IDE_BCOUNTH_REG); OUT_BYTE(bcount.b.low, IDE_BCOUNTL_REG); OUT_BYTE(drive->select.all, IDE_SELECT_REG); - if (dma_ok) { /* Begin DMA, if necessary */ + if (dma_ok) /* Will begin DMA later */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); - (void) (HWIF(drive)->ide_dma_begin(drive)); - } if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { if (HWGROUP(drive)->handler != NULL) /* paranoia check */ BUG(); @@ -3069,7 +3114,7 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) tape->waiting = &wait; spin_unlock(&tape->spinlock); wait_for_completion(&wait); - rq->waiting = NULL; + /* The stage and its struct request have been deallocated */ tape->waiting = NULL; spin_lock_irq(&tape->spinlock); } @@ -3333,11 +3378,15 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive) if (tape->chrdev_direction != idetape_direction_read) return 0; + cnt = tape->merge_stage_size / tape->tape_block_size; + if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) + ++cnt; /* Filemarks count as 1 sector */ tape->merge_stage_size = 0; if (tape->merge_stage != NULL) { __idetape_kfree_stage(tape->merge_stage); tape->merge_stage = NULL; } + clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); tape->chrdev_direction = idetape_direction_none; if (tape->first_stage == NULL) @@ -3349,9 +3398,14 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive) idetape_wait_for_request(drive, tape->active_data_request); spin_unlock_irqrestore(&tape->spinlock, flags); - cnt = tape->nr_stages - tape->nr_pending_stages; - while (tape->first_stage != NULL) + while (tape->first_stage != NULL) { + struct request *rq_ptr = &tape->first_stage->rq; + + cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors; + if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) + ++cnt; idetape_remove_stage_head(drive); + } tape->nr_pending_stages = 0; tape->max_stages = tape->min_pipeline; return cnt; @@ -3946,7 +4000,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) */ bytes_read = idetape_queue_rw_tail(drive, IDETAPE_READ_RQ, 0, tape->merge_stage->bio); if (bytes_read < 0) { - kfree(tape->merge_stage); + __idetape_kfree_stage(tape->merge_stage); tape->merge_stage = NULL; tape->chrdev_direction = idetape_direction_none; return bytes_read; @@ -3959,7 +4013,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) rq.sector = tape->first_frame_position; rq.nr_sectors = rq.current_nr_sectors = blocks; if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && - tape->nr_stages <= max_stages) { + tape->nr_stages < max_stages) { new_stage = idetape_kmalloc_stage(tape); while (new_stage != NULL) { new_stage->rq = rq; @@ -4069,6 +4123,12 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) #endif /* IDETAPE_DEBUG_LOG */ /* + * If we are at a filemark, return a read length of 0 + */ + if (test_bit(IDETAPE_FILEMARK, &tape->flags)) + return 0; + + /* * Wait for the next logical block to be available at the head * of the pipeline */ @@ -4097,14 +4157,7 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) } if (rq_ptr->errors == IDETAPE_ERROR_EOD) return 0; - if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) { - idetape_switch_buffers(tape, tape->first_stage); - set_bit(IDETAPE_FILEMARK, &tape->flags); -#if USE_IOTRACE - IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); -#endif - calculate_speeds(drive); - } else { + else { idetape_switch_buffers(tape, tape->first_stage); if (rq_ptr->errors == IDETAPE_ERROR_GENERAL) { #if ONSTREAM_DEBUG @@ -4112,7 +4165,8 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) printk(KERN_INFO "ide-tape: error detected, bytes_read %d\n", bytes_read); #endif } - clear_bit(IDETAPE_FILEMARK, &tape->flags); + if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) + set_bit(IDETAPE_FILEMARK, &tape->flags); spin_lock_irqsave(&tape->spinlock, flags); idetape_remove_stage_head(drive); spin_unlock_irqrestore(&tape->spinlock, flags); @@ -4455,6 +4509,14 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c tape->restart_speed_control_req = 1; return retval; } + + if (mt_count == 0) + return 0; + if (MTBSF == mt_op || MTBSFM == mt_op) { + if (!tape->capabilities.sprev) + return -EIO; + mt_count = - mt_count; + } if (tape->chrdev_direction == idetape_direction_read) { /* @@ -4462,28 +4524,36 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c * filemarks. */ tape->merge_stage_size = 0; - clear_bit(IDETAPE_FILEMARK, &tape->flags); + if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) + ++count; while (tape->first_stage != NULL) { - idetape_wait_first_stage(drive); - if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK) - count++; if (count == mt_count) { - switch (mt_op) { - case MTFSF: - spin_lock_irqsave(&tape->spinlock, flags); - idetape_remove_stage_head(drive); - spin_unlock_irqrestore(&tape->spinlock, flags); - case MTFSFM: - return (0); - default: - break; - } + if (mt_op == MTFSFM) + set_bit(IDETAPE_FILEMARK, &tape->flags); + return 0; } spin_lock_irqsave(&tape->spinlock, flags); + if (tape->first_stage == tape->active_stage) { + /* + * We have reached the active stage in the read pipeline. + * There is no point in allowing the drive to continue + * reading any farther, so we stop the pipeline. + * + * This section should be moved to a separate subroutine, + * because a similar function is performed in + * __idetape_discard_read_pipeline(), for example. + */ + tape->next_stage = NULL; + spin_unlock_irqrestore(&tape->spinlock, flags); + idetape_wait_first_stage(drive); + tape->next_stage = tape->first_stage->next; + } else + spin_unlock_irqrestore(&tape->spinlock, flags); + if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK) + ++count; idetape_remove_stage_head(drive); - spin_unlock_irqrestore(&tape->spinlock, flags); } - idetape_discard_read_pipeline(drive, 1); + idetape_discard_read_pipeline(drive, 0); } /* @@ -4492,25 +4562,17 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c */ switch (mt_op) { case MTFSF: + case MTBSF: idetape_create_space_cmd(&pc,mt_count-count,IDETAPE_SPACE_OVER_FILEMARK); return (idetape_queue_pc_tail(drive, &pc)); case MTFSFM: - if (!tape->capabilities.sprev) - return (-EIO); - retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); - if (retval) return (retval); - return (idetape_space_over_filemarks(drive, MTBSF, 1)); - case MTBSF: - if (!tape->capabilities.sprev) - return (-EIO); - idetape_create_space_cmd(&pc,-(mt_count+count),IDETAPE_SPACE_OVER_FILEMARK); - return (idetape_queue_pc_tail(drive, &pc)); case MTBSFM: if (!tape->capabilities.sprev) return (-EIO); - retval = idetape_space_over_filemarks(drive, MTBSF, mt_count+count); + retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); if (retval) return (retval); - return (idetape_space_over_filemarks(drive, MTFSF, 1)); + count = (MTBSFM == mt_op ? 1 : -1); + return (idetape_space_over_filemarks(drive, MTFSF, count)); default: printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n",mt_op); return (-EIO); @@ -4861,7 +4923,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char *buf, */ retval = idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, 0, tape->merge_stage->bio); if (retval < 0) { - kfree(tape->merge_stage); + __idetape_kfree_stage(tape->merge_stage); tape->merge_stage = NULL; tape->chrdev_direction = idetape_direction_none; return retval; @@ -5447,8 +5509,10 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp) printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); return -EBUSY; } - idetape_read_position(drive); - clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); + if (tape->onstream) + idetape_read_position(drive); + if (tape->chrdev_direction != idetape_direction_read) + clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); if (tape->chrdev_direction == idetape_direction_none) { if (idetape_create_prevent_cmd(drive, &pc, 1)) { @@ -5520,10 +5584,11 @@ static int idetape_chrdev_release (struct inode *inode, struct file *filp) if (minor < 128) (void) idetape_rewind_tape(drive); if (tape->chrdev_direction == idetape_direction_none) { - if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) { - if (idetape_create_prevent_cmd(drive, &pc, 0)) + if (tape->door_locked == DOOR_LOCKED) { + if (idetape_create_prevent_cmd(drive, &pc, 0)) { if (!idetape_queue_pc_tail(drive, &pc)) tape->door_locked = DOOR_UNLOCKED; + } } } clear_bit(IDETAPE_BUSY, &tape->flags); @@ -5556,34 +5621,34 @@ static int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id) printk(KERN_INFO "ide-tape: Dumping ATAPI Identify Device tape parameters\n"); printk(KERN_INFO "ide-tape: Protocol Type: "); switch (gcw.protocol) { - case 0: case 1: printk(KERN_INFO "ATA\n");break; - case 2: printk(KERN_INFO "ATAPI\n");break; - case 3: printk(KERN_INFO "Reserved (Unknown to ide-tape)\n");break; + case 0: case 1: printk("ATA\n");break; + case 2: printk("ATAPI\n");break; + case 3: printk("Reserved (Unknown to ide-tape)\n");break; } printk(KERN_INFO "ide-tape: Device Type: %x - ",gcw.device_type); switch (gcw.device_type) { - case 0: printk(KERN_INFO "Direct-access Device\n");break; - case 1: printk(KERN_INFO "Streaming Tape Device\n");break; - case 2: case 3: case 4: printk(KERN_INFO "Reserved\n");break; - case 5: printk(KERN_INFO "CD-ROM Device\n");break; - case 6: printk(KERN_INFO "Reserved\n"); - case 7: printk(KERN_INFO "Optical memory Device\n");break; - case 0x1f: printk(KERN_INFO "Unknown or no Device type\n");break; - default: printk(KERN_INFO "Reserved\n"); + case 0: printk("Direct-access Device\n");break; + case 1: printk("Streaming Tape Device\n");break; + case 2: case 3: case 4: printk("Reserved\n");break; + case 5: printk("CD-ROM Device\n");break; + case 6: printk("Reserved\n"); + case 7: printk("Optical memory Device\n");break; + case 0x1f: printk("Unknown or no Device type\n");break; + default: printk("Reserved\n"); } printk(KERN_INFO "ide-tape: Removable: %s",gcw.removable ? "Yes\n":"No\n"); printk(KERN_INFO "ide-tape: Command Packet DRQ Type: "); switch (gcw.drq_type) { - case 0: printk(KERN_INFO "Microprocessor DRQ\n");break; - case 1: printk(KERN_INFO "Interrupt DRQ\n");break; - case 2: printk(KERN_INFO "Accelerated DRQ\n");break; - case 3: printk(KERN_INFO "Reserved\n");break; + case 0: printk("Microprocessor DRQ\n");break; + case 1: printk("Interrupt DRQ\n");break; + case 2: printk("Accelerated DRQ\n");break; + case 3: printk("Reserved\n");break; } printk(KERN_INFO "ide-tape: Command Packet Size: "); switch (gcw.packet_size) { - case 0: printk(KERN_INFO "12 bytes\n");break; - case 1: printk(KERN_INFO "16 bytes\n");break; - default: printk(KERN_INFO "Reserved\n");break; + case 0: printk("12 bytes\n");break; + case 1: printk("16 bytes\n");break; + default: printk("Reserved\n");break; } printk(KERN_INFO "ide-tape: Model: %.40s\n",id->model); printk(KERN_INFO "ide-tape: Firmware Revision: %.8s\n",id->fw_rev); @@ -5599,45 +5664,45 @@ static int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id) printk(KERN_INFO "ide-tape: Single Word DMA supported modes: "); for (i=0,mask=1;i<8;i++,mask=mask << 1) { if (id->dma_1word & mask) - printk(KERN_INFO "%d ",i); + printk("%d ",i); if (id->dma_1word & (mask << 8)) - printk(KERN_INFO "(active) "); + printk("(active) "); } - printk(KERN_INFO "\n"); + printk("\n"); printk(KERN_INFO "ide-tape: Multi Word DMA supported modes: "); for (i=0,mask=1;i<8;i++,mask=mask << 1) { if (id->dma_mword & mask) - printk(KERN_INFO "%d ",i); + printk("%d ",i); if (id->dma_mword & (mask << 8)) - printk(KERN_INFO "(active) "); + printk("(active) "); } - printk(KERN_INFO "\n"); + printk("\n"); if (id->field_valid & 0x0002) { printk(KERN_INFO "ide-tape: Enhanced PIO Modes: %s\n", id->eide_pio_modes & 1 ? "Mode 3":"None"); printk(KERN_INFO "ide-tape: Minimum Multi-word DMA cycle per word: "); if (id->eide_dma_min == 0) - printk(KERN_INFO "Not supported\n"); + printk("Not supported\n"); else - printk(KERN_INFO "%d ns\n",id->eide_dma_min); + printk("%d ns\n",id->eide_dma_min); printk(KERN_INFO "ide-tape: Manufacturer\'s Recommended Multi-word cycle: "); if (id->eide_dma_time == 0) - printk(KERN_INFO "Not supported\n"); + printk("Not supported\n"); else - printk(KERN_INFO "%d ns\n",id->eide_dma_time); + printk("%d ns\n",id->eide_dma_time); printk(KERN_INFO "ide-tape: Minimum PIO cycle without IORDY: "); if (id->eide_pio == 0) - printk(KERN_INFO "Not supported\n"); + printk("Not supported\n"); else - printk(KERN_INFO "%d ns\n",id->eide_pio); + printk("%d ns\n",id->eide_pio); printk(KERN_INFO "ide-tape: Minimum PIO cycle with IORDY: "); if (id->eide_pio_iordy == 0) - printk(KERN_INFO "Not supported\n"); + printk("Not supported\n"); else - printk(KERN_INFO "%d ns\n",id->eide_pio_iordy); + printk("%d ns\n",id->eide_pio_iordy); } else printk(KERN_INFO "ide-tape: According to the device, fields 64-70 are not valid.\n"); @@ -5946,9 +6011,9 @@ static void idetape_add_settings (ide_drive_t *drive) * drive setting name read/write ioctl ioctl data type min max mul_factor div_factor data pointer set function */ ide_add_setting(drive, "buffer", SETTING_READ, -1, -1, TYPE_SHORT, 0, 0xffff, 1, 2, &tape->capabilities.buffer_size, NULL); - ide_add_setting(drive, "pipeline_min", SETTING_RW, -1, -1, TYPE_INT, 2, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); - ide_add_setting(drive, "pipeline", SETTING_RW, -1, -1, TYPE_INT, 2, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); - ide_add_setting(drive, "pipeline_max", SETTING_RW, -1, -1, TYPE_INT, 2, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); + ide_add_setting(drive, "pipeline_min", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); + ide_add_setting(drive, "pipeline", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); + ide_add_setting(drive, "pipeline_max", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); ide_add_setting(drive, "pipeline_used",SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); ide_add_setting(drive, "pipeline_pending",SETTING_READ,-1, -1, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); ide_add_setting(drive, "speed", SETTING_READ, -1, -1, TYPE_SHORT, 0, 0xffff, 1, 1, &tape->capabilities.speed, NULL); @@ -6063,8 +6128,11 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) si_meminfo(&si); if (tape->max_stages * tape->stage_size > si.totalram * si.mem_unit / 10) tape->max_stages = si.totalram * si.mem_unit / (10 * tape->stage_size); - tape->min_pipeline = tape->max_stages; - tape->max_pipeline = tape->max_stages * 2; + tape->max_stages = min(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES); + tape->min_pipeline = min(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES); + tape->max_pipeline = min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES); + if (tape->max_stages == 0) + tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; t1 = (tape->stage_size * HZ) / (speed * 1000); tmid = (tape->capabilities.buffer_size * 32 * HZ) / (speed * 125); diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 0ae396abfcc1..a138e13d6b44 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1332,7 +1332,7 @@ int ata_attach(ide_drive_t *drive) spin_lock(&drivers_lock); list_for_each(p, &drivers) { ide_driver_t *driver = list_entry(p, ide_driver_t, drivers); - if (!try_inc_mod_count(driver->owner)) + if (!try_module_get(driver->owner)) continue; spin_unlock(&drivers_lock); if (driver->attach(drive) == 0) { diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index b5e00b4b12b5..5433a0466ce9 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -1066,8 +1066,7 @@ static int ieee1394_get_chardev(int blocknum, if(*file_ops == NULL) goto out; - /* don't need try_inc_mod_count if the driver is non-modular */ - if(*module && (try_inc_mod_count(*module) == 0)) + if(!try_module_get(*module)) goto out; /* success! */ diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index ad595be2a0a6..4e01b76e1fcb 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -207,9 +207,7 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) printk(KERN_ERR "capi: can't alloc capiminor\n"); return 0; } -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capiminor_alloc %d\n", GET_USE_COUNT(THIS_MODULE)); -#endif + memset(mp, 0, sizeof(struct capiminor)); mp->ap = ap; mp->ncci = ncci; @@ -252,9 +250,6 @@ static void capiminor_free(struct capiminor *mp) capiminor_del_all_ack(mp); kfree(mp); MOD_DEC_USE_COUNT; -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capiminor_free %d\n", GET_USE_COUNT(THIS_MODULE)); -#endif } struct capiminor *capiminor_find(unsigned int minor) @@ -980,9 +975,7 @@ static int capinc_tty_open(struct tty_struct * tty, struct file * file) return -ENXIO; tty->driver_data = (void *)mp; -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capi_tty_open %d\n", GET_USE_COUNT(THIS_MODULE)); -#endif + if (atomic_read(&mp->ttyopencount) == 0) mp->tty = tty; atomic_inc(&mp->ttyopencount); diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 337124784e9c..0e07e706a576 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -77,15 +77,9 @@ static struct work_struct tq_recv_notify; static inline struct capi_ctr * capi_ctr_get(struct capi_ctr *card) { - if (card->owner) { - if (try_inc_mod_count(card->owner)) { - DBG("MOD_COUNT INC"); - return card; - } else - return NULL; - } - DBG("MOD_COUNT INC"); - return card; + if (try_module_get(card->owner)) + return card; + return NULL; } static inline void diff --git a/drivers/isdn/eicon/eicon_mod.c b/drivers/isdn/eicon/eicon_mod.c index 54edc7d3f470..4fd7dbcb6968 100644 --- a/drivers/isdn/eicon/eicon_mod.c +++ b/drivers/isdn/eicon/eicon_mod.c @@ -54,10 +54,6 @@ extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, unsigned int command, unsigned long arg); extern void eicon_pci_init_conf(eicon_card *card); -#ifdef MODULE -#define MOD_USE_COUNT (GET_USE_COUNT (&__this_module)) -#endif - #define EICON_CTRL_VERSION 2 ulong DebugVar; @@ -370,12 +366,6 @@ eicon_command(eicon_card * card, isdn_ctrl * c) DebugVar = a; eicon_log(card, 1, "Eicon: Debug Value set to %ld\n", DebugVar); return 0; -#ifdef MODULE - case EICON_IOCTL_FREEIT: - while (MOD_USE_COUNT > 0) MOD_DEC_USE_COUNT; - MOD_INC_USE_COUNT; - return 0; -#endif case EICON_IOCTL_LOADPCI: eicon_log(card, 1, "Eicon: Wrong version of load-utility,\n"); eicon_log(card, 1, "Eicon: re-compile eiconctrl !\n"); diff --git a/drivers/isdn/hardware/eicon/i4lididrv.c b/drivers/isdn/hardware/eicon/i4lididrv.c index d086cdd17d00..38cf7c984607 100644 --- a/drivers/isdn/hardware/eicon/i4lididrv.c +++ b/drivers/isdn/hardware/eicon/i4lididrv.c @@ -40,10 +40,6 @@ static char *DRIVERRELEASE = "2.0"; static char *eicon_revision = "$Revision: 1.1.2.2 $"; extern char *eicon_idi_revision; -#ifdef MODULE -#define MOD_USE_COUNT (GET_USE_COUNT (&__this_module)) -#endif - #define EICON_CTRL_VERSION 2 ulong DebugVar; @@ -507,12 +503,6 @@ eicon_command(eicon_card * card, isdn_ctrl * c) DebugVar = a; eicon_log(card, 1, "%s: Debug Value set to %ld\n", DRIVERLNAME, DebugVar); return 0; -#ifdef MODULE - case EICON_IOCTL_FREEIT: - while (MOD_USE_COUNT > 0) MOD_DEC_USE_COUNT; - MOD_INC_USE_COUNT; - return 0; -#endif case EICON_IOCTL_LOADPCI: eicon_log(card, 1, "%s: Wrong version of load-utility,\n", DRIVERLNAME); eicon_log(card, 1, "%s: re-compile eiconctrl !\n", DRIVERLNAME); diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c index 4e366732644d..d2958c806c62 100644 --- a/drivers/isdn/hisax/callc.c +++ b/drivers/isdn/hisax/callc.c @@ -21,9 +21,6 @@ #include "hisax.h" #include <linux/isdn/capicmd.h> -#ifdef MODULE -#define MOD_USE_COUNT ( GET_USE_COUNT (&__this_module)) -#endif /* MODULE */ const char *lli_revision = "$Revision: 2.51.6.6 $"; diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 0936646dbc8d..bbe615f727be 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -396,39 +396,26 @@ static int adv717x_command(struct i2c_client *client, unsigned int cmd, return 0; } -static void adv717x_inc_use(struct i2c_client *client) -{ - MOD_INC_USE_COUNT; -} - -static void adv717x_dec_use(struct i2c_client *client) -{ - MOD_DEC_USE_COUNT; -} - - /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_adv7175 = { + .owner = THIS_MODULE, .name = "adv7175", /* name */ .id = I2C_DRIVERID_ADV717x, /* ID */ .flags = I2C_DF_NOTIFY, //I2C_ADV7175, I2C_ADV7175 + 3, .attach_adapter = adv717x_probe, .detach_client = adv717x_detach, .command = adv717x_command, - .inc_use = &adv717x_inc_use, - .dec_use = &adv717x_dec_use }; static struct i2c_driver i2c_driver_adv7176 = { + .owner = THIS_MODULE, .name = "adv7176", /* name */ .id = I2C_DRIVERID_ADV717x, /* ID */ .flags = I2C_DF_NOTIFY, //I2C_ADV7176, I2C_ADV7176 + 3, .attach_adapter = adv717x_probe, .detach_client = adv717x_detach, .command = adv717x_command, - .inc_use = &adv717x_inc_use, - .dec_use = &adv717x_dec_use }; static struct i2c_client client_template = { diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c index 08eff8c66cfa..5603d9ce59c2 100644 --- a/drivers/media/video/bttv-if.c +++ b/drivers/media/video/bttv-if.c @@ -194,16 +194,6 @@ static int bttv_bit_getsda(void *data) return state; } -static void bttv_inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void bttv_dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - static int attach_inform(struct i2c_client *client) { struct bttv *btv = (struct bttv*)client->adapter->data; @@ -272,10 +262,9 @@ static struct i2c_algo_bit_data bttv_i2c_algo_template = { }; static struct i2c_adapter bttv_i2c_adap_template = { + .owner = THIS_MODULE, .name = "bt848", .id = I2C_HW_B_BT848, - .inc_use = bttv_inc_use, - .dec_use = bttv_dec_use, .client_register = attach_inform, .client_unregister = detach_inform, }; diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index bcc26db53c6a..af042ec7b2ad 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -3173,7 +3173,7 @@ static int cpia_open(struct inode *inode, struct file *file) return -ENODEV; } - if (!try_inc_mod_count(cam->ops->owner)) + if (!try_module_get(cam->ops->owner)) return -ENODEV; down(&cam->busy_lock); diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index fbbe02a10faf..0e4d9b8d4b86 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -318,16 +318,6 @@ static u32 functionality(struct i2c_adapter *adap) return I2C_FUNC_SMBUS_EMUL; } -static void inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - static int attach_inform(struct i2c_client *client) { struct saa7134_dev *dev = client->adapter->algo_data; @@ -346,11 +336,10 @@ static struct i2c_algorithm saa7134_algo = { }; static struct i2c_adapter saa7134_adap_template = { + .owner = THIS_MODULE, .name = "saa7134", .id = I2C_ALGO_SAA7134, .algo = &saa7134_algo, - .inc_use = inc_use, - .dec_use = dec_use, .client_register = attach_inform, }; diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 62f1b96b0e78..e3ab127a6d3b 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -195,8 +195,9 @@ static int tvmixer_open(struct inode *inode, struct file *file) /* lock bttv in memory while the mixer is in use */ file->private_data = mix; - if (client->adapter->inc_use) - client->adapter->inc_use(client->adapter); + + if (!try_module_get(client->adapter->owner)) + return -ENODEV; return 0; } @@ -210,8 +211,7 @@ static int tvmixer_release(struct inode *inode, struct file *file) return -ENODEV; } - if (client->adapter->dec_use) - client->adapter->dec_use(client->adapter); + module_put(client->adapter->owner); return 0; } diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c index efdd7ee41d34..b33292c88be6 100644 --- a/drivers/mtd/chips/chipreg.c +++ b/drivers/mtd/chips/chipreg.c @@ -44,7 +44,7 @@ static struct mtd_chip_driver *get_mtd_chip_driver (char *name) break; } } - if (ret && !try_inc_mod_count(ret->module)) { + if (ret && !try_module_get(ret->module)) { /* Eep. Failed. */ ret = NULL; } diff --git a/drivers/net/defxx.h b/drivers/net/defxx.h index dc88192bcd48..4fc9425dcbc8 100644 --- a/drivers/net/defxx.h +++ b/drivers/net/defxx.h @@ -1669,13 +1669,6 @@ typedef union #define XMT_BUFF_K_SA 7 /* six byte source address */ #define XMT_BUFF_K_DATA 13 /* offset to start of packet data */ -/* - * Macro evaluates to "value" aligned to "size" bytes. Make sure that - * "size" is greater than 0 bytes. - */ - -#define ALIGN(value,size) ((value + (size - 1)) & ~(size - 1)) - /* Macro for checking a "value" is within a specific range */ #define IN_RANGE(value,low,high) ((value >= low) && (value <= high)) diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index a27737026547..09823085fa2d 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c @@ -466,13 +466,9 @@ static int sirdev_open(struct net_device *ndev) if (!drv) return -ENODEV; - lock_kernel(); /* serialize with rmmod */ /* increase the reference count of the driver module before doing serious stuff */ - if (drv->owner && !try_inc_mod_count(drv->owner)) { - unlock_kernel(); + if (!try_module_get(drv->owner)) return -ESTALE; - } - unlock_kernel(); IRDA_DEBUG(2, "%s()\n", __FUNCTION__); diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c index cf7a17a002d3..b23cd3480519 100644 --- a/drivers/net/irda/sir_dongle.c +++ b/drivers/net/irda/sir_dongle.c @@ -95,13 +95,13 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type) * 1) dongle driver was already unregistered - then we haven't found the * requested dongle above and are already out here * 2) the module is already marked deleted but the driver is still - * registered - then the try_inc_mod_count() below will fail - * 3) the try_inc_mod_count() below succeeds before the module is marked + * registered - then the try_module_get() below will fail + * 3) the try_module_get() below succeeds before the module is marked * deleted - then sys_delete_module() fails and prevents the removal * because the module is in use. */ - if (drv->owner && !try_inc_mod_count(drv->owner)) { + if (!try_module_get(drv->owner)) { err = -ESTALE; goto out_unlock; /* rmmod already pending */ } diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 8eedee623a04..5be431297f86 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1734,7 +1734,7 @@ dasd_open(struct inode *inp, struct file *filp) rc = 0; if (atomic_inc_return(&device->open_count) == 1) { - if (!try_inc_mod_count(device->discipline->owner)) { + if (!try_module_get(device->discipline->owner)) { /* Discipline is currently unloaded! */ atomic_dec(&device->open_count); rc = -ENODEV; diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index 9047d68fb20a..e570db2497bd 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -111,13 +111,10 @@ dasd_ioctl(struct inode *inp, struct file *filp, ioctl = list_entry(l, dasd_ioctl_list_t, list); if (ioctl->no == no) { /* Found a matching ioctl. Call it. */ - if (ioctl->owner) { - if (try_inc_mod_count(ioctl->owner) != 0) - continue; - rc = ioctl->handler(bdev, no, data); - module_put(ioctl->owner); - } else - rc = ioctl->handler(bdev, no, data); + if (try_module_get(ioctl->owner) != 0) + continue; + rc = ioctl->handler(bdev, no, data); + module_put(ioctl->owner); return rc; } } diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c index af71fadf2f52..7da7493a6a63 100644 --- a/drivers/s390/char/tape_core.c +++ b/drivers/s390/char/tape_core.c @@ -837,7 +837,7 @@ tape_open(struct tape_device *device) DBF_EVENT(6, "TAPE:dbusy\n"); rc = -EBUSY; } else if (device->discipline != NULL && - !try_inc_mod_count(device->discipline->owner)) { + !try_module_get(device->discipline->owner)) { DBF_EVENT(6, "TAPE:nodisc\n"); rc = -ENODEV; } else { diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 4a30106757b6..69f6593b6072 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -1297,7 +1297,6 @@ Scsi_Host_Template aic7xxx_driver_template = { */ .max_sectors = 8192, #endif -#if defined CONFIG_HIGHIO #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) /* Assume RedHat Distribution with its different HIGHIO conventions. */ .can_dma_32 = 1, @@ -1305,7 +1304,6 @@ Scsi_Host_Template aic7xxx_driver_template = { #else .highmem_io = 1, #endif -#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) .name = "aic7xxx", .slave_alloc = ahc_linux_slave_alloc, diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index 495367b66a6d..05b12228dc10 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -166,6 +166,9 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ahc->flags |= AHC_39BIT_ADDRESSING; ahc->platform_data->hw_dma_mask = (bus_addr_t)(0x7FFFFFFFFFULL & (bus_addr_t)~0); + } else { + ahc_pci_set_dma_mask(pdev, 0xffffffffULL); + ahc->platform_data->hw_dma_mask = 0xffffffffULL; } #endif ahc->dev_softc = pci; diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 27bee295b157..f7c3379dafe3 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -16,15 +16,15 @@ Copyright 1992 - 2002 Kai Makisara / Willem Riede email Kai.Makisara@metla.fi / osst@riede.org - $Header: /home/cvsroot/Driver/osst.c,v 1.65 2001/11/11 20:38:56 riede Exp $ + $Header: /home/cvsroot/Driver/osst.c,v 1.68 2002/12/23 16:33:36 riede Exp $ Microscopic alterations - Rik Ling, 2000/12/21 Last st.c sync: Tue Oct 15 22:01:04 2002 by makisara Some small formal changes - aeb, 950809 */ -static const char * cvsid = "$Id: osst.c,v 1.65 2001/11/11 20:38:56 riede Exp $"; -const char * osst_version = "0.99.0p5"; +static const char * cvsid = "$Id: osst.c,v 1.68 2002/12/23 16:33:36 riede Exp $"; +const char * osst_version = "0.99.0"; /* The "failure to reconnect" firmware bug */ #define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/ @@ -470,7 +470,7 @@ static void osst_init_aux(OS_Scsi_Tape * STp, int frame_type, int frame_seq_numb */ static int osst_verify_frame(OS_Scsi_Tape * STp, int frame_seq_number, int quiet) { - char *name = tape_name(STp); + char * name = tape_name(STp); os_aux_t * aux = STp->buffer->aux; os_partition_t * par = &(aux->partition); ST_partstat * STps = &(STp->ps[STp->partition]); @@ -676,7 +676,7 @@ static int osst_wait_for_medium(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsi long startwait = jiffies; #if DEBUG int dbg = debugging; - char *name = tape_name(STp); + char * name = tape_name(STp); printk(OSST_DEB_MSG "%s:D: Reached onstream wait for medium\n", name); #endif @@ -748,7 +748,7 @@ static int osst_flush_drive_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) int result = 0; int delay = OSST_WAIT_WRITE_COMPLETE; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); printk(OSST_DEB_MSG "%s:D: Reached onstream flush drive buffer (write filemark)\n", name); #endif @@ -778,7 +778,7 @@ static int osst_flush_drive_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) static int osst_wait_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int curr, int minlast, int to) { long startwait = jiffies; - char *name = tape_name(STp); + char * name = tape_name(STp); #if DEBUG char notyetprinted = 1; #endif @@ -841,7 +841,7 @@ static int osst_read_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int timeo int retval = 0; #if DEBUG os_aux_t * aux = STp->buffer->aux; - char *name = tape_name(STp); + char * name = tape_name(STp); #endif /* TODO: Error handling */ @@ -888,10 +888,12 @@ static int osst_read_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int timeo STp->first_frame_position++; #if DEBUG if (debugging) { + char sig[8]; int i; + for (i=0;i<4;i++) + sig[i] = aux->application_sig[i]<32?'^':aux->application_sig[i]; + sig[4] = '\0'; printk(OSST_DEB_MSG - "%s:D: AUX: %c%c%c%c UpdFrCt#%d Wpass#%d %s FrSeq#%d LogBlk#%d Qty=%d Sz=%d\n", name, - aux->application_sig[0], aux->application_sig[1], - aux->application_sig[2], aux->application_sig[3], + "%s:D: AUX: %s UpdFrCt#%d Wpass#%d %s FrSeq#%d LogBlk#%d Qty=%d Sz=%d\n", name, sig, ntohl(aux->update_frame_cntr), ntohs(aux->partition.wrt_pass_cntr), aux->frame_type==1?"EOD":aux->frame_type==2?"MARK": aux->frame_type==8?"HEADR":aux->frame_type==0x80?"DATA":"FILL", @@ -913,7 +915,7 @@ static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) unsigned char cmd[MAX_COMMAND_SIZE]; int retval = 0; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); #endif if (STps->rw != ST_READING) { /* Initialize read operation */ @@ -947,7 +949,7 @@ static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int frame_seq_number, int quiet) { ST_partstat * STps = &(STp->ps[STp->partition]); - char *name = tape_name(STp); + char * name = tape_name(STp); int cnt = 0, bad = 0, past = 0, @@ -1073,7 +1075,7 @@ static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, in static int osst_seek_logical_blk(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int logical_blk_num) { ST_partstat * STps = &(STp->ps[STp->partition]); - char *name = tape_name(STp); + char * name = tape_name(STp); int retries = 0; int frame_seq_estimate, ppos_estimate, move; @@ -1183,7 +1185,7 @@ static int osst_get_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) { int sector; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); printk(OSST_DEB_MSG "%s:D: Positioned at ppos %d, frame %d, lbn %d, file %d, blk %d, %cptr %d, eof %d\n", @@ -1216,7 +1218,7 @@ static int osst_seek_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int sect offset = (sector & OSST_SECTOR_MASK) << OSST_SECTOR_SHIFT, r; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); printk(OSST_DEB_MSG "%s:D: Seeking sector %d in frame %d at offset %d\n", name, sector, frame, offset); @@ -1285,7 +1287,7 @@ static int osst_read_back_buffer_and_rewrite(OS_Scsi_Tape * STp, Scsi_Request ** - (nframes + pending - 1); int logical_blk_num = ntohl(STp->buffer->aux->logical_blk_num) - (nframes + pending - 1) * blks_per_frame; - char *name = tape_name(STp); + char * name = tape_name(STp); long startwait = jiffies; #if DEBUG int dbg = debugging; @@ -1471,7 +1473,7 @@ static int osst_reposition_and_retry(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, { unsigned char cmd[MAX_COMMAND_SIZE]; Scsi_Request * SRpnt; - char *name = tape_name(STp); + char * name = tape_name(STp); int expected = 0; int attempts = 1000 / skip; int flag = 1; @@ -1574,7 +1576,7 @@ static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, { Scsi_Request * SRpnt = * aSRpnt; ST_partstat * STps = & STp->ps[STp->partition]; - char *name = tape_name(STp); + char * name = tape_name(STp); int retval = 0; int rw_state; unsigned int frame, skip; @@ -1650,7 +1652,7 @@ static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, static int osst_space_over_filemarks_backward(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int mt_op, int mt_count) { - char *name = tape_name(STp); + char * name = tape_name(STp); int cnt; int last_mark_ppos = -1; @@ -1751,7 +1753,7 @@ static int osst_space_over_filemarks_forward_slow(OS_Scsi_Tape * STp, Scsi_Reque { int cnt = 0; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); printk(OSST_DEB_MSG "%s:D: Reached space_over_filemarks_forward_slow %d %d\n", name, mt_op, mt_count); #endif @@ -1803,8 +1805,8 @@ static int osst_space_over_filemarks_forward_slow(OS_Scsi_Tape * STp, Scsi_Reque static int osst_space_over_filemarks_forward_fast(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int mt_op, int mt_count) { - char *name = tape_name(STp); - int cnt = 0, + char * name = tape_name(STp); + int cnt = 0, next_mark_ppos = -1; #if DEBUG @@ -1954,8 +1956,8 @@ static int osst_space_over_filemarks_forward_fast(OS_Scsi_Tape * STp, Scsi_Reque static void osst_set_retries(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int retries) { unsigned char cmd[MAX_COMMAND_SIZE]; - Scsi_Request * SRpnt = * aSRpnt; - char *name = tape_name(STp); + Scsi_Request * SRpnt = * aSRpnt; + char * name = tape_name(STp); memset(cmd, 0, MAX_COMMAND_SIZE); cmd[0] = MODE_SELECT; @@ -1989,7 +1991,7 @@ static int osst_write_filemark(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) int this_mark_ppos = STp->first_frame_position; int this_mark_lbn = STp->logical_blk_num; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); #endif if (STp->raw) return 0; @@ -2015,7 +2017,7 @@ static int osst_write_eod(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) { int result; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); #endif if (STp->raw) return 0; @@ -2036,7 +2038,7 @@ static int osst_write_eod(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) static int osst_write_filler(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int where, int count) { - char *name = tape_name(STp); + char * name = tape_name(STp); #if DEBUG printk(OSST_DEB_MSG "%s:D: Reached onstream write filler group %d\n", name, where); @@ -2061,7 +2063,7 @@ static int osst_write_filler(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int whe static int __osst_write_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int where, int count) { - char *name = tape_name(STp); + char * name = tape_name(STp); int result; #if DEBUG @@ -2090,7 +2092,7 @@ static int osst_write_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int loc { os_header_t * header; int result; - char *name = tape_name(STp); + char * name = tape_name(STp); #if DEBUG printk(OSST_DEB_MSG "%s:D: Writing tape header\n", name); @@ -2175,7 +2177,7 @@ static int osst_reset_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) static int __osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int ppos) { - char *name = tape_name(STp); + char * name = tape_name(STp); os_header_t * header; os_aux_t * aux; char id_string[8]; @@ -2352,10 +2354,10 @@ static int __osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, in static int osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) { - int position, ppos; + int position, ppos; int first, last; int valid = 0; - char *name = tape_name(STp); + char * name = tape_name(STp); position = osst_get_frame_position(STp, aSRpnt); @@ -2408,14 +2410,14 @@ static int osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) static int osst_verify_position(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) { int frame_position = STp->first_frame_position; - int frame_seq_numbr = STp->frame_seq_number; + int frame_seq_numbr = STp->frame_seq_number; int logical_blk_num = STp->logical_blk_num; - int halfway_frame = STp->frame_in_buffer; - int read_pointer = STp->buffer->read_pointer; + int halfway_frame = STp->frame_in_buffer; + int read_pointer = STp->buffer->read_pointer; int prev_mark_ppos = -1; int actual_mark_ppos, i, n; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); printk(OSST_DEB_MSG "%s:D: Verify that the tape is really the one we think before writing\n", name); #endif @@ -2484,8 +2486,8 @@ static unsigned int osst_parse_firmware_rev (const char * str) static int osst_configure_onstream(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) { unsigned char cmd[MAX_COMMAND_SIZE]; - char *name = tape_name(STp); - Scsi_Request * SRpnt = * aSRpnt; + char * name = tape_name(STp); + Scsi_Request * SRpnt = * aSRpnt; osst_mode_parameter_header_t * header; osst_block_size_page_t * bs; osst_capabilities_page_t * cp; @@ -2655,7 +2657,7 @@ static int osst_configure_onstream(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) static int cross_eof(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, int forward) { int result; - char *name = tape_name(STp); + char * name = tape_name(STp); #if DEBUG if (debugging) @@ -2692,7 +2694,7 @@ static int osst_get_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) char mybuf[24]; char * olddata = STp->buffer->b_data; int oldsize = STp->buffer->buffer_size; - char *name = tape_name(STp); + char * name = tape_name(STp); if (STp->ready != ST_READY) return (-EIO); @@ -2765,8 +2767,8 @@ static int osst_set_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, in Scsi_Request * SRpnt; ST_partstat * STps; int result = 0; - int pp = (ppos == 3000 && !skip)? 0 : ppos; - char *name = tape_name(STp); + int pp = (ppos == 3000 && !skip)? 0 : ppos; + char * name = tape_name(STp); if (STp->ready != ST_READY) return (-EIO); @@ -2824,12 +2826,12 @@ static int osst_set_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, in /* Flush the write buffer (never need to write if variable blocksize). */ static int osst_flush_write_buffer(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) { - int offset, transfer, blks = 0; - int result = 0; - unsigned char cmd[MAX_COMMAND_SIZE]; + int offset, transfer, blks = 0; + int result = 0; + unsigned char cmd[MAX_COMMAND_SIZE]; Scsi_Request * SRpnt = *aSRpnt; - ST_partstat * STps; - char *name = tape_name(STp); + ST_partstat * STps; + char * name = tape_name(STp); if ((STp->buffer)->writing) { if (SRpnt == (STp->buffer)->last_SRpnt) @@ -2954,10 +2956,10 @@ static int osst_flush_write_buffer(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) seek_next is true. */ static int osst_flush_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int seek_next) { - ST_partstat * STps; - int backspace = 0, result = 0; + ST_partstat * STps; + int backspace = 0, result = 0; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); #endif /* @@ -3017,10 +3019,10 @@ static int osst_flush_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int see static int osst_write_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int synchronous) { unsigned char cmd[MAX_COMMAND_SIZE]; - Scsi_Request * SRpnt; + Scsi_Request * SRpnt; int blks; #if DEBUG - char *name = tape_name(STp); + char * name = tape_name(STp); #endif if ((!STp-> raw) && (STp->first_frame_position == 0xbae)) { /* _must_ preserve buffer! */ @@ -3139,16 +3141,16 @@ static void reset_state(OS_Scsi_Tape *STp) /* Write command */ static ssize_t osst_write(struct file * filp, const char * buf, size_t count, loff_t *ppos) { - ssize_t total, retval = 0; - ssize_t i, do_count, blks, transfer; - int write_threshold; - int doing_write = 0; - const char *b_point; + ssize_t total, retval = 0; + ssize_t i, do_count, blks, transfer; + int write_threshold; + int doing_write = 0; + const char * b_point; Scsi_Request * SRpnt = NULL; - ST_mode * STm; - ST_partstat * STps; - OS_Scsi_Tape * STp = filp->private_data; - char *name = tape_name(STp); + ST_mode * STm; + ST_partstat * STps; + OS_Scsi_Tape * STp = filp->private_data; + char * name = tape_name(STp); if (down_interruptible(&STp->lock)) @@ -3468,14 +3470,14 @@ out: /* Read command */ static ssize_t osst_read(struct file * filp, char * buf, size_t count, loff_t *ppos) { - ssize_t total, retval = 0; - ssize_t i, transfer; - int special; - ST_mode * STm; - ST_partstat * STps; - Scsi_Request *SRpnt = NULL; - OS_Scsi_Tape * STp = filp->private_data; - char *name = tape_name(STp); + ssize_t total, retval = 0; + ssize_t i, transfer; + int special; + ST_mode * STm; + ST_partstat * STps; + Scsi_Request * SRpnt = NULL; + OS_Scsi_Tape * STp = filp->private_data; + char * name = tape_name(STp); if (down_interruptible(&STp->lock)) @@ -3523,8 +3525,7 @@ static ssize_t osst_read(struct file * filp, char * buf, size_t count, loff_t *p goto out; } - if (STp->do_auto_lock && STp->door_locked == ST_UNLOCKED && - !osst_int_ioctl(STp, &SRpnt, MTLOCK, 0)) + if (STp->do_auto_lock && STp->door_locked == ST_UNLOCKED && !do_door_lock(STp, 1)) STp->door_locked = ST_LOCKED_AUTO; STps = &(STp->ps[STp->partition]); @@ -3683,10 +3684,10 @@ static void osst_log_options(OS_Scsi_Tape *STp, ST_mode *STm, char *name) static int osst_set_options(OS_Scsi_Tape *STp, long options) { - int value; - long code; - ST_mode *STm; - char *name = tape_name(STp); + int value; + long code; + ST_mode * STm; + char * name = tape_name(STp); STm = &(STp->modes[STp->current_mode]); if (!STm->defined) { @@ -3839,16 +3840,16 @@ static int osst_set_options(OS_Scsi_Tape *STp, long options) /* Internal ioctl function */ static int osst_int_ioctl(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsigned int cmd_in, unsigned long arg) { - int timeout; - long ltmp; - int i, ioctl_result; - int chg_eof = TRUE; - unsigned char cmd[MAX_COMMAND_SIZE]; + int timeout; + long ltmp; + int i, ioctl_result; + int chg_eof = TRUE; + unsigned char cmd[MAX_COMMAND_SIZE]; Scsi_Request * SRpnt = * aSRpnt; - ST_partstat * STps; - int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num; - int datalen = 0, direction = SCSI_DATA_NONE; - char *name = tape_name(STp); + ST_partstat * STps; + int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num; + int datalen = 0, direction = SCSI_DATA_NONE; + char * name = tape_name(STp); if (STp->ready != ST_READY && cmd_in != MTLOAD) { if (STp->ready == ST_NO_TAPE) @@ -4208,15 +4209,15 @@ os_bypass: static int os_scsi_tape_open(struct inode * inode, struct file * filp) { unsigned short flags; - int i, b_size, new_session = FALSE, retval = 0; - unsigned char cmd[MAX_COMMAND_SIZE]; + int i, b_size, new_session = FALSE, retval = 0; + unsigned char cmd[MAX_COMMAND_SIZE]; Scsi_Request * SRpnt; OS_Scsi_Tape * STp; - ST_mode * STm; - ST_partstat * STps; - char *name; - int dev = TAPE_NR(inode->i_rdev); - int mode = TAPE_MODE(inode->i_rdev); + ST_mode * STm; + ST_partstat * STps; + char * name; + int dev = TAPE_NR(inode->i_rdev); + int mode = TAPE_MODE(inode->i_rdev); write_lock(&os_scsi_tapes_lock); if (dev >= osst_max_dev || os_scsi_tapes == NULL || @@ -4267,44 +4268,32 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) STp->raw = TAPE_IS_RAW(inode->i_rdev); if (STp->raw) STp->header_ok = 0; -#if 0 - /* Allocate a buffer for this user */ - need_dma_buffer = STp->restr_dma; - for (i=0; i < osst_nbr_buffers; i++) - if (!osst_buffers[i]->in_use && - (!need_dma_buffer || osst_buffers[i]->dma)) - break; - if (i >= osst_nbr_buffers) { - STp->buffer = new_tape_buffer(FALSE, need_dma_buffer); - if (STp->buffer == NULL) { - printk(KERN_WARNING "%s:W: Can't allocate tape buffer.\n", name); - retval = (-EBUSY); - goto err_out; - } - } - else - STp->buffer = osst_buffers[i]; -#endif /* now pre_allocated */ + /* Allocate data segments for this device's tape buffer */ if (!enlarge_buffer(STp->buffer, STp->restr_dma)) { printk(KERN_ERR "%s:E: Unable to allocate memory segments for tape buffer.\n", name); retval = (-EOVERFLOW); goto err_out; } - (STp->buffer)->writing = 0; - (STp->buffer)->syscall_result = 0; -#if 0 - (STp->buffer)->use_sg = STp->device->host->sg_tablesize; - - /* Compute the usable buffer size for this SCSI adapter */ - if (!(STp->buffer)->use_sg) - (STp->buffer)->buffer_size = (STp->buffer)->sg[0].length; - else { - for (i=0, (STp->buffer)->buffer_size = 0; i < (STp->buffer)->use_sg && - i < (STp->buffer)->sg_segs; i++) - (STp->buffer)->buffer_size += (STp->buffer)->sg[i].length; - } + if (STp->buffer->buffer_size >= OS_FRAME_SIZE) { + for (i = 0, b_size = 0; + (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); + b_size += STp->buffer->sg[i++].length); + STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size); +#if DEBUG + printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, + STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); + printk(OSST_DEB_MSG "%s:D: AUX points to %p in segment %d at %p\n", name, + STp->buffer->aux, i, page_address(STp->buffer->sg[i].page)); #endif + } else { + STp->buffer->aux = NULL; /* this had better never happen! */ + printk(KERN_NOTICE "%s:A: Framesize %d too large for buffer.\n", name, OS_FRAME_SIZE); + retval = (-EIO); + goto err_out; + } + STp->buffer->writing = 0; + STp->buffer->syscall_result = 0; STp->dirty = 0; for (i=0; i < ST_NBR_PARTITIONS; i++) { STps = &(STp->ps[i]); @@ -4410,7 +4399,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) i = STp->first_frame_position; if (STp->header_ok && i == osst_get_frame_position(STp, &SRpnt)) { if (STp->door_locked == ST_UNLOCKED) { - if (osst_int_ioctl(STp, &SRpnt, MTLOCK, 0)) + if (do_door_lock(STp, 1)) printk(KERN_INFO "%s:I: Can't lock drive door\n", name); else STp->door_locked = ST_LOCKED_AUTO; @@ -4512,24 +4501,6 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) osst_configure_onstream(STp, &SRpnt); - if (STp->buffer->buffer_size >= OS_FRAME_SIZE) { - for (i = 0, b_size = 0; - (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); - b_size += STp->buffer->sg[i++].length); - STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size); -#if DEBUG - printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, - STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); - printk(OSST_DEB_MSG "%s:D: AUX points to %p in segment %d at %p\n", name, - STp->buffer->aux, i, page_address(STp->buffer->sg[i].page)); -#endif - } else { - STp->buffer->aux = NULL; /* this had better never happen! */ - printk(KERN_NOTICE "%s:A: Framesize %d too large for buffer.\n", name, OS_FRAME_SIZE); - retval = (-EIO); - goto err_out; - } - STp->block_size = STp->raw ? OS_FRAME_SIZE : ( (STm->default_blksize > 0) ? STm->default_blksize : OS_DATA_SIZE); STp->buffer->buffer_blocks = STp->raw ? 1 : OS_DATA_SIZE / STp->block_size; @@ -4569,7 +4540,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) * properly position the tape and check the ADR headers */ if (STp->door_locked == ST_UNLOCKED) { - if (osst_int_ioctl(STp, &SRpnt, MTLOCK, 0)) + if (do_door_lock(STp, 1)) printk(KERN_INFO "%s:I: Can't lock drive door\n", name); else STp->door_locked = ST_LOCKED_AUTO; @@ -4597,12 +4568,12 @@ err_out: /* Flush the tape buffer before close */ static int os_scsi_tape_flush(struct file * filp) { - int result = 0, result2; - OS_Scsi_Tape * STp = filp->private_data; - ST_mode * STm = &(STp->modes[STp->current_mode]); - ST_partstat * STps = &(STp->ps[STp->partition]); - Scsi_Request *SRpnt = NULL; - char *name = tape_name(STp); + int result = 0, result2; + OS_Scsi_Tape * STp = filp->private_data; + ST_mode * STm = &(STp->modes[STp->current_mode]); + ST_partstat * STps = &(STp->ps[STp->partition]); + Scsi_Request * SRpnt = NULL; + char * name = tape_name(STp); if (file_count(filp) > 1) return 0; @@ -4727,13 +4698,13 @@ static int os_scsi_tape_close(struct inode * inode, struct file * filp) static int osst_ioctl(struct inode * inode,struct file * file, unsigned int cmd_in, unsigned long arg) { - int i, cmd_nr, cmd_type, retval = 0; - unsigned int blk; - ST_mode *STm; - ST_partstat *STps; - Scsi_Request *SRpnt = NULL; - OS_Scsi_Tape *STp = file->private_data; - char *name = tape_name(STp); + int i, cmd_nr, cmd_type, retval = 0; + unsigned int blk; + ST_mode * STm; + ST_partstat * STps; + Scsi_Request * SRpnt = NULL; + OS_Scsi_Tape * STp = file->private_data; + char * name = tape_name(STp); if (down_interruptible(&STp->lock)) return -ERESTARTSYS; @@ -4813,6 +4784,8 @@ static int osst_ioctl(struct inode * inode,struct file * file, i = mtc.mt_op == MTREW || mtc.mt_op == MTOFFL || mtc.mt_op == MTRETEN || mtc.mt_op == MTEOM || mtc.mt_op == MTLOCK || mtc.mt_op == MTLOAD || + mtc.mt_op == MTFSF || mtc.mt_op == MTFSFM || + mtc.mt_op == MTBSF || mtc.mt_op == MTBSFM || mtc.mt_op == MTCOMPRESSION; } i = osst_flush_buffer(STp, &SRpnt, i); @@ -5123,8 +5096,9 @@ static int enlarge_buffer(OSST_buffer *STbuffer, int need_dma) "osst :D: Expanded tape buffer (%d bytes, %d->%d segments, dma: %d, at: %p).\n", got, STbuffer->orig_sg_segs, STbuffer->sg_segs, need_dma, STbuffer->b_data); printk(OSST_DEB_MSG - "osst :D: segment sizes: first %d, last %d bytes.\n", - STbuffer->sg[0].length, STbuffer->sg[segs-1].length); + "osst :D: segment sizes: first %d at %p, last %d bytes at %p.\n", + STbuffer->sg[0].length, page_address(STbuffer->sg[0].page), + STbuffer->sg[segs-1].length, page_address(STbuffer->sg[segs-1].page)); } #endif @@ -5410,12 +5384,12 @@ static struct osst_support_data support_list[] = { static int osst_attach(Scsi_Device * SDp) { - OS_Scsi_Tape * tpnt; - ST_mode * STm; - ST_partstat * STps; - OSST_buffer *buffer; - struct gendisk *drive; - int i, mode, dev_num; + OS_Scsi_Tape * tpnt; + ST_mode * STm; + ST_partstat * STps; + OSST_buffer * buffer; + struct gendisk * drive; + int i, mode, dev_num; if (SDp->type != TYPE_TAPE || !osst_supports(SDp)) return 1; diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index b3acfcffc73b..1449db800808 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -172,8 +172,7 @@ void scsi_times_out(Scsi_Cmnd *scmd) * see whether the host or the device is offline. * * Return value: - * FALSE when dev was taken offline by error recovery. TRUE OK to - * proceed. + * 0 when dev was taken offline by error recovery. 1 OK to proceed. **/ int scsi_block_when_processing_errors(Scsi_Device *sdev) { @@ -1157,7 +1156,7 @@ static void scsi_eh_offline_sdevs(Scsi_Cmnd *sc_todo, struct Scsi_Host *shost) if (scsi_eh_eflags_chk(scmd, SCSI_EH_CMD_TIMEOUT)) scmd->result |= (DRIVER_TIMEOUT << 24); - scmd->device->online = FALSE; + scmd->device->online = 0; scsi_eh_finish_cmd(scmd, shost); } return; @@ -1222,7 +1221,7 @@ int scsi_decide_disposition(Scsi_Cmnd *scmd) * if the device is offline, then we clearly just pass the result back * up to the top level. */ - if (scmd->device->online == FALSE) { + if (!scmd->device->online) { SCSI_LOG_ERROR_RECOVERY(5, printk("%s: device offline - report" " as SUCCESS\n", __FUNCTION__)); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 475e58db7ace..d3b5bc941760 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1060,7 +1060,7 @@ void scsi_request_fn(request_queue_t * q) */ void scsi_block_requests(struct Scsi_Host * SHpnt) { - SHpnt->host_self_blocked = TRUE; + SHpnt->host_self_blocked = 1; } /* @@ -1087,7 +1087,7 @@ void scsi_unblock_requests(struct Scsi_Host * SHpnt) { Scsi_Device *SDloop; - SHpnt->host_self_blocked = FALSE; + SHpnt->host_self_blocked = 0; /* Now that we are unblocked, try to start the queues. */ list_for_each_entry(SDloop, &SHpnt->my_devices, siblings) scsi_queue_next_request(SDloop->request_queue, NULL); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index b5276bdc69b6..2ce2cb32ee76 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -537,9 +537,20 @@ static int sd_ioctl(struct inode * inode, struct file * filp, return sd_hdio_getgeo(bdev, (struct hd_geometry *)arg); } - error = scsi_cmd_ioctl(bdev, cmd, arg); - if (error != -ENOTTY) - return error; + /* + * Send SCSI addressing ioctls directly to mid level, send other + * ioctls to block level and then onto mid level if they can't be + * resolved. + */ + switch (cmd) { + case SCSI_IOCTL_GET_IDLUN: + case SCSI_IOCTL_GET_BUS_NUMBER: + return scsi_ioctl(sdp, cmd, (void *)arg); + default: + error = scsi_cmd_ioctl(bdev, cmd, arg); + if (error != -ENOTTY) + return error; + } return scsi_ioctl(sdp, cmd, (void *)arg); } diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 780d516c291d..0de2e7c68206 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -434,6 +434,17 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, unsigned long arg) { struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); + struct scsi_device *sdev = cd->device; + + /* + * Send SCSI addressing ioctls directly to mid level, send other + * ioctls to cdrom/block level. + */ + switch (cmd) { + case SCSI_IOCTL_GET_IDLUN: + case SCSI_IOCTL_GET_BUS_NUMBER: + return scsi_ioctl(sdev, cmd, (void *)arg); + } return cdrom_ioctl(&cd->cdi, inode, cmd, arg); } diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c index 76a701bb4502..690d8feafe6e 100644 --- a/drivers/scsi/sr_vendor.c +++ b/drivers/scsi/sr_vendor.c @@ -37,6 +37,7 @@ #include <linux/config.h> #include <linux/errno.h> #include <linux/string.h> +#include <linux/bcd.h> #include <linux/blk.h> #include "scsi.h" @@ -151,8 +152,6 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) /* This function gets called after a media change. Checks if the CD is multisession, asks for offset etc. */ -#define BCD_TO_BIN(x) ((((int)x & 0xf0) >> 4)*10 + ((int)x & 0x0f)) - int sr_cd_check(struct cdrom_device_info *cdi) { Scsi_CD *cd = cdi->handle; @@ -223,9 +222,9 @@ int sr_cd_check(struct cdrom_device_info *cdi) no_multi = 1; break; } - min = BCD_TO_BIN(buffer[15]); - sec = BCD_TO_BIN(buffer[16]); - frame = BCD_TO_BIN(buffer[17]); + min = BCD2BIN(buffer[15]); + sec = BCD2BIN(buffer[16]); + frame = BCD2BIN(buffer[17]); sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; break; } @@ -252,9 +251,9 @@ int sr_cd_check(struct cdrom_device_info *cdi) } if (rc != 0) break; - min = BCD_TO_BIN(buffer[1]); - sec = BCD_TO_BIN(buffer[2]); - frame = BCD_TO_BIN(buffer[3]); + min = BCD2BIN(buffer[1]); + sec = BCD2BIN(buffer[2]); + frame = BCD2BIN(buffer[3]); sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; if (sector) sector -= CD_MSF_OFFSET; diff --git a/drivers/serial/core.c b/drivers/serial/core.c index 4e4c736318bb..22d42e3b18e9 100644 --- a/drivers/serial/core.c +++ b/drivers/serial/core.c @@ -1584,7 +1584,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) * is about to be unloaded). Therefore, it is safe to set * tty->driver_data to be NULL, so uart_close() doesn't bite us. */ - if (!try_inc_mod_count(drv->owner)) { + if (!try_module_get(drv->owner)) { tty->driver_data = NULL; goto fail; } @@ -2096,7 +2096,7 @@ __uart_register_port(struct uart_driver *drv, struct uart_state *state, * Register the port whether it's detected or not. This allows * setserial to be used to alter this ports parameters. */ - tty_register_devfs(drv->tty_driver, 0, drv->minor + port->line); + tty_register_device(drv->tty_driver, drv->minor + port->line); if (port->type != PORT_UNKNOWN) { unsigned long flags; @@ -2153,7 +2153,7 @@ __uart_unregister_port(struct uart_driver *drv, struct uart_state *state) /* * Remove the devices from devfs */ - tty_unregister_devfs(drv->tty_driver, drv->minor + port->line); + tty_unregister_device(drv->tty_driver, drv->minor + port->line); /* * Free the port IO and memory resources, if any. diff --git a/drivers/sgi/char/ds1286.c b/drivers/sgi/char/ds1286.c index ae11cb96484b..d98e2a63ec63 100644 --- a/drivers/sgi/char/ds1286.c +++ b/drivers/sgi/char/ds1286.c @@ -36,6 +36,7 @@ #include <linux/poll.h> #include <linux/rtc.h> #include <linux/spinlock.h> +#include <linux/bcd.h> #include <asm/ds1286.h> #include <asm/io.h> diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 70b494f4df48..6ffa6a963d3a 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c @@ -1971,9 +1971,9 @@ int __init zs_init(void) printk("ttyS%02d at 0x%08x (irq = %d)", info->line, info->port, info->irq); printk(" is a Z85C30 SCC\n"); - tty_register_devfs(&serial_driver, 0, + tty_register_device(&serial_driver, serial_driver.minor_start + info->line); - tty_register_devfs(&callout_driver, 0, + tty_register_device(&callout_driver, callout_driver.minor_start + info->line); } diff --git a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c index cf977e5d7f8f..628ae2e50f21 100644 --- a/drivers/usb/class/bluetty.c +++ b/drivers/usb/class/bluetty.c @@ -1201,7 +1201,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf, bluetooth, endpoint->bInterval); /* initialize the devfs nodes for this device and let the user know what bluetooths we are bound to */ - tty_register_devfs (&bluetooth_tty_driver, 0, minor); + tty_register_device (&bluetooth_tty_driver, minor); info("Bluetooth converter now attached to ttyUB%d (or usb/ttub/%d for devfs)", minor, minor); bluetooth_table[minor] = bluetooth; @@ -1267,7 +1267,7 @@ static void usb_bluetooth_disconnect(struct usb_interface *intf) if (bluetooth->interrupt_in_buffer) kfree (bluetooth->interrupt_in_buffer); - tty_unregister_devfs (&bluetooth_tty_driver, bluetooth->minor); + tty_unregister_device (&bluetooth_tty_driver, bluetooth->minor); for (i = 0; i < NUM_BULK_URBS; ++i) { if (bluetooth->write_urb_pool[i]) { diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index d9a98785a569..9df95d543407 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -361,7 +361,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) usb_unlink_urb(acm->writeurb); usb_unlink_urb(acm->readurb); } else { - tty_unregister_devfs(&acm_tty_driver, acm->minor); + tty_unregister_device(&acm_tty_driver, acm->minor); acm_table[acm->minor] = NULL; usb_free_urb(acm->ctrlurb); usb_free_urb(acm->readurb); @@ -649,7 +649,7 @@ static int acm_probe (struct usb_interface *intf, usb_driver_claim_interface(&acm_driver, acm->iface + 0, acm); usb_driver_claim_interface(&acm_driver, acm->iface + 1, acm); - tty_register_devfs(&acm_tty_driver, 0, minor); + tty_register_device(&acm_tty_driver, minor); acm_table[minor] = acm; usb_set_intfdata (intf, acm); @@ -681,7 +681,7 @@ static void acm_disconnect(struct usb_interface *intf) usb_driver_release_interface(&acm_driver, acm->iface + 1); if (!acm->used) { - tty_unregister_devfs(&acm_tty_driver, acm->minor); + tty_unregister_device(&acm_tty_driver, acm->minor); acm_table[acm->minor] = NULL; usb_free_urb(acm->ctrlurb); usb_free_urb(acm->readurb); diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index fee75805b1c9..dbc09ec31dd5 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -78,7 +78,7 @@ static int usb_serial_device_probe (struct device *dev) minor = port->number; - tty_register_devfs (&usb_serial_tty_driver, 0, minor); + tty_register_device (&usb_serial_tty_driver, minor); dev_info(*dev, "%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)\n", driver->name, minor, minor); @@ -110,7 +110,7 @@ static int usb_serial_device_remove (struct device *dev) } exit: minor = port->number; - tty_unregister_devfs (&usb_serial_tty_driver, minor); + tty_unregister_device (&usb_serial_tty_driver, minor); dev_info(*dev, "%s converter now disconnected from ttyUSB%d\n", driver->name, minor); @@ -128,6 +128,7 @@ int usb_serial_bus_register(struct usb_serial_device_type *device) device->driver.bus = &usb_serial_bus_type; device->driver.probe = usb_serial_device_probe; device->driver.remove = usb_serial_device_remove; + device->driver.devclass = &tty_devclass; retval = driver_register(&device->driver); diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c index 54eda88e89de..39e0c3d2775d 100644 --- a/drivers/video/console/fonts.c +++ b/drivers/video/console/fonts.c @@ -130,9 +130,6 @@ struct font_desc *get_default_font(int xres, int yres) return g; } -int init_module(void) { return 0; }; -void cleanup_module(void) {}; - EXPORT_SYMBOL(fonts); EXPORT_SYMBOL(find_font); EXPORT_SYMBOL(get_default_font); diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index f984722caa89..116c4e3fbefb 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c @@ -87,19 +87,10 @@ static int matroxfb_gpio_getscl(void* data) { return (matroxfb_read_gpio(b->minfo) & b->mask.clock) ? 1 : 0; } -static void matroxfb_dh_inc_use(struct i2c_adapter* dummy) { - MOD_INC_USE_COUNT; -} - -static void matroxfb_dh_dec_use(struct i2c_adapter* dummy) { - MOD_DEC_USE_COUNT; -} - static struct i2c_adapter matrox_i2c_adapter_template = { + .owner = THIS_MODULE, .id = I2C_HW_B_G400, - .inc_use = matroxfb_dh_inc_use, - .dec_use = matroxfb_dh_dec_use, }; static struct i2c_algo_bit_data matrox_i2c_algo_template = diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 02bc8d68378f..4f2c23038bf4 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -945,14 +945,6 @@ static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END }; I2C_CLIENT_INSMOD; -static void maven_inc_use(struct i2c_client* clnt) { - MOD_INC_USE_COUNT; -} - -static void maven_dec_use(struct i2c_client* clnt) { - MOD_DEC_USE_COUNT; -} - static struct i2c_driver maven_driver; static int maven_detect_client(struct i2c_adapter* adapter, int address, unsigned short flags, @@ -1016,17 +1008,13 @@ static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) return -ENOIOCTLCMD; /* or -EINVAL, depends on who will call this */ } -static int maven_driver_registered = 0; - static struct i2c_driver maven_driver={ - "maven", - I2C_DRIVERID_MGATVO, - I2C_DF_NOTIFY, - maven_attach_adapter, - maven_detach_client, - maven_command, - maven_inc_use, - maven_dec_use + .owner = THIS_MODULE, + .name = "maven", + .id = I2C_DRIVERID_MGATVO, + .flags = I2C_DF_NOTIFY, + .attach_adapter = maven_attach_adapter, + .detach_client = maven_detach_client, }; /* ************************** */ @@ -1039,13 +1027,11 @@ static int matroxfb_maven_init(void) { printk(KERN_ERR "maven: Maven driver failed to register (%d).\n", err); return err; } - maven_driver_registered = 1; return 0; } static void matroxfb_maven_exit(void) { - if (maven_driver_registered) - i2c_del_driver(&maven_driver); + i2c_del_driver(&maven_driver); } MODULE_AUTHOR("(c) 1999-2002 Petr Vandrovec <vandrove@vc.cvut.cz>"); |
