Skip to content

Commit 2cf8aa1

Browse files
Erik HugnePaul Gortmaker
authored andcommitted
tipc: use standard printk shortcut macros (pr_err etc.)
All messages should go directly to the kernel log. The TIPC specific error, warning, info and debug trace macro's are removed and all references replaced with pr_err, pr_warn, pr_info and pr_debug. Commonly used sub-strings are explicitly declared as a const char to reduce .text size. Note that this means the debug messages (changed to pr_debug), are now enabled through dynamic debugging, instead of a TIPC specific Kconfig option (TIPC_DEBUG). The latter will be phased out completely Signed-off-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> [PG: use pr_fmt as suggested by Joe Perches <joe@perches.com>] Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
1 parent f705ab9 commit 2cf8aa1

18 files changed

Lines changed: 177 additions & 174 deletions

‎net/tipc/bcast.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
880880
if (!item->next) {
881881
item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
882882
if (!item->next) {
883-
warn("Incomplete multicast delivery, no memory\n");
883+
pr_warn("Incomplete multicast delivery, no memory\n");
884884
return;
885885
}
886886
item->next->next = NULL;

‎net/tipc/bearer.c‎

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int tipc_register_media(struct tipc_media *m_ptr)
123123
exit:
124124
write_unlock_bh(&tipc_net_lock);
125125
if (res)
126-
warn("Media <%s> registration error\n", m_ptr->name);
126+
pr_warn("Media <%s> registration error\n", m_ptr->name);
127127
return res;
128128
}
129129

@@ -418,12 +418,12 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
418418
int res = -EINVAL;
419419

420420
if (!tipc_own_addr) {
421-
warn("Bearer <%s> rejected, not supported in standalone mode\n",
422-
name);
421+
pr_warn("Bearer <%s> rejected, not supported in standalone mode\n",
422+
name);
423423
return -ENOPROTOOPT;
424424
}
425425
if (!bearer_name_validate(name, &b_names)) {
426-
warn("Bearer <%s> rejected, illegal name\n", name);
426+
pr_warn("Bearer <%s> rejected, illegal name\n", name);
427427
return -EINVAL;
428428
}
429429
if (tipc_addr_domain_valid(disc_domain) &&
@@ -435,21 +435,22 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
435435
res = 0; /* accept specified node in own cluster */
436436
}
437437
if (res) {
438-
warn("Bearer <%s> rejected, illegal discovery domain\n", name);
438+
pr_warn("Bearer <%s> rejected, illegal discovery domain\n",
439+
name);
439440
return -EINVAL;
440441
}
441442
if ((priority > TIPC_MAX_LINK_PRI) &&
442443
(priority != TIPC_MEDIA_LINK_PRI)) {
443-
warn("Bearer <%s> rejected, illegal priority\n", name);
444+
pr_warn("Bearer <%s> rejected, illegal priority\n", name);
444445
return -EINVAL;
445446
}
446447

447448
write_lock_bh(&tipc_net_lock);
448449

449450
m_ptr = tipc_media_find(b_names.media_name);
450451
if (!m_ptr) {
451-
warn("Bearer <%s> rejected, media <%s> not registered\n", name,
452-
b_names.media_name);
452+
pr_warn("Bearer <%s> rejected, media <%s> not registered\n",
453+
name, b_names.media_name);
453454
goto exit;
454455
}
455456

@@ -465,32 +466,34 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
465466
continue;
466467
}
467468
if (!strcmp(name, tipc_bearers[i].name)) {
468-
warn("Bearer <%s> rejected, already enabled\n", name);
469+
pr_warn("Bearer <%s> rejected, already enabled\n",
470+
name);
469471
goto exit;
470472
}
471473
if ((tipc_bearers[i].priority == priority) &&
472474
(++with_this_prio > 2)) {
473475
if (priority-- == 0) {
474-
warn("Bearer <%s> rejected, duplicate priority\n",
475-
name);
476+
pr_warn("Bearer <%s> rejected, duplicate priority\n",
477+
name);
476478
goto exit;
477479
}
478-
warn("Bearer <%s> priority adjustment required %u->%u\n",
479-
name, priority + 1, priority);
480+
pr_warn("Bearer <%s> priority adjustment required %u->%u\n",
481+
name, priority + 1, priority);
480482
goto restart;
481483
}
482484
}
483485
if (bearer_id >= MAX_BEARERS) {
484-
warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
485-
name, MAX_BEARERS);
486+
pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
487+
name, MAX_BEARERS);
486488
goto exit;
487489
}
488490

