From 5edc68b8530ff1b3133d057350da98c93cca5a82 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 12 Mar 2008 14:15:00 +0100 Subject: i2c-amd756: Fix off-by-one This patch fixes an off-by-one error spotted by the Coverity checker. Signed-off-by: Adrian Bunk Signed-off-by: Jean Delvare diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 573abe4..2fa4318 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -335,7 +335,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, u8 temp; /* driver_data might come from user-space, so check it */ - if (id->driver_data > ARRAY_SIZE(chipname)) + if (id->driver_data >= ARRAY_SIZE(chipname)) return -EINVAL; if (amd756_ioport) { -- cgit v0.10.2 From 50c3304a5e1e5217fc6b58fb686edc7d1114f2fa Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Mar 2008 14:15:00 +0100 Subject: i2c: Keep client->driver and client->dev.driver in sync Ensure that client->driver is set to NULL if the probe() returns an error (this keeps client->driver and client->dev.driver in sync). Signed-off-by: Hans Verkuil Acked-by: David Brownell Signed-off-by: Jean Delvare diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 96da22e..fd84b2a 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -90,12 +90,16 @@ static int i2c_device_probe(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct i2c_driver *driver = to_i2c_driver(dev->driver); + int status; if (!driver->probe) return -ENODEV; client->driver = driver; dev_dbg(dev, "probe\n"); - return driver->probe(client); + status = driver->probe(client); + if (status) + client->driver = NULL; + return status; } static int i2c_device_remove(struct device *dev) -- cgit v0.10.2 From 3d706d952cf238a60c5571e33329448b453a2ab9 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 12 Mar 2008 14:15:00 +0100 Subject: i2c: chips subdirectory is deprecated Let driver authors know that drivers/i2c/chips is usually the wrong place for new drivers. Signed-off-by: Jean Delvare diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 501f00c..e47aca0 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile @@ -1,6 +1,13 @@ # # Makefile for miscellaneous I2C chip drivers. # +# Think twice before you add a new driver to this directory. +# Device drivers are better grouped according to the functionality they +# implement rather than to the bus they are connected to. In particular: +# * Hardware monitoring chip drivers go to drivers/hwmon +# * RTC chip drivers go to drivers/rtc +# * I/O expander drivers go to drivers/gpio +# obj-$(CONFIG_DS1682) += ds1682.o obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o -- cgit v0.10.2