hwmon fixes for v5.13-rc2

Fix bugs/regressions in adm9240, ltc2992, pmbus/fsp-3y, and occ drivers,
 plus a minor cleanup in the corsair-psu driver.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmCdPtsACgkQyx8mb86f
 mYHLCBAAn2tkcLxrRYbUxi74o8Ep0y+3ropdtjZWtAukW47WrgtMMrfRRptMQwTa
 3+Cy1VPsoko6r8KybQyf0Zok+6czjl9tZyjrc8/4GpjSLP5FVzf47v1zrE5sx/vN
 mtcMhvpnQNTI1jx0I9wGI1R8dBz1NGJytMLVQgiMEcXOGw1A6WOhan/fIQgdBo5D
 84l0/jFwXytahkVCZ7TJWwUETbq0yf0GD8oCCSWCPrjCOm9Wt0QmoFhcHNEQXDud
 kr9GloUpHqpLy7TFejIiv8bXgHjOZMmVydRRT8YWKifpPPd9SJtkL83Qcyk5MNUs
 sDpwmHRmsKzUQZ29mqczC9ucHu9mc8oS8kxhlBVyPZiSSg4S6HJitzU5PSCSMigk
 MdOHxynFJJ/LLHrLAoC/dUjLWZ3kXMKTtpJh/tTEsxWMXMKYu2JsEFlXtWqGKnMq
 qbYtV1f5041gZ5awRGP0gBgKMCAu9cweFZALjrAqarygvb20dDFFBXoqYB8UEaEU
 gkuNr6LdAnO/oqnSm3s4x5jy5ahw7szcdaE/8s1PXW8LmZO2rUNInHRiqlTCwZLz
 2i74h9VQZ08sCUOCc9O37+BdZgnvVY8SWpIjMm/jwpBde/c5UH0Vqu2s/SXxofbj
 pIgL64cA2rKEBbQ20r4/sOnEXsevuz1dj3giHnJ5ai2G/C0C46E=
 =L3Ns
 -----END PGP SIGNATURE-----

Merge tag 'hwmon-for-v5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:
 "Fix bugs/regressions in adm9240, ltc2992, pmbus/fsp-3y, and occ
  drivers, plus a minor cleanup in the corsair-psu driver"

* tag 'hwmon-for-v5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (adm9240) Fix writes into inX_max attributes
  hwmon: (ltc2992) Put fwnode in error case during ->probe()
  hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E non-compliant vout encoding
  hwmon: (occ) Fix poll rate limiting
  hwmon: (corsair-psu) Remove unneeded semicolons
This commit is contained in:
Linus Torvalds 2021-05-13 09:58:53 -07:00
commit d1e7c13a9b
6 changed files with 38 additions and 10 deletions

View file

@ -485,7 +485,7 @@ static int adm9240_in_write(struct device *dev, u32 attr, int channel, long val)
reg = ADM9240_REG_IN_MIN(channel); reg = ADM9240_REG_IN_MIN(channel);
break; break;
case hwmon_in_max: case hwmon_in_max:
reg = ADM9240_REG_IN(channel); reg = ADM9240_REG_IN_MAX(channel);
break; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;

View file

@ -355,7 +355,7 @@ static umode_t corsairpsu_hwmon_power_is_visible(const struct corsairpsu_data *p
return 0444; return 0444;
default: default:
return 0; return 0;
}; }
} }
static umode_t corsairpsu_hwmon_in_is_visible(const struct corsairpsu_data *priv, u32 attr, static umode_t corsairpsu_hwmon_in_is_visible(const struct corsairpsu_data *priv, u32 attr,
@ -376,7 +376,7 @@ static umode_t corsairpsu_hwmon_in_is_visible(const struct corsairpsu_data *priv
break; break;
default: default:
break; break;
}; }
return res; return res;
} }

View file

