* [PATCH 1/3] Input: da9063 - Simplify obtaining OF match data
2023-12-11 16:57 [PATCH 0/3] Add polling support for DA9063 onkey driver Biju Das
@ 2023-12-11 16:57 ` Biju Das
2023-12-11 16:57 ` [PATCH 2/3] Input: da9063 - Use dev_err_probe() Biju Das
2023-12-11 16:57 ` [PATCH 3/3] Input: da9063 - Add polling support Biju Das
2 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2023-12-11 16:57 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Biju Das, Support Opensource, linux-input, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc
Simplify probe() by replacing of_match_node() for retrieving match data by
device_get_match_data().
Some minor cleanups:
* Remove the trailing comma in the terminator entry for the OF
table making code robust against (theoretical) misrebases or other
similar things where the new entry goes _after_ the termination without
the compiler noticing.
* Move OF table near to the user.
* Arrange variables in reverse xmas tree order in probe().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/input/misc/da9063_onkey.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c
index 74808bae326a..9351ce0bb405 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -74,13 +74,6 @@ static const struct da906x_chip_config da9062_regs = {
.name = "da9062-onkey",
};
-static const struct of_device_id da9063_compatible_reg_id_table[] = {
- { .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
- { .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
- { },
-};
-MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
-
static void da9063_poll_on(struct work_struct *work)
{
struct da9063_onkey *onkey = container_of(work,
@@ -187,14 +180,8 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
static int da9063_onkey_probe(struct platform_device *pdev)
{
struct da9063_onkey *onkey;
- const struct of_device_id *match;
- int irq;
int error;
-
- match = of_match_node(da9063_compatible_reg_id_table,
- pdev->dev.of_node);
- if (!match)
- return -ENXIO;
+ int irq;
onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey),
GFP_KERNEL);
@@ -203,7 +190,10 @@ static int da9063_onkey_probe(struct platform_device *pdev)
return -ENOMEM;
}
- onkey->config = match->data;
+ onkey->config = device_get_match_data(&pdev->dev);
+ if (!onkey->config)
+ return -ENXIO;
+
onkey->dev = &pdev->dev;
onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL);
@@ -270,6 +260,13 @@ static int da9063_onkey_probe(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id da9063_compatible_reg_id_table[] = {
+ { .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
+ { .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
+ { }
+};
+MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
+
static struct platform_driver da9063_onkey_driver = {
.probe = da9063_onkey_probe,
.driver = {
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-11 16:57 [PATCH 0/3] Add polling support for DA9063 onkey driver Biju Das
2023-12-11 16:57 ` [PATCH 1/3] Input: da9063 - Simplify obtaining OF match data Biju Das
@ 2023-12-11 16:57 ` Biju Das
2023-12-11 19:05 ` Sergey Shtylyov
2023-12-12 8:01 ` Geert Uytterhoeven
2023-12-11 16:57 ` [PATCH 3/3] Input: da9063 - Add polling support Biju Das
2 siblings, 2 replies; 12+ messages in thread
From: Biju Das @ 2023-12-11 16:57 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Biju Das, Support Opensource, linux-input, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc
Replace dev_err()->dev_err_probe() to simpilfy probe().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/input/misc/da9063_onkey.c | 46 ++++++++++++-------------------
1 file changed, 18 insertions(+), 28 deletions(-)
diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c
index 9351ce0bb405..536220662b38 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -185,10 +185,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey),
GFP_KERNEL);
- if (!onkey) {
- dev_err(&pdev->dev, "Failed to allocate memory.\n");
- return -ENOMEM;
- }
+ if (!onkey)
+ return dev_err_probe(&pdev->dev, -ENOMEM,
+ "Failed to allocate memory.\n");
onkey->config = device_get_match_data(&pdev->dev);
if (!onkey->config)
@@ -197,19 +196,17 @@ static int da9063_onkey_probe(struct platform_device *pdev)
onkey->dev = &pdev->dev;
onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL);
- if (!onkey->regmap) {
- dev_err(&pdev->dev, "Parent regmap unavailable.\n");
- return -ENXIO;
- }
+ if (!onkey->regmap)
+ return dev_err_probe(&pdev->dev, -ENXIO,
+ "Parent regmap unavailable.\n");
onkey->key_power = !of_property_read_bool(pdev->dev.of_node,
"dlg,disable-key-power");
onkey->input = devm_input_allocate_device(&pdev->dev);
- if (!onkey->input) {
- dev_err(&pdev->dev, "Failed to allocated input device.\n");
- return -ENOMEM;
- }
+ if (!onkey->input)
+ return dev_err_probe(&pdev->dev, -ENOMEM,
+ "Failed to allocated input device.\n");
onkey->input->name = onkey->config->name;
snprintf(onkey->phys, sizeof(onkey->phys), "%s/input0",
@@ -221,12 +218,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
error = devm_delayed_work_autocancel(&pdev->dev, &onkey->work,
da9063_poll_on);
- if (error) {
- dev_err(&pdev->dev,
- "Failed to add cancel poll action: %d\n",
- error);
- return error;
- }
+ if (error)
+ return dev_err_probe(&pdev->dev, error,
+ "Failed to add cancel poll action\n");
irq = platform_get_irq_byname(pdev, "ONKEY");
if (irq < 0)
@@ -236,11 +230,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
NULL, da9063_onkey_irq_handler,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"ONKEY", onkey);
- if (error) {
- dev_err(&pdev->dev,
- "Failed to request IRQ %d: %d\n", irq, error);
- return error;
- }
+ if (error)
+ return dev_err_probe(&pdev->dev, error,
+ "Failed to request IRQ %d\n", irq);
error = dev_pm_set_wake_irq(&pdev->dev, irq);
if (error)
@@ -251,11 +243,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, true);
error = input_register_device(onkey->input);
- if (error) {
- dev_err(&pdev->dev,
- "Failed to register input device: %d\n", error);
- return error;
- }
+ if (error)
+ return dev_err_probe(&pdev->dev, error,
+ "Failed to register input device\n");
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-11 16:57 ` [PATCH 2/3] Input: da9063 - Use dev_err_probe() Biju Das
@ 2023-12-11 19:05 ` Sergey Shtylyov
2023-12-11 19:07 ` Biju Das
2023-12-12 8:01 ` Geert Uytterhoeven
1 sibling, 1 reply; 12+ messages in thread
From: Sergey Shtylyov @ 2023-12-11 19:05 UTC (permalink / raw)
To: Biju Das, Dmitry Torokhov
Cc: Support Opensource, linux-input, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc
On 12/11/23 7:57 PM, Biju Das wrote:
> Replace dev_err()->dev_err_probe() to simpilfy probe().
Simplify. :-)
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-11 19:05 ` Sergey Shtylyov
@ 2023-12-11 19:07 ` Biju Das
0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2023-12-11 19:07 UTC (permalink / raw)
To: Sergey Shtylyov, Dmitry Torokhov
Cc: Support Opensource, linux-input@vger.kernel.org,
Geert Uytterhoeven, Prabhakar Mahadev Lad, biju.das.au,
linux-renesas-soc@vger.kernel.org
Hi Sergey Shtylyov,
Thanks for the feedback.
> -----Original Message-----
> From: Sergey Shtylyov <s.shtylyov@omp.ru>
> Sent: Monday, December 11, 2023 7:05 PM
> Subject: Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
>
> On 12/11/23 7:57 PM, Biju Das wrote:
>
> > Replace dev_err()->dev_err_probe() to simpilfy probe().
>
> Simplify. :-)
OK will fix it in v2.
Cheers,
Biju
>
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> [...]
>
> MBR, Sergey
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-11 16:57 ` [PATCH 2/3] Input: da9063 - Use dev_err_probe() Biju Das
2023-12-11 19:05 ` Sergey Shtylyov
@ 2023-12-12 8:01 ` Geert Uytterhoeven
2023-12-12 9:03 ` Biju Das
1 sibling, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2023-12-12 8:01 UTC (permalink / raw)
To: Biju Das
Cc: Dmitry Torokhov, Support Opensource, linux-input,
Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc
Hi Biju,
On Mon, Dec 11, 2023 at 5:57 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Replace dev_err()->dev_err_probe() to simpilfy probe().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Thanks for your patch!
> --- a/drivers/input/misc/da9063_onkey.c
> +++ b/drivers/input/misc/da9063_onkey.c
> @@ -185,10 +185,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
>
> onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey),
> GFP_KERNEL);
> - if (!onkey) {
> - dev_err(&pdev->dev, "Failed to allocate memory.\n");
> - return -ENOMEM;
> - }
> + if (!onkey)
> + return dev_err_probe(&pdev->dev, -ENOMEM,
> + "Failed to allocate memory.\n");
Please drop the error printing instead, the memory allocation core
code already takes care of that in case of OOM.
>
> onkey->config = device_get_match_data(&pdev->dev);
> if (!onkey->config)
> @@ -197,19 +196,17 @@ static int da9063_onkey_probe(struct platform_device *pdev)
> onkey->dev = &pdev->dev;
>
> onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> - if (!onkey->regmap) {
> - dev_err(&pdev->dev, "Parent regmap unavailable.\n");
> - return -ENXIO;
> - }
> + if (!onkey->regmap)
> + return dev_err_probe(&pdev->dev, -ENXIO,
> + "Parent regmap unavailable.\n");
>
> onkey->key_power = !of_property_read_bool(pdev->dev.of_node,
> "dlg,disable-key-power");
>
> onkey->input = devm_input_allocate_device(&pdev->dev);
> - if (!onkey->input) {
> - dev_err(&pdev->dev, "Failed to allocated input device.\n");
> - return -ENOMEM;
> - }
> + if (!onkey->input)
> + return dev_err_probe(&pdev->dev, -ENOMEM,
> + "Failed to allocated input device.\n");
devm_input_allocate_device() only fails on OOM, so no need to
print anything.
>
> onkey->input->name = onkey->config->name;
> snprintf(onkey->phys, sizeof(onkey->phys), "%s/input0",
> @@ -221,12 +218,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
>
> error = devm_delayed_work_autocancel(&pdev->dev, &onkey->work,
> da9063_poll_on);
> - if (error) {
> - dev_err(&pdev->dev,
> - "Failed to add cancel poll action: %d\n",
> - error);
> - return error;
> - }
> + if (error)
> + return dev_err_probe(&pdev->dev, error,
> + "Failed to add cancel poll action\n");
devm_delayed_work_autocancel() only fails on OOM, so no need to
print anything.
>
> irq = platform_get_irq_byname(pdev, "ONKEY");
> if (irq < 0)
> @@ -236,11 +230,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
> NULL, da9063_onkey_irq_handler,
> IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> "ONKEY", onkey);
> - if (error) {
> - dev_err(&pdev->dev,
> - "Failed to request IRQ %d: %d\n", irq, error);
> - return error;
> - }
> + if (error)
> + return dev_err_probe(&pdev->dev, error,
> + "Failed to request IRQ %d\n", irq);
platform_get_irq_byname() already prints an error message on failure.
>
> error = dev_pm_set_wake_irq(&pdev->dev, irq);
> if (error)
> @@ -251,11 +243,9 @@ static int da9063_onkey_probe(struct platform_device *pdev)
> device_init_wakeup(&pdev->dev, true);
>
> error = input_register_device(onkey->input);
> - if (error) {
> - dev_err(&pdev->dev,
> - "Failed to register input device: %d\n", error);
> - return error;
> - }
> + if (error)
> + return dev_err_probe(&pdev->dev, error,
> + "Failed to register input device\n");
Looks like all non-OOM failure paths in input_register_device()
already print an error message, too...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 12+ messages in thread* RE: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-12 8:01 ` Geert Uytterhoeven
@ 2023-12-12 9:03 ` Biju Das
2023-12-12 9:28 ` Geert Uytterhoeven
0 siblings, 1 reply; 12+ messages in thread
From: Biju Das @ 2023-12-12 9:03 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Dmitry Torokhov, Support Opensource, linux-input@vger.kernel.org,
Prabhakar Mahadev Lad, biju.das.au,
linux-renesas-soc@vger.kernel.org
Hi Geert,
Thanks for the feedback.
> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: Tuesday, December 12, 2023 8:02 AM
> Subject: Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
>
> Hi Biju,
>
> On Mon, Dec 11, 2023 at 5:57 PM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > Replace dev_err()->dev_err_probe() to simpilfy probe().
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>
> Thanks for your patch!
>
> > --- a/drivers/input/misc/da9063_onkey.c
> > +++ b/drivers/input/misc/da9063_onkey.c
> > @@ -185,10 +185,9 @@ static int da9063_onkey_probe(struct
> > platform_device *pdev)
> >
> > onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey),
> > GFP_KERNEL);
> > - if (!onkey) {
> > - dev_err(&pdev->dev, "Failed to allocate memory.\n");
> > - return -ENOMEM;
> > - }
> > + if (!onkey)
> > + return dev_err_probe(&pdev->dev, -ENOMEM,
> > + "Failed to allocate memory.\n");
>
> Please drop the error printing instead, the memory allocation core code
> already takes care of that in case of OOM.
OK.
>
> >
> > onkey->config = device_get_match_data(&pdev->dev);
> > if (!onkey->config)
> > @@ -197,19 +196,17 @@ static int da9063_onkey_probe(struct
> platform_device *pdev)
> > onkey->dev = &pdev->dev;
> >
> > onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> > - if (!onkey->regmap) {
> > - dev_err(&pdev->dev, "Parent regmap unavailable.\n");
> > - return -ENXIO;
> > - }
> > + if (!onkey->regmap)
> > + return dev_err_probe(&pdev->dev, -ENXIO,
> > + "Parent regmap unavailable.\n");
> >
> > onkey->key_power = !of_property_read_bool(pdev->dev.of_node,
> >
> > "dlg,disable-key-power");
> >
> > onkey->input = devm_input_allocate_device(&pdev->dev);
> > - if (!onkey->input) {
> > - dev_err(&pdev->dev, "Failed to allocated input
> device.\n");
> > - return -ENOMEM;
> > - }
> > + if (!onkey->input)
> > + return dev_err_probe(&pdev->dev, -ENOMEM,
> > + "Failed to allocated input
> > + device.\n");
>
> devm_input_allocate_device() only fails on OOM, so no need to print
> anything.
OK.
>
> >
> > onkey->input->name = onkey->config->name;
> > snprintf(onkey->phys, sizeof(onkey->phys), "%s/input0", @@
> > -221,12 +218,9 @@ static int da9063_onkey_probe(struct platform_device
> > *pdev)
> >
> > error = devm_delayed_work_autocancel(&pdev->dev, &onkey->work,
> > da9063_poll_on);
> > - if (error) {
> > - dev_err(&pdev->dev,
> > - "Failed to add cancel poll action: %d\n",
> > - error);
> > - return error;
> > - }
> > + if (error)
> > + return dev_err_probe(&pdev->dev, error,
> > + "Failed to add cancel poll
> > + action\n");
>
> devm_delayed_work_autocancel() only fails on OOM, so no need to print
> anything.
OK.
>
> >
> > irq = platform_get_irq_byname(pdev, "ONKEY");
> > if (irq < 0)
> > @@ -236,11 +230,9 @@ static int da9063_onkey_probe(struct
> platform_device *pdev)
> > NULL,
> da9063_onkey_irq_handler,
> > IRQF_TRIGGER_LOW |
> IRQF_ONESHOT,
> > "ONKEY", onkey);
> > - if (error) {
> > - dev_err(&pdev->dev,
> > - "Failed to request IRQ %d: %d\n", irq, error);
> > - return error;
> > - }
> > + if (error)
> > + return dev_err_probe(&pdev->dev, error,
> > + "Failed to request IRQ %d\n",
> > + irq);
>
> platform_get_irq_byname() already prints an error message on failure.
I will change the print message as " Failed to allocate onkey irq"??
>
> >
> > error = dev_pm_set_wake_irq(&pdev->dev, irq);
> > if (error)
> > @@ -251,11 +243,9 @@ static int da9063_onkey_probe(struct
> platform_device *pdev)
> > device_init_wakeup(&pdev->dev, true);
> >
> > error = input_register_device(onkey->input);
> > - if (error) {
> > - dev_err(&pdev->dev,
> > - "Failed to register input device: %d\n", error);
> > - return error;
> > - }
> > + if (error)
> > + return dev_err_probe(&pdev->dev, error,
> > + "Failed to register input
> > + device\n");
>
> Looks like all non-OOM failure paths in input_register_device() already
> print an error message, too...
OK, I will send
1) separate patch for dropping unneeded prints related to OOM
2) A patch for replacing dev_err()->dev_err_probe() + Update error message for devm_request_threaded_irq()
3) separate patch for dropping print message for input_register_device();
Is it ok?
Cheers,
Biju
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-12 9:03 ` Biju Das
@ 2023-12-12 9:28 ` Geert Uytterhoeven
2023-12-13 20:48 ` Dmitry Torokhov
0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2023-12-12 9:28 UTC (permalink / raw)
To: Biju Das
Cc: Dmitry Torokhov, Support Opensource, linux-input@vger.kernel.org,
Prabhakar Mahadev Lad, biju.das.au,
linux-renesas-soc@vger.kernel.org
Hi Biju,
On Tue, Dec 12, 2023 at 10:03 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > From: Geert Uytterhoeven <geert@linux-m68k.org>
> > On Mon, Dec 11, 2023 at 5:57 PM Biju Das <biju.das.jz@bp.renesas.com>
> > wrote:
> > > Replace dev_err()->dev_err_probe() to simpilfy probe().
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> OK, I will send
>
> 1) separate patch for dropping unneeded prints related to OOM
> 2) A patch for replacing dev_err()->dev_err_probe() + Update error message for devm_request_threaded_irq()
> 3) separate patch for dropping print message for input_register_device();
>
> Is it ok?
Personally, I'd be fine with just a single "cleanup error printing" patch.
But Dmitry has the final say.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-12 9:28 ` Geert Uytterhoeven
@ 2023-12-13 20:48 ` Dmitry Torokhov
2023-12-13 21:09 ` Biju Das
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2023-12-13 20:48 UTC (permalink / raw)
To: Geert Uytterhoeven, Biju Das
Cc: Support Opensource, linux-input@vger.kernel.org,
Prabhakar Mahadev Lad, biju.das.au,
linux-renesas-soc@vger.kernel.org
On December 12, 2023 8:28:45 PM GMT+11:00, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>Hi Biju,
>
>On Tue, Dec 12, 2023 at 10:03 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
>> > From: Geert Uytterhoeven <geert@linux-m68k.org>
>> > On Mon, Dec 11, 2023 at 5:57 PM Biju Das <biju.das.jz@bp.renesas.com>
>> > wrote:
>> > > Replace dev_err()->dev_err_probe() to simpilfy probe().
>> > >
>> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>
>> OK, I will send
>>
>> 1) separate patch for dropping unneeded prints related to OOM
>> 2) A patch for replacing dev_err()->dev_err_probe() + Update error message for devm_request_threaded_irq()
>> 3) separate patch for dropping print message for input_register_device();
>>
>> Is it ok?
>
>Personally, I'd be fine with just a single "cleanup error printing" patch.
>But Dmitry has the final say.
I'm fine with a single patch unless you feel strongly about splitting it in 2.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
2023-12-13 20:48 ` Dmitry Torokhov
@ 2023-12-13 21:09 ` Biju Das
0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2023-12-13 21:09 UTC (permalink / raw)
To: Dmitry Torokhov, Geert Uytterhoeven
Cc: Support Opensource, linux-input@vger.kernel.org,
Prabhakar Mahadev Lad, biju.das.au,
linux-renesas-soc@vger.kernel.org
Hi Dmitry Torokhov,
Thanks for the feedback.
> -----Original Message-----
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Sent: Wednesday, December 13, 2023 8:49 PM
> Subject: Re: [PATCH 2/3] Input: da9063 - Use dev_err_probe()
>
> On December 12, 2023 8:28:45 PM GMT+11:00, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> >Hi Biju,
> >
> >On Tue, Dec 12, 2023 at 10:03 AM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> >> > From: Geert Uytterhoeven <geert@linux-m68k.org> On Mon, Dec 11,
> >> > 2023 at 5:57 PM Biju Das <biju.das.jz@bp.renesas.com>
> >> > wrote:
> >> > > Replace dev_err()->dev_err_probe() to simpilfy probe().
> >> > >
> >> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >
> >> OK, I will send
> >>
> >> 1) separate patch for dropping unneeded prints related to OOM
> >> 2) A patch for replacing dev_err()->dev_err_probe() + Update error
> >> message for devm_request_threaded_irq()
> >> 3) separate patch for dropping print message for
> >> input_register_device();
> >>
> >> Is it ok?
> >
> >Personally, I'd be fine with just a single "cleanup error printing"
> patch.
> >But Dmitry has the final say.
>
> I'm fine with a single patch unless you feel strongly about splitting it
> in 2.
I will split into 2,
1) First patch for dropping redundant print messages.
2) Replace dev_err()->dev_err_probe()
Cheers,
Biju
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] Input: da9063 - Add polling support
2023-12-11 16:57 [PATCH 0/3] Add polling support for DA9063 onkey driver Biju Das
2023-12-11 16:57 ` [PATCH 1/3] Input: da9063 - Simplify obtaining OF match data Biju Das
2023-12-11 16:57 ` [PATCH 2/3] Input: da9063 - Use dev_err_probe() Biju Das
@ 2023-12-11 16:57 ` Biju Das
2023-12-11 17:07 ` Biju Das
2 siblings, 1 reply; 12+ messages in thread
From: Biju Das @ 2023-12-11 16:57 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Biju Das, Support Opensource, linux-input, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc
On some platforms (eg: RZ/{G2UL,Five} SMARC EVK), there is no IRQ
populated by default. Add polling support.
While at it, doing some cleanups in da9063_poll_on().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/input/misc/da9063_onkey.c | 88 +++++++++++++++++++++++--------
1 file changed, 66 insertions(+), 22 deletions(-)
diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c
index 536220662b38..b9bb8c1cb758 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -19,6 +19,8 @@
#include <linux/mfd/da9062/core.h>
#include <linux/mfd/da9062/registers.h>
+#define DA9062_KEY_THRESHOLD_MSEC (200)
+
struct da906x_chip_config {
/* REGS */
int onkey_status;
@@ -42,6 +44,8 @@ struct da9063_onkey {
const struct da906x_chip_config *config;
char phys[32];
bool key_power;
+ unsigned int poll_interval;
+ unsigned int key_threshold_release_time;
};
static const struct da906x_chip_config da9063_regs = {
@@ -86,15 +90,27 @@ static void da9063_poll_on(struct work_struct *work)
int error;
/* Poll to see when the pin is released */
- error = regmap_read(onkey->regmap,
- config->onkey_status,
- &val);
+ error = regmap_read(onkey->regmap, config->onkey_status, &val);
if (error) {
- dev_err(onkey->dev,
- "Failed to read ON status: %d\n", error);
+ dev_err(onkey->dev, "Failed to read ON status: %d\n", error);
goto err_poll;
}
+ if (onkey->poll_interval &&
+ onkey->key_threshold_release_time <= DA9062_KEY_THRESHOLD_MSEC) {
+ /* detect short press or long key press */
+ if (!(val & config->onkey_nonkey_mask)) {
+ input_report_key(onkey->input, KEY_POWER, 0);
+ input_sync(onkey->input);
+ onkey->key_threshold_release_time = 0;
+ dev_dbg(onkey->dev, "KEY_POWER short press.\n");
+ } else {
+ schedule_delayed_work(&onkey->work, msecs_to_jiffies(50));
+ onkey->key_threshold_release_time += 50;
+ }
+ return;
+ }
+
if (!(val & config->onkey_nonkey_mask)) {
error = regmap_update_bits(onkey->regmap,
config->onkey_pwr_signalling,
@@ -177,6 +193,21 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}
+static void da9063_onkey_polled_poll(struct input_dev *input)
+{
+ struct da9063_onkey *onkey = input_get_drvdata(input);
+ const struct da906x_chip_config *config = onkey->config;
+ unsigned int val;
+ int error;
+
+ error = regmap_read(onkey->regmap, config->onkey_status, &val);
+ if (onkey->key_power && !error && (val & config->onkey_nonkey_mask)) {
+ input_report_key(onkey->input, KEY_POWER, 1);
+ input_sync(onkey->input);
+ schedule_delayed_work(&onkey->work, 0);
+ }
+}
+
static int da9063_onkey_probe(struct platform_device *pdev)
{
struct da9063_onkey *onkey;
@@ -222,25 +253,38 @@ static int da9063_onkey_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, error,
"Failed to add cancel poll action\n");
- irq = platform_get_irq_byname(pdev, "ONKEY");
- if (irq < 0)
+ irq = platform_get_irq_byname_optional(pdev, "ONKEY");
+ if (irq != -ENXIO)
return irq;
- error = devm_request_threaded_irq(&pdev->dev, irq,
- NULL, da9063_onkey_irq_handler,
- IRQF_TRIGGER_LOW | IRQF_ONESHOT,
- "ONKEY", onkey);
- if (error)
- return dev_err_probe(&pdev->dev, error,
- "Failed to request IRQ %d\n", irq);
-
- error = dev_pm_set_wake_irq(&pdev->dev, irq);
- if (error)
- dev_warn(&pdev->dev,
- "Failed to set IRQ %d as a wake IRQ: %d\n",
- irq, error);
- else
- device_init_wakeup(&pdev->dev, true);
+ if (irq >= 0) {
+ error = devm_request_threaded_irq(&pdev->dev, irq,
+ NULL, da9063_onkey_irq_handler,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+ "ONKEY", onkey);
+ if (error)
+ return dev_err_probe(&pdev->dev, error,
+ "Failed to request IRQ %d\n", irq);
+
+ error = dev_pm_set_wake_irq(&pdev->dev, irq);
+ if (error)
+ dev_warn(&pdev->dev,
+ "Failed to set IRQ %d as a wake IRQ: %d\n",
+ irq, error);
+ else
+ device_init_wakeup(&pdev->dev, true);
+ } else {
+ input_set_drvdata(onkey->input, onkey);
+ device_property_read_u32(&pdev->dev, "poll-interval",
+ &onkey->poll_interval);
+ error = input_setup_polling(onkey->input,
+ da9063_onkey_polled_poll);
+ if (error)
+ return dev_err_probe(&pdev->dev, error,
+ "unable to set up polling\n");
+
+ input_set_poll_interval(onkey->input, onkey->poll_interval);
+ }
error = input_register_device(onkey->input);
if (error)
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* RE: [PATCH 3/3] Input: da9063 - Add polling support
2023-12-11 16:57 ` [PATCH 3/3] Input: da9063 - Add polling support Biju Das
@ 2023-12-11 17:07 ` Biju Das
0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2023-12-11 17:07 UTC (permalink / raw)
To: Biju Das, Dmitry Torokhov
Cc: Support Opensource, linux-input@vger.kernel.org,
Geert Uytterhoeven, Prabhakar Mahadev Lad, biju.das.au,
linux-renesas-soc@vger.kernel.org
Hi All,
> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: Monday, December 11, 2023 4:57 PM
> Subject: [PATCH 3/3] Input: da9063 - Add polling support
>
> On some platforms (eg: RZ/{G2UL,Five} SMARC EVK), there is no IRQ
> populated by default. Add polling support.
>
> While at it, doing some cleanups in da9063_poll_on().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> drivers/input/misc/da9063_onkey.c | 88 +++++++++++++++++++++++--------
> 1 file changed, 66 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/input/misc/da9063_onkey.c
> b/drivers/input/misc/da9063_onkey.c
> index 536220662b38..b9bb8c1cb758 100644
> --- a/drivers/input/misc/da9063_onkey.c
> +++ b/drivers/input/misc/da9063_onkey.c
> @@ -19,6 +19,8 @@
> #include <linux/mfd/da9062/core.h>
> #include <linux/mfd/da9062/registers.h>
>
> +#define DA9062_KEY_THRESHOLD_MSEC (200)
> +
> struct da906x_chip_config {
> /* REGS */
> int onkey_status;
> @@ -42,6 +44,8 @@ struct da9063_onkey {
> const struct da906x_chip_config *config;
> char phys[32];
> bool key_power;
> + unsigned int poll_interval;
> + unsigned int key_threshold_release_time;
> };
>
> static const struct da906x_chip_config da9063_regs = { @@ -86,15 +90,27
> @@ static void da9063_poll_on(struct work_struct *work)
> int error;
>
> /* Poll to see when the pin is released */
> - error = regmap_read(onkey->regmap,
> - config->onkey_status,
> - &val);
> + error = regmap_read(onkey->regmap, config->onkey_status, &val);
> if (error) {
> - dev_err(onkey->dev,
> - "Failed to read ON status: %d\n", error);
> + dev_err(onkey->dev, "Failed to read ON status: %d\n", error);
> goto err_poll;
> }
>
> + if (onkey->poll_interval &&
> + onkey->key_threshold_release_time <= DA9062_KEY_THRESHOLD_MSEC)
> {
> + /* detect short press or long key press */
> + if (!(val & config->onkey_nonkey_mask)) {
> + input_report_key(onkey->input, KEY_POWER, 0);
> + input_sync(onkey->input);
> + onkey->key_threshold_release_time = 0;
> + dev_dbg(onkey->dev, "KEY_POWER short press.\n");
> + } else {
> + schedule_delayed_work(&onkey->work,
> msecs_to_jiffies(50));
> + onkey->key_threshold_release_time += 50;
> + }
> + return;
> + }
> +
> if (!(val & config->onkey_nonkey_mask)) {
> error = regmap_update_bits(onkey->regmap,
> config->onkey_pwr_signalling,
> @@ -177,6 +193,21 @@ static irqreturn_t da9063_onkey_irq_handler(int irq,
> void *data)
> return IRQ_HANDLED;
> }
>
> +static void da9063_onkey_polled_poll(struct input_dev *input) {
> + struct da9063_onkey *onkey = input_get_drvdata(input);
> + const struct da906x_chip_config *config = onkey->config;
> + unsigned int val;
> + int error;
> +
> + error = regmap_read(onkey->regmap, config->onkey_status, &val);
> + if (onkey->key_power && !error && (val & config->onkey_nonkey_mask))
> {
> + input_report_key(onkey->input, KEY_POWER, 1);
> + input_sync(onkey->input);
> + schedule_delayed_work(&onkey->work, 0);
> + }
> +}
> +
> static int da9063_onkey_probe(struct platform_device *pdev) {
> struct da9063_onkey *onkey;
> @@ -222,25 +253,38 @@ static int da9063_onkey_probe(struct platform_device
> *pdev)
> return dev_err_probe(&pdev->dev, error,
> "Failed to add cancel poll action\n");
>
> - irq = platform_get_irq_byname(pdev, "ONKEY");
> - if (irq < 0)
> + irq = platform_get_irq_byname_optional(pdev, "ONKEY");
> + if (irq != -ENXIO)
> return irq;
Oops, this check is wrong for IRQ case.
I will send v2, once I get feedback for this patch series.
It should be like [1]
[1]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20231204130504.126787-2-biju.das.jz@bp.renesas.com/
Cheers,
Biju
>
> - error = devm_request_threaded_irq(&pdev->dev, irq,
> - NULL, da9063_onkey_irq_handler,
> - IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> - "ONKEY", onkey);
> - if (error)
> - return dev_err_probe(&pdev->dev, error,
> - "Failed to request IRQ %d\n", irq);
> -
> - error = dev_pm_set_wake_irq(&pdev->dev, irq);
> - if (error)
> - dev_warn(&pdev->dev,
> - "Failed to set IRQ %d as a wake IRQ: %d\n",
> - irq, error);
> - else
> - device_init_wakeup(&pdev->dev, true);
> + if (irq >= 0) {
> + error = devm_request_threaded_irq(&pdev->dev, irq,
> + NULL, da9063_onkey_irq_handler,
> + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> + "ONKEY", onkey);
> + if (error)
> + return dev_err_probe(&pdev->dev, error,
> + "Failed to request IRQ %d\n", irq);
> +
> + error = dev_pm_set_wake_irq(&pdev->dev, irq);
> + if (error)
> + dev_warn(&pdev->dev,
> + "Failed to set IRQ %d as a wake IRQ: %d\n",
> + irq, error);
> + else
> + device_init_wakeup(&pdev->dev, true);
> + } else {
> + input_set_drvdata(onkey->input, onkey);
> + device_property_read_u32(&pdev->dev, "poll-interval",
> + &onkey->poll_interval);
> + error = input_setup_polling(onkey->input,
> + da9063_onkey_polled_poll);
> + if (error)
> + return dev_err_probe(&pdev->dev, error,
> + "unable to set up polling\n");
> +
> + input_set_poll_interval(onkey->input, onkey->poll_interval);
> + }
>
> error = input_register_device(onkey->input);
> if (error)
> --
> 2.25.1
^ permalink raw reply [flat|nested] 12+ messages in thread