From 7d9db67febf67dd76329a9dd8f97cf4611a8ac2e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 3 Sep 2006 22:20:24 +0200 Subject: 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 Cc: Ben Gardner Cc: Aurelien Jarno Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/pca9539.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/i2c/chips/pca9539.c') 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) 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; -- cgit v1.2.3