mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 10:33:27 +00:00
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
This commit is contained in:
commit
9508d80530
3 changed files with 24 additions and 13 deletions
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
@ -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++) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue