aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/pcf8591.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/pcf8591.c')
-rw-r--r--drivers/i2c/chips/pcf8591.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index d3a24524817a..db735379f22f 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -188,7 +188,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
188/* This function is called by i2c_probe */ 188/* This function is called by i2c_probe */
189static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) 189static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
190{ 190{
191 struct i2c_client *new_client; 191 struct i2c_client *client;
192 struct pcf8591_data *data; 192 struct pcf8591_data *data;
193 int err = 0; 193 int err = 0;
194 194
@@ -203,12 +203,11 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
203 goto exit; 203 goto exit;
204 } 204 }
205 205
206 new_client = &data->client; 206 client = &data->client;
207 i2c_set_clientdata(new_client, data); 207 i2c_set_clientdata(client, data);
208 new_client->addr = address; 208 client->addr = address;
209 new_client->adapter = adapter; 209 client->adapter = adapter;
210 new_client->driver = &pcf8591_driver; 210 client->driver = &pcf8591_driver;
211 new_client->flags = 0;
212 211
213 /* 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
214 impossible to detect! Stupid chip. */ 213 impossible to detect! Stupid chip. */
@@ -219,31 +218,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
219 218
220 /* 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
221 list */ 220 list */
222 strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); 221 strlcpy(client->name, "pcf8591", I2C_NAME_SIZE);
223 mutex_init(&data->update_lock); 222 mutex_init(&data->update_lock);
224 223
225 /* Tell the I2C layer a new client has arrived */ 224 /* Tell the I2C layer a new client has arrived */
226 if ((err = i2c_attach_client(new_client))) 225 if ((err = i2c_attach_client(client)))
227 goto exit_kfree; 226 goto exit_kfree;
228 227
229 /* Initialize the PCF8591 chip */ 228 /* Initialize the PCF8591 chip */
230 pcf8591_init_client(new_client); 229 pcf8591_init_client(client);
231 230
232 /* Register sysfs hooks */ 231 /* Register sysfs hooks */
233 err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group); 232 err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group);
234 if (err) 233 if (err)
235 goto exit_detach; 234 goto exit_detach;
236 235
237 /* Register input2 if not in "two differential inputs" mode */ 236 /* Register input2 if not in "two differential inputs" mode */
238 if (input_mode != 3) { 237 if (input_mode != 3) {
239 if ((err = device_create_file(&new_client->dev, 238 if ((err = device_create_file(&client->dev,
240 &dev_attr_in2_input))) 239 &dev_attr_in2_input)))
241 goto exit_sysfs_remove; 240 goto exit_sysfs_remove;
242 } 241 }
243 242
244 /* Register input3 only in "four single ended inputs" mode */ 243 /* Register input3 only in "four single ended inputs" mode */
245 if (input_mode == 0) { 244 if (input_mode == 0) {
246 if ((err = device_create_file(&new_client->dev, 245 if ((err = device_create_file(&client->dev,
247 &dev_attr_in3_input))) 246 &dev_attr_in3_input)))
248 goto exit_sysfs_remove; 247 goto exit_sysfs_remove;
249 } 248 }
@@ -251,10 +250,10 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
251 return 0; 250 return 0;
252 251
253exit_sysfs_remove: 252exit_sysfs_remove:
254 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt); 253 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt);
255 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group); 254 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group);
256exit_detach: 255exit_detach:
257 i2c_detach_client(new_client); 256 i2c_detach_client(client);
258exit_kfree: 257exit_kfree:
259 kfree(data); 258 kfree(data);
260exit: 259exit: