diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-09-03 16:20:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-26 18:38:51 -0400 |
commit | 7d9db67febf67dd76329a9dd8f97cf4611a8ac2e (patch) | |
tree | 6354fa99b17f89c8f26ccf7c440d0d29096f2dc2 /drivers/i2c/chips/pca9539.c | |
parent | b32d20dc8b187e03605f091dbde9a78676a2a642 (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.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index cb22280cdd27..f43c4e79b55e 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) | |||
148 | if ((err = i2c_attach_client(new_client))) | 148 | if ((err = i2c_attach_client(new_client))) |
149 | goto exit_kfree; | 149 | goto exit_kfree; |
150 | 150 | ||
151 | /* Register sysfs hooks (don't care about failure) */ | 151 | /* Register sysfs hooks */ |
152 | sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group); | 152 | err = sysfs_create_group(&new_client->dev.kobj, |
153 | &pca9539_defattr_group); | ||
154 | if (err) | ||
155 | goto exit_detach; | ||
153 | 156 | ||
154 | return 0; | 157 | return 0; |
155 | 158 | ||
159 | exit_detach: | ||
160 | i2c_detach_client(new_client); | ||
156 | exit_kfree: | 161 | exit_kfree: |
157 | kfree(data); | 162 | kfree(data); |
158 | exit: | 163 | exit: |
@@ -163,6 +168,8 @@ static int pca9539_detach_client(struct i2c_client *client) | |||
163 | { | 168 | { |
164 | int err; | 169 | int err; |
165 | 170 | ||
171 | sysfs_remove_group(&client->dev.kobj, &pca9539_defattr_group); | ||
172 | |||
166 | if ((err = i2c_detach_client(client))) | 173 | if ((err = i2c_detach_client(client))) |
167 | return err; | 174 | return err; |
168 | 175 | ||