Skip to content

Commit a3cf859

Browse files
committed
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: (44 commits) hwmon: (w83l786ng) Convert to a new-style i2c driver hwmon: (w83l785ts) Convert to a new-style i2c driver hwmon: (w83793) Convert to a new-style i2c driver hwmon: (w83792d) Convert to a new-style i2c driver hwmon: (w83791d) Convert to a new-style i2c driver hwmon: (thmc50) Convert to a new-style i2c driver hwmon: (smsc47m192) Convert to a new-style i2c driver hwmon: (max6650) Convert to a new-style i2c driver hwmon: (max1619) Convert to a new-style i2c driver hwmon: (lm93) Convert to a new-style i2c driver hwmon: (lm92) Convert to a new-style i2c driver hwmon: (lm90) Convert to a new-style i2c driver hwmon: (lm87) Convert to a new-style i2c driver hwmon: (lm83) Convert to a new-style i2c driver hwmon: (lm80) Convert to a new-style i2c driver hwmon: (lm77) Convert to a new-style i2c driver hwmon: (lm63) Convert to a new-style i2c driver hwmon: (gl520sm) Convert to a new-style i2c driver hwmon: (gl518sm) Convert to a new-style i2c driver hwmon: (fscpos) Convert to a new-style i2c driver ...
2 parents 3c3622d + 33468e7 commit a3cf859

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2129
-2797
lines changed

Documentation/i2c/chips/max6875

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ $ modprobe max6875 force=0,0x50
4949

5050
The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple
5151
addresses. For example, for address 0x50, it also reserves 0x51.
52-
The even-address instance is called 'max6875', the odd one is 'max6875 subclient'.
52+
The even-address instance is called 'max6875', the odd one is 'dummy'.
5353

5454

5555
Programming the chip using i2c-dev

Documentation/i2c/chips/pca9539

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ drivers/gpio/pca9539.c instead.
77
Supported chips:
88
* Philips PCA9539
99
Prefix: 'pca9539'
10-
Addresses scanned: 0x74 - 0x77
10+
Addresses scanned: none
1111
Datasheet:
1212
http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf
1313

@@ -23,6 +23,14 @@ The input sense can also be inverted.
2323
The 16 lines are split between two bytes.
2424

2525

26+
Detection
27+
---------
28+
29+
The PCA9539 is difficult to detect and not commonly found in PC machines,
30+
so you have to pass the I2C bus and address of the installed PCA9539
31+
devices explicitly to the driver at load time via the force=... parameter.
32+
33+
2634
Sysfs entries
2735
-------------
2836

Documentation/i2c/chips/pcf8574

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Kernel driver pcf8574
44
Supported chips:
55
* Philips PCF8574
66
Prefix: 'pcf8574'
7-
Addresses scanned: I2C 0x20 - 0x27
7+
Addresses scanned: none
88
Datasheet: Publicly available at the Philips Semiconductors website
99
http://www.semiconductors.philips.com/pip/PCF8574P.html
1010

1111
* Philips PCF8574A
1212
Prefix: 'pcf8574a'
13-
Addresses scanned: I2C 0x38 - 0x3f
13+
Addresses scanned: none
1414
Datasheet: Publicly available at the Philips Semiconductors website
1515
http://www.semiconductors.philips.com/pip/PCF8574P.html
1616

@@ -38,12 +38,10 @@ For more informations see the datasheet.
3838
Accessing PCF8574(A) via /sys interface
3939
-------------------------------------
4040

41-
! Be careful !
4241
The PCF8574(A) is plainly impossible to detect ! Stupid chip.
43-
So every chip with address in the interval [20..27] and [38..3f] are
44-
detected as PCF8574(A). If you have other chips in this address
45-
range, the workaround is to load this module after the one
46-
for your others chips.
42+
So, you have to pass the I2C bus and address of the installed PCF857A
43+
and PCF8574A devices explicitly to the driver at load time via the
44+
force=... parameter.
4745

4846
On detection (i.e. insmod, modprobe et al.), directories are being
4947
created for each detected PCF8574(A):

Documentation/i2c/chips/pcf8575

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ Detection
4040
---------
4141

4242
There is no method known to detect whether a chip on a given I2C address is
43-
a PCF8575 or whether it is any other I2C device. So there are two alternatives
44-
to let the driver find the installed PCF8575 devices:
45-
- Load this driver after any other I2C driver for I2C devices with addresses
46-
in the range 0x20 .. 0x27.
47-
- Pass the I2C bus and address of the installed PCF8575 devices explicitly to
48-
the driver at load time via the probe=... or force=... parameters.
43+
a PCF8575 or whether it is any other I2C device, so you have to pass the I2C
44+
bus and address of the installed PCF8575 devices explicitly to the driver at
45+
load time via the force=... parameter.
4946

5047
/sys interface
5148
--------------

drivers/hwmon/ad7418.c

Lines changed: 26 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@
2323

2424
#include "lm75.h"
2525

26-
#define DRV_VERSION "0.3"
26+
#define DRV_VERSION "0.4"
2727

28-
/* Addresses to scan */
29-
static const unsigned short normal_i2c[] = { 0x28, I2C_CLIENT_END };
30-
/* Insmod parameters */
31-
I2C_CLIENT_INSMOD_3(ad7416, ad7417, ad7418);
28+
enum chips { ad7416, ad7417, ad7418 };
3229

3330
/* AD7418 registers */
3431
#define AD7418_REG_TEMP_IN 0x00
@@ -46,7 +43,6 @@ static const u8 AD7418_REG_TEMP[] = { AD7418_REG_TEMP_IN,
4643
AD7418_REG_TEMP_OS };
4744

