staging: spmi: hisi-spmi-controller: add debug when values are read/write
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 17 Aug 2020 07:10:26 +0000 (09:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Aug 2020 14:15:23 +0000 (16:15 +0200)
It is interesting to be able to check if the driver is doing
the right thing. So, add some debug macros to allow checking it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/11dc4583c41a9c5e2804114d6a7a87374d2a23b4.1597647359.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/hikey9xx/hisi-spmi-controller.c

index cacd28150b4950f1ed81d244b922c5ab167bc73d..e996114bc71777c4c0ec047368f83c7eec3ed41f 100644 (file)
@@ -41,7 +41,6 @@
 #define SPMI_APB_SPMI_CMD_EN                           BIT(31)
 #define SPMI_APB_SPMI_CMD_TYPE_OFFSET                  24
 #define SPMI_APB_SPMI_CMD_LENGTH_OFFSET                        20
-
 #define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET               16
 #define SPMI_APB_SPMI_CMD_ADDR_OFFSET                  0
 
@@ -135,10 +134,11 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev,
 }
 
 static int spmi_read_cmd(struct spmi_controller *ctrl,
-                        u8 opc, u8 sid, u16 addr, u8 *buf, size_t bc)
+                        u8 opc, u8 sid, u16 addr, u8 *__buf, size_t bc)
 {
        struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev);
        unsigned long flags;
+       u8 *buf = __buf;
        u32 cmd, data;
        int rc;
        u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel;
@@ -197,13 +197,18 @@ done:
        if (rc)
                dev_err(spmi_controller->dev, "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n",
                        opc, sid, addr, bc + 1);
+       else
+               dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, read value: %*ph\n",
+                       __func__, sid, addr, (int)bc, __buf);
+
        return rc;
 }
 
 static int spmi_write_cmd(struct spmi_controller *ctrl,
-                         u8 opc, u8 sid, u16 addr, const u8 *buf, size_t bc)
+                         u8 opc, u8 sid, u16 addr, const u8 *__buf, size_t bc)
 {
        struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev);
+       const u8 *buf = __buf;
        unsigned long flags;
        u32 cmd, data;
        int rc;
@@ -263,6 +268,9 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
        if (rc)
                dev_err(spmi_controller->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n",
                        opc, sid, addr, bc);
+       else
+               dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, wrote value: %*ph\n",
+                       __func__, sid, addr, (int)bc, __buf);
 
        return rc;
 }
@@ -275,6 +283,7 @@ static int spmi_controller_probe(struct platform_device *pdev)
        int ret = 0;
 
        dev_info(&pdev->dev, "HISI SPMI probe\n");
+
        ctrl = spmi_controller_alloc(&pdev->dev, sizeof(*spmi_controller));
        if (!ctrl) {
                dev_err(&pdev->dev, "can not allocate spmi_controller data\n");