Skip to contentSkip to conversation

staging: rtl8192u: r8192U_wx: use netdev_warn() instead of printk()

PATCH Superseded Lourdes Pedrajas 3 participants 8 messages Mar 10, 2020 – Mar 11, 2020 Staging

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8192u: r8192U_wx: use netdev_warn() instead of printk()

printk() is deprecated, use netdev_warn() instead, which is a message printing function for network devices, defined in include/linux/netdevice.h. Issue found by checkpatch.

---
Changes since v1:
- Replace message printing function pr_warn with network devices specific, netdev_warn()

 drivers/staging/rtl8192u/r8192U_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_wx.c +1 -1
index 0118edb0b9ab..58c1a8da7a8d 100644
@@ -588,7 +588,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 				hwkey);                 /* KeyContent */
 
 		} else {
-			printk("wrong type in WEP, not WEP40 and WEP104\n");
+			netdev_warn("wrong type in WEP, not WEP40 and WEP104\n");
 		}
 
 	}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 18 lines · Lourdes Pedrajas

printk() is deprecated, use netdev_warn() instead, which is a message printing function for network devices, defined in include/linux/netdevice.h. Issue found by checkpatch.

---
Changes since v1:
- Replace message printing function pr_warn with network devices specific, netdev_warn()

 drivers/staging/rtl8192u/r8192U_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_wx.c +0 -0
index 0118edb0b9ab..58c1a8da7a8d 100644

drivers/staging/rtl8192u/r8192U_wx.c static int r8192_wx_set_enc(struct net_device *dev, · line 591

Quoted 5 lines
drivers/staging/rtl8192u/r8192U_wx.c +1 -1
@@ -588,7 +588,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 				hwkey);                 /* KeyContent */
 
 		} else {
-			printk("wrong type in WEP, not WEP40 and WEP104\n");
+			netdev_warn("wrong type in WEP, not WEP40 and WEP104\n");

This does not look correct. Are you sure that you actually compiled this file. Ie, do you have a corresponding .o file?

julia

Quoted 11 lines
drivers/staging/rtl8192u/r8192U_wx.c +0 -1
 		}
 
 	}
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20200310212658.4075-1-lu%40pplo.net.

#2 lore raw
In reply to Lourdes Pedrajas
Quoted 18 lines · On Tue, 10 Mar 2020 22:26:58 +0100 Lourdes Pedrajas <[email protected]> wrote:

printk() is deprecated, use netdev_warn() instead, which is a message printing function for network devices, defined in include/linux/netdevice.h. Issue found by checkpatch.

---
Changes since v1:
- Replace message printing function pr_warn with network devices specific, netdev_warn()

 drivers/staging/rtl8192u/r8192U_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_wx.c +0 -0
index 0118edb0b9ab..58c1a8da7a8d 100644

drivers/staging/rtl8192u/r8192U_wx.c static int r8192_wx_set_enc(struct net_device *dev, · line 591

Quoted 5 lines
drivers/staging/rtl8192u/r8192U_wx.c +1 -1
@@ -588,7 +588,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 				hwkey);                 /* KeyContent */
 
 		} else {
-			printk("wrong type in WEP, not WEP40 and WEP104\n");
+			netdev_warn("wrong type in WEP, not WEP40 and WEP104\n");

Err, wait, did you try to compile this? :)

The idea of netdev_warn() is that it prefixes the error message by a reference to the specific network device, so that one knows what device is actually giving the problem (let's say you have two of these adapters on a system, or that you have virtual interfaces, etc.).

But for that to happen, it needs a pointer to the appropriate struct net_device.

Signature · 1 line
Stefano
#3 lore raw
Quoted 29 lines · Stefano Brivio
Quoted 18 lines · On Tue, 10 Mar 2020 22:26:58 +0100 Lourdes Pedrajas <[email protected]> wrote:

printk() is deprecated, use netdev_warn() instead, which is a message printing function for network devices, defined in include/linux/netdevice.h. Issue found by checkpatch.

---
Changes since v1:
- Replace message printing function pr_warn with network devices specific, netdev_warn()

 drivers/staging/rtl8192u/r8192U_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_wx.c +0 -0
index 0118edb0b9ab..58c1a8da7a8d 100644

drivers/staging/rtl8192u/r8192U_wx.c static int r8192_wx_set_enc(struct net_device *dev, · line 591

Quoted 5 lines
drivers/staging/rtl8192u/r8192U_wx.c +1 -1
@@ -588,7 +588,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 				hwkey);                 /* KeyContent */
 
 		} else {
-			printk("wrong type in WEP, not WEP40 and WEP104\n");
+			netdev_warn("wrong type in WEP, not WEP40 and WEP104\n");

Err, wait, did you try to compile this? :)

Quoted 11 lines

The idea of netdev_warn() is that it prefixes the error message by a reference to the specific network device, so that one knows what device is actually giving the problem (let's say you have two of these adapters on a system, or that you have virtual interfaces, etc.).

But for that to happen, it needs a pointer to the appropriate struct net_device.

Signature · 1 line
Stefano

Stefano, Julia: oh my bad, I did the worst error: break the compilation! :( It won't happen again!

Will search wich function is correct here.

Lourdes

#4 lore raw
Quoted 38 lines · On Tue, 10 Mar 2020 23:10:18 +0100 Lourdes Pedrajas <[email protected]> wrote:
Quoted 37 lines · Stefano Brivio
Quoted 18 lines · On Tue, 10 Mar 2020 22:26:58 +0100 Lourdes Pedrajas <[email protected]> wrote:

printk() is deprecated, use netdev_warn() instead, which is a message printing function for network devices, defined in include/linux/netdevice.h. Issue found by checkpatch.

---
Changes since v1:
- Replace message printing function pr_warn with network devices specific, netdev_warn()

 drivers/staging/rtl8192u/r8192U_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_wx.c +0 -0
index 0118edb0b9ab..58c1a8da7a8d 100644

drivers/staging/rtl8192u/r8192U_wx.c static int r8192_wx_set_enc(struct net_device *dev, · line 591

Quoted 5 lines
drivers/staging/rtl8192u/r8192U_wx.c +1 -1
@@ -588,7 +588,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 				hwkey);                 /* KeyContent */
 
 		} else {
-			printk("wrong type in WEP, not WEP40 and WEP104\n");
+			netdev_warn("wrong type in WEP, not WEP40 and WEP104\n");  

Err, wait, did you try to compile this? :)

The idea of netdev_warn() is that it prefixes the error message by a reference to the specific network device, so that one knows what device is actually giving the problem (let's say you have two of these adapters on a system, or that you have virtual interfaces, etc.).

But for that to happen, it needs a pointer to the appropriate struct net_device.

Quoted 7 lines
Quoted 3 lines
Signature · 1 line
Stefano

Stefano, Julia: oh my bad, I did the worst error: break the compilation! :( It won't happen again!

Will search wich function is correct here.

The one you already found, that part was correct. :)

Signature · 1 line
Stefano
#5 lore raw
Quoted 44 lines · Stefano Brivio
Quoted 41 lines · On Tue, 10 Mar 2020 23:10:18 +0100 Lourdes Pedrajas <[email protected]> wrote:
Quoted 40 lines · Stefano Brivio
Quoted 18 lines · On Tue, 10 Mar 2020 22:26:58 +0100 Lourdes Pedrajas <[email protected]> wrote:

printk() is deprecated, use netdev_warn() instead, which is a message printing function for network devices, defined in include/linux/netdevice.h. Issue found by checkpatch.

---
Changes since v1:
- Replace message printing function pr_warn with network devices specific, netdev_warn()

 drivers/staging/rtl8192u/r8192U_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_wx.c +0 -0
index 0118edb0b9ab..58c1a8da7a8d 100644

drivers/staging/rtl8192u/r8192U_wx.c static int r8192_wx_set_enc(struct net_device *dev, · line 591

Quoted 5 lines
drivers/staging/rtl8192u/r8192U_wx.c +1 -1
@@ -588,7 +588,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 				hwkey);                 /* KeyContent */
 
 		} else {
-			printk("wrong type in WEP, not WEP40 and WEP104\n");
+			netdev_warn("wrong type in WEP, not WEP40 and WEP104\n");  

Err, wait, did you try to compile this? :)

The idea of netdev_warn() is that it prefixes the error message by a reference to the specific network device, so that one knows what device is actually giving the problem (let's say you have two of these adapters on a system, or that you have virtual interfaces, etc.).

But for that to happen, it needs a pointer to the appropriate struct net_device.

Signature · 1 line
Stefano
Quoted 10 lines
Quoted 4 lines

Stefano, Julia: oh my bad, I did the worst error: break the compilation! :( It won't happen again!

Will search wich function is correct here.

The one you already found, that part was correct. :)

Signature · 1 line
Stefano

Indeed, also found dev_warn and dev_printk functions, but they are similar, they expect a pointer to a network device. Also thank for your explanation, I re-read those functions and now makes me sense.

Lourdes

#6 lore raw
Quoted 2 lines · On Tue, 10 Mar 2020 23:28:44 +0100 Lourdes Pedrajas <[email protected]> wrote:

Indeed, also found dev_warn and dev_printk functions, but they are similar, they expect a pointer to a network device.

Careful, those expect a more generic "struct device" instead, not a network device: a "struct net_device" embeds a "struct device".

About the representation of a "device", you can have a look at LDD3, chapter 14, page 381 (note: the book might be outdated, especially API-wise, but for general concepts I find it's still very actual):

	https://lwn.net/Kernel/LDD3/

a struct net_device is a complicated, horrible beast. Chapter 17 in LDD3 has some notes, but a quick look at:
https://www.kernel.org/doc/htmldocs/networking/API-struct-net-device.html

should be enough to give you an idea. You don't need to understand all the details now, of course!

Signature · 1 line
Stefano
#7 lore raw
Quoted 12 lines · Stefano Brivio
Quoted 2 lines · On Tue, 10 Mar 2020 23:28:44 +0100 Lourdes Pedrajas <[email protected]> wrote:

Indeed, also found dev_warn and dev_printk functions, but they are similar, they expect a pointer to a network device.

Careful, those expect a more generic "struct device" instead, not a network device: a "struct net_device" embeds a "struct device".

About the representation of a "device", you can have a look at LDD3, chapter 14, page 381 (note: the book might be outdated, especially API-wise, but for general concepts I find it's still very actual):

Quoted 12 lines
	https://lwn.net/Kernel/LDD3/

a struct net_device is a complicated, horrible beast. Chapter 17 in LDD3 has some notes, but a quick look at:
https://www.kernel.org/doc/htmldocs/networking/API-struct-net-device.html

should be enough to give you an idea. You don't need to understand all the details now, of course!

Signature · 1 line
Stefano

Thank you, I'll read that :) About the patch, pr_warn() is better this time.