Skip to content

Commit 68c624f

Browse files
bijudasalexandrebelloni
authored andcommitted
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>
1 parent b7f73b6 commit 68c624f

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

drivers/rtc/rtc-pcf85063.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ static struct pcf85063_config pcf85063_cfg[] = {
556556
},
557557
};
558558

559-
static const struct i2c_device_id pcf85063_ids[];
560-
561559
static int pcf85063_probe(struct i2c_client *client)
562560
{
563561
struct pcf85063 *pcf85063;
@@ -579,17 +577,9 @@ static int pcf85063_probe(struct i2c_client *client)
579577
if (!pcf85063)
580578
return -ENOMEM;
581579

582-
if (client->dev.of_node) {
583-
config = of_device_get_match_data(&client->dev);
584-
if (!config)
585-
return -ENODEV;
586-
} else {
587-
enum pcf85063_type type =
588-
i2c_match_id(pcf85063_ids, client)->driver_data;
589-
if (type >= PCF85063_LAST_ID)
590-
return -ENODEV;
591-
config = &pcf85063_cfg[type];
592-
}
580+
config = i2c_get_match_data(client);
581+
if (!config)
582+
return -ENODEV;
593583

594584
pcf85063->regmap = devm_regmap_init_i2c(client, &config->regmap);
595585
if (IS_ERR(pcf85063->regmap))
@@ -655,11 +645,11 @@ static int pcf85063_probe(struct i2c_client *client)
655645
}
656646

657647
static const struct i2c_device_id pcf85063_ids[] = {
658-
{ "pca85073a", PCF85063A },
659-
{ "pcf85063", PCF85063 },
660-
{ "pcf85063tp", PCF85063TP },
661-
{ "pcf85063a", PCF85063A },
662-
{ "rv8263", RV8263 },
648+
{ "pca85073a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] },
649+
{ "pcf85063", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063] },
650+
{ "pcf85063tp", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063TP] },
651+
{ "pcf85063a", .driver_data = (kernel_ulong_t)&pcf85063_cfg[PCF85063A] },
652+
{ "rv8263", .driver_data = (kernel_ulong_t)&pcf85063_cfg[RV8263] },
663653
{}
664654
};
665655
MODULE_DEVICE_TABLE(i2c, pcf85063_ids);

0 commit comments

Comments
 (0)