diff mbox

[U-Boot] dm: simplify uclass_foreach_dev() implementation

Message ID 1439222983-18990-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Masahiro Yamada Aug. 10, 2015, 4:09 p.m. UTC
This can be simply written with list_for_each_entry(), maybe
this macro was not necessary in the first place.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 include/dm/uclass.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Simon Glass Aug. 12, 2015, 2:15 p.m. UTC | #1
On 10 August 2015 at 10:09, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> This can be simply written with list_for_each_entry(), maybe
> this macro was not necessary in the first place.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  include/dm/uclass.h | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/include/dm/uclass.h b/include/dm/uclass.h
> index d56877c..d214b88 100644
> --- a/include/dm/uclass.h
> +++ b/include/dm/uclass.h
> @@ -240,12 +240,7 @@ int uclass_resolve_seq(struct udevice *dev);
>   * are no more devices.
>   * @uc: uclass to scan
>   */
> -#define uclass_foreach_dev(pos, uc)                                    \
> -       for (pos = list_entry((&(uc)->dev_head)->next, typeof(*pos),    \
> -                       uclass_node);                                   \
> -            prefetch(pos->uclass_node.next),                           \
> -                       &pos->uclass_node != (&(uc)->dev_head);         \
> -            pos = list_entry(pos->uclass_node.next, typeof(*pos),      \
> -                       uclass_node))
> +#define uclass_foreach_dev(pos, uc)    \
> +       list_for_each_entry(pos, &uc->dev_head, uclass_node)
>
>  #endif
> --
> 1.9.1
>
Simon Glass Aug. 14, 2015, 9:18 p.m. UTC | #2
On 12 August 2015 at 08:15, Simon Glass <sjg@chromium.org> wrote:
> On 10 August 2015 at 10:09, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> This can be simply written with list_for_each_entry(), maybe
>> this macro was not necessary in the first place.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>>  include/dm/uclass.h | 9 ++-------
>>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index d56877c..d214b88 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -240,12 +240,7 @@  int uclass_resolve_seq(struct udevice *dev);
  * are no more devices.
  * @uc: uclass to scan
  */
-#define uclass_foreach_dev(pos, uc)					\
-	for (pos = list_entry((&(uc)->dev_head)->next, typeof(*pos),	\
-			uclass_node);					\
-	     prefetch(pos->uclass_node.next),				\
-			&pos->uclass_node != (&(uc)->dev_head);		\
-	     pos = list_entry(pos->uclass_node.next, typeof(*pos),	\
-			uclass_node))
+#define uclass_foreach_dev(pos, uc)	\
+	list_for_each_entry(pos, &uc->dev_head, uclass_node)
 
 #endif