Linux-RTC Archive mirror
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	"linux-rtc@vger.kernel.org" <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" 
	<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH] rtc: pcf2127: Simplify probe()
Date: Mon, 28 Aug 2023 10:31:29 +0000	[thread overview]
Message-ID: <OS0PR01MB5922185A4E6E8567572A758D86E0A@OS0PR01MB5922.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20230828100836fa0fad9c@mail.local>

Hi Alexandre Belloni,

Thanks for the feedback.

> Subject: Re: [PATCH] rtc: pcf2127: Simplify probe()
> 
> 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.

I agree, users of this driver can test this patch and add their
Tested by tag. It is similar to the change done for rtc-isl1208.c
driver and similar OF/ID match tables tested on that driver.

Cheers,
Biju

 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
> >

      reply	other threads:[~2023-08-28 10:33 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
2023-08-28 10:31   ` Biju Das [this message]

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=OS0PR01MB5922185A4E6E8567572A758D86E0A@OS0PR01MB5922.jpnprd01.prod.outlook.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andriy.shevchenko@linux.intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).