Message ID | 20230716152858.92696-1-biju.das.jz@bp.renesas.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | rtc: pcf85063: Simplify probe() | expand |
Hi Biju, On Sun, Jul 16, 2023 at 5:29 PM Biju Das <biju.das.jz@bp.renesas.com> wrote: > The pcf85063_ids[].driver_data could store a pointer to the config, > like for DT-based matching, making I2C 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 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> One suggestion for improvement (which can be a separate patch, as it would also touch pcf85063_of_match[]) below... > --- a/drivers/rtc/rtc-pcf85063.c > +++ b/drivers/rtc/rtc-pcf85063.c > @@ -579,17 +577,9 @@ static int pcf85063_probe(struct i2c_client *client) > if (!pcf85063) > return -ENOMEM; > > - if (client->dev.of_node) { > - config = of_device_get_match_data(&client->dev); > - if (!config) > - return -ENODEV; > - } else { > - enum pcf85063_type type = > - i2c_match_id(pcf85063_ids, client)->driver_data; > - if (type >= PCF85063_LAST_ID) Note that this was the sole user of PCF85063_LAST_ID... > @@ -655,11 +645,11 @@ static int pcf85063_probe(struct i2c_client *client) > } > > static const struct i2c_device_id pcf85063_ids[] = { > - { "pca85073a", PCF85063A }, > - { "pcf85063", PCF85063 }, > - { "pcf85063tp", PCF85063TP }, > - { "pcf85063a", PCF85063A }, > - { "rv8263", RV8263 }, > + { "pca85073a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] }, > + { "pcf85063", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063] }, > + { "pcf85063tp", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063TP] }, > + { "pcf85063a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] }, > + { "rv8263", .driver_data = (kernel_ulong_t)&pcf85063_cfg[RV8263] }, These lines can be shortened (and enum pcf85063_type can be removed) by splitting pcf85063_cfg[] in individual variables. > {} > }; > MODULE_DEVICE_TABLE(i2c, pcf85063_ids); Gr{oetje,eeting}s, Geert
Hi Geert, Thanks for the feedback. > -----Original Message----- > From: Geert Uytterhoeven <geert@linux-m68k.org> > Sent: Monday, July 17, 2023 8:32 AM > To: Biju Das <biju.das.jz@bp.renesas.com> > Cc: Alessandro Zummo <a.zummo@towertech.it>; Alexandre Belloni > <alexandre.belloni@bootlin.com>; linux-rtc@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] rtc: pcf85063: Simplify probe() > > Hi Biju, > > On Sun, Jul 16, 2023 at 5:29 PM Biju Das <biju.das.jz@bp.renesas.com> > wrote: > > The pcf85063_ids[].driver_data could store a pointer to the config, > > like for DT-based matching, making I2C 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 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> > > One suggestion for improvement (which can be a separate patch, as it > would also touch pcf85063_of_match[]) below.. OK. > > > --- a/drivers/rtc/rtc-pcf85063.c > > +++ b/drivers/rtc/rtc-pcf85063.c > > @@ -579,17 +577,9 @@ static int pcf85063_probe(struct i2c_client > *client) > > if (!pcf85063) > > return -ENOMEM; > > > > - if (client->dev.of_node) { > > - config = of_device_get_match_data(&client->dev); > > - if (!config) > > - return -ENODEV; > > - } else { > > - enum pcf85063_type type = > > - i2c_match_id(pcf85063_ids, client)- > >driver_data; > > - if (type >= PCF85063_LAST_ID) > > Note that this was the sole user of PCF85063_LAST_ID... Ok. > > > @@ -655,11 +645,11 @@ static int pcf85063_probe(struct i2c_client > > *client) } > > > > static const struct i2c_device_id pcf85063_ids[] = { > > - { "pca85073a", PCF85063A }, > > - { "pcf85063", PCF85063 }, > > - { "pcf85063tp", PCF85063TP }, > > - { "pcf85063a", PCF85063A }, > > - { "rv8263", RV8263 }, > > + { "pca85073a", .driver_data = > (kernel_ulong_t)&pcf85063_cfg[PCF85063A] }, > > + { "pcf85063", .driver_data = > (kernel_ulong_t)&pcf85063_cfg[PCF85063] }, > > + { "pcf85063tp", .driver_data = > (kernel_ulong_t)&pcf85063_cfg[PCF85063TP] }, > > + { "pcf85063a", .driver_data = > (kernel_ulong_t)&pcf85063_cfg[PCF85063A] }, > > + { "rv8263", .driver_data = > > + (kernel_ulong_t)&pcf85063_cfg[RV8263] }, > > These lines can be shortened (and enum pcf85063_type can be removed) by > splitting pcf85063_cfg[] in individual variables. OK will send separate patch by splitting pcf85063_cfg[] as individual variables and remove enum pcf85063_type. Cheers, Biju > > > {} > > }; > > MODULE_DEVICE_TABLE(i2c, pcf85063_ids); > > 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
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c index e517abfaee2a..a3b75c96ff9a 100644 --- a/drivers/rtc/rtc-pcf85063.c +++ b/drivers/rtc/rtc-pcf85063.c @@ -556,8 +556,6 @@ static struct pcf85063_config pcf85063_cfg[] = { }, }; -static const struct i2c_device_id pcf85063_ids[]; - static int pcf85063_probe(struct i2c_client *client) { struct pcf85063 *pcf85063; @@ -579,17 +577,9 @@ static int pcf85063_probe(struct i2c_client *client) if (!pcf85063) return -ENOMEM; - if (client->dev.of_node) { - config = of_device_get_match_data(&client->dev); - if (!config) - return -ENODEV; - } else { - enum pcf85063_type type = - i2c_match_id(pcf85063_ids, client)->driver_data; - if (type >= PCF85063_LAST_ID) - return -ENODEV; - config = &pcf85063_cfg[type]; - } + config = i2c_get_match_data(client); + if (!config) + return -ENODEV; pcf85063->regmap = devm_regmap_init_i2c(client, &config->regmap); if (IS_ERR(pcf85063->regmap)) @@ -655,11 +645,11 @@ static int pcf85063_probe(struct i2c_client *client) } static const struct i2c_device_id pcf85063_ids[] = { - { "pca85073a", PCF85063A }, - { "pcf85063", PCF85063 }, - { "pcf85063tp", PCF85063TP }, - { "pcf85063a", PCF85063A }, - { "rv8263", RV8263 }, + { "pca85073a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] }, + { "pcf85063", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063] }, + { "pcf85063tp", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063TP] }, + { "pcf85063a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] }, + { "rv8263", .driver_data = (kernel_ulong_t)&pcf85063_cfg[RV8263] }, {} }; MODULE_DEVICE_TABLE(i2c, pcf85063_ids);
The pcf85063_ids[].driver_data could store a pointer to the config, like for DT-based matching, making I2C 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 and DT-based matching table. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> --- Note: This patch is based on the work done for rtc-isl1208 and is just compile tested. --- drivers/rtc/rtc-pcf85063.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)