Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2cf8aa19 authored by Erik Hugne's avatar Erik Hugne Committed by Paul Gortmaker
Browse files

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: default avatarErik Hugne <erik.hugne@ericsson.com>
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
[PG: use pr_fmt as suggested by Joe Perches <joe@perches.com>]
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent f705ab95
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -880,7 +880,7 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
		if (!item->next) {
		if (!item->next) {
			item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
			item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
			if (!item->next) {
			if (!item->next) {
				warn("Incomplete multicast delivery, no memory\n");
				pr_warn("Incomplete multicast delivery, no memory\n");
				return;
				return;
			}
			}
			item->next->next = NULL;
			item->next->next = NULL;
+28 −24
Original line number Original line Diff line number Diff line
@@ -123,7 +123,7 @@ int tipc_register_media(struct tipc_media *m_ptr)
exit:
exit:
	write_unlock_bh(&tipc_net_lock);
	write_unlock_bh(&tipc_net_lock);
	if (res)
	if (res)
		warn("Media <%s> registration error\n", m_ptr->name);
		pr_warn("Media <%s> registration error\n", m_ptr->name);
	return res;
	return res;
}
}


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


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


@@ -448,8 +449,8 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)


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


@@ -465,23 +466,24 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
			continue;
			continue;
		}
		}
		if (!strcmp(name, tipc_bearers[i].name)) {
		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;
			goto exit;
		}
		}
		if ((tipc_bearers[i].priority == priority) &&
		if ((tipc_bearers[i].priority == priority) &&
		    (++with_this_prio > 2)) {
		    (++with_this_prio > 2)) {
			if (priority-- == 0) {
			if (priority-- == 0) {
				warn("Bearer <%s> rejected, duplicate priority\n",
				pr_warn("Bearer <%s> rejected, duplicate priority\n",
					name);
					name);
				goto exit;
				goto exit;
			}
			}
			warn("Bearer <%s> priority adjustment required %u->%u\n",
			pr_warn("Bearer <%s> priority adjustment required %u->%u\n",
				name, priority + 1, priority);
				name, priority + 1, priority);
			goto restart;
			goto restart;
		}
		}
	}
	}
	if (bearer_id >= MAX_BEARERS) {
	if (bearer_id >= MAX_BEARERS) {
		warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
		pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
			name, MAX_BEARERS);
			name, MAX_BEARERS);
		goto exit;
		goto exit;
	}
	}
@@ -490,7 +492,8 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
	strcpy(b_ptr->name, name);
	strcpy(b_ptr->name, name);
	res = m_ptr->enable_bearer(b_ptr);
	res = m_ptr->enable_bearer(b_ptr);
	if (res) {
	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;
		goto exit;
	}
	}


@@ -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);
	res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
	if (res) {
	if (res) {
		bearer_disable(b_ptr);
		bearer_disable(b_ptr);
		warn("Bearer <%s> rejected, discovery object creation failed\n",
		pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
			name);
			name);
		goto exit;
		goto exit;
	}
	}
	info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
	pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
	     name, tipc_addr_string_fill(addr_string, disc_domain), priority);
		name,
		tipc_addr_string_fill(addr_string, disc_domain), priority);
exit:
exit:
	write_unlock_bh(&tipc_net_lock);
	write_unlock_bh(&tipc_net_lock);
	return res;
	return res;
@@ -531,12 +535,12 @@ int tipc_block_bearer(const char *name)
	read_lock_bh(&tipc_net_lock);
	read_lock_bh(&tipc_net_lock);
	b_ptr = tipc_bearer_find(name);
	b_ptr = tipc_bearer_find(name);
	if (!b_ptr) {
	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);
		read_unlock_bh(&tipc_net_lock);
		return -EINVAL;
		return -EINVAL;
	}
	}


	info("Blocking bearer <%s>\n", name);
	pr_info("Blocking bearer <%s>\n", name);
	spin_lock_bh(&b_ptr->lock);
	spin_lock_bh(&b_ptr->lock);
	b_ptr->blocked = 1;
	b_ptr->blocked = 1;
	list_splice_init(&b_ptr->cong_links, &b_ptr->links);
	list_splice_init(&b_ptr->cong_links, &b_ptr->links);
@@ -562,7 +566,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
	struct tipc_link *l_ptr;
	struct tipc_link *l_ptr;
	struct tipc_link *temp_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);
	spin_lock_bh(&b_ptr->lock);
	b_ptr->blocked = 1;
	b_ptr->blocked = 1;
	b_ptr->media->disable_bearer(b_ptr);
	b_ptr->media->disable_bearer(b_ptr);
@@ -584,7 +588,7 @@ int tipc_disable_bearer(const char *name)
	write_lock_bh(&tipc_net_lock);
	write_lock_bh(&tipc_net_lock);
	b_ptr = tipc_bearer_find(name);
	b_ptr = tipc_bearer_find(name);
	if (b_ptr == NULL) {
	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;
		res = -EINVAL;
	} else {
	} else {
		bearer_disable(b_ptr);
		bearer_disable(b_ptr);
+3 −3
Original line number Original line Diff line number Diff line
@@ -432,7 +432,7 @@ static void cfg_named_msg_event(void *userdata,
	if ((size < sizeof(*req_hdr)) ||
	if ((size < sizeof(*req_hdr)) ||
	    (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) ||
	    (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) ||
	    (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) {
	    (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) {
		warn("Invalid configuration message discarded\n");
		pr_warn("Invalid configuration message discarded\n");
		return;
		return;
	}
	}


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


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


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


void tipc_cfg_stop(void)
void tipc_cfg_stop(void)
+6 −7
Original line number Original line Diff line number Diff line
@@ -34,14 +34,13 @@
 * POSSIBILITY OF SUCH DAMAGE.
 * POSSIBILITY OF SUCH DAMAGE.
 */
 */


#include <linux/module.h>

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


#include <linux/module.h>


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


	if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
	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_own_addr = 0;
	tipc_remote_management = 1;
	tipc_remote_management = 1;
@@ -175,9 +174,9 @@ static int __init tipc_init(void)


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


@@ -185,7 +184,7 @@ static void __exit tipc_exit(void)
{
{
	tipc_core_stop_net();
	tipc_core_stop_net();
	tipc_core_stop();
	tipc_core_stop();
	info("Deactivated\n");
	pr_info("Deactivated\n");
}
}


module_init(tipc_init);
module_init(tipc_init);
+2 −10
Original line number Original line Diff line number Diff line
@@ -37,6 +37,8 @@
#ifndef _TIPC_CORE_H
#ifndef _TIPC_CORE_H
#define _TIPC_CORE_H
#define _TIPC_CORE_H


#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/tipc.h>
#include <linux/tipc.h>
#include <linux/tipc_config.h>
#include <linux/tipc_config.h>
#include <linux/types.h>
#include <linux/types.h>
@@ -89,13 +91,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
#define TIPC_OUTPUT TIPC_LOG
#define TIPC_OUTPUT TIPC_LOG
#endif
#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
#ifdef CONFIG_TIPC_DEBUG


/*
/*
@@ -105,15 +100,12 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
#define DBG_OUTPUT TIPC_LOG
#define DBG_OUTPUT TIPC_LOG
#endif
#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);
#define msg_dbg(msg, txt) tipc_msg_dbg(DBG_OUTPUT, msg, txt);


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


#else
#else


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


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