The sigrok core needs a list of all available drivers. Currently this list is manually maintained by updating a global list whenever a driver is added or removed. Introduce a new special section that contains the list of all drivers. The SR_REGISTER_DEV_DRIVER() and SR_REGISTER_DEV_DRIVER_LIST() macro is used to add drivers to this new list. This is done by placing the pointers to the driver into a special section. Since nothing else is in this section it is known that it is simply a list of driver pointers and the core can iterate over it as if it was an array. The advantage of this approach is that the code necessary to add a driver to the list is completely contained to the driver source and it is no longer necessary to maintain a global list. If a driver is built it will automatically appear in the list, if it is not built in won't. This means that the list is always correct, whereas the previous approach used ifdefs in the global driver list file which could get out-of-sync with the actual condition when the driver was built. Any sr_dev_driver structs that are no longer used outside the driver module are marked as static. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> |
||
---|---|---|
.. | ||
api.c | ||
protocol.c | ||
protocol.h |