4845
struct ad7418_data {
49-
struct i2c_client client;
5046
struct device *hwmon_dev;
5147
struct attribute_group attrs;
5248
enum chips type;
@@ -58,16 +54,25 @@ struct ad7418_data {
5854
u16 in[4];
5955
};
6056

61-
static int ad7418_attach_adapter(struct i2c_adapter *adapter);
62-
static int ad7418_detect(struct i2c_adapter *adapter, int address, int kind);
63-
static int ad7418_detach_client(struct i2c_client *client);
57+
static int ad7418_probe(struct i2c_client *client,
58+
const struct i2c_device_id *id);
59+
static int ad7418_remove(struct i2c_client *client);
60+
61+
static const struct i2c_device_id ad7418_id[] = {
62+
{ "ad7416", ad7416 },
63+
{ "ad7417", ad7417 },
64+
{ "ad7418", ad7418 },
65+
{ }
66+
};
67+
MODULE_DEVICE_TABLE(i2c, ad7418_id);
6468

6569
static struct i2c_driver ad7418_driver = {
6670
.driver = {
6771
.name = "ad7418",
6872
},
69-
.attach_adapter = ad7418_attach_adapter,
70-
.detach_client = ad7418_detach_client,
73+
.probe = ad7418_probe,
74+
.remove = ad7418_remove,
75+
.id_table = ad7418_id,
7176
};
7277

7378
/* All registers are word-sized, except for the configuration registers.
@@ -192,13 +197,6 @@ static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 1);
192197
static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 2);
193198
static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 3);
194199

195-
static int ad7418_attach_adapter(struct i2c_adapter *adapter)
196-
{
197-
if (!(adapter->class & I2C_CLASS_HWMON))
198-
return 0;
199-
return i2c_probe(adapter, &addr_data, ad7418_detect);
200-
}
201-
202200
static struct attribute *ad7416_attributes[] = {
203201
&sensor_dev_attr_temp1_max.dev_attr.attr,
204202
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
@@ -225,106 +223,54 @@ static struct attribute *ad7418_attributes[] = {
225223
NULL
226224
};
227225

228-
static int ad7418_detect(struct i2c_adapter *adapter, int address, int kind)
226+
static int ad7418_probe(struct i2c_client *client,
227+
const struct i2c_device_id *id)
229228
{
230-
struct i2c_client *client;
229+
struct i2c_adapter *adapter = client->adapter;
231230
struct ad7418_data *data;
232-
int err = 0;
231+
int err;
233232

234233
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
235-
I2C_FUNC_SMBUS_WORD_DATA))
234+
I2C_FUNC_SMBUS_WORD_DATA)) {
235+
err = -EOPNOTSUPP;
236236
goto exit;
237+
}
237238

238239
if (!(data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL))) {
239240
err = -ENOMEM;
240241
goto exit;
241242
}
242243

243-
client = &data->client;
244-
client->addr = address;
245-
client->adapter = adapter;
246-
client->driver = &ad7418_driver;
247-
248244
i2c_set_clientdata(client, data);
249245

250246
mutex_init(&data->lock);
251-
252-
/* AD7418 has a curious behaviour on registers 6 and 7. They
253-
* both always read 0xC071 and are not documented on the datasheet.
254-
* We use them to detect the chip.
255-
*/
256-
if (kind <= 0) {
257-
int reg, reg6, reg7;
258-
259-
/* the AD7416 lies within this address range, but I have
260-
* no means to check.
261-
*/
262-
if (address >= 0x48 && address <= 0x4f) {
263-
/* XXX add tests for AD7416 here */
264-
/* data->type = ad7416; */
265-
}
266-
/* here we might have AD7417 or AD7418 */
267-
else if (address >= 0x28 && address <= 0x2f) {
268-
reg6 = i2c_smbus_read_word_data(client, 0x06);
269-
reg7 = i2c_smbus_read_word_data(client, 0x07);
270-
271-
if (address == 0x28 && reg6 == 0xC071 && reg7 == 0xC071)
272-
data->type = ad7418;
273-
274-
/* XXX add tests for AD7417 here */
275-
276-
277-
/* both AD7417 and AD7418 have bits 0-5 of
278-
* the CONF2 register at 0
279-
*/
280-
reg = i2c_smbus_read_byte_data(client,
281-
AD7418_REG_CONF2);
282-
if (reg & 0x3F)
283-
data->type = any_chip; /* detection failed */
284-
}
285-
} else {
286-
dev_dbg(&adapter->dev, "detection forced\n");
287-
}
288-
289-
if (kind > 0)
290-
data->type = kind;
291-
else if (kind < 0 && data->type == any_chip) {
292-
err = -ENODEV;
293-
goto exit_free;
294-
}
247+
data->type = id->driver_data;
295248

296249
switch (data->type) {
297-
case any_chip:
298250
case ad7416:
299251
data->adc_max = 0;
300252
data->attrs.attrs = ad7416_attributes;
301-
strlcpy(client->name, "ad7416", I2C_NAME_SIZE);
302253
break;
303254

304255
case ad7417:
305256
data->adc_max = 4;
306257
data->attrs.attrs = ad7417_attributes;
307-
strlcpy(client->name, "ad7417", I2C_NAME_SIZE);
308258
break;
309259

310260
case ad7418:
311261
data->adc_max = 1;
312262
data->attrs.attrs = ad7418_attributes;
313-
strlcpy(client->name, "ad7418", I2C_NAME_SIZE);
314263
break;
315264
}
316265

317-
if ((err = i2c_attach_client(client)))
318-
goto exit_free;
319-
320266
dev_info(&client->dev, "%s chip found\n", client->name);
321267

322268
/* Initialize the AD7418 chip */
323269
ad7418_init_client(client);
324270

325271
/* Register sysfs hooks */
326272
if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs)))
327-
goto exit_detach;
273+
goto exit_free;
328274

329275
data->hwmon_dev = hwmon_device_register(&client->dev);
330276
if (IS_ERR(data->hwmon_dev)) {
@@ -336,20 +282,17 @@ static int ad7418_detect(struct i2c_adapter *adapter, int address, int kind)
336282

337283
exit_remove:
338284
sysfs_remove_group(&client->dev.kobj, &data->attrs);
339-
exit_detach:
340-
i2c_detach_client(client);
341285
exit_free:
342286
kfree(data);
343287
exit:
344288
return err;
345289
}
346290

347-
static int ad7418_detach_client(struct i2c_client *client)
291+
static int ad7418_remove(struct i2c_client *client)
348292
{
349293
struct ad7418_data *data = i2c_get_clientdata(client);
350294
hwmon_device_unregister(data->hwmon_dev);
351295
sysfs_remove_group(&client->dev.kobj, &data->attrs);
352-
i2c_detach_client(client);
353296
kfree(data);
354297
return 0;
355298
}

0 commit comments

Comments
 (0)