aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-07-27 16:14:49 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:14 -0400
commit7bef559455fc71f66f8573cc1aafe1dd33966c1c (patch)
tree6c342574710f730d39bf5383f81eaa9f9bb10a25 /drivers/i2c
parent1ff4e3065b41847b6fe5908b1214cb508dd49e61 (diff)
[PATCH] I2C: refactor message in i2c_detach_client
We could refactor the error message 34 different i2c drivers print if i2c_detach_client() fails in this function itself. Saves quite a few lines of code. Documentation is updated to reflect that change. Note that this patch should be applied after Rudolf Marek's w83792d patches. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/chips/ds1337.c5
-rw-r--r--drivers/i2c/chips/eeprom.c4
-rw-r--r--drivers/i2c/chips/max6875.c4
-rw-r--r--drivers/i2c/chips/pca9539.c4
-rw-r--r--drivers/i2c/chips/pcf8574.c5
-rw-r--r--drivers/i2c/chips/pcf8591.c5
-rw-r--r--drivers/i2c/i2c-core.c6
7 files changed, 11 insertions, 22 deletions
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 6ac0a6e00769..8ab4e2348cda 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -353,11 +353,8 @@ static int ds1337_detach_client(struct i2c_client *client)
353 int err; 353 int err;
354 struct ds1337_data *data = i2c_get_clientdata(client); 354 struct ds1337_data *data = i2c_get_clientdata(client);
355 355
356 if ((err = i2c_detach_client(client))) { 356 if ((err = i2c_detach_client(client)))
357 dev_err(&client->dev, "Client deregistration failed, "
358 "client not detached.\n");
359 return err; 357 return err;
360 }
361 358
362 list_del(&data->list); 359 list_del(&data->list);
363 kfree(data); 360 kfree(data);
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 88f83bac3845..9466ada68932 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -230,10 +230,8 @@ static int eeprom_detach_client(struct i2c_client *client)
230 int err; 230 int err;
231 231
232 err = i2c_detach_client(client); 232 err = i2c_detach_client(client);
233 if (err) { 233 if (err)
234 dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
235 return err; 234 return err;
236 }
237 235
238 kfree(i2c_get_clientdata(client)); 236 kfree(i2c_get_clientdata(client));
239 237
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index d1d48586b90e..52fd6bf29133 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -242,10 +242,8 @@ static int max6875_detach_client(struct i2c_client *client)
242 int err; 242 int err;
243 243
244 err = i2c_detach_client(client); 244 err = i2c_detach_client(client);
245 if (err) { 245 if (err)
246 dev_err(&client->dev, "i2c_detach_client() failed\n");
247 return err; 246 return err;
248 }
249 kfree(i2c_get_clientdata(client)); 247 kfree(i2c_get_clientdata(client));
250 return 0; 248 return 0;
251} 249}
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index c5b052363d9a..1500b1842ce5 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -163,10 +163,8 @@ static int pca9539_detach_client(struct i2c_client *client)
163{ 163{
164 int err; 164 int err;
165 165
166 if ((err = i2c_detach_client(client))) { 166 if ((err = i2c_detach_client(client)))
167 dev_err(&client->dev, "Client deregistration failed.\n");
168 return err; 167 return err;
169 }
170 168
171 kfree(i2c_get_clientdata(client)); 169 kfree(i2c_get_clientdata(client));
172 return 0; 170 return 0;
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index 7a1fa7914630..a109dfd3dbe7 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -185,11 +185,8 @@ static int pcf8574_detach_client(struct i2c_client *client)
185{ 185{
186 int err; 186 int err;
187 187
188 if ((err = i2c_detach_client(client))) { 188 if ((err = i2c_detach_client(client)))
189 dev_err(&client->dev,
190 "Client deregistration failed, client not detached.\n");
191 return err; 189 return err;
192 }
193 190
194 kfree(i2c_get_clientdata(client)); 191 kfree(i2c_get_clientdata(client));
195 return 0; 192 return 0;
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 225b512dd4ad..7fce0fc048d9 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -240,11 +240,8 @@ static int pcf8591_detach_client(struct i2c_client *client)
240{ 240{
241 int err; 241 int err;
242 242
243 if ((err = i2c_detach_client(client))) { 243 if ((err = i2c_detach_client(client)))
244 dev_err(&client->dev,
245 "Client deregistration failed, client not detached.\n");
246 return err; 244 return err;
247 }
248 245
249 kfree(i2c_get_clientdata(client)); 246 kfree(i2c_get_clientdata(client));
250 return 0; 247 return 0;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7a7837ae3114..b0bceb2fb8b1 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -449,8 +449,12 @@ int i2c_detach_client(struct i2c_client *client)
449 struct i2c_adapter *adapter = client->adapter; 449 struct i2c_adapter *adapter = client->adapter;
450 int res = 0; 450 int res = 0;
451 451
452 if ((client->flags & I2C_CLIENT_ALLOW_USE) && (client->usage_count > 0)) 452 if ((client->flags & I2C_CLIENT_ALLOW_USE)
453 && (client->usage_count > 0)) {
454 dev_warn(&client->dev, "Client [%s] still busy, "
455 "can't detach\n", client->name);
453 return -EBUSY; 456 return -EBUSY;
457 }
454 458
455 if (adapter->client_unregister) { 459 if (adapter->client_unregister) {
456 res = adapter->client_unregister(client); 460 res = adapter->client_unregister(client);
class="hl opt">= bcd2bin(tmp)+100; dev_dbg(dev, "\n%s : Read RTC values\n", __func__); dev_dbg(dev, "tm_hour: %i\n", dt->tm_hour); dev_dbg(dev, "tm_min : %i\n", dt->tm_min); dev_dbg(dev, "tm_sec : %i\n", dt->tm_sec); dev_dbg(dev, "tm_year: %i\n", dt->tm_year); dev_dbg(dev, "tm_mon : %i\n", dt->tm_mon); dev_dbg(dev, "tm_mday: %i\n", dt->tm_mday); dev_dbg(dev, "tm_wday: %i\n", dt->tm_wday); return 0; } static int v3020_set_time(struct device *dev, struct rtc_time *dt) { struct v3020 *chip = dev_get_drvdata(dev); dev_dbg(dev, "\n%s : Setting RTC values\n", __func__); dev_dbg(dev, "tm_sec : %i\n", dt->tm_sec); dev_dbg(dev, "tm_min : %i\n", dt->tm_min); dev_dbg(dev, "tm_hour: %i\n", dt->tm_hour); dev_dbg(dev, "tm_mday: %i\n", dt->tm_mday); dev_dbg(dev, "tm_wday: %i\n", dt->tm_wday); dev_dbg(dev, "tm_year: %i\n", dt->tm_year); /* Write all the values to ram... */ v3020_set_reg(chip, V3020_SECONDS, bin2bcd(dt->tm_sec)); v3020_set_reg(chip, V3020_MINUTES, bin2bcd(dt->tm_min)); v3020_set_reg(chip, V3020_HOURS, bin2bcd(dt->tm_hour)); v3020_set_reg(chip, V3020_MONTH_DAY, bin2bcd(dt->tm_mday)); v3020_set_reg(chip, V3020_MONTH, bin2bcd(dt->tm_mon + 1)); v3020_set_reg(chip, V3020_WEEK_DAY, bin2bcd(dt->tm_wday)); v3020_set_reg(chip, V3020_YEAR, bin2bcd(dt->tm_year % 100)); /* ...and set the clock. */ v3020_set_reg(chip, V3020_CMD_RAM2CLOCK, 0); /* Compulab used this delay here. I dont know why, * the datasheet does not specify a delay. */ /*mdelay(5);*/ return 0; } static const struct rtc_class_ops v3020_rtc_ops = { .read_time = v3020_read_time, .set_time = v3020_set_time, }; static int rtc_probe(struct platform_device *pdev) { struct v3020_platform_data *pdata = pdev->dev.platform_data; struct v3020 *chip; struct rtc_device *rtc; int retval = -EBUSY; int i; int temp; chip = kzalloc(sizeof *chip, GFP_KERNEL); if (!chip) return -ENOMEM; if (pdata->use_gpio) chip->ops = &v3020_gpio_ops; else chip->ops = &v3020_mmio_ops; retval = chip->ops->map_io(chip, pdev, pdata); if (retval) goto err_chip; /* Make sure the v3020 expects a communication cycle * by reading 8 times */ for (i = 0; i < 8; i++) temp = chip->ops->read_bit(chip); /* Test chip by doing a write/read sequence * to the chip ram */ v3020_set_reg(chip, V3020_SECONDS, 0x33); if (v3020_get_reg(chip, V3020_SECONDS) != 0x33) { retval = -ENODEV; goto err_io; } /* Make sure frequency measurment mode, test modes, and lock * are all disabled */ v3020_set_reg(chip, V3020_STATUS_0, 0x0); if (pdata->use_gpio) dev_info(&pdev->dev, "Chip available at GPIOs " "%d, %d, %d, %d\n", chip->gpio[V3020_CS].gpio, chip->gpio[V3020_WR].gpio, chip->gpio[V3020_RD].gpio, chip->gpio[V3020_IO].gpio); else dev_info(&pdev->dev, "Chip available at " "physical address 0x%llx," "data connected to D%d\n", (unsigned long long)pdev->resource[0].start, chip->leftshift); platform_set_drvdata(pdev, chip); rtc = rtc_device_register("v3020", &pdev->dev, &v3020_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { retval = PTR_ERR(rtc); goto err_io; } chip->rtc = rtc; return 0; err_io: chip->ops->unmap_io(chip); err_chip: kfree(chip); return retval; } static int rtc_remove(struct platform_device *dev) { struct v3020 *chip = platform_get_drvdata(dev); struct rtc_device *rtc = chip->rtc; if (rtc) rtc_device_unregister(rtc); chip->ops->unmap_io(chip); kfree(chip); return 0; } static struct platform_driver rtc_device_driver = { .probe = rtc_probe, .remove = rtc_remove, .driver = { .name = "v3020", .owner = THIS_MODULE, }, }; static __init int v3020_init(void) { return platform_driver_register(&rtc_device_driver); } static __exit void v3020_exit(void) { platform_driver_unregister(&rtc_device_driver); } module_init(v3020_init); module_exit(v3020_exit); MODULE_DESCRIPTION("V3020 RTC"); MODULE_AUTHOR("Raphael Assenat"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:v3020");