drivers: Modify drivers to use DEVICE_AND_API_INIT()

Modified drivers to use DEVICE_AND_API_INIT() instead of DEVICE_INIT()

This will make sure driver_api,is populated at build time and is exposed
to user space

Signed-off-by: Varun Sharma <varun.sharma@intel.com>
This commit is contained in:
Varun Sharma 2018-12-09 23:17:34 +05:30 committed by Andrew Boie
commit 77c643a5a3
19 changed files with 74 additions and 95 deletions

View file

@ -267,16 +267,6 @@ int glcd_initialize(struct device *port)
return -EPERM;
}
/* Since device_get_binding() will not return any
* reference to a driver instance if port->driver_api
* is NULL and grove_lcd does not have any API struct,
* just populate it with some magic number
* so grove_lcd can be referenced.
*
* Since dev is probably still in registers.
* use that to minimize code addition.
*/
port->driver_api = (void *)dev;
/*
* Initialization sequence from the data sheet:
@ -344,6 +334,14 @@ static struct glcd_data grove_lcd_driver = {
.function = 0,
};
DEVICE_INIT(grove_lcd, GROVE_LCD_NAME, glcd_initialize,
/* Since device_get_binding() will not return any
* reference to a driver instance if driver_api
* is NULL and grove_lcd does not have any API struct,
* just populate it with some magic number
* so grove_lcd can be referenced.
* since grove_lcd_driver struct is available, populating with it
*/
DEVICE_AND_API_INIT(grove_lcd, GROVE_LCD_NAME, glcd_initialize,
&grove_lcd_driver, &grove_lcd_config,
POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY);
POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY,
(void *)&grove_lcd_driver);