mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 10:11:38 -04:00
Merge tag 'hwmon-for-v7.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - max6639: Fix pulses-per-revolution implementation - Several PMBus drivers: Add missing error checks * tag 'hwmon-for-v7.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (max6639) Fix pulses-per-revolution implementation hwmon: (pmbus/isl68137) Fix unchecked return value and use sysfs_emit() hwmon: (pmbus/ina233) Add error check for pmbus_read_word_data() return value hwmon: (pmbus/mp2869) Check pmbus_read_byte_data() before using its return value hwmon: (pmbus/mp2975) Add error check for pmbus_read_word_data() return value hwmon: (pmbus/hac300s) Add error check for pmbus_read_word_data() return value
This commit is contained in:
@@ -232,7 +232,7 @@ static int max6639_read_fan(struct device *dev, u32 attr, int channel,
|
||||
static int max6639_set_ppr(struct max6639_data *data, int channel, u8 ppr)
|
||||
{
|
||||
/* Decrement the PPR value and shift left by 6 to match the register format */
|
||||
return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), ppr-- << 6);
|
||||
return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), --ppr << 6);
|
||||
}
|
||||
|
||||
static int max6639_write_fan(struct device *dev, u32 attr, int channel,
|
||||
@@ -524,8 +524,8 @@ static int max6639_probe_child_from_dt(struct i2c_client *client,
|
||||
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
u32 i;
|
||||
int err, val;
|
||||
u32 i, val;
|
||||
int err;
|
||||
|
||||
err = of_property_read_u32(child, "reg", &i);
|
||||
if (err) {
|
||||
@@ -540,8 +540,8 @@ static int max6639_probe_child_from_dt(struct i2c_client *client,
|
||||
|
||||
err = of_property_read_u32(child, "pulses-per-revolution", &val);
|
||||
if (!err) {
|
||||
if (val < 1 || val > 5) {
|
||||
dev_err(dev, "invalid pulses-per-revolution %d of %pOFn\n", val, child);
|
||||
if (val < 1 || val > 4) {
|
||||
dev_err(dev, "invalid pulses-per-revolution %u of %pOFn\n", val, child);
|
||||
return -EINVAL;
|
||||
}
|
||||
data->ppr[i] = val;
|
||||
|
||||
@@ -58,6 +58,8 @@ static int hac300s_read_word_data(struct i2c_client *client, int page,
|
||||
case PMBUS_MFR_VOUT_MIN:
|
||||
case PMBUS_READ_VOUT:
|
||||
rv = pmbus_read_word_data(client, page, phase, reg);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
return FIELD_GET(LINEAR11_MANTISSA_MASK, rv);
|
||||
default:
|
||||
return -ENODATA;
|
||||
|
||||
@@ -67,6 +67,8 @@ static int ina233_read_word_data(struct i2c_client *client, int page,
|
||||
switch (reg) {
|
||||
case PMBUS_VIRT_READ_VMON:
|
||||
ret = pmbus_read_word_data(client, 0, 0xff, MFR_READ_VSHUNT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Adjust returned value to match VIN coefficients */
|
||||
/* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */
|
||||
|
||||
@@ -98,8 +98,11 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
|
||||
{
|
||||
int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
(val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS ? 1 : 0);
|
||||
if (val < 0)
|
||||
return val;
|
||||
|
||||
return sysfs_emit(buf, "%d\n",
|
||||
(val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS);
|
||||
}
|
||||
|
||||
static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,
|
||||
|
||||
@@ -165,7 +165,7 @@ static int mp2869_read_byte_data(struct i2c_client *client, int page, int reg)
|
||||
{
|
||||
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
|
||||
struct mp2869_data *data = to_mp2869_data(info);
|
||||
int ret;
|
||||
int ret, mfr;
|
||||
|
||||
switch (reg) {
|
||||
case PMBUS_VOUT_MODE:
|
||||
@@ -188,11 +188,14 @@ static int mp2869_read_byte_data(struct i2c_client *client, int page, int reg)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mfr = pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC);
|
||||
if (mfr < 0)
|
||||
return mfr;
|
||||
|
||||
ret = (ret & ~GENMASK(2, 2)) |
|
||||
FIELD_PREP(GENMASK(2, 2),
|
||||
FIELD_GET(GENMASK(1, 1),
|
||||
pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC)));
|
||||
FIELD_GET(GENMASK(1, 1), mfr));
|
||||
break;
|
||||
case PMBUS_STATUS_TEMPERATURE:
|
||||
/*
|
||||
@@ -207,15 +210,16 @@ static int mp2869_read_byte_data(struct i2c_client *client, int page, int reg)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mfr = pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC);
|
||||
if (mfr < 0)
|
||||
return mfr;
|
||||
|
||||
ret = (ret & ~GENMASK(7, 6)) |
|
||||
FIELD_PREP(GENMASK(6, 6),
|
||||
FIELD_GET(GENMASK(1, 1),
|
||||
pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC))) |
|
||||
FIELD_GET(GENMASK(1, 1), mfr)) |
|
||||
FIELD_PREP(GENMASK(7, 7),
|
||||
FIELD_GET(GENMASK(1, 1),
|
||||
pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC)));
|
||||
FIELD_GET(GENMASK(1, 1), mfr));
|
||||
break;
|
||||
default:
|
||||
ret = -ENODATA;
|
||||
@@ -230,7 +234,7 @@ static int mp2869_read_word_data(struct i2c_client *client, int page, int phase,
|
||||
{
|
||||
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
|
||||
struct mp2869_data *data = to_mp2869_data(info);
|
||||
int ret;
|
||||
int ret, mfr;
|
||||
|
||||
switch (reg) {
|
||||
case PMBUS_STATUS_WORD:
|
||||
@@ -246,11 +250,14 @@ static int mp2869_read_word_data(struct i2c_client *client, int page, int phase,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mfr = pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC);
|
||||
if (mfr < 0)
|
||||
return mfr;
|
||||
|
||||
ret = (ret & ~GENMASK(2, 2)) |
|
||||
FIELD_PREP(GENMASK(2, 2),
|
||||
FIELD_GET(GENMASK(1, 1),
|
||||
pmbus_read_byte_data(client, page,
|
||||
PMBUS_STATUS_MFR_SPECIFIC)));
|
||||
FIELD_GET(GENMASK(1, 1), mfr));
|
||||
break;
|
||||
case PMBUS_READ_VIN:
|
||||
/*
|
||||
|
||||
@@ -313,6 +313,8 @@ static int mp2973_read_word_data(struct i2c_client *client, int page,
|
||||
case PMBUS_STATUS_WORD:
|
||||
/* MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. */
|
||||
ret = pmbus_read_word_data(client, page, phase, reg);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret ^= PB_STATUS_POWER_GOOD_N;
|
||||
break;
|
||||
case PMBUS_OT_FAULT_LIMIT:
|
||||
|
||||
Reference in New Issue
Block a user