pwm: sti: Avoid conditional gotos
Using gotos for conditional code complicates this code significantly. Convert the code to simple conditional blocks to increase readability. Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
97960addcd
commit
fd3ae02bb6
|
@ -590,38 +590,34 @@ static int sti_pwm_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!cdata->pwm_num_devs)
|
||||
goto skip_pwm;
|
||||
if (cdata->pwm_num_devs) {
|
||||
pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm");
|
||||
if (IS_ERR(pc->pwm_clk)) {
|
||||
dev_err(dev, "failed to get PWM clock\n");
|
||||
return PTR_ERR(pc->pwm_clk);
|
||||
}
|
||||
|
||||
pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm");
|
||||
if (IS_ERR(pc->pwm_clk)) {
|
||||
dev_err(dev, "failed to get PWM clock\n");
|
||||
return PTR_ERR(pc->pwm_clk);
|
||||
ret = clk_prepare(pc->pwm_clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to prepare clock\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = clk_prepare(pc->pwm_clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to prepare clock\n");
|
||||
return ret;
|
||||
if (cdata->cpt_num_devs) {
|
||||
pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
|
||||
if (IS_ERR(pc->cpt_clk)) {
|
||||
dev_err(dev, "failed to get PWM capture clock\n");
|
||||
return PTR_ERR(pc->cpt_clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare(pc->cpt_clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to prepare clock\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
skip_pwm:
|
||||
if (!cdata->cpt_num_devs)
|
||||
goto skip_cpt;
|
||||
|
||||
pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
|
||||
if (IS_ERR(pc->cpt_clk)) {
|
||||
dev_err(dev, "failed to get PWM capture clock\n");
|
||||
return PTR_ERR(pc->cpt_clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare(pc->cpt_clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to prepare clock\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
skip_cpt:
|
||||
pc->chip.dev = dev;
|
||||
pc->chip.ops = &sti_pwm_ops;
|
||||
pc->chip.base = -1;
|
||||
|
|
Loading…
Reference in New Issue