Skip to content

Commit

Permalink
pwm: meson: Use devm_clk_get_optional() to get the input clock
Browse files Browse the repository at this point in the history
Simplify the code which fetches the input clock for a PWM channel by
using devm_clk_get_optional().
This comes with a small functional change: previously all errors except
EPROBE_DEFER were ignored. Now all other errors are also treated as
errors. If no input clock is present devm_clk_get_optional() will return
NULL instead of an error which matches the behavior of the old code.

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Martin Blumenstingl authored and Thierry Reding committed Jun 26, 2019
1 parent 084f137 commit ba4004c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/pwm/pwm-meson.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,9 @@ static int meson_pwm_init_channels(struct meson_pwm *meson,

snprintf(name, sizeof(name), "clkin%u", i);

channel->clk_parent = devm_clk_get(dev, name);
if (IS_ERR(channel->clk_parent)) {
err = PTR_ERR(channel->clk_parent);
if (err == -EPROBE_DEFER)
return err;

channel->clk_parent = NULL;
}
channel->clk_parent = devm_clk_get_optional(dev, name);
if (IS_ERR(channel->clk_parent))
return PTR_ERR(channel->clk_parent);
}

return 0;
Expand Down

0 comments on commit ba4004c

Please sign in to comment.