summaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/pca9539.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-09-03 22:20:24 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-26 15:38:51 -0700
commit7d9db67febf67dd76329a9dd8f97cf4611a8ac2e (patch)
tree6354fa99b17f89c8f26ccf7c440d0d29096f2dc2 /drivers/i2c/chips/pca9539.c
parentb32d20dc8b187e03605f091dbde9a78676a2a642 (diff)
i2c: __must_check fixes (chip drivers)
i2c: __must_check fixes (chip drivers) Check for error on sysfs file creation. Delete sysfs files on device removal. The approach taken for the most complex case (pcf8591) is similar to what Mark M. Hoffman proposed for hardware monitoring chip drivers. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Ben Gardner <bgardner@wabtec.com> Cc: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/chips/pca9539.c')
-rw-r--r--drivers/i2c/chips/pca9539.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index cb22280cdd2..f43c4e79b55 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -148,11 +148,16 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
if ((err = i2c_attach_client(new_client)))
goto exit_kfree;
- /* Register sysfs hooks (don't care about failure) */
- sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group);
+ /* Register sysfs hooks */
+ err = sysfs_create_group(&new_client->dev.kobj,
+ &pca9539_defattr_group);
+ if (err)
+ goto exit_detach;
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_kfree:
kfree(data);
exit:
@@ -163,6 +168,8 @@ static int pca9539_detach_client(struct i2c_client *client)
{
int err;
+ sysfs_remove_group(&client->dev.kobj, &pca9539_defattr_group);
+
if ((err = i2c_detach_client(client)))
return err;