* [PATCH] Input: exc3000 - Simplify probe()
@ 2023-07-16 18:24 Biju Das
2023-07-17 9:13 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Biju Das @ 2023-07-16 18:24 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Biju Das, Andreas Helbech Kleist, Uwe Kleine-König,
Mike Looijmans, linux-input, Geert Uytterhoeven,
Prabhakar Mahadev Lad, linux-renesas-soc
The exc3000_id.driver_data could store a pointer to the info,
like for ACPI/DT-based matching, making I2C, ACPI and DT-based
matching more similar.
After that, we can simplify the probe() by replacing of_device_get_
match_data() and i2c_match_id() by i2c_get_match_data() as we have
similar I2C, ACPI and DT-based matching table.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/input/touchscreen/exc3000.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index 4c0d99aae9e0..8b65b4e2aa50 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -42,8 +42,6 @@
#define EXC3000_RESET_MS 10
#define EXC3000_READY_MS 100
-static const struct i2c_device_id exc3000_id[];
-
struct eeti_dev_info {
const char *name;
int max_xy;
@@ -347,12 +345,10 @@ static int exc3000_probe(struct i2c_client *client)
return -ENOMEM;
data->client = client;
- data->info = device_get_match_data(&client->dev);
- if (!data->info) {
- enum eeti_dev_id eeti_dev_id =
- i2c_match_id(exc3000_id, client)->driver_data;
- data->info = &exc3000_info[eeti_dev_id];
- }
+ data->info = i2c_get_match_data(client);
+ if (!data->info)
+ return -ENODEV;
+
timer_setup(&data->timer, exc3000_timer, 0);
init_completion(&data->wait_event);
mutex_init(&data->query_lock);
@@ -445,9 +441,9 @@ static int exc3000_probe(struct i2c_client *client)
}
static const struct i2c_device_id exc3000_id[] = {
- { "exc3000", EETI_EXC3000 },
- { "exc80h60", EETI_EXC80H60 },
- { "exc80h84", EETI_EXC80H84 },
+ { "exc3000", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC3000] },
+ { "exc80h60", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC80H60] },
+ { "exc80h84", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC80H84] },
{ }
};
MODULE_DEVICE_TABLE(i2c, exc3000_id);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: exc3000 - Simplify probe()
2023-07-16 18:24 [PATCH] Input: exc3000 - Simplify probe() Biju Das
@ 2023-07-17 9:13 ` Geert Uytterhoeven
2023-07-17 9:18 ` Biju Das
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2023-07-17 9:13 UTC (permalink / raw)
To: Biju Das
Cc: Dmitry Torokhov, Andreas Helbech Kleist, Uwe Kleine-König,
Mike Looijmans, linux-input, Geert Uytterhoeven,
Prabhakar Mahadev Lad, linux-renesas-soc
Hi Biju,
On Sun, Jul 16, 2023 at 8:25 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> The exc3000_id.driver_data could store a pointer to the info,
> like for ACPI/DT-based matching, making I2C, ACPI and DT-based
> matching more similar.
>
> After that, we can simplify the probe() by replacing of_device_get_
> match_data() and i2c_match_id() by i2c_get_match_data() as we have
> similar I2C, ACPI and DT-based matching table.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Thanks for your patch!
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
A suggestion for improvement (which can be a separate patch, as it would
touch exc3000_of_match[]) below.
> ---
> drivers/input/touchscreen/exc3000.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
> index 4c0d99aae9e0..8b65b4e2aa50 100644
> --- a/drivers/input/touchscreen/exc3000.c
> +++ b/drivers/input/touchscreen/exc3000.c
> @@ -445,9 +441,9 @@ static int exc3000_probe(struct i2c_client *client)
> }
>
> static const struct i2c_device_id exc3000_id[] = {
> - { "exc3000", EETI_EXC3000 },
> - { "exc80h60", EETI_EXC80H60 },
> - { "exc80h84", EETI_EXC80H84 },
> + { "exc3000", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC3000] },
> + { "exc80h60", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC80H60] },
> + { "exc80h84", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC80H84] },
As after this the eeti_dev_id values are used only for hardcoded
indexing inside the exc3000_info array, you can get rid of them by
splitting the array in individual variables, shortening the lines above
(and in exc3000_of_match[] below) in the process.
> { }
> };
> MODULE_DEVICE_TABLE(i2c, exc3000_id);
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] 3+ messages in thread
* RE: [PATCH] Input: exc3000 - Simplify probe()
2023-07-17 9:13 ` Geert Uytterhoeven
@ 2023-07-17 9:18 ` Biju Das
0 siblings, 0 replies; 3+ messages in thread
From: Biju Das @ 2023-07-17 9:18 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Dmitry Torokhov, Andreas Helbech Kleist, Uwe Kleine-König,
Mike Looijmans, linux-input@vger.kernel.org, Geert Uytterhoeven,
Prabhakar Mahadev Lad, linux-renesas-soc@vger.kernel.org
Hi Geert,
Thanks for the feedback.
> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: Monday, July 17, 2023 10:13 AM
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>; Andreas Helbech Kleist
> <andreaskleist@gmail.com>; Uwe Kleine-König <u.kleine-
> koenig@pengutronix.de>; Mike Looijmans <mike.looijmans@topic.nl>; linux-
> input@vger.kernel.org; Geert Uytterhoeven <geert+renesas@glider.be>;
> Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>; linux-
> renesas-soc@vger.kernel.org
> Subject: Re: [PATCH] Input: exc3000 - Simplify probe()
>
> Hi Biju,
>
> On Sun, Jul 16, 2023 at 8:25 PM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > The exc3000_id.driver_data could store a pointer to the info, like for
> > ACPI/DT-based matching, making I2C, ACPI and DT-based matching more
> > similar.
> >
> > After that, we can simplify the probe() by replacing of_device_get_
> > match_data() and i2c_match_id() by i2c_get_match_data() as we have
> > similar I2C, ACPI and DT-based matching table.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>
> Thanks for your patch!
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> A suggestion for improvement (which can be a separate patch, as it would
> touch exc3000_of_match[]) below.
OK. exc3000_acpi_match[] as well.
>
> > ---
> > drivers/input/touchscreen/exc3000.c | 18 +++++++-----------
> > 1 file changed, 7 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/input/touchscreen/exc3000.c
> > b/drivers/input/touchscreen/exc3000.c
> > index 4c0d99aae9e0..8b65b4e2aa50 100644
> > --- a/drivers/input/touchscreen/exc3000.c
> > +++ b/drivers/input/touchscreen/exc3000.c
> > @@ -445,9 +441,9 @@ static int exc3000_probe(struct i2c_client
> > *client) }
> >
> > static const struct i2c_device_id exc3000_id[] = {
> > - { "exc3000", EETI_EXC3000 },
> > - { "exc80h60", EETI_EXC80H60 },
> > - { "exc80h84", EETI_EXC80H84 },
> > + { "exc3000", .driver_data =
> (kernel_ulong_t)&exc3000_info[EETI_EXC3000] },
> > + { "exc80h60", .driver_data =
> (kernel_ulong_t)&exc3000_info[EETI_EXC80H60] },
> > + { "exc80h84", .driver_data =
> > + (kernel_ulong_t)&exc3000_info[EETI_EXC80H84] },
>
> As after this the eeti_dev_id values are used only for hardcoded
> indexing inside the exc3000_info array, you can get rid of them by
> splitting the array in individual variables, shortening the lines above
> (and in exc3000_of_match[] below) in the process.
OK, will send a separate patch for splitting the array in individual variables for all match tables (OF/ACPI/I2C)
Cheers,
Biju
>
> > { }
> > };
> > MODULE_DEVICE_TABLE(i2c, exc3000_id);
>
> 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] 3+ messages in thread
end of thread, other threads:[~2023-07-17 9:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-16 18:24 [PATCH] Input: exc3000 - Simplify probe() Biju Das
2023-07-17 9:13 ` Geert Uytterhoeven
2023-07-17 9:18 ` Biju Das
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).