]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: core: device: add function: dev_get_driver_ops()
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Wed, 15 Apr 2015 11:07:24 +0000 (13:07 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:30:10 +0000 (22:30 +0200)
This commit extends the driver model device's API by function:
- dev_get_driver_ops()

And this function returns the device's driver's operations if given:
- dev pointer, is non-NULL
- dev->driver->ops pointer, is non-NULL
in other case the, the NULL pointer is returned.

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>
drivers/core/device.c
include/dm/device.h

index 80eb55bb3b8f662fe87bbdef1bff5b1e9fff0e4c..d024abbd41782185797ccf29d18a8f85f9bfcdfe 100644 (file)
@@ -499,6 +499,14 @@ ulong dev_get_driver_data(struct udevice *dev)
        return dev->driver_data;
 }
 
+const void *dev_get_driver_ops(struct udevice *dev)
+{
+       if (!dev || !dev->driver->ops)
+               return NULL;
+
+       return dev->driver->ops;
+}
+
 enum uclass_id device_get_uclass_id(struct udevice *dev)
 {
        return dev->uclass->uc_drv->id;
index ad002feca2fe4c5e6ede8136f6ecb5f4f816e75c..049cb2f5e2d6ba9c7fa20a8a1eea3139f327ffe0 100644 (file)
@@ -280,6 +280,17 @@ void *dev_get_uclass_priv(struct udevice *dev);
  */
 ulong dev_get_driver_data(struct udevice *dev);
 
+/**
+ * dev_get_driver_ops() - get the device's driver's operations
+ *
+ * This checks that dev is not NULL, and returns the pointer to device's
+ * driver's operations.
+ *
+ * @dev:       Device to check
+ * @return void pointer to driver's operations or NULL for NULL-dev or NULL-ops
+ */
+const void *dev_get_driver_ops(struct udevice *dev);
+
 /*
  * device_get_uclass_id() - return the uclass ID of a device
  *