[U-Boot] [PATCH 02/45] dm: core: Update some functions to use const
Simon Glass
sjg at chromium.org
Mon Oct 1 18:22:06 UTC 2018
Quite a few functions do not actually modify the device that is passed in.
Update the function signatures to reflect that.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
drivers/core/device.c | 24 ++++++++++++------------
include/dm/device.h | 24 ++++++++++++------------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 73c99d1a65a..a9e5906e7cd 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -442,7 +442,7 @@ fail:
return ret;
}
-void *dev_get_platdata(struct udevice *dev)
+void *dev_get_platdata(const struct udevice *dev)
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
@@ -452,7 +452,7 @@ void *dev_get_platdata(struct udevice *dev)
return dev->platdata;
}
-void *dev_get_parent_platdata(struct udevice *dev)
+void *dev_get_parent_platdata(const struct udevice *dev)
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
@@ -462,7 +462,7 @@ void *dev_get_parent_platdata(struct udevice *dev)
return dev->parent_platdata;
}
-void *dev_get_uclass_platdata(struct udevice *dev)
+void *dev_get_uclass_platdata(const struct udevice *dev)
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
@@ -472,7 +472,7 @@ void *dev_get_uclass_platdata(struct udevice *dev)
return dev->uclass_platdata;
}
-void *dev_get_priv(struct udevice *dev)
+void *dev_get_priv(const struct udevice *dev)
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
@@ -482,7 +482,7 @@ void *dev_get_priv(struct udevice *dev)
return dev->priv;
}
-void *dev_get_uclass_priv(struct udevice *dev)
+void *dev_get_uclass_priv(const struct udevice *dev)
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
@@ -492,7 +492,7 @@ void *dev_get_uclass_priv(struct udevice *dev)
return dev->uclass_priv;
}
-void *dev_get_parent_priv(struct udevice *dev)
+void *dev_get_parent_priv(const struct udevice *dev)
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
@@ -681,17 +681,17 @@ int device_find_next_child(struct udevice **devp)
return 0;
}
-struct udevice *dev_get_parent(struct udevice *child)
+struct udevice *dev_get_parent(const struct udevice *child)
{
return child->parent;
}
-ulong dev_get_driver_data(struct udevice *dev)
+ulong dev_get_driver_data(const struct udevice *dev)
{
return dev->driver_data;
}
-const void *dev_get_driver_ops(struct udevice *dev)
+const void *dev_get_driver_ops(const struct udevice *dev)
{
if (!dev || !dev->driver->ops)
return NULL;
@@ -699,12 +699,12 @@ const void *dev_get_driver_ops(struct udevice *dev)
return dev->driver->ops;
}
-enum uclass_id device_get_uclass_id(struct udevice *dev)
+enum uclass_id device_get_uclass_id(const struct udevice *dev)
{
return dev->uclass->uc_drv->id;
}
-const char *dev_get_uclass_name(struct udevice *dev)
+const char *dev_get_uclass_name(const struct udevice *dev)
{
if (!dev)
return NULL;
@@ -712,7 +712,7 @@ const char *dev_get_uclass_name(struct udevice *dev)
return dev->uclass->uc_drv->name;
}
-bool device_has_children(struct udevice *dev)
+bool device_has_children(const struct udevice *dev)
{
return !list_empty(&dev->child_head);
}
diff --git a/include/dm/device.h b/include/dm/device.h
index 9812d86f08b..f873fc66e12 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -270,7 +270,7 @@ struct driver {
* @dev Device to check
* @return platform data, or NULL if none
*/
-void *dev_get_platdata(struct udevice *dev);
+void *dev_get_platdata(const struct udevice *dev);
/**
* dev_get_parent_platdata() - Get the parent platform data for a device
@@ -280,7 +280,7 @@ void *dev_get_platdata(struct udevice *dev);
* @dev Device to check
* @return parent's platform data, or NULL if none
*/
-void *dev_get_parent_platdata(struct udevice *dev);
+void *dev_get_parent_platdata(const struct udevice *dev);
/**
* dev_get_uclass_platdata() - Get the uclass platform data for a device
@@ -290,7 +290,7 @@ void *dev_get_parent_platdata(struct udevice *dev);
* @dev Device to check
* @return uclass's platform data, or NULL if none
*/
-void *dev_get_uclass_platdata(struct udevice *dev);
+void *dev_get_uclass_platdata(const struct udevice *dev);
/**
* dev_get_priv() - Get the private data for a device
@@ -300,7 +300,7 @@ void *dev_get_uclass_platdata(struct udevice *dev);
* @dev Device to check
* @return private data, or NULL if none
*/
-void *dev_get_priv(struct udevice *dev);
+void *dev_get_priv(const struct udevice *dev);
/**
* dev_get_parent_priv() - Get the parent private data for a device
@@ -314,7 +314,7 @@ void *dev_get_priv(struct udevice *dev);
* @dev Device to check
* @return parent data, or NULL if none
*/
-void *dev_get_parent_priv(struct udevice *dev);
+void *dev_get_parent_priv(const struct udevice *dev);
/**
* dev_get_uclass_priv() - Get the private uclass data for a device
@@ -324,7 +324,7 @@ void *dev_get_parent_priv(struct udevice *dev);
* @dev Device to check
* @return private uclass data for this device, or NULL if none
*/
-void *dev_get_uclass_priv(struct udevice *dev);
+void *dev_get_uclass_priv(const struct udevice *dev);
/**
* struct dev_get_parent() - Get the parent of a device
@@ -332,7 +332,7 @@ void *dev_get_uclass_priv(struct udevice *dev);
* @child: Child to check
* @return parent of child, or NULL if this is the root device
*/
-struct udevice *dev_get_parent(struct udevice *child);
+struct udevice *dev_get_parent(const struct udevice *child);
/**
* dev_get_driver_data() - get the driver data used to bind a device
@@ -359,7 +359,7 @@ struct udevice *dev_get_parent(struct udevice *child);
* @dev: Device to check
* @return driver data (0 if none is provided)
*/
-ulong dev_get_driver_data(struct udevice *dev);
+ulong dev_get_driver_data(const struct udevice *dev);
/**
* dev_get_driver_ops() - get the device's driver's operations
@@ -370,7 +370,7 @@ ulong dev_get_driver_data(struct udevice *dev);
* @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);
+const void *dev_get_driver_ops(const struct udevice *dev);
/**
* device_get_uclass_id() - return the uclass ID of a device
@@ -378,7 +378,7 @@ const void *dev_get_driver_ops(struct udevice *dev);
* @dev: Device to check
* @return uclass ID for the device
*/
-enum uclass_id device_get_uclass_id(struct udevice *dev);
+enum uclass_id device_get_uclass_id(const struct udevice *dev);
/**
* dev_get_uclass_name() - return the uclass name of a device
@@ -388,7 +388,7 @@ enum uclass_id device_get_uclass_id(struct udevice *dev);
* @dev: Device to check
* @return pointer to the uclass name for the device
*/
-const char *dev_get_uclass_name(struct udevice *dev);
+const char *dev_get_uclass_name(const struct udevice *dev);
/**
* device_get_child() - Get the child of a device by index
@@ -525,7 +525,7 @@ int device_find_next_child(struct udevice **devp);
* @dev: Device to check
* @return true if the device has one or more children
*/
-bool device_has_children(struct udevice *dev);
+bool device_has_children(const struct udevice *dev);
/**
* device_has_active_children() - check if a device has any active children
--
2.19.0.605.g01d371f741-goog
More information about the U-Boot
mailing list