Skip to content

Commit

Permalink
spmi: pmic-arb: Always allocate ppid_to_apid table
Browse files Browse the repository at this point in the history
After commit 7f1d4e5 ("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 <[email protected]>
Cc: Kiran Gunda <[email protected]>
Fixes: 7f1d4e5 ("spmi: pmic-arb: optimize table lookups")
Signed-off-by: Stephen Boyd <[email protected]>
Tested-by: Luca Weiss <[email protected]>
Reviewed-by: Kiran Gunda <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bebarino authored and gregkh committed Jul 17, 2017
1 parent 6b71016 commit eba9718
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions drivers/spmi/spmi-pmic-arb.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ struct apid_data {
* @spmic: SPMI controller object
* @ver_ops: version dependent operations.
* @ppid_to_apid in-memory copy of PPID -> channel (APID) mapping table.
* v2 only.
*/
struct spmi_pmic_arb {
void __iomem *rd_base;
Expand Down Expand Up @@ -1016,6 +1015,13 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
goto err_put_ctrl;
}

pa->ppid_to_apid = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PPID,
sizeof(*pa->ppid_to_apid), GFP_KERNEL);
if (!pa->ppid_to_apid) {
err = -ENOMEM;
goto err_put_ctrl;
}

hw_ver = readl_relaxed(core + PMIC_ARB_VERSION);

if (hw_ver < PMIC_ARB_VERSION_V2_MIN) {
Expand Down Expand Up @@ -1048,15 +1054,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
err = PTR_ERR(pa->wr_base);
goto err_put_ctrl;
}

pa->ppid_to_apid = devm_kcalloc(&ctrl->dev,
PMIC_ARB_MAX_PPID,
sizeof(*pa->ppid_to_apid),
GFP_KERNEL);
if (!pa->ppid_to_apid) {
err = -ENOMEM;
goto err_put_ctrl;
}
}

dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n",
Expand Down

0 comments on commit eba9718

Please sign in to comment.