Skip to content

Commit

Permalink
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/groeck/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging:
  hwmon: (pmbus) Auto-detect temp2 and temp3 registers/attributes
  hwmon: (pmbus) Improve fan detection
  hwmon: (adm1275) Free allocated memory if probe function fails
  hwmon: (pmbus) Drop check for PMBus revision register in probe function
  • Loading branch information
Linus Torvalds committed Jul 2, 2011
2 parents 8aa7ad9 + 0e502ec commit 9508d80
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
16 changes: 13 additions & 3 deletions drivers/hwmon/adm1275.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static int adm1275_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int config;
int ret;
struct pmbus_driver_info *info;

if (!i2c_check_functionality(client->adapter,
Expand All @@ -43,8 +44,10 @@ static int adm1275_probe(struct i2c_client *client,
return -ENOMEM;

config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG);
if (config < 0)
return config;
if (config < 0) {
ret = config;
goto err_mem;
}

info->pages = 1;
info->direct[PSC_VOLTAGE_IN] = true;
Expand Down Expand Up @@ -76,7 +79,14 @@ static int adm1275_probe(struct i2c_client *client,
else
info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT;

return pmbus_do_probe(client, id, info);
ret = pmbus_do_probe(client, id, info);
if (ret)
goto err_mem;
return 0;

err_mem:
kfree(info);
return ret;
}

static int adm1275_remove(struct i2c_client *client)
Expand Down
10 changes: 8 additions & 2 deletions drivers/hwmon/pmbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
if (info->func[0]
&& pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
info->func[0] |= PMBUS_HAVE_FAN12;
if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
info->func[0] |= PMBUS_HAVE_STATUS_FAN12;
}
if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) &&
pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
info->func[0] |= PMBUS_HAVE_FAN34;
if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
info->func[0] |= PMBUS_HAVE_STATUS_FAN34;
Expand All @@ -63,6 +65,10 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
PMBUS_STATUS_TEMPERATURE))
info->func[0] |= PMBUS_HAVE_STATUS_TEMP;
}
if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2))
info->func[0] |= PMBUS_HAVE_TEMP2;
if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3))
info->func[0] |= PMBUS_HAVE_TEMP3;

/* Sensors detected on all pages */
for (page = 0; page < info->pages; page++) {
Expand Down
11 changes: 3 additions & 8 deletions drivers/hwmon/pmbus_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,14 +1430,9 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);

/*
* Bail out if status register or PMBus revision register
* does not exist.
*/
if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0
|| i2c_smbus_read_byte_data(client, PMBUS_REVISION) < 0) {
dev_err(&client->dev,
"Status or revision register not found\n");
/* Bail out if PMBus status register does not exist. */
if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
dev_err(&client->dev, "PMBus status register not found\n");
ret = -ENODEV;
goto out_data;
}
Expand Down

0 comments on commit 9508d80

Please sign in to comment.