From 6c566fb7b3cda741dd6ed60c7d6aae0e17c9c8fe Mon Sep 17 00:00:00 2001 From: Vitaly Wool Date: Thu, 4 Jan 2007 13:07:03 +0100 Subject: i2c-pnx: Fix interrupt handler, get rid of EARLY config option This fixes two issues raised by David Brownell on the i2c list: << Someone needs to update i2c-pnx.c to handle the IRQ handler doesn't expect pt_regs (gone now for a while), and so it doesn't try to reference "mudule_init()" if I2C isn't initialized "early". For that matter, to get rid of that _option_ to initialize then, and always init that driver with subsystem_init() ... it's common with embedded systems to need I2C access to tweak a GPIO expander or do some other work when bringing up drivers, that's not specific to USB stacks. >> Signed-off-by: Vitaly Wool Signed-off-by: Jean Delvare --- drivers/i2c/busses/Kconfig | 9 --------- drivers/i2c/busses/i2c-pnx.c | 7 +------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index e1989f3a2684..9367c4cfe936 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -564,13 +564,4 @@ config I2C_PNX This driver can also be built as a module. If so, the module will be called i2c-pnx. -config I2C_PNX_EARLY - bool "Early initialization for I2C on PNXxxxx" - depends on I2C_PNX=y - help - Under certain circumstances one may need to make sure I2C on PNXxxxx - is initialized earlier than some other driver that depends on it - (for instance, that might be USB in case of PNX4008). With this - option turned on you can guarantee that. - endmenu diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index de0bca77e926..17376feb1acc 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c @@ -305,8 +305,7 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap) return 0; } -static irqreturn_t -i2c_pnx_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id) { u32 stat, ctl; struct i2c_adapter *adap = dev_id; @@ -699,10 +698,6 @@ MODULE_AUTHOR("Vitaly Wool, Dennis Kovalev "); MODULE_DESCRIPTION("I2C driver for Philips IP3204-based I2C busses"); MODULE_LICENSE("GPL"); -#ifdef CONFIG_I2C_PNX_EARLY /* We need to make sure I2C is initialized before USB */ subsys_initcall(i2c_adap_pnx_init); -#else -mudule_init(i2c_adap_pnx_init); -#endif module_exit(i2c_adap_pnx_exit); -- cgit v1.2.3-59-g8ed1b From 999445d4372812f361807b76411c158099e8e93e Mon Sep 17 00:00:00 2001 From: Vitaly Wool Date: Thu, 4 Jan 2007 13:07:03 +0100 Subject: i2c-pnx: Add entry to MAINTAINERS Add me to MAINTAINERS for i2c-pnx. Signed-off-by: Vitaly Wool Signed-off-by: Jean Delvare --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7f6c051cac65..0d54cc45ea3e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2579,6 +2579,12 @@ P: Adam Belay M: ambx1@neo.rr.com S: Maintained +PNXxxxx I2C DRIVER +P: Vitaly Wool +M: vitalywool@gmail.com +L: i2c@lm-sensors.org +S: Maintained + PPP PROTOCOL DRIVERS AND COMPRESSORS P: Paul Mackerras M: paulus@samba.org -- cgit v1.2.3-59-g8ed1b From b119dc3f992183a04e508fc0a09f550eb19bf30e Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 4 Jan 2007 13:07:04 +0100 Subject: i2c: Migration aids for i2c_adapter.dev removal Flag i2c_adapter.dev for removal after userspace tools get upgraded, and include a near-term code migration aid to facilitate this: - The class device gets the name attribute it should have had. This was previously (wrongly) associated with the i2c_adapter.dev node. Sysfs based tools and libraries can start converting right away. - Issue a warning for legacy adapter drivers that don't provide any physical device node; so systems with those drivers will know to fix this problem earlier. This is one of a series of patches to help the I2C stack become a better citizen of the Linux Driver Model world. Signed-off-by: David Brownell Signed-off-by: Jean Delvare --- Documentation/feature-removal-schedule.txt | 17 +++++++++++++++++ drivers/i2c/i2c-core.c | 28 ++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 30f3c8c9c12a..f2024df7ebe5 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt @@ -226,6 +226,23 @@ Who: Jean Delvare --------------------------- +What: i2c_adapter.dev + i2c_adapter.list +When: July 2007 +Why: Superfluous, given i2c_adapter.class_dev: + * The "dev" was a stand-in for the physical device node that legacy + drivers would not have; but now it's almost always present. Any + remaining legacy drivers must upgrade (they now trigger warnings). + * The "list" duplicates class device children. + The delay in removing this is so upgraded lm_sensors and libsensors + can get deployed. (Removal causes minor changes in the sysfs layout, + notably the location of the adapter type name and parenting the i2c + client hardware directly from their controller.) +Who: Jean Delvare , + David Brownell + +--------------------------- + What: IPv4 only connection tracking/NAT/helpers When: 2.6.22 Why: The new layer 3 independant connection tracking replaces the old diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 3e31f1d265c9..b05378a3d673 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -95,16 +95,32 @@ struct device_driver i2c_adapter_driver = { .bus = &i2c_bus_type, }; +/* ------------------------------------------------------------------------- */ + +/* I2C bus adapters -- one roots each I2C or SMBUS segment */ + static void i2c_adapter_class_dev_release(struct class_device *dev) { struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); complete(&adap->class_dev_released); } +static ssize_t i2c_adapter_show_name(struct class_device *cdev, char *buf) +{ + struct i2c_adapter *adap = class_dev_to_i2c_adapter(cdev); + return sprintf(buf, "%s\n", adap->name); +} + +static struct class_device_attribute i2c_adapter_attrs[] = { + __ATTR(name, S_IRUGO, i2c_adapter_show_name, NULL), + { }, +}; + struct class i2c_adapter_class = { - .owner = THIS_MODULE, - .name = "i2c-adapter", - .release = &i2c_adapter_class_dev_release, + .owner = THIS_MODULE, + .name = "i2c-adapter", + .class_dev_attrs = i2c_adapter_attrs, + .release = &i2c_adapter_class_dev_release, }; static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) @@ -175,8 +191,12 @@ int i2c_add_adapter(struct i2c_adapter *adap) * If the parent pointer is not set up, * we add this adapter to the host bus. */ - if (adap->dev.parent == NULL) + if (adap->dev.parent == NULL) { adap->dev.parent = &platform_bus; + printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] " + "forgot to specify physical device; fix it!\n", + adap->name); + } sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); adap->dev.driver = &i2c_adapter_driver; adap->dev.release = &i2c_adapter_dev_release; -- cgit v1.2.3-59-g8ed1b From 3269bb63eb076318ce4fb554851d047e1c9aa1a5 Mon Sep 17 00:00:00 2001 From: Maxime Bizon Date: Fri, 5 Jan 2007 17:54:05 +0100 Subject: i2c-mv64xxx: Fix random oops at boot I have a Marvell board which has the same i2c hw block than mv64xxx, so I'm trying to use i2c-mv64xxx driver. But I get the following random oops at boot: Unable to handle kernel NULL pointer dereference at virtual address 00000002 Backtrace: [] (mv64xxx_i2c_intr+0x0/0x2b8) from [] (__do_irq+0x4c/0x8c) [] (__do_irq+0x0/0x8c) from [] (do_level_IRQ+0x68/0xc0) r8 = C0501E08 r7 = 00000005 r6 = C0501E08 r5 = 00000005 r4 = C048BB78 [] (do_level_IRQ+0x0/0xc0) from [] (asm_do_IRQ+0x50/0x134) r6 = C0449C78 r5 = F1020000 r4 = FFFFFFFF [] (asm_do_IRQ+0x0/0x134) from [] (__irq_svc+0x24/0x100) r8 = C1CAC400 r7 = 00000005 r6 = 00000002 r5 = F1020000 r4 = FFFFFFFF [] (setup_irq+0x0/0x124) from [] (request_irq+0xb0/0xd0) r7 = C041B2AC r6 = C0397E4C r5 = 00000000 r4 = 00000005 [] (request_irq+0x0/0xd0) from [] (mv64xxx_i2c_probe+0x148/0x244) [] (mv64xxx_i2c_probe+0x0/0x244) from [] (platform_drv_probe+0x20/0x24) The oops is caused by a spurious interrupt that occurs when request_irq is called. mv64xxx_i2c_fsm() tries to read drv_data->msg, which is NULL. I noticed that hardware init is done after requesting irq. Thus any pending irq from previous hardware usage may cause this. The following patch fixes it: Signed-off-by: Maxime Bizon Acked-by: Mark A. Greer Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-mv64xxx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index bbc8e3a7ff55..490173611d6b 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -529,6 +529,8 @@ mv64xxx_i2c_probe(struct platform_device *pd) platform_set_drvdata(pd, drv_data); i2c_set_adapdata(&drv_data->adapter, drv_data); + mv64xxx_i2c_hw_init(drv_data); + if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, MV64XXX_I2C_CTLR_NAME, drv_data)) { dev_err(&drv_data->adapter.dev, @@ -542,8 +544,6 @@ mv64xxx_i2c_probe(struct platform_device *pd) goto exit_free_irq; } - mv64xxx_i2c_hw_init(drv_data); - return 0; exit_free_irq: -- cgit v1.2.3-59-g8ed1b From 81ffbc04a8ea06c4bea534154f49ed598013ee6b Mon Sep 17 00:00:00 2001 From: Philippe De Muyter Date: Fri, 5 Jan 2007 17:54:05 +0100 Subject: i2c/m41t00: Do not forget to write year m41t00.c forgets to set the year field in set_rtc_time; fix that. Signed-off-by: Philippe De Muyter Signed-off-by: Andrew Morton Acked-by: Mark A. Greer Signed-off-by: Jean Delvare --- drivers/i2c/chips/m41t00.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 420377c86422..3fcb646e2073 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -209,6 +209,7 @@ m41t00_set(void *arg) buf[m41t00_chip->hour] = (buf[m41t00_chip->hour] & ~0x3f) | (hour& 0x3f); buf[m41t00_chip->day] = (buf[m41t00_chip->day] & ~0x3f) | (day & 0x3f); buf[m41t00_chip->mon] = (buf[m41t00_chip->mon] & ~0x1f) | (mon & 0x1f); + buf[m41t00_chip->year] = year; if (i2c_master_send(save_client, wbuf, 9) < 0) dev_err(&save_client->dev, "m41t00_set: Write error\n"); -- cgit v1.2.3-59-g8ed1b