summaryrefslogtreecommitdiff
path: root/drivers/core/device.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-01-27 08:49:36 -0700
committerSimon Glass <sjg@chromium.org>2020-02-05 19:33:45 -0700
commitfc347fbdd44a01b1aba6283dec56c1374baca383 (patch)
treedca9fbbe065e827cfd27d2e668b3a080436cea43 /drivers/core/device.c
parentf5cc89a82a9990ba9805ff5800c0872b891533ce (diff)
dm: core: Use const where possible in device.h
Update this header file to use const devices where possible, to permit callers to also use const. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r--drivers/core/device.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 9f39218423..b7f59fcde3 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -591,7 +591,8 @@ static int device_find_by_ofnode(ofnode node, struct udevice **devp)
}
#endif
-int device_get_child(struct udevice *parent, int index, struct udevice **devp)
+int device_get_child(const struct udevice *parent, int index,
+ struct udevice **devp)
{
struct udevice *dev;
@@ -603,7 +604,7 @@ int device_get_child(struct udevice *parent, int index, struct udevice **devp)
return -ENODEV;
}
-int device_get_child_count(struct udevice *parent)
+int device_get_child_count(const struct udevice *parent)
{
struct udevice *dev;
int count = 0;
@@ -614,7 +615,7 @@ int device_get_child_count(struct udevice *parent)
return count;
}
-int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq,
+int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq,
bool find_req_seq, struct udevice **devp)
{
struct udevice *dev;
@@ -634,7 +635,7 @@ int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq,
return -ENODEV;
}
-int device_get_child_by_seq(struct udevice *parent, int seq,
+int device_get_child_by_seq(const struct udevice *parent, int seq,
struct udevice **devp)
{
struct udevice *dev;
@@ -652,7 +653,7 @@ int device_get_child_by_seq(struct udevice *parent, int seq,
return device_get_device_tail(dev, ret, devp);
}
-int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
+int device_find_child_by_of_offset(const struct udevice *parent, int of_offset,
struct udevice **devp)
{
struct udevice *dev;
@@ -669,7 +670,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
return -ENODEV;
}
-int device_get_child_by_of_offset(struct udevice *parent, int node,
+int device_get_child_by_of_offset(const struct udevice *parent, int node,
struct udevice **devp)
{
struct udevice *dev;
@@ -712,7 +713,7 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)
return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
}
-int device_find_first_child(struct udevice *parent, struct udevice **devp)
+int device_find_first_child(const struct udevice *parent, struct udevice **devp)
{
if (list_empty(&parent->child_head)) {
*devp = NULL;
@@ -739,7 +740,7 @@ int device_find_next_child(struct udevice **devp)
return 0;
}
-int device_find_first_inactive_child(struct udevice *parent,
+int device_find_first_inactive_child(const struct udevice *parent,
enum uclass_id uclass_id,
struct udevice **devp)
{
@@ -757,7 +758,7 @@ int device_find_first_inactive_child(struct udevice *parent,
return -ENODEV;
}
-int device_find_first_child_by_uclass(struct udevice *parent,
+int device_find_first_child_by_uclass(const struct udevice *parent,
enum uclass_id uclass_id,
struct udevice **devp)
{
@@ -774,7 +775,7 @@ int device_find_first_child_by_uclass(struct udevice *parent,
return -ENODEV;
}
-int device_find_child_by_name(struct udevice *parent, const char *name,
+int device_find_child_by_name(const struct udevice *parent, const char *name,
struct udevice **devp)
{
struct udevice *dev;
@@ -827,7 +828,7 @@ bool device_has_children(const struct udevice *dev)
return !list_empty(&dev->child_head);
}
-bool device_has_active_children(struct udevice *dev)
+bool device_has_active_children(const struct udevice *dev)
{
struct udevice *child;
@@ -841,7 +842,7 @@ bool device_has_active_children(struct udevice *dev)
return false;
}
-bool device_is_last_sibling(struct udevice *dev)
+bool device_is_last_sibling(const struct udevice *dev)
{
struct udevice *parent = dev->parent;
@@ -867,7 +868,7 @@ int device_set_name(struct udevice *dev, const char *name)
}
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
-bool device_is_compatible(struct udevice *dev, const char *compat)
+bool device_is_compatible(const struct udevice *dev, const char *compat)
{
return ofnode_device_is_compatible(dev_ofnode(dev), compat);
}