Skip to content

Commit e892b75

Browse files
committed
hwmon: (atxp1) Drop auto-detection
Auto-detection for this chip is highly unreliable, and one of its I2C addresses can also be used by EEPROMs, increasing the risk for false positives even more. Drop auto-detection entirely to remove the risk. Reviewed-by: Jean Delvare <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent ea33a5e commit e892b75

File tree

1 file changed

+9
-46
lines changed

1 file changed

+9
-46
lines changed

drivers/hwmon/atxp1.c

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14+
*
15+
* The ATXP1 can reside on I2C addresses 0x37 or 0x4e. The chip is
16+
* not auto-detected by the driver and must be instantiated explicitly.
17+
* See Documentation/i2c/instantiating-devices for more information.
1418
*/
1519

1620
#include <linux/kernel.h>
@@ -38,8 +42,6 @@ MODULE_AUTHOR("Sebastian Witt <[email protected]>");
3842
#define ATXP1_VIDMASK 0x1f
3943
#define ATXP1_GPIO1MASK 0x0f
4044

41-
static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
42-
4345
struct atxp1_data {
4446
struct i2c_client *client;
4547
struct mutex update_lock;
@@ -254,48 +256,6 @@ static struct attribute *atxp1_attrs[] = {
254256
};
255257
ATTRIBUTE_GROUPS(atxp1);
256258

257-
/* Return 0 if detection is successful, -ENODEV otherwise */
258-
static int atxp1_detect(struct i2c_client *new_client,
259-
struct i2c_board_info *info)
260-
{
261-
struct i2c_adapter *adapter = new_client->adapter;
262-
263-
u8 temp;
264-
265-
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
266-
return -ENODEV;
267-
268-
/* Detect ATXP1, checking if vendor ID registers are all zero */
269-
if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) &&
270-
(i2c_smbus_read_byte_data(new_client, 0x3f) == 0) &&
271-
(i2c_smbus_read_byte_data(new_client, 0xfe) == 0) &&
272-
(i2c_smbus_read_byte_data(new_client, 0xff) == 0)))
273-
return -ENODEV;
274-
275-
/*
276-
* No vendor ID, now checking if registers 0x10,0x11 (non-existent)
277-
* showing the same as register 0x00
278-
*/
279-
temp = i2c_smbus_read_byte_data(new_client, 0x00);
280-
281-
if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) &&
282-
(i2c_smbus_read_byte_data(new_client, 0x11) == temp)))
283-
return -ENODEV;
284-
285-
/* Get VRM */
286-
temp = vid_which_vrm();
287-
288-
if ((temp != 90) && (temp != 91)) {
289-
dev_err(&adapter->dev, "atxp1: Not supporting VRM %d.%d\n",
290-
temp / 10, temp % 10);
291-
return -ENODEV;
292-
}
293-
294-
strlcpy(info->type, "atxp1", I2C_NAME_SIZE);
295-
296-
return 0;
297-
}
298-
299259
static int atxp1_probe(struct i2c_client *client,
300260
const struct i2c_device_id *id)
301261
{
@@ -309,6 +269,11 @@ static int atxp1_probe(struct i2c_client *client,
309269

310270
/* Get VRM */
311271
data->vrm = vid_which_vrm();
272+
if (data->vrm != 90 && data->vrm != 91) {
273+
dev_err(dev, "atxp1: Not supporting VRM %d.%d\n",
274+
data->vrm / 10, data->vrm % 10);
275+
return -ENODEV;
276+
}
312277

313278
data->client = client;
314279
mutex_init(&data->update_lock);
@@ -337,8 +302,6 @@ static struct i2c_driver atxp1_driver = {
337302
},
338303
.probe = atxp1_probe,
339304
.id_table = atxp1_id,
340-
.detect = atxp1_detect,
341-
.address_list = normal_i2c,
342305
};
343306

344307
module_i2c_driver(atxp1_driver);

0 commit comments

Comments
 (0)