* [PATCH v2] Input: bcm-keypad - Simplify with dev_err_probe()
@ 2020-08-26 20:04 Krzysztof Kozlowski
2020-08-27 9:04 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-26 20:04 UTC (permalink / raw)
To: Dmitry Torokhov, Hans de Goede, Krzysztof Kozlowski, linux-input,
linux-kernel
Cc: Andy Shevchenko
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 <krzk@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
Changes since v1:
1. Use also devm_clk_get_optional()
---
drivers/input/keyboard/bcm-keypad.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c
index 2b771c3a5578..23e11b4efd13 100644
--- a/drivers/input/keyboard/bcm-keypad.c
+++ b/drivers/input/keyboard/bcm-keypad.c
@@ -376,17 +376,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;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Input: bcm-keypad - Simplify with dev_err_probe()
2020-08-26 20:04 [PATCH v2] Input: bcm-keypad - Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2020-08-27 9:04 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-08-27 9:04 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Dmitry Torokhov, Hans de Goede, linux-input,
Linux Kernel Mailing List
On Wed, Aug 26, 2020 at 11:04 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> 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.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>
> ---
>
> Changes since v1:
> 1. Use also devm_clk_get_optional()
> ---
> drivers/input/keyboard/bcm-keypad.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c
> index 2b771c3a5578..23e11b4efd13 100644
> --- a/drivers/input/keyboard/bcm-keypad.c
> +++ b/drivers/input/keyboard/bcm-keypad.c
> @@ -376,17 +376,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;
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-27 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-26 20:04 [PATCH v2] Input: bcm-keypad - Simplify with dev_err_probe() Krzysztof Kozlowski
2020-08-27 9:04 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).