From 2c6e82051682b5ad3bf4bb8bebb4b07a6a2f54b8 Mon Sep 17 00:00:00 2001 From: Yimin Peng Date: Thu, 1 Mar 2018 19:43:04 +0800 Subject: [PATCH] spmi: msm: correct len part in formatted cmd value. When the bytes count required by SPMI clients is 8, read and write fail. This was observed when PMIC MPPs initialized. Fix this by adding bytes count restore in cmd formation as read and write process. Change-Id: I56dbbc0b8e99727c29ddae568ce6f17195888b4a Signed-off-by: Yimin Peng --- drivers/spmi/virtspmi-pmic-arb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/spmi/virtspmi-pmic-arb.c b/drivers/spmi/virtspmi-pmic-arb.c index 59fc76149ba0..26994bed6025 100644 --- a/drivers/spmi/virtspmi-pmic-arb.c +++ b/drivers/spmi/virtspmi-pmic-arb.c @@ -183,7 +183,7 @@ static int vspmi_pmic_arb_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid, { struct vspmi_pmic_arb *pa = spmi_controller_get_drvdata(ctrl); unsigned long flags; - u8 bc = len; + u8 bc = len - 1; u32 cmd; int rc; @@ -228,7 +228,7 @@ static int vspmi_pmic_arb_write_cmd(struct spmi_controller *ctrl, u8 opc, { struct vspmi_pmic_arb *pa = spmi_controller_get_drvdata(ctrl); unsigned long flags; - u8 bc = len; + u8 bc = len - 1; u32 cmd; int rc; @@ -270,7 +270,8 @@ static int vspmi_pmic_arb_write_cmd(struct spmi_controller *ctrl, u8 opc, static u32 vspmi_pmic_arb_fmt_cmd_v1(u8 opc, u8 sid, u16 addr, u8 bc) { - return (opc << 27) | ((sid & 0xf) << 20) | (addr << 4) | (bc & 0x7); + return (opc << 27) | ((sid & 0xf) << 20) | (addr << 4) | + ((bc & 0x7) + 1); } static const struct vspmi_backend_driver_ver_ops pmic_arb_v1 = {