pnp: Use list_for_each_entry() instead of open coding
authorJason Gunthorpe <jgg@mellanox.com>
Tue, 14 Apr 2020 15:10:50 +0000 (12:10 -0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 22 Apr 2020 09:36:11 +0000 (11:36 +0200)
commit01b2bafe57b19d9119413f138765ef57990921ce
tree67b559d6fe8ddc7b5547c3dd22121da545d30ec3
parentae83d0b416db002fe95601e7f97f64b59514d936
pnp: Use list_for_each_entry() instead of open coding

Aside from good practice, this avoids a warning from gcc 10:

./include/linux/kernel.h:997:3: warning: array subscript -31 is outside array bounds of ‘struct list_head[1]’ [-Warray-bounds]
  997 |  ((type *)(__mptr - offsetof(type, member))); })
      |  ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/list.h:493:2: note: in expansion of macro ‘container_of’
  493 |  container_of(ptr, type, member)
      |  ^~~~~~~~~~~~
./include/linux/pnp.h:275:30: note: in expansion of macro ‘list_entry’
  275 | #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
      |                              ^~~~~~~~~~
./include/linux/pnp.h:281:11: note: in expansion of macro ‘global_to_pnp_dev’
  281 |  (dev) != global_to_pnp_dev(&pnp_global); \
      |           ^~~~~~~~~~~~~~~~~
arch/x86/kernel/rtc.c:189:2: note: in expansion of macro ‘pnp_for_each_dev’
  189 |  pnp_for_each_dev(dev) {

Because the common code doesn't cast the starting list_head to the
containing struct.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
[ rjw: Whitespace adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
include/linux/pnp.h