aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiviu Dudau2018-09-28 08:12:55 -0500
committerSimon Glass2018-11-14 11:16:28 -0600
commit81f351d6e7ebb371de8ea849fc21dd07dc2eff24 (patch)
tree9097708fe12d8e6245018b927de658f62b240c36
parent216460ec12cce2a6b7fa83f42a48ed20d448e0dc (diff)
downloadu-boot-81f351d6e7ebb371de8ea849fc21dd07dc2eff24.tar.gz
u-boot-81f351d6e7ebb371de8ea849fc21dd07dc2eff24.tar.xz
u-boot-81f351d6e7ebb371de8ea849fc21dd07dc2eff24.zip
uclass: Use uclass_foreach_dev() macro instead of open coding
Use the uclass_foreach_dev() macro instead of the open coded version. Signed-off-by: Liviu Dudau <liviu.dudau@foss.arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/core/dump.c2
-rw-r--r--drivers/core/uclass.c18
2 files changed, 10 insertions, 10 deletions
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index d7cdb1475d..9068084404 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -89,7 +89,7 @@ void dm_dump_uclass(void)
89 printf("uclass %d: %s\n", id, uc->uc_drv->name); 89 printf("uclass %d: %s\n", id, uc->uc_drv->name);
90 if (list_empty(&uc->dev_head)) 90 if (list_empty(&uc->dev_head))
91 continue; 91 continue;
92 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 92 uclass_foreach_dev(dev, uc) {
93 dm_display_line(dev, i); 93 dm_display_line(dev, i);
94 i++; 94 i++;
95 } 95 }
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 3c7b9cf0ad..6cfcde8918 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -180,7 +180,7 @@ int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)
180 if (list_empty(&uc->dev_head)) 180 if (list_empty(&uc->dev_head))
181 return -ENODEV; 181 return -ENODEV;
182 182
183 list_for_each_entry(iter, &uc->dev_head, uclass_node) { 183 uclass_foreach_dev(iter, uc) {
184 if (iter == dev) { 184 if (iter == dev) {
185 if (ucp) 185 if (ucp)
186 *ucp = uc; 186 *ucp = uc;
@@ -205,7 +205,7 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
205 if (list_empty(&uc->dev_head)) 205 if (list_empty(&uc->dev_head))
206 return -ENODEV; 206 return -ENODEV;
207 207
208 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 208 uclass_foreach_dev(dev, uc) {
209 if (!index--) { 209 if (!index--) {
210 *devp = dev; 210 *devp = dev;
211 return 0; 211 return 0;
@@ -259,7 +259,7 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
259 if (ret) 259 if (ret)
260 return ret; 260 return ret;
261 261
262 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 262 uclass_foreach_dev(dev, uc) {
263 if (!strncmp(dev->name, name, strlen(name))) { 263 if (!strncmp(dev->name, name, strlen(name))) {
264 *devp = dev; 264 *devp = dev;
265 return 0; 265 return 0;
@@ -284,7 +284,7 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
284 if (ret) 284 if (ret)
285 return ret; 285 return ret;
286 286
287 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 287 uclass_foreach_dev(dev, uc) {
288 debug(" - %d %d '%s'\n", dev->req_seq, dev->seq, dev->name); 288 debug(" - %d %d '%s'\n", dev->req_seq, dev->seq, dev->name);
289 if ((find_req_seq ? dev->req_seq : dev->seq) == 289 if ((find_req_seq ? dev->req_seq : dev->seq) ==
290 seq_or_req_seq) { 290 seq_or_req_seq) {
@@ -312,7 +312,7 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node,
312 if (ret) 312 if (ret)
313 return ret; 313 return ret;
314 314
315 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 315 uclass_foreach_dev(dev, uc) {
316 if (dev_of_offset(dev) == node) { 316 if (dev_of_offset(dev) == node) {
317 *devp = dev; 317 *devp = dev;
318 return 0; 318 return 0;
@@ -337,7 +337,7 @@ int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node,
337 if (ret) 337 if (ret)
338 return ret; 338 return ret;
339 339
340 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 340 uclass_foreach_dev(dev, uc) {
341 log(LOGC_DM, LOGL_DEBUG_CONTENT, " - checking %s\n", 341 log(LOGC_DM, LOGL_DEBUG_CONTENT, " - checking %s\n",
342 dev->name); 342 dev->name);
343 if (ofnode_equal(dev_ofnode(dev), node)) { 343 if (ofnode_equal(dev_ofnode(dev), node)) {
@@ -372,7 +372,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
372 if (ret) 372 if (ret)
373 return ret; 373 return ret;
374 374
375 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 375 uclass_foreach_dev(dev, uc) {
376 uint phandle; 376 uint phandle;
377 377
378 phandle = dev_read_phandle(dev); 378 phandle = dev_read_phandle(dev);
@@ -399,7 +399,7 @@ int uclass_get_device_by_driver(enum uclass_id id,
399 if (ret) 399 if (ret)
400 return ret; 400 return ret;
401 401
402 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 402 uclass_foreach_dev(dev, uc) {
403 if (dev->driver == find_drv) 403 if (dev->driver == find_drv)
404 return uclass_get_device_tail(dev, 0, devp); 404 return uclass_get_device_tail(dev, 0, devp);
405 } 405 }
@@ -499,7 +499,7 @@ int uclass_get_device_by_phandle_id(enum uclass_id id, uint phandle_id,
499 if (ret) 499 if (ret)
500 return ret; 500 return ret;
501 501
502 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 502 uclass_foreach_dev(dev, uc) {
503 uint phandle; 503 uint phandle;
504 504
505 phandle = dev_read_phandle(dev); 505 phandle = dev_read_phandle(dev);