489491
b_ptr = &tipc_bearers[bearer_id];
490492
strcpy(b_ptr->name, name);
491493
res = m_ptr->enable_bearer(b_ptr);
492494
if (res) {
493-
warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res);
495+
pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
496+
name, -res);
494497
goto exit;
495498
}
496499

@@ -508,12 +511,13 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
508511
res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
509512
if (res) {
510513
bearer_disable(b_ptr);
511-
warn("Bearer <%s> rejected, discovery object creation failed\n",
512-
name);
514+
pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
515+
name);
513516
goto exit;
514517
}
515-
info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
516-
name, tipc_addr_string_fill(addr_string, disc_domain), priority);
518+
pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
519+
name,
520+
tipc_addr_string_fill(addr_string, disc_domain), priority);
517521
exit:
518522
write_unlock_bh(&tipc_net_lock);
519523
return res;
@@ -531,12 +535,12 @@ int tipc_block_bearer(const char *name)
531535
read_lock_bh(&tipc_net_lock);
532536
b_ptr = tipc_bearer_find(name);
533537
if (!b_ptr) {
534-
warn("Attempt to block unknown bearer <%s>\n", name);
538+
pr_warn("Attempt to block unknown bearer <%s>\n", name);
535539
read_unlock_bh(&tipc_net_lock);
536540
return -EINVAL;
537541
}
538542

539-
info("Blocking bearer <%s>\n", name);
543+
pr_info("Blocking bearer <%s>\n", name);
540544
spin_lock_bh(&b_ptr->lock);
541545
b_ptr->blocked = 1;
542546
list_splice_init(&b_ptr->cong_links, &b_ptr->links);
@@ -562,7 +566,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
562566
struct tipc_link *l_ptr;
563567
struct tipc_link *temp_l_ptr;
564568

565-
info("Disabling bearer <%s>\n", b_ptr->name);
569+
pr_info("Disabling bearer <%s>\n", b_ptr->name);
566570
spin_lock_bh(&b_ptr->lock);
567571
b_ptr->blocked = 1;
568572
b_ptr->media->disable_bearer(b_ptr);
@@ -584,7 +588,7 @@ int tipc_disable_bearer(const char *name)
584588
write_lock_bh(&tipc_net_lock);
585589
b_ptr = tipc_bearer_find(name);
586590
if (b_ptr == NULL) {
587-
warn("Attempt to disable unknown bearer <%s>\n", name);
591+
pr_warn("Attempt to disable unknown bearer <%s>\n", name);
588592
res = -EINVAL;
589593
} else {
590594
bearer_disable(b_ptr);

‎net/tipc/config.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static void cfg_named_msg_event(void *userdata,
432432
if ((size < sizeof(*req_hdr)) ||
433433
(size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) ||
434434
(ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) {
435-
warn("Invalid configuration message discarded\n");
435+
pr_warn("Invalid configuration message discarded\n");
436436
return;
437437
}
438438

@@ -478,7 +478,7 @@ int tipc_cfg_init(void)
478478
return 0;
479479

480480
failed:
481-
err("Unable to create configuration service\n");
481+
pr_err("Unable to create configuration service\n");
482482
return res;
483483
}
484484

@@ -494,7 +494,7 @@ void tipc_cfg_reinit(void)
494494
seq.lower = seq.upper = tipc_own_addr;
495495
res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq);
496496
if (res)
497-
err("Unable to reinitialize configuration service\n");
497+
pr_err("Unable to reinitialize configuration service\n");
498498
}
499499

500500
void tipc_cfg_stop(void)

‎net/tipc/core.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
* POSSIBILITY OF SUCH DAMAGE.
3535
*/
3636

37-
#include <linux/module.h>
38-
3937
#include "core.h"
4038
#include "ref.h"
4139
#include "name_table.h"
4240
#include "subscr.h"
4341
#include "config.h"
4442

43+
#include <linux/module.h>
4544

4645
#ifndef CONFIG_TIPC_PORTS
4746
#define CONFIG_TIPC_PORTS 8191
@@ -162,9 +161,9 @@ static int __init tipc_init(void)
162161
int res;
163162

164163
if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
165-
warn("Unable to create log buffer\n");
164+
pr_warn("Unable to create log buffer\n");
166165

167-
info("Activated (version " TIPC_MOD_VER ")\n");
166+
pr_info("Activated (version " TIPC_MOD_VER ")\n");
168167

169168
tipc_own_addr = 0;
170169
tipc_remote_management = 1;
@@ -175,17 +174,17 @@ static int __init tipc_init(void)
175174

176175
res = tipc_core_start();
177176
if (res)
178-
err("Unable to start in single node mode\n");
177+
pr_err("Unable to start in single node mode\n");
179178
else
180-
info("Started in single node mode\n");
179+
pr_info("Started in single node mode\n");
181180
return res;
182181
}
183182

184183
static void __exit tipc_exit(void)
185184
{
186185
tipc_core_stop_net();
187186
tipc_core_stop();
188-
info("Deactivated\n");
187+
pr_info("Deactivated\n");
189188
}
190189

191190
module_init(tipc_init);

‎net/tipc/core.h‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#ifndef _TIPC_CORE_H
3838
#define _TIPC_CORE_H
3939

40+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
41+
4042
#include <linux/tipc.h>
4143
#include <linux/tipc_config.h>
4244
#include <linux/types.h>
@@ -89,13 +91,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
8991
#define TIPC_OUTPUT TIPC_LOG
9092
#endif
9193

92-
#define err(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
93-
KERN_ERR "TIPC: " fmt, ## arg)
94-
#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
95-
KERN_WARNING "TIPC: " fmt, ## arg)
96-
#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
97-
KERN_NOTICE "TIPC: " fmt, ## arg)
98-
9994
#ifdef CONFIG_TIPC_DEBUG
10095

10196
/*
@@ -105,15 +100,12 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
105100
#define DBG_OUTPUT TIPC_LOG
106101
#endif
107102

108-
#define dbg(fmt, arg...) tipc_printf(DBG_OUTPUT, KERN_DEBUG fmt, ## arg);
109-
110103
#define msg_dbg(msg, txt) tipc_msg_dbg(DBG_OUTPUT, msg, txt);
111104

112105
void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
113106

114107
#else
115108

116-
#define dbg(fmt, arg...) do {} while (0)
117109
#define msg_dbg(msg, txt) do {} while (0)
118110

119111
#define tipc_msg_dbg(buf, msg, txt) do {} while (0)

‎net/tipc/discover.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
106106
tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str));
107107
tipc_media_addr_printf(&pb, media_addr);
108108
tipc_printbuf_validate(&pb);
109-
warn("Duplicate %s using %s seen on <%s>\n",
110-
node_addr_str, media_addr_str, b_ptr->name);
109+
pr_warn("Duplicate %s using %s seen on <%s>\n", node_addr_str,
110+
media_addr_str, b_ptr->name);
111111
}
112112

113113
/**

‎net/tipc/handler.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ unsigned int tipc_k_signal(Handler routine, unsigned long argument)
5757
struct queue_item *item;
5858

5959
if (!handler_enabled) {
60-
err("Signal request ignored by handler\n");
60+
pr_err("Signal request ignored by handler\n");
6161
return -ENOPROTOOPT;
6262
}
6363

6464
spin_lock_bh(&qitem_lock);
6565
item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC);
6666
if (!item) {
67-
err("Signal queue out of memory\n");
67+
pr_err("Signal queue out of memory\n");
6868
spin_unlock_bh(&qitem_lock);
6969
return -ENOMEM;
7070
}

0 commit comments

Comments
 (0)