From 524465df2accf54604cb89c04dbaab0c8aaa5bb4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 31 Mar 2006 23:05:01 +0200 Subject: [PATCH] i2c: convert ds1374 to use a workqueue A tasklet is not suitable for what the ds1374 driver does: neither sleeping nor mutex operations are allowed in tasklets, and ds1374_set_tlet may do both. We can use a workqueue instead, where both sleeping and mutex operations are allowed. Signed-off-by: Jean Delvare Acked-by: Randy Vinson Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/ds1374.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 03d09ed5ec2..4630f1969a0 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -27,6 +27,7 @@ #include #include #include +#include #define DS1374_REG_TOD0 0x00 #define DS1374_REG_TOD1 0x01 @@ -139,7 +140,7 @@ ulong ds1374_get_rtc_time(void) return t1; } -static void ds1374_set_tlet(ulong arg) +static void ds1374_set_work(void *arg) { ulong t1, t2; int limit = 10; /* arbitrary retry limit */ @@ -168,17 +169,18 @@ static void ds1374_set_tlet(ulong arg) static ulong new_time; -static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, - (ulong) & new_time); +static struct workqueue_struct *ds1374_workqueue; + +static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time); int ds1374_set_rtc_time(ulong nowtime) { new_time = nowtime; if (in_interrupt()) - tasklet_schedule(&ds1374_tasklet); + queue_work(ds1374_workqueue, &ds1374_work); else - ds1374_set_tlet((ulong) & new_time); + ds1374_set_work(&new_time); return 0; } @@ -204,6 +206,8 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) client->adapter = adap; client->driver = &ds1374_driver; + ds1374_workqueue = create_singlethread_workqueue("ds1374"); + if ((rc = i2c_attach_client(client)) != 0) { kfree(client); return rc; @@ -227,7 +231,7 @@ static int ds1374_detach(struct i2c_client *client) if ((rc = i2c_detach_client(client)) == 0) { kfree(i2c_get_clientdata(client)); - tasklet_kill(&ds1374_tasklet); + destroy_workqueue(ds1374_workqueue); } return rc; } -- cgit v1.2.3 From 8c750c0bd2fa6f73cd3cd3f1a58d48f94de343b6 Mon Sep 17 00:00:00 2001 From: "Mark A. Greer" Date: Fri, 31 Mar 2006 23:06:03 +0200 Subject: [PATCH] i2c: convert m41t00 to use a workqueue The m41t00 i2c/rtc driver currently uses a tasklet to schedule interrupt-level writes to the rtc. This patch causes the driver to use a workqueue instead. Signed-off-by: Mark A. Greer Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/m41t00.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index b5aabe7cf79..27fc9ff2961 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -111,7 +112,7 @@ m41t00_get_rtc_time(void) } static void -m41t00_set_tlet(ulong arg) +m41t00_set(void *arg) { struct rtc_time tm; ulong nowtime = *(ulong *)arg; @@ -145,9 +146,9 @@ m41t00_set_tlet(ulong arg) return; } -static ulong new_time; - -DECLARE_TASKLET_DISABLED(m41t00_tasklet, m41t00_set_tlet, (ulong)&new_time); +static ulong new_time; +static struct workqueue_struct *m41t00_wq; +static DECLARE_WORK(m41t00_work, m41t00_set, &new_time); int m41t00_set_rtc_time(ulong nowtime) @@ -155,9 +156,9 @@ m41t00_set_rtc_time(ulong nowtime) new_time = nowtime; if (in_interrupt()) - tasklet_schedule(&m41t00_tasklet); + queue_work(m41t00_wq, &m41t00_work); else - m41t00_set_tlet((ulong)&new_time); + m41t00_set(&new_time); return 0; } @@ -189,6 +190,7 @@ m41t00_probe(struct i2c_adapter *adap, int addr, int kind) return rc; } + m41t00_wq = create_singlethread_workqueue("m41t00"); save_client = client; return 0; } @@ -206,7 +208,7 @@ m41t00_detach(struct i2c_client *client) if ((rc = i2c_detach_client(client)) == 0) { kfree(client); - tasklet_kill(&m41t00_tasklet); + destroy_workqueue(m41t00_wq); } return rc; } -- cgit v1.2.3 From ac987c1f65cedd98d953e14ba219db2f8cc009d4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 23 Mar 2006 16:38:21 +0100 Subject: [PATCH] w83792d: Be quiet on misdetection Make the w83792d driver keep quiet when misdetecting a chip. This can happen, and the user doesn't need to know. Also renumber the messages, and add one, for consistency. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/w83792d.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 6865c64d8a5..958602e2841 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -1161,7 +1161,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) bank. */ if (kind < 0) { if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) { - dev_warn(dev, "Detection failed at step 3\n"); + dev_dbg(dev, "Detection failed at step 1\n"); goto ERROR1; } val1 = w83792d_read_value(client, W83792D_REG_BANK); @@ -1170,6 +1170,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) if (!(val1 & 0x07)) { /* is Bank0 */ if (((!(val1 & 0x80)) && (val2 != 0xa3)) || ((val1 & 0x80) && (val2 != 0x5c))) { + dev_dbg(dev, "Detection failed at step 2\n"); goto ERROR1; } } @@ -1177,7 +1178,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) should match */ if (w83792d_read_value(client, W83792D_REG_I2C_ADDR) != address) { - dev_warn(dev, "Detection failed at step 5\n"); + dev_dbg(dev, "Detection failed at step 3\n"); goto ERROR1; } } -- cgit v1.2.3 From 3cb8e1a92ef7588d3acdecf493ddddd0dd71a709 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Thu, 23 Mar 2006 16:49:34 +0100 Subject: [PATCH] i2c-sis96x: Remove an init-time log message This patch removes an init-time kernel log message. http://marc.theaimsgroup.com/?l=linux-kernel&m=114232987208628&w=3 Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-sis96x.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 3024907cdaf..1a73c0532fc 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c @@ -43,13 +43,6 @@ #include #include -/* - HISTORY: - 2003-05-11 1.0.0 Updated from lm_sensors project for kernel 2.5 - (was i2c-sis645.c from lm_sensors 2.7.0) -*/ -#define SIS96x_VERSION "1.0.0" - /* base address register in PCI config space */ #define SIS96x_BAR 0x04 @@ -337,7 +330,6 @@ static struct pci_driver sis96x_driver = { static int __init i2c_sis96x_init(void) { - printk(KERN_INFO "i2c-sis96x version %s\n", SIS96x_VERSION); return pci_register_driver(&sis96x_driver); } -- cgit v1.2.3 From e97b81ddbb8b8c72b85330ac4a454a4513dcba8a Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Thu, 23 Mar 2006 16:50:25 +0100 Subject: [PATCH] i2c-parport: Make type parameter mandatory This patch forces the user to specify what type of adapter is present when loading i2c-parport or i2c-parport-light. If none is specified, the driver init simply fails - instead of assuming adapter type 0. This alleviates the sometimes lengthy boot time delays which can be caused by accidentally building one of these into a kernel along with several i2c slave drivers that have lengthy probe routines (e.g. hwmon drivers). Kconfig and documentation updated accordingly. Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/busses/i2c-parport | 16 ++++++++++------ drivers/i2c/busses/Kconfig | 5 ++++- drivers/i2c/busses/i2c-parport-light.c | 9 +++++++-- drivers/i2c/busses/i2c-parport.c | 9 +++++++-- drivers/i2c/busses/i2c-parport.h | 2 +- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Documentation/i2c/busses/i2c-parport b/Documentation/i2c/busses/i2c-parport index d9f23c0763f..77b995dfca2 100644 --- a/Documentation/i2c/busses/i2c-parport +++ b/Documentation/i2c/busses/i2c-parport @@ -12,18 +12,22 @@ meant as a replacement for the older, individual drivers: teletext adapters) It currently supports the following devices: - * Philips adapter - * home brew teletext adapter - * Velleman K8000 adapter - * ELV adapter - * Analog Devices evaluation boards (ADM1025, ADM1030, ADM1031, ADM1032) - * Barco LPT->DVI (K5800236) adapter + * (type=0) Philips adapter + * (type=1) home brew teletext adapter + * (type=2) Velleman K8000 adapter + * (type=3) ELV adapter + * (type=4) Analog Devices ADM1032 evaluation board + * (type=5) Analog Devices evaluation boards: ADM1025, ADM1030, ADM1031 + * (type=6) Barco LPT->DVI (K5800236) adapter These devices use different pinout configurations, so you have to tell the driver what you have, using the type module parameter. There is no way to autodetect the devices. Support for different pinout configurations can be easily added when needed. +Earlier kernels defaulted to type=0 (Philips). But now, if the type +parameter is missing, the driver will simply fail to initialize. + Building your own adapter ------------------------- diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 089c6f5b24d..d6d44946a28 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -286,7 +286,10 @@ config I2C_PARPORT This driver is a replacement for (and was inspired by) an older driver named i2c-philips-par. The new driver supports more devices, and makes it easier to add support for new devices. - + + An adapter type parameter is now mandatory. Please read the file + Documentation/i2c/busses/i2c-parport for details. + Another driver exists, named i2c-parport-light, which doesn't depend on the parport driver. This is meant for embedded systems. Don't say Y here if you intend to say Y or M there. diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index c63025a4c86..e09ebbb2f9f 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c @@ -121,9 +121,14 @@ static struct i2c_adapter parport_adapter = { static int __init i2c_parport_init(void) { - if (type < 0 || type >= ARRAY_SIZE(adapter_parm)) { + if (type < 0) { + printk(KERN_WARNING "i2c-parport: adapter type unspecified\n"); + return -ENODEV; + } + + if (type >= ARRAY_SIZE(adapter_parm)) { printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type); - type = 0; + return -ENODEV; } if (base == 0) { diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 7e2e8cd1c14..934bd55bae1 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c @@ -241,9 +241,14 @@ static struct parport_driver i2c_parport_driver = { static int __init i2c_parport_init(void) { - if (type < 0 || type >= ARRAY_SIZE(adapter_parm)) { + if (type < 0) { + printk(KERN_WARNING "i2c-parport: adapter type unspecified\n"); + return -ENODEV; + } + + if (type >= ARRAY_SIZE(adapter_parm)) { printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type); - type = 0; + return -ENODEV; } return parport_register_driver(&i2c_parport_driver); diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h index d702e5e0388..9ddd816d5d0 100644 --- a/drivers/i2c/busses/i2c-parport.h +++ b/drivers/i2c/busses/i2c-parport.h @@ -90,7 +90,7 @@ static struct adapter_parm adapter_parm[] = { }, }; -static int type; +static int type = -1; module_param(type, int, 0); MODULE_PARM_DESC(type, "Type of adapter:\n" -- cgit v1.2.3