diff mbox series

rtc: m41t80: Simplify probe()

Message ID 20230828092737.30816-1-biju.das.jz@bp.renesas.com
State New
Headers show
Series rtc: m41t80: Simplify probe() | expand

Commit Message

Biju Das Aug. 28, 2023, 9:27 a.m. UTC
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(-)

Comments

Andy Shevchenko Aug. 28, 2023, 11:10 a.m. UTC | #1
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?
Biju Das Aug. 28, 2023, 11:13 a.m. UTC | #2
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
Andy Shevchenko Aug. 28, 2023, 11:29 a.m. UTC | #3
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).
diff mbox series

Patch

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