]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: spmi: hisi-spmi-controller: fix the dev_foo() logic
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 17 Aug 2020 07:10:27 +0000 (09:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Aug 2020 14:15:23 +0000 (16:15 +0200)
Right now, driver is printing some messages as:

[   33.833026] (NULL device *): spmi_read_cmd: id:0 addr:0x17, read value: 00

This is because dev_foo() are not using a device with a name
set. Change the logic for it to print it right.

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

index e996114bc71777c4c0ec047368f83c7eec3ed41f..153bcdb0cde4032f4636d8a6dc216492119c4acb 100644 (file)
@@ -102,7 +102,8 @@ struct spmi_controller_dev {
        u32                     channel;
 };
 
-static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev,
+static int spmi_controller_wait_for_done(struct device *dev,
+                                        struct spmi_controller_dev *ctrl_dev,
                                         void __iomem *base, u8 sid, u16 addr)
 {
        u32 status = 0;
@@ -117,19 +118,17 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev,
 
                if (status & SPMI_APB_TRANS_DONE) {
                        if (status & SPMI_APB_TRANS_FAIL) {
-                               dev_err(ctrl_dev->dev,
-                                       "%s: transaction failed (0x%x)\n",
+                               dev_err(dev, "%s: transaction failed (0x%x)\n",
                                        __func__, status);
                                return -EIO;
                        }
+                       dev_dbg(dev, "%s: status 0x%x\n", __func__, status);
                        return 0;
                }
                udelay(1);
        }
 
-       dev_err(ctrl_dev->dev,
-               "%s: timeout, status 0x%x\n",
-               __func__, status);
+       dev_err(dev, "%s: timeout, status 0x%x\n", __func__, status);
        return -ETIMEDOUT;
 }
 
@@ -145,9 +144,9 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
        u8 op_code, i;
 
        if (bc > SPMI_CONTROLLER_MAX_TRANS_BYTES) {
-               dev_err(spmi_controller->dev
-               , "spmi_controller supports 1..%d bytes per trans, but:%ld requested"
-                                       , SPMI_CONTROLLER_MAX_TRANS_BYTES, bc);
+               dev_err(&ctrl->dev,
+                       "spmi_controller supports 1..%d bytes per trans, but:%ld requested",
+                       SPMI_CONTROLLER_MAX_TRANS_BYTES, bc);
                return  -EINVAL;
        }
 
@@ -159,7 +158,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
        } else if (opc == SPMI_CMD_EXT_READL) {
                op_code = SPMI_CMD_EXT_REG_READ_L;
        } else {
-               dev_err(spmi_controller->dev, "invalid read cmd 0x%x", opc);
+               dev_err(&ctrl->dev, "invalid read cmd 0x%x", opc);
                return -EINVAL;
        }
 
@@ -173,7 +172,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
 
        writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR);
 
-       rc = spmi_controller_wait_for_done(spmi_controller,
+       rc = spmi_controller_wait_for_done(&ctrl->dev, spmi_controller,
                                           spmi_controller->base, sid, addr);
        if (rc)
                goto done;
@@ -195,10 +194,11 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
 done:
        spin_unlock_irqrestore(&spmi_controller->lock, flags);
        if (rc)
-               dev_err(spmi_controller->dev, "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n",
+               dev_err(&ctrl->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",
+               dev_dbg(&ctrl->dev, "%s: id:%d addr:0x%x, read value: %*ph\n",
                        __func__, sid, addr, (int)bc, __buf);
 
        return rc;
@@ -216,9 +216,9 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
        u8 op_code, i;
 
        if (bc > SPMI_CONTROLLER_MAX_TRANS_BYTES) {
-               dev_err(spmi_controller->dev
-               , "spmi_controller supports 1..%d bytes per trans, but:%ld requested"
-                                       , SPMI_CONTROLLER_MAX_TRANS_BYTES, bc);
+               dev_err(&ctrl->dev,
+                       "spmi_controller supports 1..%d bytes per trans, but:%ld requested",
+                       SPMI_CONTROLLER_MAX_TRANS_BYTES, bc);
                return  -EINVAL;
        }
 
@@ -230,7 +230,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
        } else if (opc == SPMI_CMD_EXT_WRITEL) {
                op_code = SPMI_CMD_EXT_REG_WRITE_L;
        } else {
-               dev_err(spmi_controller->dev, "invalid write cmd 0x%x", opc);
+               dev_err(&ctrl->dev, "invalid write cmd 0x%x", opc);
                return -EINVAL;
        }
 
@@ -262,14 +262,15 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
        /* Start the transaction */
        writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR);
 
-       rc = spmi_controller_wait_for_done(spmi_controller, spmi_controller->base, sid, addr);
+       rc = spmi_controller_wait_for_done(&ctrl->dev, spmi_controller,
+                                          spmi_controller->base, sid, addr);
        spin_unlock_irqrestore(&spmi_controller->lock, flags);
 
        if (rc)
-               dev_err(spmi_controller->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n",
+               dev_err(&ctrl->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",
+               dev_dbg(&ctrl->dev, "%s: id:%d addr:0x%x, wrote value: %*ph\n",
                        __func__, sid, addr, (int)bc, __buf);
 
        return rc;