[API-NEXT,PATCHv2,22/23] linux-gen: adding functions to attach driver's data to the device

Message ID 1490194110-40168-23-git-send-email-christophe.milard@linaro.org
State New
Headers show
Series
  • driver items registration and probing
Related show

Commit Message

Christophe Milard March 22, 2017, 2:48 p.m.
Implementation of the functions to set/retrieve driver's data to/from
a bound device.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/drv_driver.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

-- 
2.7.4

Patch

diff --git a/platform/linux-generic/drv_driver.c b/platform/linux-generic/drv_driver.c
index ea92457..70bf318 100644
--- a/platform/linux-generic/drv_driver.c
+++ b/platform/linux-generic/drv_driver.c
@@ -70,6 +70,7 @@  struct _odpdrv_device_s {
 	odpdrv_device_param_t param;
 	_odpdrv_driver_t *driver; /* driver for the device (if bound), or NULL*/
 	_odpdrv_devio_t *devio;   /* devio used for device (if bound), or NULL*/
+	void *driver_data;        /* anything that the driver need to attach. */
 	void (*enumr_destroy_callback)(void *enum_dev);/*dev destroy callback */
 	struct _odpdrv_device_s *next;
 } _odpdrv_device_s;
@@ -395,6 +396,7 @@  odpdrv_device_t odpdrv_device_create(odpdrv_device_param_t *param)
 	dev->enumr_destroy_callback = NULL;
 	dev->driver = NULL;
 	dev->devio = NULL;
+	dev->driver_data = NULL;
 	dev_list_write_lock();
 	dev->next = device_lst.head;
 	device_lst.head = dev;
@@ -852,6 +854,22 @@  void _odpdrv_driver_probe_drv_items(void)
 	probe_all();
 }
 
+void odpdrv_device_set_data(odpdrv_device_t dev, void *data)
+{
+	_odpdrv_device_t *_dev;
+
+	_dev = get_device(dev);
+	_dev->driver_data = data;
+}
+
+void *odpdrv_device_get_data(odpdrv_device_t dev)
+{
+	_odpdrv_device_t *_dev;
+
+	_dev = get_device(dev);
+	return _dev->driver_data;
+}
+
 int odpdrv_print_all(void)
 {
 	_odpdrv_enumr_class_t *enumr_c;