aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2017-06-26 22:17:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-17 09:00:47 -0400
commiteba9718ed25b2f8a3c066bf985edd5046485a018 (patch)
tree0b33424797c6bdefb02e846490518004e9d37664
parent6b71016e4b253172545e8388ff646f0dcbda18a8 (diff)
spmi: pmic-arb: Always allocate ppid_to_apid table
After commit 7f1d4e58dabb ("spmi: pmic-arb: optimize table lookups") we always need the ppid_to_apid table regardless of the version of pmic arbiter we have. Otherwise, we will try to deref the array when we don't allocate it on v2 hardware like the msm8974 SoCs. Cc: Abhijeet Dharmapurikar <adharmap@codeaurora.org> Cc: Kiran Gunda <kgunda@codeaurora.org> Fixes: 7f1d4e58dabb ("spmi: pmic-arb: optimize table lookups") Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Tested-by: Luca Weiss <luca@z3ntu.xyz> Reviewed-by: Kiran Gunda <kgunda@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/spmi/spmi-pmic-arb.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 2afe3597982e..f4b7a98a7913 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -134,7 +134,6 @@ struct apid_data {
134 * @spmic: SPMI controller object 134 * @spmic: SPMI controller object
135 * @ver_ops: version dependent operations. 135 * @ver_ops: version dependent operations.
136 * @ppid_to_apid in-memory copy of PPID -> channel (APID) mapping table. 136 * @ppid_to_apid in-memory copy of PPID -> channel (APID) mapping table.
137 * v2 only.
138 */ 137 */
139struct spmi_pmic_arb { 138struct spmi_pmic_arb {
140 void __iomem *rd_base; 139 void __iomem *rd_base;
@@ -1016,6 +1015,13 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
1016 goto err_put_ctrl; 1015 goto err_put_ctrl;
1017 } 1016 }
1018 1017
1018 pa->ppid_to_apid = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PPID,
1019 sizeof(*pa->ppid_to_apid), GFP_KERNEL);
1020 if (!pa->ppid_to_apid) {
1021 err = -ENOMEM;
1022 goto err_put_ctrl;
1023 }
1024
1019 hw_ver = readl_relaxed(core + PMIC_ARB_VERSION); 1025 hw_ver = readl_relaxed(core + PMIC_ARB_VERSION);
1020 1026
1021 if (hw_ver < PMIC_ARB_VERSION_V2_MIN) { 1027 if (hw_ver < PMIC_ARB_VERSION_V2_MIN) {
@@ -1048,15 +1054,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
1048 err = PTR_ERR(pa->wr_base); 1054 err = PTR_ERR(pa->wr_base);
1049 goto err_put_ctrl; 1055 goto err_put_ctrl;
1050 } 1056 }
1051
1052 pa->ppid_to_apid = devm_kcalloc(&ctrl->dev,
1053 PMIC_ARB_MAX_PPID,
1054 sizeof(*pa->ppid_to_apid),
1055 GFP_KERNEL);
1056 if (!pa->ppid_to_apid) {
1057 err = -ENOMEM;
1058 goto err_put_ctrl;
1059 }
1060 } 1057 }
1061 1058
1062 dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n", 1059 dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n",