Skip to content

Commit

Permalink
tipc: use standard printk shortcut macros (pr_err etc.)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Erik Hugne authored and Paul Gortmaker committed Jul 13, 2012
1 parent f705ab9 commit 2cf8aa1
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 174 deletions.
2 changes: 1 addition & 1 deletion net/tipc/bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
if (!item->next) {
item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
if (!item->next) {
warn("Incomplete multicast delivery, no memory\n");
pr_warn("Incomplete multicast delivery, no memory\n");
return;
}
item->next->next = NULL;
Expand Down
52 changes: 28 additions & 24 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int tipc_register_media(struct tipc_media *m_ptr)
exit:
write_unlock_bh(&tipc_net_lock);
if (res)
warn("Media <%s> registration error\n", m_ptr->name);
pr_warn("Media <%s> registration error\n", m_ptr->name);
return res;
}

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

if (!tipc_own_addr) {
warn("Bearer <%s> rejected, not supported in standalone mode\n",
name);
pr_warn("Bearer <%s> rejected, not supported in standalone mode\n",
name);
return -ENOPROTOOPT;
}
if (!bearer_name_validate(name, &b_names)) {
warn("Bearer <%s> rejected, illegal name\n", name);
pr_warn("Bearer <%s> rejected, illegal name\n", name);
return -EINVAL;
}
if (tipc_addr_domain_valid(disc_domain) &&
Expand All @@ -435,21 +435,22 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
res = 0; /* accept specified node in own cluster */
}
if (res) {
warn("Bearer <%s> rejected, illegal discovery domain\n", name);
pr_warn("Bearer <%s> rejected, illegal discovery domain\n",
name);
return -EINVAL;
}
if ((priority > TIPC_MAX_LINK_PRI) &&
(priority != TIPC_MEDIA_LINK_PRI)) {
warn("Bearer <%s> rejected, illegal priority\n", name);
pr_warn("Bearer <%s> rejected, illegal priority\n", name);
return -EINVAL;
}

write_lock_bh(&tipc_net_lock);

m_ptr = tipc_media_find(b_names.media_name);
if (!m_ptr) {
warn("Bearer <%s> rejected, media <%s> not registered\n", name,
b_names.media_name);
pr_warn("Bearer <%s> rejected, media <%s> not registered\n",
name, b_names.media_name);
goto exit;
}

Expand All @@ -465,32 +466,34 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
continue;
}
if (!strcmp(name, tipc_bearers[i].name)) {
warn("Bearer <%s> rejected, already enabled\n", name);
pr_warn("Bearer <%s> rejected, already enabled\n",
name);
goto exit;
}
if ((tipc_bearers[i].priority == priority) &&
(++with_this_prio > 2)) {
if (priority-- == 0) {
warn("Bearer <%s> rejected, duplicate priority\n",
name);
pr_warn("Bearer <%s> rejected, duplicate priority\n",
name);
goto exit;
}
warn("Bearer <%s> priority adjustment required %u->%u\n",
name, priority + 1, priority);
pr_warn("Bearer <%s> priority adjustment required %u->%u\n",
name, priority + 1, priority);
goto restart;
}
}
if (bearer_id >= MAX_BEARERS) {
warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
name, MAX_BEARERS);
pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
name, MAX_BEARERS);
goto exit;
}

b_ptr = &tipc_bearers[bearer_id];
strcpy(b_ptr->name, name);
res = m_ptr->enable_bearer(b_ptr);
if (res) {
warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res);
pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
name, -res);
goto exit;
}

Expand All @@ -508,12 +511,13 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
if (res) {
bearer_disable(b_ptr);
warn("Bearer <%s> rejected, discovery object creation failed\n",
name);
pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
name);
goto exit;
}
info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
name, tipc_addr_string_fill(addr_string, disc_domain), priority);
pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
name,
tipc_addr_string_fill(addr_string, disc_domain), priority);
exit:
write_unlock_bh(&tipc_net_lock);
return res;
Expand All @@ -531,12 +535,12 @@ int tipc_block_bearer(const char *name)
read_lock_bh(&tipc_net_lock);
b_ptr = tipc_bearer_find(name);
if (!b_ptr) {
warn("Attempt to block unknown bearer <%s>\n", name);
pr_warn("Attempt to block unknown bearer <%s>\n", name);
read_unlock_bh(&tipc_net_lock);
return -EINVAL;
}

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

