| 1 | // Minimal platform driver showing how Linux matches a device-tree node. |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/of.h> |
| 4 | #include <linux/platform_device.h> |
| 5 | |
| 6 | static int drhyme_probe(struct platform_device *pdev) |
| 7 | { |
| 8 | const char *label = "unnamed"; |
| 9 | |
| 10 | of_property_read_string(pdev->dev.of_node, "label", &label); |
| 11 | dev_info(&pdev->dev, "matched device-tree node: %s\n", label); |
| 12 | return 0; |
| 13 | } |
| 14 | |
| 15 | static const struct of_device_id drhyme_of_match[] = { |
| 16 | { .compatible = "digital-rhyme,orin-demo" }, |
| 17 | { } |
| 18 | }; |
| 19 | MODULE_DEVICE_TABLE(of, drhyme_of_match); |
| 20 | |
| 21 | static struct platform_driver drhyme_driver = { |
| 22 | .probe = drhyme_probe, |
| 23 | .driver = { |
| 24 | .name = "drhyme-dt-demo", |
| 25 | .of_match_table = drhyme_of_match, |
| 26 | }, |
| 27 | }; |
| 28 | module_platform_driver(drhyme_driver); |
| 29 | |
| 30 | MODULE_LICENSE("GPL"); |
| 31 | MODULE_DESCRIPTION("Device-tree platform-driver match example"); |