aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/pcf8591.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-07-15 21:07:59 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-07-15 21:07:59 -0400
commit84c3d4aaec3338201b449034beac41635866bddf (patch)
tree3412951682fb2dd4feb8a5532f8efbaf8b345933 /drivers/i2c/chips/pcf8591.c
parent43d2548bb2ef7e6d753f91468a746784041e522d (diff)
parentfafa3a3f16723997f039a0193997464d66dafd8f (diff)
Merge commit 'origin/master'
Manual merge of: arch/powerpc/Kconfig arch/powerpc/kernel/stacktrace.c arch/powerpc/mm/slice.c arch/ppc/kernel/smp.c
Diffstat (limited to 'drivers/i2c/chips/pcf8591.c')
-rw-r--r--drivers/i2c/chips/pcf8591.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 66c7c3bb942..db735379f22 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 */
191static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) 189static 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
255exit_sysfs_remove: 252exit_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);
258exit_detach: 255exit_detach:
259 i2c_detach_client(new_client); 256 i2c_detach_client(client);
260exit_kfree: 257exit_kfree:
261 kfree(data); 258 kfree(data);
262exit: 259exit: