Message ID | 20171014200942.27388-1-harshasharmaiitr@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Harsha, [auto build test ERROR on drm/drm-next] [also build test ERROR on v4.14-rc5 next-20171013] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Harsha-Sharma/drm-omap-Replace-list_for_each-with-list_for_each_entry/20171017-014028 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm All error/warnings (new ones prefixed by >>): In file included from include/linux/linkage.h:4:0, from include/linux/kernel.h:6, from drivers/gpu//drm/omapdrm/dss/display.c:25: drivers/gpu//drm/omapdrm/dss/display.c: In function 'omapdss_register_display': >> include/linux/list.h:463:43: error: dereferencing pointer to incomplete type 'struct omp_dss_device' for (pos = list_first_entry(head, typeof(*pos), member); \ include/linux/compiler.h:553:19: note: in definition of macro '__compiletime_assert' bool __cond = !(condition); \ ^~~~~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/kernel.h:870:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~~~~~~ include/linux/kernel.h:870:20: note: in expansion of macro '__same_type' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~ >> include/linux/list.h:365:2: note: in expansion of macro 'container_of' container_of(ptr, type, member) ^~~~~~~~~~~~ >> include/linux/list.h:376:2: note: in expansion of macro 'list_entry' list_entry((ptr)->next, type, member) ^~~~~~~~~~ >> include/linux/list.h:463:13: note: in expansion of macro 'list_first_entry' for (pos = list_first_entry(head, typeof(*pos), member); \ ^~~~~~~~~~~~~~~~ >> drivers/gpu//drm/omapdrm/dss/display.c:71:2: note: in expansion of macro 'list_for_each_entry' list_for_each_entry(ldev, &panel_list, panel_list) ^~~~~~~~~~~~~~~~~~~ -- In file included from include/linux/linkage.h:4:0, from include/linux/kernel.h:6, from drivers/gpu/drm/omapdrm/dss/display.c:25: drivers/gpu/drm/omapdrm/dss/display.c: In function 'omapdss_register_display': >> include/linux/list.h:463:43: error: dereferencing pointer to incomplete type 'struct omp_dss_device' for (pos = list_first_entry(head, typeof(*pos), member); \ include/linux/compiler.h:553:19: note: in definition of macro '__compiletime_assert' bool __cond = !(condition); \ ^~~~~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/kernel.h:870:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~~~~~~ include/linux/kernel.h:870:20: note: in expansion of macro '__same_type' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~ >> include/linux/list.h:365:2: note: in expansion of macro 'container_of' container_of(ptr, type, member) ^~~~~~~~~~~~ >> include/linux/list.h:376:2: note: in expansion of macro 'list_entry' list_entry((ptr)->next, type, member) ^~~~~~~~~~ >> include/linux/list.h:463:13: note: in expansion of macro 'list_first_entry' for (pos = list_first_entry(head, typeof(*pos), member); \ ^~~~~~~~~~~~~~~~ drivers/gpu/drm/omapdrm/dss/display.c:71:2: note: in expansion of macro 'list_for_each_entry' list_for_each_entry(ldev, &panel_list, panel_list) ^~~~~~~~~~~~~~~~~~~ vim +463 include/linux/list.h ^1da177e Linus Torvalds 2005-04-16 357 ^1da177e Linus Torvalds 2005-04-16 358 /** ^1da177e Linus Torvalds 2005-04-16 359 * list_entry - get the struct for this entry ^1da177e Linus Torvalds 2005-04-16 360 * @ptr: the &struct list_head pointer. ^1da177e Linus Torvalds 2005-04-16 361 * @type: the type of the struct this is embedded in. 3943f42c Andrey Utkin 2014-11-14 362 * @member: the name of the list_head within the struct. ^1da177e Linus Torvalds 2005-04-16 363 */ ^1da177e Linus Torvalds 2005-04-16 364 #define list_entry(ptr, type, member) \ ^1da177e Linus Torvalds 2005-04-16 @365 container_of(ptr, type, member) ^1da177e Linus Torvalds 2005-04-16 366 ^1da177e Linus Torvalds 2005-04-16 367 /** b5e61818 Pavel Emelianov 2007-05-08 368 * list_first_entry - get the first element from a list b5e61818 Pavel Emelianov 2007-05-08 369 * @ptr: the list head to take the element from. b5e61818 Pavel Emelianov 2007-05-08 370 * @type: the type of the struct this is embedded in. 3943f42c Andrey Utkin 2014-11-14 371 * @member: the name of the list_head within the struct. b5e61818 Pavel Emelianov 2007-05-08 372 * b5e61818 Pavel Emelianov 2007-05-08 373 * Note, that list is expected to be not empty. b5e61818 Pavel Emelianov 2007-05-08 374 */ b5e61818 Pavel Emelianov 2007-05-08 375 #define list_first_entry(ptr, type, member) \ b5e61818 Pavel Emelianov 2007-05-08 @376 list_entry((ptr)->next, type, member) b5e61818 Pavel Emelianov 2007-05-08 377 b5e61818 Pavel Emelianov 2007-05-08 378 /** 93be3c2e Oleg Nesterov 2013-11-12 379 * list_last_entry - get the last element from a list 93be3c2e Oleg Nesterov 2013-11-12 380 * @ptr: the list head to take the element from. 93be3c2e Oleg Nesterov 2013-11-12 381 * @type: the type of the struct this is embedded in. 3943f42c Andrey Utkin 2014-11-14 382 * @member: the name of the list_head within the struct. 93be3c2e Oleg Nesterov 2013-11-12 383 * 93be3c2e Oleg Nesterov 2013-11-12 384 * Note, that list is expected to be not empty. 93be3c2e Oleg Nesterov 2013-11-12 385 */ 93be3c2e Oleg Nesterov 2013-11-12 386 #define list_last_entry(ptr, type, member) \ 93be3c2e Oleg Nesterov 2013-11-12 387 list_entry((ptr)->prev, type, member) 93be3c2e Oleg Nesterov 2013-11-12 388 93be3c2e Oleg Nesterov 2013-11-12 389 /** 6d7581e6 Jiri Pirko 2013-05-29 390 * list_first_entry_or_null - get the first element from a list 6d7581e6 Jiri Pirko 2013-05-29 391 * @ptr: the list head to take the element from. 6d7581e6 Jiri Pirko 2013-05-29 392 * @type: the type of the struct this is embedded in. 3943f42c Andrey Utkin 2014-11-14 393 * @member: the name of the list_head within the struct. 6d7581e6 Jiri Pirko 2013-05-29 394 * 6d7581e6 Jiri Pirko 2013-05-29 395 * Note that if the list is empty, it returns NULL. 6d7581e6 Jiri Pirko 2013-05-29 396 */ 12adfd88 Chris Wilson 2016-07-23 397 #define list_first_entry_or_null(ptr, type, member) ({ \ 12adfd88 Chris Wilson 2016-07-23 398 struct list_head *head__ = (ptr); \ 12adfd88 Chris Wilson 2016-07-23 399 struct list_head *pos__ = READ_ONCE(head__->next); \ 12adfd88 Chris Wilson 2016-07-23 400 pos__ != head__ ? list_entry(pos__, type, member) : NULL; \ 12adfd88 Chris Wilson 2016-07-23 401 }) 6d7581e6 Jiri Pirko 2013-05-29 402 6d7581e6 Jiri Pirko 2013-05-29 403 /** 008208c6 Oleg Nesterov 2013-11-12 404 * list_next_entry - get the next element in list 008208c6 Oleg Nesterov 2013-11-12 405 * @pos: the type * to cursor 3943f42c Andrey Utkin 2014-11-14 406 * @member: the name of the list_head within the struct. 008208c6 Oleg Nesterov 2013-11-12 407 */ 008208c6 Oleg Nesterov 2013-11-12 408 #define list_next_entry(pos, member) \ 008208c6 Oleg Nesterov 2013-11-12 409 list_entry((pos)->member.next, typeof(*(pos)), member) 008208c6 Oleg Nesterov 2013-11-12 410 008208c6 Oleg Nesterov 2013-11-12 411 /** 008208c6 Oleg Nesterov 2013-11-12 412 * list_prev_entry - get the prev element in list 008208c6 Oleg Nesterov 2013-11-12 413 * @pos: the type * to cursor 3943f42c Andrey Utkin 2014-11-14 414 * @member: the name of the list_head within the struct. 008208c6 Oleg Nesterov 2013-11-12 415 */ 008208c6 Oleg Nesterov 2013-11-12 416 #define list_prev_entry(pos, member) \ 008208c6 Oleg Nesterov 2013-11-12 417 list_entry((pos)->member.prev, typeof(*(pos)), member) 008208c6 Oleg Nesterov 2013-11-12 418 008208c6 Oleg Nesterov 2013-11-12 419 /** ^1da177e Linus Torvalds 2005-04-16 420 * list_for_each - iterate over a list 8e3a67a9 Randy Dunlap 2006-06-25 421 * @pos: the &struct list_head to use as a loop cursor. ^1da177e Linus Torvalds 2005-04-16 422 * @head: the head for your list. ^1da177e Linus Torvalds 2005-04-16 423 */ ^1da177e Linus Torvalds 2005-04-16 424 #define list_for_each(pos, head) \ e66eed65 Linus Torvalds 2011-05-19 425 for (pos = (head)->next; pos != (head); pos = pos->next) ^1da177e Linus Torvalds 2005-04-16 426 ^1da177e Linus Torvalds 2005-04-16 427 /** ^1da177e Linus Torvalds 2005-04-16 428 * list_for_each_prev - iterate over a list backwards 8e3a67a9 Randy Dunlap 2006-06-25 429 * @pos: the &struct list_head to use as a loop cursor. ^1da177e Linus Torvalds 2005-04-16 430 * @head: the head for your list. ^1da177e Linus Torvalds 2005-04-16 431 */ ^1da177e Linus Torvalds 2005-04-16 432 #define list_for_each_prev(pos, head) \ e66eed65 Linus Torvalds 2011-05-19 433 for (pos = (head)->prev; pos != (head); pos = pos->prev) ^1da177e Linus Torvalds 2005-04-16 434 ^1da177e Linus Torvalds 2005-04-16 435 /** ^1da177e Linus Torvalds 2005-04-16 436 * list_for_each_safe - iterate over a list safe against removal of list entry 8e3a67a9 Randy Dunlap 2006-06-25 437 * @pos: the &struct list_head to use as a loop cursor. ^1da177e Linus Torvalds 2005-04-16 438 * @n: another &struct list_head to use as temporary storage ^1da177e Linus Torvalds 2005-04-16 439 * @head: the head for your list. ^1da177e Linus Torvalds 2005-04-16 440 */ ^1da177e Linus Torvalds 2005-04-16 441 #define list_for_each_safe(pos, n, head) \ ^1da177e Linus Torvalds 2005-04-16 442 for (pos = (head)->next, n = pos->next; pos != (head); \ ^1da177e Linus Torvalds 2005-04-16 443 pos = n, n = pos->next) ^1da177e Linus Torvalds 2005-04-16 444 ^1da177e Linus Torvalds 2005-04-16 445 /** 8f731f7d Randy Dunlap 2007-10-18 446 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry 37c42524 Denis V. Lunev 2007-10-16 447 * @pos: the &struct list_head to use as a loop cursor. 37c42524 Denis V. Lunev 2007-10-16 448 * @n: another &struct list_head to use as temporary storage 37c42524 Denis V. Lunev 2007-10-16 449 * @head: the head for your list. 37c42524 Denis V. Lunev 2007-10-16 450 */ 37c42524 Denis V. Lunev 2007-10-16 451 #define list_for_each_prev_safe(pos, n, head) \ 37c42524 Denis V. Lunev 2007-10-16 452 for (pos = (head)->prev, n = pos->prev; \ e66eed65 Linus Torvalds 2011-05-19 453 pos != (head); \ 37c42524 Denis V. Lunev 2007-10-16 454 pos = n, n = pos->prev) 37c42524 Denis V. Lunev 2007-10-16 455 37c42524 Denis V. Lunev 2007-10-16 456 /** ^1da177e Linus Torvalds 2005-04-16 457 * list_for_each_entry - iterate over list of given type 8e3a67a9 Randy Dunlap 2006-06-25 458 * @pos: the type * to use as a loop cursor. ^1da177e Linus Torvalds 2005-04-16 459 * @head: the head for your list. 3943f42c Andrey Utkin 2014-11-14 460 * @member: the name of the list_head within the struct. ^1da177e Linus Torvalds 2005-04-16 461 */ ^1da177e Linus Torvalds 2005-04-16 462 #define list_for_each_entry(pos, head, member) \ 93be3c2e Oleg Nesterov 2013-11-12 @463 for (pos = list_first_entry(head, typeof(*pos), member); \ e66eed65 Linus Torvalds 2011-05-19 464 &pos->member != (head); \ 8120e2e5 Oleg Nesterov 2013-11-12 465 pos = list_next_entry(pos, member)) ^1da177e Linus Torvalds 2005-04-16 466 :::::: The code at line 463 was first introduced by commit :::::: 93be3c2eb3371f022ad88acf1ab6bee8e3c38378 list: introduce list_last_entry(), use list_{first,last}_entry() :::::: TO: Oleg Nesterov <oleg@redhat.com> :::::: CC: Linus Torvalds <torvalds@linux-foundation.org> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 42279933790e..e6f86026dd93 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -43,6 +43,7 @@ static int disp_num_counter; int omapdss_register_display(struct omap_dss_device *dssdev) { + struct omp_dss_device *ldev; struct omap_dss_driver *drv = dssdev->driver; struct list_head *cur; int id; @@ -67,13 +68,9 @@ int omapdss_register_display(struct omap_dss_device *dssdev) drv->get_timings = omapdss_default_get_timings; mutex_lock(&panel_list_mutex); - list_for_each(cur, &panel_list) { - struct omap_dss_device *ldev = list_entry(cur, - struct omap_dss_device, - panel_list); + list_for_each_entry(ldev, &panel_list, panel_list) if (strcmp(ldev->alias, dssdev->alias) > 0) break; - } list_add_tail(&dssdev->panel_list, cur); mutex_unlock(&panel_list_mutex); return 0; @@ -94,12 +91,11 @@ bool omapdss_component_is_display(struct device_node *node) bool found = false; mutex_lock(&panel_list_mutex); - list_for_each_entry(dssdev, &panel_list, panel_list) { + list_for_each_entry(dssdev, &panel_list, panel_list) if (dssdev->dev->of_node == node) { found = true; goto out; } - } out: mutex_unlock(&panel_list_mutex); return found; @@ -152,8 +148,7 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from) omap_dss_put_device(from); - list_for_each(l, &panel_list) { - dssdev = list_entry(l, struct omap_dss_device, panel_list); + list_for_each_entry(dssdev, &panel_list, panel_list) if (dssdev == from) { if (list_is_last(l, &panel_list)) { dssdev = NULL; @@ -165,7 +160,6 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from) omap_dss_get_device(dssdev); goto out; } - } WARN(1, "'from' dssdev not found\n");
Replace use of list_for_each with list_for_each_entry to simplify the code and remove variables that are used only in list_for_each. Done with following coccinelle patch: @r@ identifier fn,i,f,p; expression e; iterator name list_for_each, list_for_each_entry; type T; @@ fn(...) { ++ T *i; <+... - list_for_each(p,e) + list_for_each_entry(i,e,f) { ... - T *i = list_entry(p,T,f); ... } ...+> } @@ identifier r.fn,r.p; @@ fn(...) { ... - struct list_head *p; ... when != p } @@ identifier r.fn,r.i,r.f; expression r.e; statement S; @@ fn(...) { <... list_for_each_entry(i,e,f) - { S - } ...> } @s@ identifier i,f,p; expression e; type T; @@ - list_for_each(p,e) + list_for_each_entry(i,e,f) { ... when != T *i; - i = list_entry(p,T,f); ... } @@ identifier s.p; @@ - struct list_head *p; ... when != p @@ identifier s.i,s.f; expression s.e; statement S; @@ list_for_each_entry(i,e,f) - { S - } Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com> --- drivers/gpu/drm/omapdrm/dss/display.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)