public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* ixp4xx_hss: Little improvement in create_chan function
@ 2008-11-26 17:38 Miguel Ángel Álvarez
  2008-12-04 20:54 ` Krzysztof Halasa
  0 siblings, 1 reply; 3+ messages in thread
From: Miguel Ángel Álvarez @ 2008-11-26 17:38 UTC (permalink / raw)
  To: netdev, Krzysztof Halasa

Hi.

We are searching for the desired channel three times in the same list.
So I think we could erase two of them. What do you think?

Signed-off-by: Miguel Ángel Álvarez (gotzoncabanes@gmail.com)
---
--- ixp4xx_hss.c.orig	2008-11-19 11:26:54.000000000 +0100
+++ ixp4xx_hss.c.create_chan	2008-11-26 18:34:23.000000000 +0100
@@ -2273,10 +2273,13 @@
 	}

 	for (ch = 0; ch < MAX_CHANNELS; ch++)
-		if (channels[ch] && port->channels[ch] != CHANNEL_UNUSED) {
-			printk(KERN_DEBUG "Channel #%i already in use\n", ch);
-			err = -EBUSY;
-			goto free;
+		if (channels[ch]) {
+		 	if (port->channels[ch] != CHANNEL_UNUSED) {
+				printk(KERN_DEBUG "Channel #%i already in use\n", ch);
+				err = -EBUSY;
+				goto free;
+			} else
+				break;
 		}

 	for (id = 0; id < MAX_CHAN_DEVICES; id++)
@@ -2288,10 +2291,6 @@
 		goto free;
 	}

-	for (ch = 0; ch < MAX_CHANNELS; ch++)
-		if (channels[ch])
-			break;
-
 	minor = port->id * MAX_CHAN_DEVICES + ch;
 	chan_dev->id = id;
 	chan_dev->port = port;
@@ -2307,9 +2306,7 @@
 	if ((err = cdev_add(&chan_dev->cdev, MKDEV(chan_major, minor), 1)))
 		goto destroy_device;

-	for (ch = 0; ch < MAX_CHANNELS; ch++)
-		if (channels[ch])
-			port->channels[ch] = id;
+	port->channels[ch] = id;
 	port->chan_devices[id] = chan_dev;
 	dev_set_drvdata(chan_dev->dev, chan_dev);
 	BUG_ON(device_create_file(chan_dev->dev, &chan_attr));

Thanks

Miguel Ángel Álvarez

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-05  8:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 17:38 ixp4xx_hss: Little improvement in create_chan function Miguel Ángel Álvarez
2008-12-04 20:54 ` Krzysztof Halasa
2008-12-05  8:32   ` Miguel Ángel Álvarez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox