Skip to content

Commit 9b413e3

Browse files
bijudaslag-linaro
authored andcommitted
mfd: da9062: Simplify obtaining I2C match data
Simplify probe() by replacing of_device_get_match_data() and ID lookup for retrieving match data by i2c_get_match_data(). Some minor cleanups: * Remove the trailing comma in the terminator entry for the ID table making code robust against (theoretical) misrebases or other similar things where the new entry goes _after_ the termination without the compiler noticing. * Move OF table near to the user. 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/20231204124507.124758-1-biju.das.jz@bp.renesas.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 41673c6 commit 9b413e3

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/mfd/da9062-core.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -588,16 +588,8 @@ static struct regmap_config da9062_regmap_config = {
588588
.volatile_table = &da9062_aa_volatile_table,
589589
};
590590

591-
static const struct of_device_id da9062_dt_ids[] = {
592-
{ .compatible = "dlg,da9061", .data = (void *)COMPAT_TYPE_DA9061, },
593-
{ .compatible = "dlg,da9062", .data = (void *)COMPAT_TYPE_DA9062, },
594-
{ }
595-
};
596-
MODULE_DEVICE_TABLE(of, da9062_dt_ids);
597-
598591
static int da9062_i2c_probe(struct i2c_client *i2c)
599592
{
600-
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
601593
struct da9062 *chip;
602594
unsigned int irq_base = 0;
603595
const struct mfd_cell *cell;
@@ -611,10 +603,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
611603
if (!chip)
612604
return -ENOMEM;
613605

614-
if (i2c->dev.of_node)
615-
chip->chip_type = (uintptr_t)of_device_get_match_data(&i2c->dev);
616-
else
617-
chip->chip_type = id->driver_data;
606+
chip->chip_type = (uintptr_t)i2c_get_match_data(i2c);
618607

619608
i2c_set_clientdata(i2c, chip);
620609
chip->dev = &i2c->dev;
@@ -714,10 +703,17 @@ static void da9062_i2c_remove(struct i2c_client *i2c)
714703
regmap_del_irq_chip(i2c->irq, chip->regmap_irq);
715704
}
716705

706+
static const struct of_device_id da9062_dt_ids[] = {
707+
{ .compatible = "dlg,da9061", .data = (void *)COMPAT_TYPE_DA9061 },
708+
{ .compatible = "dlg,da9062", .data = (void *)COMPAT_TYPE_DA9062 },
709+
{ }
710+
};
711+
MODULE_DEVICE_TABLE(of, da9062_dt_ids);
712+
717713
static const struct i2c_device_id da9062_i2c_id[] = {
718714
{ "da9061", COMPAT_TYPE_DA9061 },
719715
{ "da9062", COMPAT_TYPE_DA9062 },
720-
{ },
716+
{ }
721717
};
722718
MODULE_DEVICE_TABLE(i2c, da9062_i2c_id);
723719

0 commit comments

Comments
 (0)