Skip to content

Commit b41ccc3

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: meson: Simplify using dev_err_probe()
Using dev_err_probe() emitting an error message mentioning a return value and returning that value can be done in a single statement. Make use of that to simplify the probe part of the driver. This has the additional advantage to emit the symbolic name for the error instead of the integer error value. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent d9eb24c commit b41ccc3

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

drivers/pwm/pwm-meson.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,9 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
468468
channel->mux.hw.init = &init;
469469

470470
err = devm_clk_hw_register(dev, &channel->mux.hw);
471-
if (err) {
472-
dev_err(dev, "failed to register %s: %d\n", name, err);
473-
return err;
474-
}
471+
if (err)
472+
return dev_err_probe(dev, err,
473+
"failed to register %s\n", name);
475474

476475
snprintf(name, sizeof(name), "%s#div%u", dev_name(dev), i);
477476

@@ -491,10 +490,9 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
491490
channel->div.lock = &meson->lock;
492491

493492
err = devm_clk_hw_register(dev, &channel->div.hw);
494-
if (err) {
495-
dev_err(dev, "failed to register %s: %d\n", name, err);
496-
return err;
497-
}
493+
if (err)
494+
return dev_err_probe(dev, err,
495+
"failed to register %s\n", name);
498496

499497
snprintf(name, sizeof(name), "%s#gate%u", dev_name(dev), i);
500498

@@ -513,17 +511,13 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
513511
channel->gate.lock = &meson->lock;
514512

515513
err = devm_clk_hw_register(dev, &channel->gate.hw);
516-
if (err) {
517-
dev_err(dev, "failed to register %s: %d\n", name, err);
518-
return err;
519-
}
514+
if (err)
515+
return dev_err_probe(dev, err, "failed to register %s\n", name);
520516

521517
channel->clk = devm_clk_hw_get_clk(dev, &channel->gate.hw, NULL);
522-
if (IS_ERR(channel->clk)) {
523-
err = PTR_ERR(channel->clk);
524-
dev_err(dev, "failed to register %s: %d\n", name, err);
525-
return err;
526-
}
518+
if (IS_ERR(channel->clk))
519+
return dev_err_probe(dev, PTR_ERR(channel->clk),
520+
"failed to register %s\n", name);
527521
}
528522

529523
return 0;
@@ -554,10 +548,9 @@ static int meson_pwm_probe(struct platform_device *pdev)
554548
return err;
555549

556550
err = devm_pwmchip_add(&pdev->dev, &meson->chip);
557-
if (err < 0) {
558-
dev_err(&pdev->dev, "failed to register PWM chip: %d\n", err);
559-
return err;
560-
}
551+
if (err < 0)
552+
return dev_err_probe(&pdev->dev, err,
553+
"failed to register PWM chip\n");
561554

562555
return 0;
563556
}

0 commit comments

Comments
 (0)