diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-10-04 16:53:42 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-10-04 16:53:42 -0400 |
commit | 2d2a7cff1b63cde1e2d981eea8ae9e69ae9ce96d (patch) | |
tree | 73e2422c4d4836c770c6ba0269f1bcf002f9d48b /drivers/hwmon/ltc4215.c | |
parent | 0314b020c49c1d6cd182d2b89775bfa6686660db (diff) |
ltc4215/ltc4245: Discard obsolete detect methods
There is no point in implementing a detect callback for the LTC4215
and LTC4245, as these devices can't be detected. It was there solely
to handle "force" module parameters to instantiate devices, but now
we have a better sysfs interface that can do the same.
So we can get rid of the ugly module parameters and the detect
callbacks. This shrinks the binary module sizes by 36% and 46%,
respectively.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Ira W. Snyder <iws@ovro.caltech.edu>
Diffstat (limited to 'drivers/hwmon/ltc4215.c')
-rw-r--r-- | drivers/hwmon/ltc4215.c | 47 |
1 files changed, 5 insertions, 42 deletions
diff --git a/drivers/hwmon/ltc4215.c b/drivers/hwmon/ltc4215.c index 6c9a04136e0..00d975eb5b8 100644 --- a/drivers/hwmon/ltc4215.c +++ b/drivers/hwmon/ltc4215.c | |||
@@ -20,11 +20,6 @@ | |||
20 | #include <linux/hwmon.h> | 20 | #include <linux/hwmon.h> |
21 | #include <linux/hwmon-sysfs.h> | 21 | #include <linux/hwmon-sysfs.h> |
22 | 22 | ||
23 | static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
24 | |||
25 | /* Insmod parameters */ | ||
26 | I2C_CLIENT_INSMOD_1(ltc4215); | ||
27 | |||
28 | /* Here are names of the chip's registers (a.k.a. commands) */ | 23 | /* Here are names of the chip's registers (a.k.a. commands) */ |
29 | enum ltc4215_cmd { | 24 | enum ltc4215_cmd { |
30 | LTC4215_CONTROL = 0x00, /* rw */ | 25 | LTC4215_CONTROL = 0x00, /* rw */ |
@@ -246,9 +241,13 @@ static const struct attribute_group ltc4215_group = { | |||
246 | static int ltc4215_probe(struct i2c_client *client, | 241 | static int ltc4215_probe(struct i2c_client *client, |
247 | const struct i2c_device_id *id) | 242 | const struct i2c_device_id *id) |
248 | { | 243 | { |
244 | struct i2c_adapter *adapter = client->adapter; | ||
249 | struct ltc4215_data *data; | 245 | struct ltc4215_data *data; |
250 | int ret; | 246 | int ret; |
251 | 247 | ||
248 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
249 | return -ENODEV; | ||
250 | |||
252 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 251 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
253 | if (!data) { | 252 | if (!data) { |
254 | ret = -ENOMEM; | 253 | ret = -ENOMEM; |
@@ -294,56 +293,20 @@ static int ltc4215_remove(struct i2c_client *client) | |||
294 | return 0; | 293 | return 0; |
295 | } | 294 | } |
296 | 295 | ||
297 | static int ltc4215_detect(struct i2c_client *client, | ||
298 | int kind, | ||
299 | struct i2c_board_info *info) | ||
300 | { | ||
301 | struct i2c_adapter *adapter = client->adapter; | ||
302 | |||
303 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
304 | return -ENODEV; | ||
305 | |||
306 | if (kind < 0) { /* probed detection - check the chip type */ | ||
307 | s32 v; /* 8 bits from the chip, or -ERRNO */ | ||
308 | |||
309 | /* | ||
310 | * Register 0x01 bit b7 is reserved, expect 0 | ||
311 | * Register 0x03 bit b6 and b7 are reserved, expect 0 | ||
312 | */ | ||
313 | v = i2c_smbus_read_byte_data(client, LTC4215_ALERT); | ||
314 | if (v < 0 || (v & (1 << 7)) != 0) | ||
315 | return -ENODEV; | ||
316 | |||
317 | v = i2c_smbus_read_byte_data(client, LTC4215_FAULT); | ||
318 | if (v < 0 || (v & ((1 << 6) | (1 << 7))) != 0) | ||
319 | return -ENODEV; | ||
320 | } | ||
321 | |||
322 | strlcpy(info->type, "ltc4215", I2C_NAME_SIZE); | ||
323 | dev_info(&adapter->dev, "ltc4215 %s at address 0x%02x\n", | ||
324 | kind < 0 ? "probed" : "forced", | ||
325 | client->addr); | ||
326 | |||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static const struct i2c_device_id ltc4215_id[] = { | 296 | static const struct i2c_device_id ltc4215_id[] = { |
331 | { "ltc4215", ltc4215 }, | 297 | { "ltc4215", 0 }, |
332 | { } | 298 | { } |
333 | }; | 299 | }; |
334 | MODULE_DEVICE_TABLE(i2c, ltc4215_id); | 300 | MODULE_DEVICE_TABLE(i2c, ltc4215_id); |
335 | 301 | ||
336 | /* This is the driver that will be inserted */ | 302 | /* This is the driver that will be inserted */ |
337 | static struct i2c_driver ltc4215_driver = { | 303 | static struct i2c_driver ltc4215_driver = { |
338 | .class = I2C_CLASS_HWMON, | ||
339 | .driver = { | 304 | .driver = { |
340 | .name = "ltc4215", | 305 | .name = "ltc4215", |
341 | }, | 306 | }, |
342 | .probe = ltc4215_probe, | 307 | .probe = ltc4215_probe, |
343 | .remove = ltc4215_remove, | 308 | .remove = ltc4215_remove, |
344 | .id_table = ltc4215_id, | 309 | .id_table = ltc4215_id, |
345 | .detect = ltc4215_detect, | ||
346 | .address_data = &addr_data, | ||
347 | }; | 310 | }; |
348 | 311 | ||
349 | static int __init ltc4215_init(void) | 312 | static int __init ltc4215_init(void) |