From mboxrd@z Thu Jan 1 00:00:00 1970 From: Domen Puncer Date: Thu, 29 Jul 2004 11:44:16 +0000 Subject: [Kernel-janitors] [patch 2.6.8-rc2] list_for_each_entry: Message-Id: <20040729114416.GE2294@masina.coderock.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============32614372488346377==" List-Id: References: <20040729114250.GB2294@masina.coderock.org> In-Reply-To: <20040729114250.GB2294@masina.coderock.org> To: kernel-janitors@vger.kernel.org --===============32614372488346377== Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Make code more readable with list_for_each_entry. Signed-off-by: Domen Puncer --- c/drivers/macintosh/via-pmu.c Wed Jun 16 07:20:03 2004 +++ list_for_each/drivers/macintosh/via-pmu.c Wed Jul 28 18:29:26 2004 @@ -2052,12 +2052,9 @@ int pmu_register_sleep_notifier(struct pmu_sleep_notifier *n) { - struct list_head *list; struct pmu_sleep_notifier *notifier; - for (list = sleep_notifiers.next; list != &sleep_notifiers; - list = list->next) { - notifier = list_entry(list, struct pmu_sleep_notifier, list); + list_for_each_entry(notifier, &sleep_notifiers, list) { if (n->priority > notifier->priority) break; } @@ -2083,8 +2080,7 @@ struct list_head *list; struct pmu_sleep_notifier *notifier; - for (list = sleep_notifiers.prev; list != &sleep_notifiers; - list = list->prev) { + list_for_each_prev(list, &sleep_notifiers) { notifier = list_entry(list, struct pmu_sleep_notifier, list); ret = notifier->notifier_call(notifier, when); if (ret != PBOOK_SLEEP_OK) { @@ -2105,14 +2101,10 @@ broadcast_wake(void) { int ret = PBOOK_SLEEP_OK; - struct list_head *list; struct pmu_sleep_notifier *notifier; - for (list = sleep_notifiers.next; list != &sleep_notifiers; - list = list->next) { - notifier = list_entry(list, struct pmu_sleep_notifier, list); + list_for_each_entry(notifier, &sleep_notifiers, list) notifier->notifier_call(notifier, PBOOK_WAKE); - } return ret; } @@ -2725,15 +2717,13 @@ pmu_pass_intr(unsigned char *data, int len) { struct pmu_private *pp; - struct list_head *list; int i; unsigned long flags; if (len > sizeof(pp->rb_buf[0].data)) len = sizeof(pp->rb_buf[0].data); spin_lock_irqsave(&all_pvt_lock, flags); - for (list = &all_pmu_pvt; (list = list->next) != &all_pmu_pvt; ) { - pp = list_entry(list, struct pmu_private, list); + list_for_each_entry(pp, &all_pmu_pvt, list) { spin_lock(&pp->lock); i = pp->rb_put + 1; if (i >= RB_SIZE) --===============32614372488346377== Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline _______________________________________________ Kernel-janitors mailing list Kernel-janitors@lists.osdl.org http://lists.osdl.org/mailman/listinfo/kernel-janitors --===============32614372488346377==--