diff options
Diffstat (limited to 'drivers/i2c/chips/pcf8591.c')
-rw-r--r-- | drivers/i2c/chips/pcf8591.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 66c7c3bb9429..db735379f22f 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | pcf8591.c - Part of lm_sensors, Linux kernel modules for hardware | ||
3 | monitoring | ||
4 | Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net> | 2 | Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net> |
5 | Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with | 3 | Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with |
6 | the help of Jean Delvare <khali@linux-fr.org> | 4 | the help of Jean Delvare <khali@linux-fr.org> |
@@ -190,7 +188,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter) | |||
190 | /* This function is called by i2c_probe */ | 188 | /* This function is called by i2c_probe */ |
191 | static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | 189 | static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) |
192 | { | 190 | { |
193 | struct i2c_client *new_client; | 191 | struct i2c_client *client; |
194 | struct pcf8591_data *data; | 192 | struct pcf8591_data *data; |
195 | int err = 0; | 193 | int err = 0; |
196 | 194 | ||
@@ -205,12 +203,11 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
205 | goto exit; | 203 | goto exit; |
206 | } | 204 | } |
207 | 205 | ||
208 | new_client = &data->client; | 206 | client = &data->client; |
209 | i2c_set_clientdata(new_client, data); | 207 | i2c_set_clientdata(client, data); |
210 | new_client->addr = address; | 208 | client->addr = address; |
211 | new_client->adapter = adapter; | 209 | client->adapter = adapter; |
212 | new_client->driver = &pcf8591_driver; | 210 | client->driver = &pcf8591_driver; |
213 | new_client->flags = 0; | ||
214 | 211 | ||
215 | /* Now, we would do the remaining detection. But the PCF8591 is plainly | 212 | /* Now, we would do the remaining detection. But the PCF8591 is plainly |
216 | impossible to detect! Stupid chip. */ | 213 | impossible to detect! Stupid chip. */ |
@@ -221,31 +218,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
221 | 218 | ||
222 | /* Fill in the remaining client fields and put it into the global | 219 | /* Fill in the remaining client fields and put it into the global |
223 | list */ | 220 | list */ |
224 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); | 221 | strlcpy(client->name, "pcf8591", I2C_NAME_SIZE); |
225 | mutex_init(&data->update_lock); | 222 | mutex_init(&data->update_lock); |
226 | 223 | ||
227 | /* Tell the I2C layer a new client has arrived */ | 224 | /* Tell the I2C layer a new client has arrived */ |
228 | if ((err = i2c_attach_client(new_client))) | 225 | if ((err = i2c_attach_client(client))) |
229 | goto exit_kfree; | 226 | goto exit_kfree; |
230 | 227 | ||
231 | /* Initialize the PCF8591 chip */ | 228 | /* Initialize the PCF8591 chip */ |
232 | pcf8591_init_client(new_client); | 229 | pcf8591_init_client(client); |
233 | 230 | ||
234 | /* Register sysfs hooks */ | 231 | /* Register sysfs hooks */ |
235 | err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group); | 232 | err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group); |
236 | if (err) | 233 | if (err) |
237 | goto exit_detach; | 234 | goto exit_detach; |
238 | 235 | ||
239 | /* Register input2 if not in "two differential inputs" mode */ | 236 | /* Register input2 if not in "two differential inputs" mode */ |
240 | if (input_mode != 3) { | 237 | if (input_mode != 3) { |
241 | if ((err = device_create_file(&new_client->dev, | 238 | if ((err = device_create_file(&client->dev, |
242 | &dev_attr_in2_input))) | 239 | &dev_attr_in2_input))) |
243 | goto exit_sysfs_remove; | 240 | goto exit_sysfs_remove; |
244 | } | 241 | } |
245 | 242 | ||
246 | /* Register input3 only in "four single ended inputs" mode */ | 243 | /* Register input3 only in "four single ended inputs" mode */ |
247 | if (input_mode == 0) { | 244 | if (input_mode == 0) { |
248 | if ((err = device_create_file(&new_client->dev, | 245 | if ((err = device_create_file(&client->dev, |
249 | &dev_attr_in3_input))) | 246 | &dev_attr_in3_input))) |
250 | goto exit_sysfs_remove; | 247 | goto exit_sysfs_remove; |
251 | } | 248 | } |
@@ -253,10 +250,10 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
253 | return 0; | 250 | return 0; |
254 | 251 | ||
255 | exit_sysfs_remove: | 252 | exit_sysfs_remove: |
256 | sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt); | 253 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
257 | sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group); | 254 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
258 | exit_detach: | 255 | exit_detach: |
259 | i2c_detach_client(new_client); | 256 | i2c_detach_client(client); |
260 | exit_kfree: | 257 | exit_kfree: |
261 | kfree(data); | 258 | kfree(data); |
262 | exit: | 259 | exit: |