[PATCH] rtc: ds1307: Simplify probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simpilfy 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@xxxxxxxxxxxxxx>
---
Note:
 * This patch is only compile tested.
---
 drivers/rtc/rtc-ds1307.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 506b7d1c2397..d41cbb5a1cbd 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1714,9 +1714,7 @@ static const struct regmap_config regmap_config = {
 
 static int ds1307_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	struct ds1307		*ds1307;
-	const void		*match;
 	int			err = -ENODEV;
 	int			tmp;
 	const struct chip_desc	*chip;
@@ -1742,17 +1740,11 @@ static int ds1307_probe(struct i2c_client *client)
 
 	i2c_set_clientdata(client, ds1307);
 
-	match = device_get_match_data(&client->dev);
-	if (match) {
-		ds1307->type = (uintptr_t)match;
-		chip = &chips[ds1307->type];
-	} else if (id) {
-		chip = &chips[id->driver_data];
-		ds1307->type = id->driver_data;
-	} else {
+	ds1307->type = (uintptr_t)i2c_get_match_data(client);
+	if (!ds1307->type)
 		return -ENODEV;
-	}
 
+	chip = &chips[ds1307->type];
 	want_irq = client->irq > 0 && chip->alarm;
 
 	if (!pdata)
-- 
2.25.1




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux