Skip to content

Commit 5182176

Browse files
AngeloGioacchino Del Regnobebarino
authored andcommitted
clk: mediatek: clk-mtk: Grab iomem pointer for divider clocks
In the rare case in which one of the clock drivers has divider clocks but not composite clocks, mtk_clk_simple_probe() would not io(re)map, hence passing a NULL pointer to mtk_clk_register_dividers(). To fix this issue, extend the `if` conditional to also check if any divider clocks are present. While at it, also make sure the iomem pointer is NULL if no composite/divider clocks are declared, as we are checking for that when iounmapping it in the error path. This hasn't been seen on any MediaTek clock driver as the current ones always declare composite clocks along with divider clocks, but this is still an important fix for a future potential KP. Fixes: 1fe074b ("clk: mediatek: Add divider clocks to mtk_clk_simple_{probe,remove}()") Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Chen-Yu Tsai <[email protected]> Reviewed-by: Markus Schneider-Pargmann <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 3db7285 commit 5182176

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/clk/mediatek/clk-mtk.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
469469
const struct platform_device_id *id;
470470
const struct mtk_clk_desc *mcd;
471471
struct clk_hw_onecell_data *clk_data;
472-
void __iomem *base;
472+
void __iomem *base = NULL;
473473
int num_clks, r;
474474

475475
mcd = device_get_match_data(&pdev->dev);
@@ -483,8 +483,8 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
483483
return -EINVAL;
484484
}
485485

486-
/* Composite clocks needs us to pass iomem pointer */
487-
if (mcd->composite_clks) {
486+
/* Composite and divider clocks needs us to pass iomem pointer */
487+
if (mcd->composite_clks || mcd->divider_clks) {
488488
if (!mcd->shared_io)
489489
base = devm_platform_ioremap_resource(pdev, 0);
490490
else

0 commit comments

Comments
 (0)