Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Biju Das and committed by
Dmitry Torokhov
9594f273 7395de64

+12 -15
+12 -15
drivers/input/misc/da9063_onkey.c
··· 74 74 .name = "da9062-onkey", 75 75 }; 76 76 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 - 84 77 static void da9063_poll_on(struct work_struct *work) 85 78 { 86 79 struct da9063_onkey *onkey = container_of(work, ··· 180 187 static int da9063_onkey_probe(struct platform_device *pdev) 181 188 { 182 189 struct da9063_onkey *onkey; 183 - const struct of_device_id *match; 184 - int irq; 185 190 int error; 186 - 187 - match = of_match_node(da9063_compatible_reg_id_table, 188 - pdev->dev.of_node); 189 - if (!match) 190 - return -ENXIO; 191 + int irq; 191 192 192 193 onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey), 193 194 GFP_KERNEL); ··· 190 203 return -ENOMEM; 191 204 } 192 205 193 - onkey->config = match->data; 206 + onkey->config = device_get_match_data(&pdev->dev); 207 + if (!onkey->config) 208 + return -ENXIO; 209 + 194 210 onkey->dev = &pdev->dev; 195 211 196 212 onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL); ··· 259 269 260 270 return 0; 261 271 } 272 + 273 + static const struct of_device_id da9063_compatible_reg_id_table[] = { 274 + { .compatible = "dlg,da9063-onkey", .data = &da9063_regs }, 275 + { .compatible = "dlg,da9062-onkey", .data = &da9062_regs }, 276 + { } 277 + }; 278 + MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table); 262 279 263 280 static struct platform_driver da9063_onkey_driver = { 264 281 .probe = da9063_onkey_probe,