Skip to content

Commit

Permalink
Revert "ASoC: mediatek: Check for error clk pointer"
Browse files Browse the repository at this point in the history
This reverts commit d491a2c which is
commit 9de2b92 upstream

With this patch in the tree, Chromebooks running the affected hardware
no longer boot. Bisect points to this patch, and reverting it fixes
the problem.

An analysis of the code with this patch applied shows:

        ret = init_clks(pdev, clk);
        if (ret)
                return ERR_PTR(ret);
...
                for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) {
                        struct clk *c = clk[data->clk_id[j]];

                        if (IS_ERR(c)) {
                                dev_err(&pdev->dev, "%s: clk unavailable\n",
                                        data->name);
                                return ERR_CAST(c);
                        }

                        scpd->clk[j] = c;
                }

Not all clocks in the clk_names array have to be present. Only the clocks
in the data->clk_id array are actually needed. The code already checks if
the required clocks are available and bails out if not. The assumption that
all clocks have to be present is wrong, and commit 9de2b92 needs to be
reverted.

Fixes: 9de2b92 ("ASoC: mediatek: Check for error clk pointer")
Cc: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: Mark Brown <broonie@kernel.org>
Cc: James Liao <jamesjj.liao@mediatek.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com
Cc: Frank Wunderlich <frank-w@public-files.de>
Cc: Daniel Golle <daniel@makrotopia.org>
Link: https://lore.kernel.org/lkml/20220205014755.699603-1-linux@roeck-us.net/
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
groeck authored and gregkh committed Feb 8, 2022
1 parent 4a9bd1e commit 080f371
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions drivers/soc/mediatek/mtk-scpsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,12 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
return ret;
}

static int init_clks(struct platform_device *pdev, struct clk **clk)
static void init_clks(struct platform_device *pdev, struct clk **clk)
{
int i;

for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
for (i = CLK_NONE + 1; i < CLK_MAX; i++)
clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
if (IS_ERR(clk[i]))
return PTR_ERR(clk[i]);
}

return 0;
}

static struct scp *init_scp(struct platform_device *pdev,
Expand All @@ -431,7 +426,7 @@ static struct scp *init_scp(struct platform_device *pdev,
{
struct genpd_onecell_data *pd_data;
struct resource *res;
int i, j, ret;
int i, j;
struct scp *scp;
struct clk *clk[CLK_MAX];

Expand Down Expand Up @@ -486,9 +481,7 @@ static struct scp *init_scp(struct platform_device *pdev,

pd_data->num_domains = num;

ret = init_clks(pdev, clk);
if (ret)
return ERR_PTR(ret);
init_clks(pdev, clk);

for (i = 0; i < num; i++) {
struct scp_domain *scpd = &scp->domains[i];
Expand Down

0 comments on commit 080f371

Please sign in to comment.