Skip to content

Commit

Permalink
Input: bcm-keypad - simplify with dev_err_probe()
Browse files Browse the repository at this point in the history
Common pattern of handling deferred probe can be simplified with
dev_err_probe() and devm_clk_get_optional().  Less code and the error
value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230625162817.100397-23-krzysztof.kozlowski@linaro.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Krzysztof Kozlowski authored and Dmitry Torokhov committed Jul 7, 2023
1 parent 337ac36 commit a2c795b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/input/keyboard/bcm-keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,11 @@ static int bcm_kp_probe(struct platform_device *pdev)
return PTR_ERR(kp->base);

/* Enable clock */
kp->clk = devm_clk_get(&pdev->dev, "peri_clk");
kp->clk = devm_clk_get_optional(&pdev->dev, "peri_clk");
if (IS_ERR(kp->clk)) {
error = PTR_ERR(kp->clk);
if (error != -ENOENT) {
if (error != -EPROBE_DEFER)
dev_err(&pdev->dev, "Failed to get clock\n");
return error;
}
dev_dbg(&pdev->dev,
"No clock specified. Assuming it's enabled\n");
kp->clk = NULL;
return dev_err_probe(&pdev->dev, error, "Failed to get clock\n");
} else if (!kp->clk) {
dev_dbg(&pdev->dev, "No clock specified. Assuming it's enabled\n");
} else {
unsigned int desired_rate;
long actual_rate;
Expand Down

0 comments on commit a2c795b

Please sign in to comment.