Skip to content

Commit 22ded57

Browse files
JoePerchesdavem330
authored andcommitted
netconsole: Convert to pr_<level>
Use a more current logging style. Convert printks to pr_<level>. Consolidate multiple printks into a single printk to avoid any possible dmesg interleaving. Add a default "event" msg in case the listed types are ever expanded. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7d1d65c commit 22ded57

1 file changed

Lines changed: 27 additions & 30 deletions

File tree

‎drivers/net/netconsole.c‎

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
*
3535
****************************************************************/
3636

37+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38+
3739
#include <linux/mm.h>
3840
#include <linux/init.h>
3941
#include <linux/module.h>
@@ -319,8 +321,8 @@ static ssize_t store_enabled(struct netconsole_target *nt,
319321
if (enabled < 0 || enabled > 1)
320322
return -EINVAL;
321323
if (enabled == nt->enabled) {
322-
printk(KERN_INFO "netconsole: network logging has already %s\n",
323-
nt->enabled ? "started" : "stopped");
324+
pr_info("network logging has already %s\n",
325+
nt->enabled ? "started" : "stopped");
324326
return -EINVAL;
325327
}
326328

@@ -339,7 +341,7 @@ static ssize_t store_enabled(struct netconsole_target *nt,
339341
return err;
340342
}
341343

342-
printk(KERN_INFO "netconsole: network logging started\n");
344+
pr_info("network logging started\n");
343345

344346
} else { /* 0 */
345347
netpoll_cleanup(&nt->np);
@@ -358,9 +360,8 @@ static ssize_t store_dev_name(struct netconsole_target *nt,
358360
size_t len;
359361

360362
if (nt->enabled) {
361-
printk(KERN_ERR "netconsole: target (%s) is enabled, "
362-
"disable to update parameters\n",
363-
config_item_name(&nt->item));
363+
pr_err("target (%s) is enabled, disable to update parameters\n",
364+
config_item_name(&nt->item));
364365
return -EINVAL;
365366
}
366367

@@ -381,9 +382,8 @@ static ssize_t store_local_port(struct netconsole_target *nt,
381382
int rv;
382383

383384
if (nt->enabled) {
384-
printk(KERN_ERR "netconsole: target (%s) is enabled, "
385-
"disable to update parameters\n",
386-
config_item_name(&nt->item));
385+
pr_err("target (%s) is enabled, disable to update parameters\n",
386+
config_item_name(&nt->item));
387387
return -EINVAL;
388388
}
389389

@@ -400,9 +400,8 @@ static ssize_t store_remote_port(struct netconsole_target *nt,
400400
int rv;
401401

402402
if (nt->enabled) {
403-
printk(KERN_ERR "netconsole: target (%s) is enabled, "
404-
"disable to update parameters\n",
405-
config_item_name(&nt->item));
403+
pr_err("target (%s) is enabled, disable to update parameters\n",
404+
config_item_name(&nt->item));
406405
return -EINVAL;
407406
}
408407

@@ -417,17 +416,16 @@ static ssize_t store_local_ip(struct netconsole_target *nt,
417416
size_t count)
418417
{
419418
if (nt->enabled) {
420-
printk(KERN_ERR "netconsole: target (%s) is enabled, "
421-
"disable to update parameters\n",
422-
config_item_name(&nt->item));
419+
pr_err("target (%s) is enabled, disable to update parameters\n",
420+
config_item_name(&nt->item));
423421
return -EINVAL;
424422
}
425423

426424
if (strnchr(buf, count, ':')) {
427425
const char *end;
428426
if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) {
429427
if (*end && *end != '\n') {
430-
printk(KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n", *end);
428+
pr_err("invalid IPv6 address at: <%c>\n", *end);
431429
return -EINVAL;
432430
}
433431
nt->np.ipv6 = true;
@@ -448,17 +446,16 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,
448446
size_t count)
449447
{
450448
if (nt->enabled) {
451-
printk(KERN_ERR "netconsole: target (%s) is enabled, "
452-
"disable to update parameters\n",
453-
config_item_name(&nt->item));
449+
pr_err("target (%s) is enabled, disable to update parameters\n",
450+
config_item_name(&nt->item));
454451
return -EINVAL;
455452
}
456453

457454
if (strnchr(buf, count, ':')) {
458455
const char *end;
459456
if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) {
460457
if (*end && *end != '\n') {
461-
printk(KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n", *end);
458+
pr_err("invalid IPv6 address at: <%c>\n", *end);
462459
return -EINVAL;
463460
}
464461
nt->np.ipv6 = true;
@@ -481,9 +478,8 @@ static ssize_t store_remote_mac(struct netconsole_target *nt,
481478
u8 remote_mac[ETH_ALEN];
482479

483480
if (nt->enabled) {
484-
printk(KERN_ERR "netconsole: target (%s) is enabled, "
485-
"disable to update parameters\n",
486-
config_item_name(&nt->item));
481+
pr_err("target (%s) is enabled, disable to update parameters\n",
482+
config_item_name(&nt->item));
487483
return -EINVAL;
488484
}
489485

@@ -704,19 +700,20 @@ static int netconsole_netdev_event(struct notifier_block *this,
704700
}
705701
spin_unlock_irqrestore(&target_list_lock, flags);
706702
if (stopped) {
707-
printk(KERN_INFO "netconsole: network logging stopped on "
708-
"interface %s as it ", dev->name);
703+
const char *msg = "had an event";
709704
switch (event) {
710705
case NETDEV_UNREGISTER:
711-
printk(KERN_CONT "unregistered\n");
706+
msg = "unregistered";
712707
break;
713708
case NETDEV_RELEASE:
714-
printk(KERN_CONT "released slaves\n");
709+
msg = "released slaves";
715710
break;
716711
case NETDEV_JOIN:
717-
printk(KERN_CONT "is joining a master device\n");
712+
msg = "is joining a master device";
718713
break;
719714
}
715+
pr_info("network logging stopped on interface %s as it %s\n",
716+
dev->name, msg);
720717
}
721718

722719
done:
@@ -802,15 +799,15 @@ static int __init init_netconsole(void)
802799
goto undonotifier;
803800

804801
register_console(&netconsole);
805-
printk(KERN_INFO "netconsole: network logging started\n");
802+
pr_info("network logging started\n");
806803

807804
return err;
808805

809806
undonotifier:
810807
unregister_netdevice_notifier(&netconsole_netdev_notifier);
811808

812809
fail:
813-
printk(KERN_ERR "netconsole: cleaning up\n");
810+
pr_err("cleaning up\n");
814811

815812
/*
816813
* Remove all targets and destroy them (only targets created

0 commit comments

Comments
 (0)