diff mbox series

rtc: rs5c372: Simplify probe()

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

Commit Message

Biju Das Aug. 28, 2023, 11:10 a.m. UTC
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.
---
 drivers/rtc/rtc-rs5c372.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Andy Shevchenko Aug. 28, 2023, 11:30 a.m. UTC | #1
On Mon, Aug 28, 2023 at 12:10:34PM +0100, Biju Das wrote:
> Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
> retrieving match data by i2c_get_match_data().

...

>  	rs5c372->client = client;
>  	i2c_set_clientdata(client, rs5c372);
> -	if (client->dev.of_node) {
> -		rs5c372->type = (uintptr_t)of_device_get_match_data(&client->dev);
> -	} else {
> -		const struct i2c_device_id *id = i2c_match_id(rs5c372_id, client);
> -		rs5c372->type = id->driver_data;
> -	}
> +	rs5c372->type = (uintptr_t)i2c_get_match_data(client);

For better reading you can swap the order

	rs5c372->type = (uintptr_t)i2c_get_match_data(client);
	i2c_set_clientdata(client, rs5c372);
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index f8fab0205f8c..936f4f05c8c7 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -825,12 +825,7 @@  static int rs5c372_probe(struct i2c_client *client)
 
 	rs5c372->client = client;
 	i2c_set_clientdata(client, rs5c372);
-	if (client->dev.of_node) {
-		rs5c372->type = (uintptr_t)of_device_get_match_data(&client->dev);
-	} else {
-		const struct i2c_device_id *id = i2c_match_id(rs5c372_id, client);
-		rs5c372->type = id->driver_data;
-	}
+	rs5c372->type = (uintptr_t)i2c_get_match_data(client);
 
 	/* we read registers 0x0f then 0x00-0x0f; skip the first one */
 	rs5c372->regs = &rs5c372->buf[1];