summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@intel.com>2022-01-29 02:16:19 +0300
committerjmbills <jasonm.bills@yahoo.com>2022-02-01 00:13:53 +0300
commitb7504577edef85b5a7b2120d7ce81c8a933163f3 (patch)
treec76148f8cf8f1ecb9607d170f43523c1bb803524
parent2797f889860a4bb2cd9fb19b74b5828477eaadb9 (diff)
downloadlinux-b7504577edef85b5a7b2120d7ce81c8a933163f3.tar.xz
intel-peci-client: Use wr_pkg_cfg struct for write command
The write command is incorrectly using the rd_pkg_cfg struct for the PECI command data, which could introduce issues if the structs change in the future. This fixes the write command and the callers (only peci-hwmon.h found using grep) to send the data as a u32 and use the wr_pkg_cfg struct. Tested: Wrote the /sys/class/hwmon/hwmon13/power1_cap attribute which triggers a write command and confirmed that the data written is the same after this change. Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
-rw-r--r--drivers/hwmon/peci-hwmon.h6
-rw-r--r--include/linux/mfd/intel-peci-client.h10
2 files changed, 6 insertions, 10 deletions
diff --git a/drivers/hwmon/peci-hwmon.h b/drivers/hwmon/peci-hwmon.h
index a3cb2fdcf8b7..918bbec03a92 100644
--- a/drivers/hwmon/peci-hwmon.h
+++ b/drivers/hwmon/peci-hwmon.h
@@ -429,13 +429,9 @@ static inline int peci_pcs_read(struct peci_client_manager *peci_mgr, u8 index,
static inline int peci_pcs_write(struct peci_client_manager *peci_mgr, u8 index,
u16 parameter, u32 reg)
{
- u32 pcs_reg;
int ret;
- pcs_reg = cpu_to_le32p(&reg);
-
- ret = peci_client_write_package_config(peci_mgr, index, parameter,
- (u8 *)&pcs_reg);
+ ret = peci_client_write_package_config(peci_mgr, index, parameter, reg);
return ret;
}
diff --git a/include/linux/mfd/intel-peci-client.h b/include/linux/mfd/intel-peci-client.h
index 55dec5be3245..31b869e058b7 100644
--- a/include/linux/mfd/intel-peci-client.h
+++ b/include/linux/mfd/intel-peci-client.h
@@ -131,23 +131,23 @@ peci_client_read_package_config(struct peci_client_manager *priv,
* @priv: driver private data structure
* @index: encoding index for the requested service
* @param: parameter to specify the exact data being requested
- * @data: data buffer with values to write
+ * @data: data to write
* Context: can sleep
*
* Return: zero on success, else a negative error code.
*/
static inline int
peci_client_write_package_config(struct peci_client_manager *priv,
- u8 index, u16 param, u8 *data)
+ u8 index, u16 param, u32 data)
{
- struct peci_rd_pkg_cfg_msg msg;
+ struct peci_wr_pkg_cfg_msg msg;
int ret;
msg.addr = priv->client->addr;
msg.index = index;
msg.param = param;
- msg.rx_len = 4u;
- memcpy(msg.pkg_config, data, msg.rx_len);
+ msg.tx_len = 4u;
+ msg.value = data;
ret = peci_command(priv->client->adapter, PECI_CMD_WR_PKG_CFG, &msg);
if (!ret) {