Commit 9594f273 authored by Biju Das's avatar Biju Das Committed by Dmitry Torokhov

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: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20231213214803.9931-2-biju.das.jz@bp.renesas.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 7395de64
...@@ -74,13 +74,6 @@ static const struct da906x_chip_config da9062_regs = { ...@@ -74,13 +74,6 @@ static const struct da906x_chip_config da9062_regs = {
.name = "da9062-onkey", .name = "da9062-onkey",
}; };
static const struct of_device_id da9063_compatible_reg_id_table[] = {
{ .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
{ .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
{ },
};
MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
static void da9063_poll_on(struct work_struct *work) static void da9063_poll_on(struct work_struct *work)
{ {
struct da9063_onkey *onkey = container_of(work, struct da9063_onkey *onkey = container_of(work,
...@@ -187,14 +180,8 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data) ...@@ -187,14 +180,8 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
static int da9063_onkey_probe(struct platform_device *pdev) static int da9063_onkey_probe(struct platform_device *pdev)
{ {
struct da9063_onkey *onkey; struct da9063_onkey *onkey;
const struct of_device_id *match;
int irq;
int error; int error;
int irq;
match = of_match_node(da9063_compatible_reg_id_table,
pdev->dev.of_node);
if (!match)
return -ENXIO;
onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey), onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey),
GFP_KERNEL); GFP_KERNEL);
...@@ -203,7 +190,10 @@ static int da9063_onkey_probe(struct platform_device *pdev) ...@@ -203,7 +190,10 @@ static int da9063_onkey_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
onkey->config = match->data; onkey->config = device_get_match_data(&pdev->dev);
if (!onkey->config)
return -ENXIO;
onkey->dev = &pdev->dev; onkey->dev = &pdev->dev;
onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL); onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL);
...@@ -270,6 +260,13 @@ static int da9063_onkey_probe(struct platform_device *pdev) ...@@ -270,6 +260,13 @@ static int da9063_onkey_probe(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id da9063_compatible_reg_id_table[] = {
{ .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
{ .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
{ }
};
MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
static struct platform_driver da9063_onkey_driver = { static struct platform_driver da9063_onkey_driver = {
.probe = da9063_onkey_probe, .probe = da9063_onkey_probe,
.driver = { .driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment