From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
linux-rtc@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] rtc: pcf2127: Simplify probe()
Date: Mon, 28 Aug 2023 12:08:36 +0200 [thread overview]
Message-ID: <20230828100836fa0fad9c@mail.local> (raw)
In-Reply-To: <20230828095116.36922-1-biju.das.jz@bp.renesas.com>
On 28/08/2023 10:51:16+0100, Biju Das wrote:
> Make similar OF and ID table for I2C and simpilfy probe() by replacing
> of_device_get_match_data() and id lookup for retrieving match data by
> i2c_get_match_data().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> Note:
> * This patch is only compile tested.
I would really prefer those kind of patches to be actually tested. Else,
I'm going to end up with 60 patches that may or may not break probing.
> ---
> drivers/rtc/rtc-pcf2127.c | 33 ++++++++++++---------------------
> 1 file changed, 12 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> index 9c04c4e1a49c..ec3968e3b8ac 100644
> --- a/drivers/rtc/rtc-pcf2127.c
> +++ b/drivers/rtc/rtc-pcf2127.c
> @@ -1349,15 +1349,6 @@ static const struct regmap_bus pcf2127_i2c_regmap = {
>
> static struct i2c_driver pcf2127_i2c_driver;
>
> -static const struct i2c_device_id pcf2127_i2c_id[] = {
> - { "pcf2127", PCF2127 },
> - { "pcf2129", PCF2129 },
> - { "pca2129", PCF2129 },
> - { "pcf2131", PCF2131 },
> - { }
> -};
> -MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id);
> -
> static int pcf2127_i2c_probe(struct i2c_client *client)
> {
> struct regmap *regmap;
> @@ -1370,18 +1361,9 @@ static int pcf2127_i2c_probe(struct i2c_client *client)
> if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
> return -ENODEV;
>
> - if (client->dev.of_node) {
> - variant = of_device_get_match_data(&client->dev);
> - if (!variant)
> - return -ENODEV;
> - } else {
> - enum pcf21xx_type type =
> - i2c_match_id(pcf2127_i2c_id, client)->driver_data;
> -
> - if (type >= PCF21XX_LAST_ID)
> - return -ENODEV;
> - variant = &pcf21xx_cfg[type];
> - }
> + variant = i2c_get_match_data(client);
> + if (!variant)
> + return -ENODEV;
>
> config.max_register = variant->max_register,
>
> @@ -1396,6 +1378,15 @@ static int pcf2127_i2c_probe(struct i2c_client *client)
> return pcf2127_probe(&client->dev, regmap, client->irq, variant);
> }
>
> +static const struct i2c_device_id pcf2127_i2c_id[] = {
> + { "pcf2127", (kernel_ulong_t)&pcf21xx_cfg[PCF2127] },
> + { "pcf2129", (kernel_ulong_t)&pcf21xx_cfg[PCF2129] },
> + { "pca2129", (kernel_ulong_t)&pcf21xx_cfg[PCF2129] },
> + { "pcf2131", (kernel_ulong_t)&pcf21xx_cfg[PCF2131] },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id);
> +
> static struct i2c_driver pcf2127_i2c_driver = {
> .driver = {
> .name = "rtc-pcf2127-i2c",
> --
> 2.25.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2023-08-28 10:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 9:51 [PATCH] rtc: pcf2127: Simplify probe() Biju Das
2023-08-28 10:08 ` Alexandre Belloni [this message]
2023-08-28 10:31 ` Biju Das
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230828100836fa0fad9c@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=andriy.shevchenko@linux.intel.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=geert+renesas@glider.be \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox