diff options
Diffstat (limited to 'drivers/misc/eeprom/eeprom.c')
-rw-r--r-- | drivers/misc/eeprom/eeprom.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/misc/eeprom/eeprom.c b/drivers/misc/eeprom/eeprom.c index 33f8673d23a6..b432873def96 100644 --- a/drivers/misc/eeprom/eeprom.c +++ b/drivers/misc/eeprom/eeprom.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/device.h> |
22 | #include <linux/jiffies.h> | 22 | #include <linux/jiffies.h> |
23 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
@@ -159,12 +159,11 @@ static int eeprom_probe(struct i2c_client *client, | |||
159 | { | 159 | { |
160 | struct i2c_adapter *adapter = client->adapter; | 160 | struct i2c_adapter *adapter = client->adapter; |
161 | struct eeprom_data *data; | 161 | struct eeprom_data *data; |
162 | int err; | ||
163 | 162 | ||
164 | if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { | 163 | data = devm_kzalloc(&client->dev, sizeof(struct eeprom_data), |
165 | err = -ENOMEM; | 164 | GFP_KERNEL); |
166 | goto exit; | 165 | if (!data) |
167 | } | 166 | return -ENOMEM; |
168 | 167 | ||
169 | memset(data->data, 0xff, EEPROM_SIZE); | 168 | memset(data->data, 0xff, EEPROM_SIZE); |
170 | i2c_set_clientdata(client, data); | 169 | i2c_set_clientdata(client, data); |
@@ -190,22 +189,12 @@ static int eeprom_probe(struct i2c_client *client, | |||
190 | } | 189 | } |
191 | 190 | ||
192 | /* create the sysfs eeprom file */ | 191 | /* create the sysfs eeprom file */ |
193 | err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr); | 192 | return sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr); |
194 | if (err) | ||
195 | goto exit_kfree; | ||
196 | |||
197 | return 0; | ||
198 | |||
199 | exit_kfree: | ||
200 | kfree(data); | ||
201 | exit: | ||
202 | return err; | ||
203 | } | 193 | } |
204 | 194 | ||
205 | static int eeprom_remove(struct i2c_client *client) | 195 | static int eeprom_remove(struct i2c_client *client) |
206 | { | 196 | { |
207 | sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr); | 197 | sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr); |
208 | kfree(i2c_get_clientdata(client)); | ||
209 | 198 | ||
210 | return 0; | 199 | return 0; |
211 | } | 200 | } |