Skip to content

Commit 9594f27

Browse files
bijudasdtor
authored andcommitted
Input: da9063 - simplify obtaining OF match data
Simplify probe() by replacing of_match_node() for retrieving match data by device_get_match_data(). Some minor cleanups: * Remove the trailing comma in the terminator entry for the OF 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. * Arrange variables in reverse xmas tree order in probe(). Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20231213214803.9931-2-biju.das.jz@bp.renesas.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 7395de6 commit 9594f27

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

drivers/input/misc/da9063_onkey.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ static const struct da906x_chip_config da9062_regs = {
7474
.name = "da9062-onkey",
7575
};
7676

77-
static const struct of_device_id da9063_compatible_reg_id_table[] = {
78-
{ .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
79-
{ .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
80-
{ },
81-
};
82-
MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
83-
8477
static void da9063_poll_on(struct work_struct *work)
8578
{
8679
struct da9063_onkey *onkey = container_of(work,
@@ -187,14 +180,8 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
187180
static int da9063_onkey_probe(struct platform_device *pdev)
188181
{
189182
struct da9063_onkey *onkey;
190-
const struct of_device_id *match;
191-
int irq;
192183
int error;
193-
194-
match = of_match_node(da9063_compatible_reg_id_table,
195-
pdev->dev.of_node);
196-
if (!match)
197-
return -ENXIO;
184+
int irq;
198185

199186
onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey),
200187
GFP_KERNEL);
@@ -203,7 +190,10 @@ static int da9063_onkey_probe(struct platform_device *pdev)
203190
return -ENOMEM;
204191
}
205192

206-
onkey->config = match->data;
193+
onkey->config = device_get_match_data(&pdev->dev);
194+
if (!onkey->config)
195+
return -ENXIO;
196+
207197
onkey->dev = &pdev->dev;
208198

209199
onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL);
@@ -270,6 +260,13 @@ static int da9063_onkey_probe(struct platform_device *pdev)
270260
return 0;
271261
}
272262

263+
static const struct of_device_id da9063_compatible_reg_id_table[] = {
264+
{ .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
265+
{ .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
266+
{ }
267+
};
268+
MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
269+
273270
static struct platform_driver da9063_onkey_driver = {
274271
.probe = da9063_onkey_probe,
275272
.driver = {

0 commit comments

Comments
 (0)