Commit 9508d805 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/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
parents 8aa7ad90 0e502ec8
...@@ -32,6 +32,7 @@ static int adm1275_probe(struct i2c_client *client, ...@@ -32,6 +32,7 @@ static int adm1275_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
int config; int config;
int ret;
struct pmbus_driver_info *info; struct pmbus_driver_info *info;
if (!i2c_check_functionality(client->adapter, if (!i2c_check_functionality(client->adapter,
...@@ -43,8 +44,10 @@ static int adm1275_probe(struct i2c_client *client, ...@@ -43,8 +44,10 @@ static int adm1275_probe(struct i2c_client *client,
return -ENOMEM; return -ENOMEM;
config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG); config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG);
if (config < 0) if (config < 0) {
return config; ret = config;
goto err_mem;
}
info->pages = 1; info->pages = 1;
info->direct[PSC_VOLTAGE_IN] = true; info->direct[PSC_VOLTAGE_IN] = true;
...@@ -76,7 +79,14 @@ static int adm1275_probe(struct i2c_client *client, ...@@ -76,7 +79,14 @@ static int adm1275_probe(struct i2c_client *client,
else else
info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT; 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) static int adm1275_remove(struct i2c_client *client)
......
...@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client, ...@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
if (info->func[0] if (info->func[0]
&& pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT)) && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
info->func[0] |= PMBUS_HAVE_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; info->func[0] |= PMBUS_HAVE_FAN12;
if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12)) if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
info->func[0] |= PMBUS_HAVE_STATUS_FAN12; 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; info->func[0] |= PMBUS_HAVE_FAN34;
if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34)) if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
info->func[0] |= PMBUS_HAVE_STATUS_FAN34; info->func[0] |= PMBUS_HAVE_STATUS_FAN34;
...@@ -63,6 +65,10 @@ static void pmbus_find_sensor_groups(struct i2c_client *client, ...@@ -63,6 +65,10 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
PMBUS_STATUS_TEMPERATURE)) PMBUS_STATUS_TEMPERATURE))
info->func[0] |= PMBUS_HAVE_STATUS_TEMP; 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 */ /* Sensors detected on all pages */
for (page = 0; page < info->pages; page++) { for (page = 0; page < info->pages; page++) {
......
...@@ -1430,14 +1430,9 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, ...@@ -1430,14 +1430,9 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
/* /* Bail out if PMBus status register does not exist. */
* Bail out if status register or PMBus revision register if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
* does not exist. dev_err(&client->dev, "PMBus status register not found\n");
*/
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");
ret = -ENODEV; ret = -ENODEV;
goto out_data; goto out_data;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment