This is the line in your code that does the magic:
1286 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
1. Driver for each device exposes its information using the API
MODULE_DEVICE_TABLE. Each device has a unique
vendor Id and
2. At compilation time, the build process extracts this information out of the driver and builds a table.
3. When the device is plugged in, the
kernel checks this
device table to see if any
available for the particular
Vendor/Device Id. If yes then it loads that driver and initializes the device.
Read following articles for more info: