ChangeSet 1.1832.55.26, 2004/09/05 05:21:11+02:00, [EMAIL PROTECTED]

[PATCH] list_for_each_entry: drivers-usb-serial-ipaq.c

Use list_for_each_entry_safe to make code more readable.
Compile tested.

Signed-off-by: Domen Puncer <[EMAIL PROTECTED]>
Signed-off-by: Maximilian Attems <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/serial/ipaq.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)


diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
--- a/drivers/usb/serial/ipaq.c 2004-10-19 08:18:11 -07:00
+++ b/drivers/usb/serial/ipaq.c 2004-10-19 08:18:11 -07:00
@@ -419,9 +419,8 @@
        struct ipaq_private     *priv = usb_get_serial_port_data(port);
        struct usb_serial       *serial = port->serial;
        int                     count, room;
-       struct ipaq_packet      *pkt;
+       struct ipaq_packet      *pkt, *tmp;
        struct urb              *urb = port->write_urb;
-       struct list_head        *tmp;
 
        if (urb->status == -EINPROGRESS) {
                /* Should never happen */
@@ -429,9 +428,7 @@
                return;
        }
        room = URBDATA_SIZE;
-       for (tmp = priv->queue.next; tmp != &priv->queue;) {
-               pkt = list_entry(tmp, struct ipaq_packet, list);
-               tmp = tmp->next;
+       list_for_each_entry_safe(pkt, tmp, &priv->queue, list) {
                count = min(room, (int)(pkt->len - pkt->written));
                memcpy(urb->transfer_buffer + (URBDATA_SIZE - room),
                       pkt->data + pkt->written, count);
@@ -503,22 +500,16 @@
 static void ipaq_destroy_lists(struct usb_serial_port *port)
 {
        struct ipaq_private     *priv = usb_get_serial_port_data(port);
-       struct list_head        *tmp;
-       struct ipaq_packet      *pkt;
+       struct ipaq_packet      *pkt, *tmp;
 
-       for (tmp = priv->queue.next; tmp != &priv->queue;) {
-               pkt = list_entry(tmp, struct ipaq_packet, list);
-               tmp = tmp->next;
+       list_for_each_entry_safe(pkt, tmp, &priv->queue, list) {
                kfree(pkt->data);
                kfree(pkt);
        }
-       for (tmp = priv->freelist.next; tmp != &priv->freelist;) {
-               pkt = list_entry(tmp, struct ipaq_packet, list);
-               tmp = tmp->next;
+       list_for_each_entry_safe(pkt, tmp, &priv->freelist, list) {
                kfree(pkt->data);
                kfree(pkt);
        }
-       return;
 }
 
 



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to