linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: m41t80: Simplify probe()
@ 2023-08-28  9:27 Biju Das
  2023-08-28 11:10 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Biju Das @ 2023-08-28  9:27 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Biju Das, linux-rtc, Geert Uytterhoeven, Andy Shevchenko,
	Prabhakar Mahadev Lad, linux-renesas-soc

Simplify probe() by replacing 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.
---
 drivers/rtc/rtc-m41t80.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 866489ad56d6..04d05d571f9e 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -896,13 +896,7 @@ static int m41t80_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	m41t80_data->client = client;
-	if (client->dev.of_node) {
-		m41t80_data->features = (unsigned long)
-			of_device_get_match_data(&client->dev);
-	} else {
-		const struct i2c_device_id *id = i2c_match_id(m41t80_id, client);
-		m41t80_data->features = id->driver_data;
-	}
+	m41t80_data->features = (unsigned long)i2c_get_match_data(client);
 	i2c_set_clientdata(client, m41t80_data);
 
 	m41t80_data->rtc =  devm_rtc_allocate_device(&client->dev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: m41t80: Simplify probe()
  2023-08-28  9:27 [PATCH] rtc: m41t80: Simplify probe() Biju Das
@ 2023-08-28 11:10 ` Andy Shevchenko
  2023-08-28 11:13   ` Biju Das
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-28 11:10 UTC (permalink / raw)
  To: Biju Das
  Cc: Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Geert Uytterhoeven, Prabhakar Mahadev Lad, linux-renesas-soc

On Mon, Aug 28, 2023 at 10:27:37AM +0100, Biju Das wrote:
> Simplify probe() by replacing device_get_match_data() and ID lookup for
> retrieving match data by i2c_get_match_data().

...

> +	m41t80_data->features = (unsigned long)i2c_get_match_data(client);

uintptr_t is more natural and de facto pattern for this. Why unsigned long
is here?


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] rtc: m41t80: Simplify probe()
  2023-08-28 11:10 ` Andy Shevchenko
@ 2023-08-28 11:13   ` Biju Das
  2023-08-28 11:29     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Biju Das @ 2023-08-28 11:13 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alessandro Zummo, Alexandre Belloni, linux-rtc@vger.kernel.org,
	Geert Uytterhoeven, Prabhakar Mahadev Lad,
	linux-renesas-soc@vger.kernel.org

Hi Andy Shevchenko,

Thanks for the feedback.

> Subject: Re: [PATCH] rtc: m41t80: Simplify probe()
> 
> On Mon, Aug 28, 2023 at 10:27:37AM +0100, Biju Das wrote:
> > Simplify probe() by replacing device_get_match_data() and ID lookup
> > for retrieving match data by i2c_get_match_data().
> 
> ...
> 
> > +	m41t80_data->features = (unsigned long)i2c_get_match_data(client);
> 
> uintptr_t is more natural and de facto pattern for this. Why unsigned long
> is here?

I just used the casting used for of_device_get_match_data.
I will change it to uintptr_t, If there is no objection.

-		m41t80_data->features = (unsigned long)
-			of_device_get_match_data(&client->dev);

Cheers,
Biju

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: m41t80: Simplify probe()
  2023-08-28 11:13   ` Biju Das
@ 2023-08-28 11:29     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-28 11:29 UTC (permalink / raw)
  To: Biju Das
  Cc: Alessandro Zummo, Alexandre Belloni, linux-rtc@vger.kernel.org,
	Geert Uytterhoeven, Prabhakar Mahadev Lad,
	linux-renesas-soc@vger.kernel.org

On Mon, Aug 28, 2023 at 11:13:29AM +0000, Biju Das wrote:
> > On Mon, Aug 28, 2023 at 10:27:37AM +0100, Biju Das wrote:

...

> > > +	m41t80_data->features = (unsigned long)i2c_get_match_data(client);
> > 
> > uintptr_t is more natural and de facto pattern for this. Why unsigned long
> > is here?
> 
> I just used the casting used for of_device_get_match_data.
> I will change it to uintptr_t, If there is no objection.
> 
> -		m41t80_data->features = (unsigned long)
> -			of_device_get_match_data(&client->dev);

Yes, but for new APIs the uintptr_t is natural (de facto).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-28 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28  9:27 [PATCH] rtc: m41t80: Simplify probe() Biju Das
2023-08-28 11:10 ` Andy Shevchenko
2023-08-28 11:13   ` Biju Das
2023-08-28 11:29     ` Andy Shevchenko

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