aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max1619.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/hwmon/max1619.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/hwmon/max1619.c')
-rw-r--r--drivers/hwmon/max1619.c76
1 files changed, 23 insertions, 53 deletions
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 7897754f3a5c..022ded098100 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -41,12 +41,6 @@ static const unsigned short normal_i2c[] = {
41 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; 41 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
42 42
43/* 43/*
44 * Insmod parameters
45 */
46
47I2C_CLIENT_INSMOD_1(max1619);
48
49/*
50 * The MAX1619 registers 44 * The MAX1619 registers
51 */ 45 */
52 46
@@ -88,7 +82,7 @@ static int temp_to_reg(int val)
88 82
89static int max1619_probe(struct i2c_client *client, 83static int max1619_probe(struct i2c_client *client,
90 const struct i2c_device_id *id); 84 const struct i2c_device_id *id);
91static int max1619_detect(struct i2c_client *client, int kind, 85static int max1619_detect(struct i2c_client *client,
92 struct i2c_board_info *info); 86 struct i2c_board_info *info);
93static void max1619_init_client(struct i2c_client *client); 87static void max1619_init_client(struct i2c_client *client);
94static int max1619_remove(struct i2c_client *client); 88static int max1619_remove(struct i2c_client *client);
@@ -99,7 +93,7 @@ static struct max1619_data *max1619_update_device(struct device *dev);
99 */ 93 */
100 94
101static const struct i2c_device_id max1619_id[] = { 95static const struct i2c_device_id max1619_id[] = {
102 { "max1619", max1619 }, 96 { "max1619", 0 },
103 { } 97 { }
104}; 98};
105MODULE_DEVICE_TABLE(i2c, max1619_id); 99MODULE_DEVICE_TABLE(i2c, max1619_id);
@@ -113,7 +107,7 @@ static struct i2c_driver max1619_driver = {
113 .remove = max1619_remove, 107 .remove = max1619_remove,
114 .id_table = max1619_id, 108 .id_table = max1619_id,
115 .detect = max1619_detect, 109 .detect = max1619_detect,
116 .address_data = &addr_data, 110 .address_list = normal_i2c,
117}; 111};
118 112
119/* 113/*
@@ -226,58 +220,34 @@ static const struct attribute_group max1619_group = {
226 */ 220 */
227 221
228/* Return 0 if detection is successful, -ENODEV otherwise */ 222/* Return 0 if detection is successful, -ENODEV otherwise */
229static int max1619_detect(struct i2c_client *new_client, int kind, 223static int max1619_detect(struct i2c_client *client,
230 struct i2c_board_info *info) 224 struct i2c_board_info *info)
231{ 225{
232 struct i2c_adapter *adapter = new_client->adapter; 226 struct i2c_adapter *adapter = client->adapter;
233 u8 reg_config=0, reg_convrate=0, reg_status=0; 227 u8 reg_config, reg_convrate, reg_status, man_id, chip_id;
234 228
235 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 229 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
236 return -ENODEV; 230 return -ENODEV;
237 231
238 /* 232 /* detection */
239 * Now we do the remaining detection. A negative kind means that 233 reg_config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG);
240 * the driver was loaded with no force parameter (default), so we 234 reg_convrate = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONVRATE);
241 * must both detect and identify the chip. A zero kind means that 235 reg_status = i2c_smbus_read_byte_data(client, MAX1619_REG_R_STATUS);
242 * the driver was loaded with the force parameter, the detection 236 if ((reg_config & 0x03) != 0x00
243 * step shall be skipped. A positive kind means that the driver 237 || reg_convrate > 0x07 || (reg_status & 0x61) != 0x00) {
244 * was loaded with the force parameter and a given kind of chip is 238 dev_dbg(&adapter->dev, "MAX1619 detection failed at 0x%02x\n",
245 * requested, so both the detection and the identification steps 239 client->addr);
246 * are skipped. 240 return -ENODEV;
247 */
248 if (kind < 0) { /* detection */
249 reg_config = i2c_smbus_read_byte_data(new_client,
250 MAX1619_REG_R_CONFIG);
251 reg_convrate = i2c_smbus_read_byte_data(new_client,
252 MAX1619_REG_R_CONVRATE);
253 reg_status = i2c_smbus_read_byte_data(new_client,
254 MAX1619_REG_R_STATUS);
255 if ((reg_config & 0x03) != 0x00
256 || reg_convrate > 0x07 || (reg_status & 0x61 ) !=0x00) {
257 dev_dbg(&adapter->dev,
258 "MAX1619 detection failed at 0x%02x.\n",
259 new_client->addr);
260 return -ENODEV;
261 }
262 } 241 }
263 242
264 if (kind <= 0) { /* identification */ 243 /* identification */
265 u8 man_id, chip_id; 244 man_id = i2c_smbus_read_byte_data(client, MAX1619_REG_R_MAN_ID);
266 245 chip_id = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CHIP_ID);
267 man_id = i2c_smbus_read_byte_data(new_client, 246 if (man_id != 0x4D || chip_id != 0x04) {
268 MAX1619_REG_R_MAN_ID); 247 dev_info(&adapter->dev,
269 chip_id = i2c_smbus_read_byte_data(new_client, 248 "Unsupported chip (man_id=0x%02X, chip_id=0x%02X).\n",
270 MAX1619_REG_R_CHIP_ID); 249 man_id, chip_id);
271 250 return -ENODEV;
272 if ((man_id == 0x4D) && (chip_id == 0x04))
273 kind = max1619;
274
275 if (kind <= 0) { /* identification failed */
276 dev_info(&adapter->dev,
277 "Unsupported chip (man_id=0x%02X, "
278 "chip_id=0x%02X).\n", man_id, chip_id);
279 return -ENODEV;
280 }
281 } 251 }
282 252
283 strlcpy(info->type, "max1619", I2C_NAME_SIZE); 253 strlcpy(info->type, "max1619", I2C_NAME_SIZE);