@ -900,11 +900,15 @@ static int ltc2992_parse_dt(struct ltc2992_state *st)
fwnode_for_each_available_child_node(fwnode, child) { fwnode_for_each_available_child_node(fwnode, child) {
ret = fwnode_property_read_u32(child, "reg", &addr); ret = fwnode_property_read_u32(child, "reg", &addr);
if (ret < 0) if (ret < 0) {
fwnode_handle_put(child);
return ret; return ret;
}
if (addr > 1) if (addr > 1) {
fwnode_handle_put(child);
return -EINVAL; return -EINVAL;
}
ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val); ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val);
if (!ret) if (!ret)

View file

@ -217,9 +217,9 @@ int occ_update_response(struct occ *occ)
return rc; return rc;
/* limit the maximum rate of polling the OCC */ /* limit the maximum rate of polling the OCC */
if (time_after(jiffies, occ->last_update + OCC_UPDATE_FREQUENCY)) { if (time_after(jiffies, occ->next_update)) {
rc = occ_poll(occ); rc = occ_poll(occ);
occ->last_update = jiffies; occ->next_update = jiffies + OCC_UPDATE_FREQUENCY;
} else { } else {
rc = occ->last_error; rc = occ->last_error;
} }
@ -1165,6 +1165,7 @@ int occ_setup(struct occ *occ, const char *name)
return rc; return rc;
} }
occ->next_update = jiffies + OCC_UPDATE_FREQUENCY;
occ_parse_poll_response(occ); occ_parse_poll_response(occ);
rc = occ_setup_sensor_attrs(occ); rc = occ_setup_sensor_attrs(occ);

View file

@ -99,7 +99,7 @@ struct occ {
u8 poll_cmd_data; /* to perform OCC poll command */ u8 poll_cmd_data; /* to perform OCC poll command */
int (*send_cmd)(struct occ *occ, u8 *cmd); int (*send_cmd)(struct occ *occ, u8 *cmd);
unsigned long last_update; unsigned long next_update;
struct mutex lock; /* lock OCC access */ struct mutex lock; /* lock OCC access */
struct device *hwmon; struct device *hwmon;

View file

@ -57,7 +57,7 @@ static int page_log_to_page_real(int page_log, enum chips chip)
case YH5151E_PAGE_12V_LOG: case YH5151E_PAGE_12V_LOG:
return YH5151E_PAGE_12V_REAL; return YH5151E_PAGE_12V_REAL;
case YH5151E_PAGE_5V_LOG: case YH5151E_PAGE_5V_LOG:
return YH5151E_PAGE_5V_LOG; return YH5151E_PAGE_5V_REAL;
case YH5151E_PAGE_3V3_LOG: case YH5151E_PAGE_3V3_LOG:
return YH5151E_PAGE_3V3_REAL; return YH5151E_PAGE_3V3_REAL;
} }
@ -103,8 +103,18 @@ static int set_page(struct i2c_client *client, int page_log)
static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg) static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct fsp3y_data *data = to_fsp3y_data(info);
int rv; int rv;
/*
* YH5151-E outputs vout in linear11. The conversion is done when
* reading. Here, we have to inject pmbus_core with the correct
* exponent (it is -6).
*/
if (data->chip == yh5151e && reg == PMBUS_VOUT_MODE)
return 0x1A;
rv = set_page(client, page); rv = set_page(client, page);
if (rv < 0) if (rv < 0)
return rv; return rv;
@ -114,6 +124,8 @@ static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase, int reg) static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct fsp3y_data *data = to_fsp3y_data(info);
int rv; int rv;
/* /*
@ -144,7 +156,18 @@ static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase,
if (rv < 0) if (rv < 0)
return rv; return rv;
return i2c_smbus_read_word_data(client, reg); rv = i2c_smbus_read_word_data(client, reg);
if (rv < 0)
return rv;
/*
* YH-5151E is non-compliant and outputs output voltages in linear11
* instead of linear16.
*/
if (data->chip == yh5151e && reg == PMBUS_READ_VOUT)
rv = sign_extend32(rv, 10) & 0xffff;
return rv;
} }
static struct pmbus_driver_info fsp3y_info[] = { static struct pmbus_driver_info fsp3y_info[] = {