info("Disabling bearer <%s>\n", b_ptr->name);
pr_info("Disabling bearer <%s>\n", b_ptr->name);
spin_lock_bh(&b_ptr->lock);
b_ptr->blocked = 1;
b_ptr->media->disable_bearer(b_ptr);
Expand All @@ -584,7 +588,7 @@ int tipc_disable_bearer(const char *name)
write_lock_bh(&tipc_net_lock);
b_ptr = tipc_bearer_find(name);
if (b_ptr == NULL) {
warn("Attempt to disable unknown bearer <%s>\n", name);
pr_warn("Attempt to disable unknown bearer <%s>\n", name);
res = -EINVAL;
} else {
bearer_disable(b_ptr);
Expand Down
6 changes: 3 additions & 3 deletions net/tipc/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static void cfg_named_msg_event(void *userdata,
if ((size < sizeof(*req_hdr)) ||
(size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) ||
(ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) {
warn("Invalid configuration message discarded\n");
pr_warn("Invalid configuration message discarded\n");
return;
}

Expand Down Expand Up @@ -478,7 +478,7 @@ int tipc_cfg_init(void)
return 0;

failed:
err("Unable to create configuration service\n");
pr_err("Unable to create configuration service\n");
return res;
}

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

void tipc_cfg_stop(void)
Expand Down
13 changes: 6 additions & 7 deletions net/tipc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <linux/module.h>

#include "core.h"
#include "ref.h"
#include "name_table.h"
#include "subscr.h"
#include "config.h"

#include <linux/module.h>

#ifndef CONFIG_TIPC_PORTS
#define CONFIG_TIPC_PORTS 8191
Expand Down Expand Up @@ -162,9 +161,9 @@ static int __init tipc_init(void)
int res;

if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
warn("Unable to create log buffer\n");
pr_warn("Unable to create log buffer\n");

info("Activated (version " TIPC_MOD_VER ")\n");
pr_info("Activated (version " TIPC_MOD_VER ")\n");

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

res = tipc_core_start();
if (res)
err("Unable to start in single node mode\n");
pr_err("Unable to start in single node mode\n");
else
info("Started in single node mode\n");
pr_info("Started in single node mode\n");
return res;
}

static void __exit tipc_exit(void)
{
tipc_core_stop_net();
tipc_core_stop();
info("Deactivated\n");
pr_info("Deactivated\n");
}

module_init(tipc_init);
Expand Down
12 changes: 2 additions & 10 deletions net/tipc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#ifndef _TIPC_CORE_H
#define _TIPC_CORE_H

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/tipc.h>
#include <linux/tipc_config.h>
#include <linux/types.h>
Expand Down Expand Up @@ -89,13 +91,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
#define TIPC_OUTPUT TIPC_LOG
#endif

#define err(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
KERN_ERR "TIPC: " fmt, ## arg)
#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
KERN_WARNING "TIPC: " fmt, ## arg)
#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
KERN_NOTICE "TIPC: " fmt, ## arg)

#ifdef CONFIG_TIPC_DEBUG

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

#define dbg(fmt, arg...) tipc_printf(DBG_OUTPUT, KERN_DEBUG fmt, ## arg);

#define msg_dbg(msg, txt) tipc_msg_dbg(DBG_OUTPUT, msg, txt);

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

#else

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

#define tipc_msg_dbg(buf, msg, txt) do {} while (0)
Expand Down
4 changes: 2 additions & 2 deletions net/tipc/discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str));
tipc_media_addr_printf(&pb, media_addr);
tipc_printbuf_validate(&pb);
warn("Duplicate %s using %s seen on <%s>\n",
node_addr_str, media_addr_str, b_ptr->name);
pr_warn("Duplicate %s using %s seen on <%s>\n", node_addr_str,
media_addr_str, b_ptr->name);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions net/tipc/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ unsigned int tipc_k_signal(Handler routine, unsigned long argument)
struct queue_item *item;

if (!handler_enabled) {
err("Signal request ignored by handler\n");
pr_err("Signal request ignored by handler\n");
return -ENOPROTOOPT;
}

spin_lock_bh(&qitem_lock);
item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC);
if (!item) {
err("Signal queue out of memory\n");
pr_err("Signal queue out of memory\n");
spin_unlock_bh(&qitem_lock);
return -ENOMEM;
}
Expand Down
Loading

0 comments on commit 2cf8aa1

Please sign in to comment.