From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Luis Chamberlain <mcgrof@kernel.org>,
Joel Granados <j.granados@samsung.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [resend, PATCH v1 2/3] parport: Use list_for_each() helper
Date: Mon, 16 Oct 2023 16:31:34 +0300 [thread overview]
Message-ID: <20231016133135.1203643-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20231016133135.1203643-1-andriy.shevchenko@linux.intel.com>
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>
---
drivers/parport/share.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 8037bcd07bcf..38780f6a9119 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -469,9 +469,11 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
/* Search for the lowest free parport number. */
spin_lock(&full_list_lock);
- for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) {
+ num = 0;
+ list_for_each(l, &all_ports) {
struct parport *p = list_entry(l, struct parport, full_list);
- if (p->number != num)
+
+ if (p->number != num++)
break;
}
tmp->portnum = tmp->number = num;
--
2.40.0.1.gaa8946217a0b
next prev parent reply other threads:[~2023-10-16 13:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 13:31 [resend, PATCH v1 0/3] parport: Switch to some modern APIs Andy Shevchenko
2023-10-16 13:31 ` [resend, PATCH v1 1/3] parport: Use kasprintf() instead of fixed buffer formatting Andy Shevchenko
2023-10-16 13:31 ` Andy Shevchenko [this message]
2023-10-16 13:31 ` [resend, PATCH v1 3/3] parport: Drop unneeded NULL or 0 assignments Andy Shevchenko
2023-10-16 19:38 ` [resend, PATCH v1 0/3] parport: Switch to some modern APIs Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231016133135.1203643-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=j.granados@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox