aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-pcf85063.c
diff options
context:
space:
mode:
authorBiju Das <biju.das.jz@bp.renesas.com>2023-07-17 13:40:58 +0100
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2023-07-27 23:07:50 +0200
commit68c624f860b30408afde81a91b4c9df3e915ed85 (patch)
treebb56836540431a39b1b4095659524f733c41fd9e /drivers/rtc/rtc-pcf85063.c
parentb7f73b6e921b457a222e86cf53fe3950c6b5aed5 (diff)
downloadlinux-68c624f860b30408afde81a91b4c9df3e915ed85.tar.gz
rtc: pcf85063: Simplify probe()
The pcf85063_ids[].driver_data could store a pointer to the config, like for DT-based matching, making I2C and DT-based matching more similar. After that, we can simplify the probe() by replacing of_device_get_ match_data() and i2c_match_id() by i2c_get_match_data() as we have similar I2C and DT-based matching table. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20230717124059.196244-2-biju.das.jz@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-pcf85063.c')
-rw-r--r--drivers/rtc/rtc-pcf85063.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index e517abfaee2a0..a3b75c96ff9ae 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -556,8 +556,6 @@ static struct pcf85063_config pcf85063_cfg[] = {
},
};
-static const struct i2c_device_id pcf85063_ids[];
-
static int pcf85063_probe(struct i2c_client *client)
{
struct pcf85063 *pcf85063;
@@ -579,17 +577,9 @@ static int pcf85063_probe(struct i2c_client *client)
if (!pcf85063)
return -ENOMEM;
- if (client->dev.of_node) {
- config = of_device_get_match_data(&client->dev);
- if (!config)
- return -ENODEV;
- } else {
- enum pcf85063_type type =
- i2c_match_id(pcf85063_ids, client)->driver_data;
- if (type >= PCF85063_LAST_ID)
- return -ENODEV;
- config = &pcf85063_cfg[type];
- }
+ config = i2c_get_match_data(client);
+ if (!config)
+ return -ENODEV;
pcf85063->regmap = devm_regmap_init_i2c(client, &config->regmap);
if (IS_ERR(pcf85063->regmap))
@@ -655,11 +645,11 @@ static int pcf85063_probe(struct i2c_client *client)
}
static const struct i2c_device_id pcf85063_ids[] = {
- { "pca85073a", PCF85063A },
- { "pcf85063", PCF85063 },
- { "pcf85063tp", PCF85063TP },
- { "pcf85063a", PCF85063A },
- { "rv8263", RV8263 },
+ { "pca85073a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] },
+ { "pcf85063", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063] },
+ { "pcf85063tp", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063TP] },
+ { "pcf85063a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] },
+ { "rv8263", .driver_data = (kernel_ulong_t)&pcf85063_cfg[RV8263] },
{}
};
MODULE_DEVICE_TABLE(i2c, pcf85063_ids);