bus: mhi: host: Use ERANGE for BHIOFF/BHIEOFF range check
authorJeffrey Hugo <quic_jhugo@quicinc.com>
Fri, 24 Mar 2023 16:21:00 +0000 (10:21 -0600)
committerManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Mon, 3 Apr 2023 05:18:17 +0000 (10:48 +0530)
If the BHIOFF or BHIEOFF range checks fail, they return EINVAL.  ERANGE
is a better error code since it implies an out of range condition.

Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/1679674860-28229-1-git-send-email-quic_jhugo@quicinc.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
drivers/bus/mhi/host/init.c

index b46a082..f72fcb6 100644 (file)
@@ -1112,7 +1112,7 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
        if (bhi_off >= mhi_cntrl->reg_len) {
                dev_err(dev, "BHI offset: 0x%x is out of range: 0x%zx\n",
                        bhi_off, mhi_cntrl->reg_len);
-               ret = -EINVAL;
+               ret = -ERANGE;
                goto error_reg_offset;
        }
        mhi_cntrl->bhi = mhi_cntrl->regs + bhi_off;
@@ -1129,7 +1129,7 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
                        dev_err(dev,
                                "BHIe offset: 0x%x is out of range: 0x%zx\n",
                                bhie_off, mhi_cntrl->reg_len);
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                        goto error_reg_offset;
                }
                mhi_cntrl->bhie = mhi_cntrl->regs + bhie_off;