diff options
Diffstat (limited to 'drivers/i2c/chips')
-rw-r--r-- | drivers/i2c/chips/eeprom.c | 8 | ||||
-rw-r--r-- | drivers/i2c/chips/isp1301_omap.c | 2 | ||||
-rw-r--r-- | drivers/i2c/chips/max6875.c | 25 | ||||
-rw-r--r-- | drivers/i2c/chips/pca9539.c | 11 | ||||
-rw-r--r-- | drivers/i2c/chips/pcf8574.c | 22 | ||||
-rw-r--r-- | drivers/i2c/chips/pcf8591.c | 58 | ||||
-rw-r--r-- | drivers/i2c/chips/tps65010.c | 2 |
7 files changed, 99 insertions, 29 deletions
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 13c108269a6d..cec3a0c3894d 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -209,10 +209,14 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) } /* create the sysfs eeprom file */ - sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr); + err = sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr); + if (err) + goto exit_detach; return 0; +exit_detach: + i2c_detach_client(new_client); exit_kfree: kfree(data); exit: @@ -223,6 +227,8 @@ static int eeprom_detach_client(struct i2c_client *client) { int err; + sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr); + err = i2c_detach_client(client); if (err) return err; diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index f92505b94c61..182f04953466 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c @@ -30,7 +30,7 @@ #include <linux/usb_ch9.h> #include <linux/usb_gadget.h> #include <linux/usb.h> -#include <linux/usb_otg.h> +#include <linux/usb/otg.h> #include <linux/i2c.h> #include <linux/workqueue.h> diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 88d2ddee4490..76645c142977 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -199,8 +199,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) mutex_init(&data->update_lock); /* Init fake client data */ - /* set the client data to the i2c_client so that it will get freed */ - i2c_set_clientdata(fake_client, fake_client); + i2c_set_clientdata(fake_client, NULL); fake_client->addr = address | 1; fake_client->adapter = adapter; fake_client->driver = &max6875_driver; @@ -214,13 +213,17 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) goto exit_kfree2; if ((err = i2c_attach_client(fake_client)) != 0) - goto exit_detach; + goto exit_detach1; - sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr); + err = sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr); + if (err) + goto exit_detach2; return 0; -exit_detach: +exit_detach2: + i2c_detach_client(fake_client); +exit_detach1: i2c_detach_client(real_client); exit_kfree2: kfree(fake_client); @@ -229,14 +232,24 @@ exit_kfree1: return err; } +/* Will be called for both the real client and the fake client */ static int max6875_detach_client(struct i2c_client *client) { int err; + struct max6875_data *data = i2c_get_clientdata(client); + + /* data is NULL for the fake client */ + if (data) + sysfs_remove_bin_file(&client->dev.kobj, &user_eeprom_attr); err = i2c_detach_client(client); if (err) return err; - kfree(i2c_get_clientdata(client)); + + if (data) /* real client */ + kfree(data); + else /* fake client */ + kfree(client); return 0; } 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; diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index c3e6449c4481..32b25427eaba 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -105,6 +105,16 @@ static ssize_t set_write(struct device *dev, struct device_attribute *attr, cons static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write); +static struct attribute *pcf8574_attributes[] = { + &dev_attr_read.attr, + &dev_attr_write.attr, + NULL +}; + +static const struct attribute_group pcf8574_attr_group = { + .attrs = pcf8574_attributes, +}; + /* * Real code */ @@ -166,13 +176,13 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) pcf8574_init_client(new_client); /* Register sysfs hooks */ - device_create_file(&new_client->dev, &dev_attr_read); - device_create_file(&new_client->dev, &dev_attr_write); + err = sysfs_create_group(&new_client->dev.kobj, &pcf8574_attr_group); + if (err) + goto exit_detach; return 0; -/* OK, this is not exactly good programming practice, usually. But it is - very code-efficient in this case. */ - + exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -183,6 +193,8 @@ static int pcf8574_detach_client(struct i2c_client *client) { int err; + sysfs_remove_group(&client->dev.kobj, &pcf8574_attr_group); + if ((err = i2c_detach_client(client))) return err; diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 925a6b371fd2..4dc36376eb32 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -158,6 +158,28 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO, show_out0_enable, set_out0_enable); +static struct attribute *pcf8591_attributes[] = { + &dev_attr_out0_enable.attr, + &dev_attr_out0_output.attr, + &dev_attr_in0_input.attr, + &dev_attr_in1_input.attr, + NULL +}; + +static const struct attribute_group pcf8591_attr_group = { + .attrs = pcf8591_attributes, +}; + +static struct attribute *pcf8591_attributes_opt[] = { + &dev_attr_in2_input.attr, + &dev_attr_in3_input.attr, + NULL +}; + +static const struct attribute_group pcf8591_attr_group_opt = { + .attrs = pcf8591_attributes_opt, +}; + /* * Real code */ @@ -211,24 +233,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) pcf8591_init_client(new_client); /* Register sysfs hooks */ - device_create_file(&new_client->dev, &dev_attr_out0_enable); - device_create_file(&new_client->dev, &dev_attr_out0_output); - device_create_file(&new_client->dev, &dev_attr_in0_input); - device_create_file(&new_client->dev, &dev_attr_in1_input); + err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group); + if (err) + goto exit_detach; /* Register input2 if not in "two differential inputs" mode */ - if (input_mode != 3 ) - device_create_file(&new_client->dev, &dev_attr_in2_input); - + if (input_mode != 3) { + if ((err = device_create_file(&new_client->dev, + &dev_attr_in2_input))) + goto exit_sysfs_remove; + } + /* Register input3 only in "four single ended inputs" mode */ - if (input_mode == 0) - device_create_file(&new_client->dev, &dev_attr_in3_input); - + if (input_mode == 0) { + if ((err = device_create_file(&new_client->dev, + &dev_attr_in3_input))) + goto exit_sysfs_remove; + } + return 0; - - /* OK, this is not exactly good programming practice, usually. But it is - very code-efficient in this case. */ +exit_sysfs_remove: + sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt); + sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group); +exit_detach: + i2c_detach_client(new_client); exit_kfree: kfree(data); exit: @@ -239,6 +268,9 @@ static int pcf8591_detach_client(struct i2c_client *client) { int err; + sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); + sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); + if ((err = i2c_detach_client(client))) return err; diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 0be6fd6a267d..6a7578217177 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c @@ -305,7 +305,7 @@ static int dbg_show(struct seq_file *s, void *_) static int dbg_tps_open(struct inode *inode, struct file *file) { - return single_open(file, dbg_show, inode->u.generic_ip); + return single_open(file, dbg_show, inode->i_private); } static struct file_operations debug_fops = { |