Skip to content

Commit b8cb855

Browse files
andy-shevgregkh
authored andcommitted
parport: Use list_for_each() helper
Convert hard to read custom code to list_for_each(). No functional changes intended. Note, we may not use list_for_each_entry() as at the end of the list the iterator will point to an invalid entry and may not be dereferenced. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20231016133135.1203643-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8d8ae17 commit b8cb855

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/parport/share.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,11 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
469469
/* Search for the lowest free parport number. */
470470

471471
spin_lock(&full_list_lock);
472-
for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) {
472+
num = 0;
473+
list_for_each(l, &all_ports) {
473474
struct parport *p = list_entry(l, struct parport, full_list);
474-
if (p->number != num)
475+
476+
if (p->number != num++)
475477
break;
476478
}
477479
tmp->portnum = tmp->number = num;

0 commit comments

Comments
 (0)