Skip to contentSkip to conversation

staging/wlags49_h2: fixed up wl_cs.c

PATCH In review Stephan Gabert 2 participants 7 messages Jun 16, 2014 Staging

lore
Share & tools
lore
#0 lore raw

cover staging/wlags49_h2: fixed up wl_cs.c

The appended patches fix up wl_cs.c from the wireless device driver wlags49 of Agere Systems Inc.

Most modifications resulted from checkpatch.pl.

Stephan Gabert (5):
staging/wlags49_h2: checkpatch: including <linux/*.h> instead of

    <asm/*.h>

staging/wlags49_h2: checkpatch: added spaces around equal sign staging/wlags49_h2: correct check of the return value of
register_netdev()
staging/wlags49_h2: convert printk calls to netdev_* calls staging/wlags49_h2: checkpatch: line over 80 characters

 drivers/staging/wlags49_h2/wl_cs.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/5 staging/wlags49_h2: checkpatch: including <linux/*.h> instead of <asm/*.h>

As warned by checkpatch.pl, one should use #include <linux/io.h> instead of #include <asm/io.h> and #include <linux/bitops.h> instead of #include <asm/bitops.h>.

---
 drivers/staging/wlags49_h2/wl_cs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/wlags49_h2/wl_cs.c +2 -2
index 3f7cf41..5c6e18c 100644
@@ -73,8 +73,8 @@
 #include <linux/interrupt.h>
 #include <linux/in.h>
 #include <linux/delay.h>
-#include <asm/io.h>
-#include <asm/bitops.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/5 staging/wlags49_h2: checkpatch: added spaces around equal sign

In reply to Stephan Gabert

Hereby the checkpatch message
ERROR: spaces required around that '=' (ctx:VxV)
gets resolved
and the neighboring equal signs are positioned in the same column.

---
 drivers/staging/wlags49_h2/wl_cs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/wlags49_h2/wl_cs.c +5 -5
index 5c6e18c..c79f1ed 100644
@@ -131,11 +131,11 @@ static int wl_adapter_attach(struct pcmcia_device *link)
 		return -ENOMEM;
 	}
 
-	link->resource[0]->end  = HCF_NUM_IO_PORTS;
-	link->resource[0]->flags= IO_DATA_PATH_WIDTH_16;
-	link->config_flags     |= CONF_ENABLE_IRQ;
-	link->config_index      = 5;
-	link->config_regs       = PRESENT_OPTION;
+	link->resource[0]->end   = HCF_NUM_IO_PORTS;
+	link->resource[0]->flags = IO_DATA_PATH_WIDTH_16;
+	link->config_flags      |= CONF_ENABLE_IRQ;
+	link->config_index       = 5;
+	link->config_regs        = PRESENT_OPTION;
 
 	link->priv = dev;
 	lp = wl_priv(dev);
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/5 staging/wlags49_h2: correct check of the return value of register_netdev()

In reply to Stephan Gabert

As mentioned in net/core/dev.c register_netdev() explicitly returns a negative errno code on failure.

So in case of failure, one should rather test whether ret is negative than just unlike 0.

---
 drivers/staging/wlags49_h2/wl_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlags49_h2/wl_cs.c +1 -1
index c79f1ed..764f547 100644
@@ -232,7 +232,7 @@ int wl_adapter_insert(struct pcmcia_device *link)
 
 	SET_NETDEV_DEV(dev, &link->dev);
 	ret = register_netdev(dev);
-	if (ret != 0) {
+	if (ret < 0) {
 		printk("%s: register_netdev() failed\n", KBUILD_MODNAME);
 		goto failed;
 	}
Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH 3/5] staging/wlags49_h2: correct check of the return value of register_netdev()

Quoted 5 lines · Stephan Gabert

As mentioned in net/core/dev.c register_netdev() explicitly returns a negative errno code on failure.

So in case of failure, one should rather test whether ret is negative than just unlike 0.

No. In the kernel the normal way is to say:

	if (ret)
		return ret;

Zero is succes and non-zero is error code.

	if (ret != 0)
		return ret;

That's a double negative and pointlessly confusing.

	if (ret != 0 != 0 != 0)

That's a hextuple negative and awesomely confusing.

There are times where a double negative is ok. When you are talking about numbers specifically:

	if (ret != 0 && ret != 3) {

That means ret is not zero or three, but zero doesn't mean success or failure, it's just a number.

For strcmp() functions you should always compare against zero because that is the idiom.

	if (strcmp(foo, bar) < 0)
	if (strcmp(foo, bar) != 0)

The first "<" means "foo" is before "bar" and "!=" means not equal.

	if (ret < 0)
		return ret;

Probably means that now ret is either zero or a positive value??? It is ambiguous.

regards,
dan carpenter

#5 lore raw

PATCH 4/5 staging/wlags49_h2: convert printk calls to netdev_* calls

In reply to Stephan Gabert

Use netdev_* where applicable.

---
 drivers/staging/wlags49_h2/wl_cs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/wlags49_h2/wl_cs.c +3 -3
index 764f547..e658000 100644
@@ -233,12 +233,12 @@ int wl_adapter_insert(struct pcmcia_device *link)
 	SET_NETDEV_DEV(dev, &link->dev);
 	ret = register_netdev(dev);
 	if (ret < 0) {
-		printk("%s: register_netdev() failed\n", KBUILD_MODNAME);
+		netdev_err(dev, "register_netdev() failed\n");
 		goto failed;
 	}
 
-	printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, mac_address"
-		" %pM\n", dev->name, dev->base_addr, dev->irq, dev->dev_addr);
+	netdev_info(dev, "io_addr %#03lx, irq %d, mac_address %pM\n",
+			dev->base_addr, dev->irq, dev->dev_addr);
 
 	return 0;
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH 5/5 staging/wlags49_h2: checkpatch: line over 80 characters

In reply to Stephan Gabert
---
 drivers/staging/wlags49_h2/wl_cs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/wlags49_h2/wl_cs.c +3 -2
index e658000..4239f0c 100644
@@ -340,8 +340,9 @@ static const struct pcmcia_device_id wl_adapter_ids[] = {
 				0x33103a9b, 0xe175b0dd),
 #else
 	PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0004),
-	PCMCIA_DEVICE_PROD_ID12("Linksys", "WCF54G_Wireless-G_CompactFlash_Card",
-				0x0733cc81, 0x98a599e1),
+	PCMCIA_DEVICE_PROD_ID12("Linksys",
+			"WCF54G_Wireless-G_CompactFlash_Card", 0x0733cc81,
+			0x98a599e1),
 #endif  /* (HCF_TYPE) & HCF_TYPE_HII5 */
 	PCMCIA_DEVICE_NULL,
 };
Signature · 1 line
1.9.1