All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Beregalov <a.beregalov@gmail.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org
Subject: [PATCH] Staging: convert to list_for_each()
Date: Sat, 6 Dec 2008 21:49:05 +0300	[thread overview]
Message-ID: <20081206184905.GA19589@orion> (raw)



Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
---

 drivers/staging/me4000/me4000.c |   42 ++++++++++++++++++--------------------
 drivers/staging/usbip/stub_rx.c |    3 +-
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/me4000/me4000.c b/drivers/staging/me4000/me4000.c
index 0ac04b7..4feb615 100644
--- a/drivers/staging/me4000/me4000.c
+++ b/drivers/staging/me4000/me4000.c
@@ -542,8 +542,7 @@ static void clear_board_info_list(void)
 	struct me4000_ao_context *ao_context;
 
 	/* Clear context lists */
-	for (board_p = me4000_board_info_list.next;
-	     board_p != &me4000_board_info_list; board_p = board_p->next) {
+	list_for_each(board_p, &me4000_board_info_list) {
 		board_info = list_entry(board_p, struct me4000_info, list);
 		/* Clear analog output context list */
 		while (!list_empty(&board_info->ao_context_list)) {
@@ -663,12 +662,13 @@ static int init_board_info(struct pci_dev *pci_dev_p,
 	}
 
 	/* Get the index of the board in the global list */
-	for (board_p = me4000_board_info_list.next, i = 0;
-	     board_p != &me4000_board_info_list; board_p = board_p->next, i++) {
+	i = 0;
+	list_for_each(board_p, &me4000_board_info_list) {
 		if (board_p == &board_info->list) {
 			board_info->board_count = i;
 			break;
 		}
+		i++;
 	}
 	if (board_p == &me4000_board_info_list) {
 		printk(KERN_ERR
@@ -1303,11 +1303,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
 		       dev, mode);
 
 		/* Search for the board context */
-		for (ptr = me4000_board_info_list.next, i = 0;
-		     ptr != &me4000_board_info_list; ptr = ptr->next, i++) {
+		i = 0;
+		list_for_each(ptr, &me4000_board_info_list) {
 			board_info = list_entry(ptr, struct me4000_info, list);
 			if (i == board)
 				break;
+			i++;
 		}
 
 		if (ptr == &me4000_board_info_list) {
@@ -1318,13 +1319,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
 		}
 
 		/* Search for the dac context */
-		for (ptr = board_info->ao_context_list.next, i = 0;
-		     ptr != &board_info->ao_context_list;
-		     ptr = ptr->next, i++) {
+		i = 0;
+		list_for_each(ptr, &board_info->ao_context_list) {
 			ao_context = list_entry(ptr, struct me4000_ao_context,
 									list);
 			if (i == dev)
 				break;
+			i++;
 		}
 
 		if (ptr == &board_info->ao_context_list) {
@@ -1384,11 +1385,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
 		PDEBUG("me4000_open():ai board = %d mode = %d\n", board, mode);
 
 		/* Search for the board context */
-		for (ptr = me4000_board_info_list.next, i = 0;
-		     ptr != &me4000_board_info_list; ptr = ptr->next, i++) {
+		i = 0;
+		list_for_each(ptr, &me4000_board_info_list) {
 			board_info = list_entry(ptr, struct me4000_info, list);
 			if (i == board)
 				break;
+			i++;
 		}
 
 		if (ptr == &me4000_board_info_list) {
@@ -1438,8 +1440,7 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
 		PDEBUG("me4000_open():board = %d\n", board);
 
 		/* Search for the board context */
-		for (ptr = me4000_board_info_list.next;
-		     ptr != &me4000_board_info_list; ptr = ptr->next) {
+		list_for_each(ptr, &me4000_board_info_list) {
 			board_info = list_entry(ptr, struct me4000_info, list);
 			if (board_info->board_count == board)
 				break;
@@ -1483,8 +1484,7 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
 		PDEBUG("me4000_open():board = %d\n", board);
 
 		/* Search for the board context */
-		for (ptr = me4000_board_info_list.next;
-		     ptr != &me4000_board_info_list; ptr = ptr->next) {
+		list_for_each(ptr, &me4000_board_info_list) {
 			board_info = list_entry(ptr, struct me4000_info, list);
 			if (board_info->board_count == board)
 				break;
@@ -1526,8 +1526,7 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
 		PDEBUG("me4000_open():board = %d\n", board);
 
 		/* Search for the board context */
-		for (ptr = me4000_board_info_list.next;
-		     ptr != &me4000_board_info_list; ptr = ptr->next) {
+		list_for_each(ptr, &me4000_board_info_list) {
 			board_info = list_entry(ptr, struct me4000_info, list);
 			if (board_info->board_count == board)
 				break;
@@ -5975,8 +5974,7 @@ static void __exit me4000_module_exit(void)
 	pci_unregister_driver(&me4000_driver);
 
 	/* Reset the boards */
-	for (board_p = me4000_board_info_list.next;
-	     board_p != &me4000_board_info_list; board_p = board_p->next) {
+	list_for_each(board_p, &me4000_board_info_list) {
 		board_info = list_entry(board_p, struct me4000_info, list);
 		me4000_reset_board(board_info);
 	}
@@ -6000,9 +5998,7 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count,
 		       (ME4000_DRIVER_VERSION & 0xFF));
 
 	/* Search for the board context */
-	for (ptr = me4000_board_info_list.next;
-	     (ptr != &me4000_board_info_list) && (len < limit);
-	     ptr = ptr->next) {
+	list_for_each(ptr, &me4000_board_info_list) {
 		board_info = list_entry(ptr, struct me4000_info, list);
 
 		len +=
@@ -6110,6 +6106,8 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count,
 		    sprintf(buf + len, "AO 3 status register = 0x%08X\n",
 			    inl(board_info->me4000_regbase +
 				ME4000_AO_03_STATUS_REG));
+		if (len >= limit)
+			break;
 	}
 
 	*eof = 1;
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 2a2cc0f..524de53 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -234,7 +234,6 @@ static void tweak_special_requests(struct urb *urb)
 static int stub_recv_cmd_unlink(struct stub_device *sdev,
 						struct usbip_header *pdu)
 {
-	struct list_head *listhead = &sdev->priv_init;
 	struct list_head *ptr;
 	unsigned long flags;
 
@@ -243,7 +242,7 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev,
 
 	spin_lock_irqsave(&sdev->priv_lock, flags);
 
-	for (ptr = listhead->next; ptr != listhead; ptr = ptr->next) {
+	list_for_each(ptr, &sdev->priv_init) {
 		priv = list_entry(ptr, struct stub_priv, list);
 		if (priv->seqnum == pdu->u.cmd_unlink.seqnum) {
 			int ret;

             reply	other threads:[~2008-12-06 18:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06 18:49 Alexander Beregalov [this message]
2008-12-06 20:37 ` [PATCH] Staging: convert to list_for_each() Alexey Dobriyan
2008-12-07  1:10   ` Greg KH

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=20081206184905.GA19589@orion \
    --to=a.beregalov@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.