spmi: pmic-arb: fix memory allocation for mapping_table
Allocate the correct memory size (max_pmic_peripherals) for the mapping_table that holds the apid to ppid mapping. Also use a local variable for mapping_table for better alignment of the code. Fixes: 987a9f128b8a ("spmi: pmic-arb: Support more than 128 peripherals") Signed-off-by: Kiran Gunda <kgunda@codeaurora.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
325255bc95
commit
4788e613a6
@ -929,6 +929,7 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
|
|||||||
struct spmi_controller *ctrl;
|
struct spmi_controller *ctrl;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
void __iomem *core;
|
void __iomem *core;
|
||||||
|
u32 *mapping_table;
|
||||||
u32 channel, ee, hw_ver;
|
u32 channel, ee, hw_ver;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -1038,16 +1039,14 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pmic_arb->ee = ee;
|
pmic_arb->ee = ee;
|
||||||
|
mapping_table = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PERIPHS,
|
||||||
pmic_arb->mapping_table = devm_kcalloc(&ctrl->dev,
|
sizeof(*mapping_table), GFP_KERNEL);
|
||||||
PMIC_ARB_MAX_PERIPHS - 1,
|
if (!mapping_table) {
|
||||||
sizeof(*pmic_arb->mapping_table),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!pmic_arb->mapping_table) {
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err_put_ctrl;
|
goto err_put_ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pmic_arb->mapping_table = mapping_table;
|
||||||
/* Initialize max_apid/min_apid to the opposite bounds, during
|
/* Initialize max_apid/min_apid to the opposite bounds, during
|
||||||
* the irq domain translation, we are sure to update these */
|
* the irq domain translation, we are sure to update these */
|
||||||
pmic_arb->max_apid = 0;
|
pmic_arb->max_apid = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user