aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/ics932s401.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/ics932s401.c')
-rw-r--r--drivers/misc/ics932s401.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c
index 6e43ab4231ae..152e9d93eecb 100644
--- a/drivers/misc/ics932s401.c
+++ b/drivers/misc/ics932s401.c
@@ -26,13 +26,11 @@
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/log2.h> 28#include <linux/log2.h>
29#include <linux/slab.h>
29 30
30/* Addresses to scan */ 31/* Addresses to scan */
31static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END }; 32static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END };
32 33
33/* Insmod parameters */
34I2C_CLIENT_INSMOD_1(ics932s401);
35
36/* ICS932S401 registers */ 34/* ICS932S401 registers */
37#define ICS932S401_REG_CFG2 0x01 35#define ICS932S401_REG_CFG2 0x01
38#define ICS932S401_CFG1_SPREAD 0x01 36#define ICS932S401_CFG1_SPREAD 0x01
@@ -106,12 +104,12 @@ struct ics932s401_data {
106 104
107static int ics932s401_probe(struct i2c_client *client, 105static int ics932s401_probe(struct i2c_client *client,
108 const struct i2c_device_id *id); 106 const struct i2c_device_id *id);
109static int ics932s401_detect(struct i2c_client *client, int kind, 107static int ics932s401_detect(struct i2c_client *client,
110 struct i2c_board_info *info); 108 struct i2c_board_info *info);
111static int ics932s401_remove(struct i2c_client *client); 109static int ics932s401_remove(struct i2c_client *client);
112 110
113static const struct i2c_device_id ics932s401_id[] = { 111static const struct i2c_device_id ics932s401_id[] = {
114 { "ics932s401", ics932s401 }, 112 { "ics932s401", 0 },
115 { } 113 { }
116}; 114};
117MODULE_DEVICE_TABLE(i2c, ics932s401_id); 115MODULE_DEVICE_TABLE(i2c, ics932s401_id);
@@ -125,7 +123,7 @@ static struct i2c_driver ics932s401_driver = {
125 .remove = ics932s401_remove, 123 .remove = ics932s401_remove,
126 .id_table = ics932s401_id, 124 .id_table = ics932s401_id,
127 .detect = ics932s401_detect, 125 .detect = ics932s401_detect,
128 .address_data = &addr_data, 126 .address_list = normal_i2c,
129}; 127};
130 128
131static struct ics932s401_data *ics932s401_update_device(struct device *dev) 129static struct ics932s401_data *ics932s401_update_device(struct device *dev)
@@ -413,36 +411,29 @@ static ssize_t show_spread(struct device *dev,
413} 411}
414 412
415/* Return 0 if detection is successful, -ENODEV otherwise */ 413/* Return 0 if detection is successful, -ENODEV otherwise */
416static int ics932s401_detect(struct i2c_client *client, int kind, 414static int ics932s401_detect(struct i2c_client *client,
417 struct i2c_board_info *info) 415 struct i2c_board_info *info)
418{ 416{
419 struct i2c_adapter *adapter = client->adapter; 417 struct i2c_adapter *adapter = client->adapter;
418 int vendor, device, revision;
420 419
421 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 420 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
422 return -ENODEV; 421 return -ENODEV;
423 422
424 if (kind <= 0) { 423 vendor = i2c_smbus_read_word_data(client, ICS932S401_REG_VENDOR_REV);
425 int vendor, device, revision; 424 vendor >>= 8;
426 425 revision = vendor >> ICS932S401_REV_SHIFT;
427 vendor = i2c_smbus_read_word_data(client, 426 vendor &= ICS932S401_VENDOR_MASK;
428 ICS932S401_REG_VENDOR_REV); 427 if (vendor != ICS932S401_VENDOR)
429 vendor >>= 8; 428 return -ENODEV;
430 revision = vendor >> ICS932S401_REV_SHIFT; 429
431 vendor &= ICS932S401_VENDOR_MASK; 430 device = i2c_smbus_read_word_data(client, ICS932S401_REG_DEVICE);
432 if (vendor != ICS932S401_VENDOR) 431 device >>= 8;
433 return -ENODEV; 432 if (device != ICS932S401_DEVICE)
434 433 return -ENODEV;
435 device = i2c_smbus_read_word_data(client, 434
436 ICS932S401_REG_DEVICE); 435 if (revision != ICS932S401_REV)
437 device >>= 8; 436 dev_info(&adapter->dev, "Unknown revision %d\n", revision);
438 if (device != ICS932S401_DEVICE)
439 return -ENODEV;
440
441 if (revision != ICS932S401_REV)
442 dev_info(&adapter->dev, "Unknown revision %d\n",
443 revision);
444 } else
445 dev_dbg(&adapter->dev, "detection forced\n");
446 437
447 strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); 438 strlcpy(info->type, "ics932s401", I2C_NAME_SIZE);
448 439