lm73.c (2d8ad8719591fa803b0d589ed057fa46f49b7155) lm73.c (24d6e2a89a1ff0a035f163a83a2812a3192083b6)
1/*
2 * LM73 Sensor driver
3 * Based on LM75
4 *
5 * Copyright (C) 2007, CenoSYS (www.cenosys.com).
6 * Copyright (C) 2009, Bollore telecom (www.bolloretelecom.eu).
7 *
8 * Guillaume Ligneul <guillaume.ligneul@gmail.com>

--- 136 unchanged lines hidden (view full) ---

145};
146MODULE_DEVICE_TABLE(i2c, lm73_ids);
147
148/* Return 0 if detection is successful, -ENODEV otherwise */
149static int lm73_detect(struct i2c_client *new_client,
150 struct i2c_board_info *info)
151{
152 struct i2c_adapter *adapter = new_client->adapter;
1/*
2 * LM73 Sensor driver
3 * Based on LM75
4 *
5 * Copyright (C) 2007, CenoSYS (www.cenosys.com).
6 * Copyright (C) 2009, Bollore telecom (www.bolloretelecom.eu).
7 *
8 * Guillaume Ligneul <guillaume.ligneul@gmail.com>

--- 136 unchanged lines hidden (view full) ---

145};
146MODULE_DEVICE_TABLE(i2c, lm73_ids);
147
148/* Return 0 if detection is successful, -ENODEV otherwise */
149static int lm73_detect(struct i2c_client *new_client,
150 struct i2c_board_info *info)
151{
152 struct i2c_adapter *adapter = new_client->adapter;
153 u16 id;
154 u8 ctrl;
153 int id, ctrl, conf;
155
156 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
157 I2C_FUNC_SMBUS_WORD_DATA))
158 return -ENODEV;
159
154
155 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
156 I2C_FUNC_SMBUS_WORD_DATA))
157 return -ENODEV;
158
159 /*
160 * Do as much detection as possible with byte reads first, as word
161 * reads can confuse other devices.
162 */
163 ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL);
164 if (ctrl < 0 || (ctrl & 0x10))
165 return -ENODEV;
166
167 conf = i2c_smbus_read_byte_data(new_client, LM73_REG_CONF);
168 if (conf < 0 || (conf & 0x0c))
169 return -ENODEV;
170
171 id = i2c_smbus_read_byte_data(new_client, LM73_REG_ID);
172 if (id < 0 || id != (LM73_ID & 0xff))
173 return -ENODEV;
174
160 /* Check device ID */
161 id = i2c_smbus_read_word_data(new_client, LM73_REG_ID);
175 /* Check device ID */
176 id = i2c_smbus_read_word_data(new_client, LM73_REG_ID);
162 ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL);
163 if ((id != LM73_ID) || (ctrl & 0x10))
177 if (id < 0 || id != LM73_ID)
164 return -ENODEV;
165
166 strlcpy(info->type, "lm73", I2C_NAME_SIZE);
167
168 return 0;
169}
170
171static struct i2c_driver lm73_driver = {

--- 29 unchanged lines hidden ---
178 return -ENODEV;
179
180 strlcpy(info->type, "lm73", I2C_NAME_SIZE);
181
182 return 0;
183}
184
185static struct i2c_driver lm73_driver = {

--- 29 unchanged lines hidden ---