October 2017
Intermediate to advanced
586 pages
14h 8m
English
Again the principle is the same as that for I2C drivers. We need to define a struct of_device_id to match devices in the DT, and call the MODULE_DEVICE_TABLE macro to register with the OF core:
static const struct of_device_id foobar_of_match[] = {
{ .compatible = "packtpub,foobar-device" },
{ .compatible = "packtpub,barfoo-device" },
{}
};
MODULE_DEVICE_TABLE(of, foobar_of_match);
Then, we define our spi_driver as the following:
static struct spi_driver foo_driver = {
.driver = {
.name = "foo",
/* The following line adds Device tree */
.of_match_table = of_match_ptr(foobar_of_match),
},
.probe = my_spi_probe,
.id_table = foo_id,
};
You can then improve the probe function this way:
static int my_spi_probe(struct ...
Read now
Unlock full access