From 3e39752d5367f9087e058abe768708165e1ec373 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Mon, 14 Jan 2008 21:53:30 +0100 Subject: i2c-omap: Fix NULL pointer dereferencing This patch fixes bug #9581 reported by Marcio Buss. If kzalloc fails, omap_i2c_write_reg() tries to reset an unallocated I2C controller. Cc: Marcio Buss Signed-off-by: Tony Lindgren Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index cb55cf2ba1e..f2552b19ea6 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -619,13 +619,13 @@ omap_i2c_probe(struct platform_device *pdev) err_free_irq: free_irq(dev->irq, dev); err_unuse_clocks: + omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); omap_i2c_disable_clocks(dev); omap_i2c_put_clocks(dev); err_free_mem: platform_set_drvdata(pdev, NULL); kfree(dev); err_release_region: - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); release_mem_region(mem->start, (mem->end - mem->start) + 1); return r; -- cgit v1.2.3-70-g09d2 From 96acafe05fad2c9429ca2c39af47efc5db2d8042 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 14 Jan 2008 21:53:30 +0100 Subject: i2c: Spelling fixes [JD: One more fix in i2c-dev.] Signed-off-by: Joe Perches Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-at91.c | 2 +- drivers/i2c/busses/i2c-powermac.c | 2 +- drivers/i2c/i2c-dev.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 9c8b6d5eaec..c09b036913b 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -135,7 +135,7 @@ static int xfer_write(struct i2c_adapter *adap, unsigned char *buf, int length) * Generic i2c master transfer entrypoint. * * Note: We do not use Atmel's feature of storing the "internal device address". - * Instead the "internal device address" has to be written using a seperate + * Instead the "internal device address" has to be written using a separate * i2c message. * http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2004-September/024411.html */ diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 0ab4f2627c2..7813127649a 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c @@ -94,7 +94,7 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap, break; /* Note that these are broken vs. the expected smbus API where - * on reads, the lenght is actually returned from the function, + * on reads, the length is actually returned from the function, * but I think the current API makes no sense and I don't want * any driver that I haven't verified for correctness to go * anywhere near a pmac i2c bus anyway ... diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index c21ae20ae36..df540d5dfaf 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -184,7 +184,7 @@ static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t c /* This address checking function differs from the one in i2c-core in that it considers an address with a registered device, but no - bounded driver, as NOT busy. */ + bound driver, as NOT busy. */ static int i2cdev_check_addr(struct i2c_adapter *adapter, unsigned int addr) { struct list_head *item; -- cgit v1.2.3-70-g09d2 From f9dd0194ff23d612e463be764d73da7825da4aa1 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 14 Jan 2008 21:53:31 +0100 Subject: i2c: Driver IDs are optional Document the fact that I2C driver IDs are optional. Signed-off-by: Jean Delvare --- include/linux/i2c-id.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 88c81403eb3..e18017d4575 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -23,6 +23,10 @@ #ifndef LINUX_I2C_ID_H #define LINUX_I2C_ID_H +/* Please note that I2C driver IDs are optional. They are only needed if a + legacy chip driver needs to identify a bus or a bus driver needs to + identify a legacy client. If you don't need them, just don't set them. */ + /* * ---- Driver types ----------------------------------------------------- */ -- cgit v1.2.3-70-g09d2 From 5cd6e675f862568ad73c061665ee5080cfd952c5 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 14 Jan 2008 21:53:31 +0100 Subject: i2c-sibyte: Fix an error path If the registration of the second I2C channel fails, we really want to unregister the first one before we return with an error. While we're here, fix the printk right above so that it displays the real driver name. Signed-off-by: Jean Delvare Cc: Ralf Baechle --- drivers/i2c/busses/i2c-sibyte.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c index 0ca599d3b40..503a134ec80 100644 --- a/drivers/i2c/busses/i2c-sibyte.c +++ b/drivers/i2c/busses/i2c-sibyte.c @@ -200,11 +200,14 @@ static struct i2c_adapter sibyte_board_adapter[2] = { static int __init i2c_sibyte_init(void) { - printk("i2c-swarm.o: i2c SMBus adapter module for SiByte board\n"); + pr_info("i2c-sibyte: i2c SMBus adapter module for SiByte board\n"); if (i2c_sibyte_add_bus(&sibyte_board_adapter[0], K_SMB_FREQ_100KHZ) < 0) return -ENODEV; - if (i2c_sibyte_add_bus(&sibyte_board_adapter[1], K_SMB_FREQ_400KHZ) < 0) + if (i2c_sibyte_add_bus(&sibyte_board_adapter[1], + K_SMB_FREQ_400KHZ) < 0) { + i2c_del_adapter(&sibyte_board_adapter[0]); return -ENODEV; + } return 0; } -- cgit v1.2.3-70-g09d2