Commit 445e2cbd authored by Joe Perches's avatar Joe Perches Committed by Corey Minyard
Browse files

ipmi: msghandler: Add and use pr_fmt and dev_fmt, remove PFX



Standardize the prefixing of output messages using the pr_fmt and dev_fmt
mechanisms instead of a separate #define PFX

Miscellanea:

o Because this message prefix is very long, use a non-standard define
  of #define pr_fmt(fmt) "%s" fmt, "IPMI message handler: "
  which removes ~170 bytes of object code in an x86-64 defconfig with ipmi
  (with even more object code reduction on 32 bit compilations)

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent 05c3d056
Loading
Loading
Loading
Loading
+24 −27
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@
 * Copyright 2002 MontaVista Software Inc.
 */

#define pr_fmt(fmt) "%s" fmt, "IPMI message handler: "
#define dev_fmt pr_fmt

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/poll.h>
@@ -30,8 +33,6 @@
#include <linux/workqueue.h>
#include <linux/uuid.h>

#define PFX "IPMI message handler: "

#define IPMI_DRIVER_VERSION "39.2"

static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
@@ -1474,8 +1475,7 @@ int ipmi_set_gets_events(struct ipmi_user *user, bool val)
			list_move_tail(&msg->link, &msgs);
		intf->waiting_events_count = 0;
		if (intf->event_msg_printed) {
			dev_warn(intf->si_dev,
				 PFX "Event queue no longer full\n");
			dev_warn(intf->si_dev, "Event queue no longer full\n");
			intf->event_msg_printed = 0;
		}

@@ -2276,7 +2276,7 @@ static void bmc_device_id_handler(struct ipmi_smi *intf,
			|| (msg->msg.netfn != IPMI_NETFN_APP_RESPONSE)
			|| (msg->msg.cmd != IPMI_GET_DEVICE_ID_CMD)) {
		dev_warn(intf->si_dev,
			 PFX "invalid device_id msg: addr_type=%d netfn=%x cmd=%x\n",
			 "invalid device_id msg: addr_type=%d netfn=%x cmd=%x\n",
			 msg->addr.addr_type, msg->msg.netfn, msg->msg.cmd);
		return;
	}
@@ -2284,8 +2284,7 @@ static void bmc_device_id_handler(struct ipmi_smi *intf,
	rv = ipmi_demangle_device_id(msg->msg.netfn, msg->msg.cmd,
			msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id);
	if (rv) {
		dev_warn(intf->si_dev,
			 PFX "device id demangle failed: %d\n", rv);
		dev_warn(intf->si_dev, "device id demangle failed: %d\n", rv);
		intf->bmc->dyn_id_set = 0;
	} else {
		/*
@@ -2908,8 +2907,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
		mutex_unlock(&bmc->dyn_mutex);

		dev_info(intf->si_dev,
			 "ipmi: interfacing existing BMC (man_id: 0x%6.6x,"
			 " prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n",
			 "interfacing existing BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n",
			 bmc->id.manufacturer_id,
			 bmc->id.product_id,
			 bmc->id.device_id);
@@ -2948,7 +2946,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
		rv = platform_device_register(&bmc->pdev);
		if (rv) {
			dev_err(intf->si_dev,
				PFX " Unable to register bmc device: %d\n",
				"Unable to register bmc device: %d\n",
				rv);
			goto out_list_del;
		}
@@ -2966,8 +2964,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
	 */
	rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc");
	if (rv) {
		dev_err(intf->si_dev,
			PFX "Unable to create bmc symlink: %d\n", rv);
		dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv);
		goto out_put_bmc;
	}

@@ -2976,8 +2973,8 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
	intf->my_dev_name = kasprintf(GFP_KERNEL, "ipmi%d", intf_num);
	if (!intf->my_dev_name) {
		rv = -ENOMEM;
		dev_err(intf->si_dev,
			PFX "Unable to allocate link from BMC: %d\n", rv);
		dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n",
			rv);
		goto out_unlink1;
	}

@@ -2986,8 +2983,8 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
	if (rv) {
		kfree(intf->my_dev_name);
		intf->my_dev_name = NULL;
		dev_err(intf->si_dev,
			PFX "Unable to create symlink to bmc: %d\n", rv);
		dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n",
			rv);
		goto out_free_my_dev_name;
	}

@@ -3071,7 +3068,7 @@ static void guid_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg)
	if (msg->msg.data_len < 17) {
		bmc->dyn_guid_set = 0;
		dev_warn(intf->si_dev,
			 PFX "The GUID response from the BMC was too short, it was %d but should have been 17.  Assuming GUID is not available.\n",
			 "The GUID response from the BMC was too short, it was %d but should have been 17.  Assuming GUID is not available.\n",
			 msg->msg.data_len);
		goto out;
	}
@@ -3195,7 +3192,7 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg)
		if (rv) {
			/* Got an error somehow, just give up. */
			dev_warn(intf->si_dev,
				 PFX "Error sending channel information for channel %d: %d\n",
				 "Error sending channel information for channel %d: %d\n",
				 intf->curr_channel, rv);

			intf->channel_list = intf->wchannels + set;
@@ -4075,7 +4072,7 @@ static int handle_read_event_rsp(struct ipmi_smi *intf,
		 * message.
		 */
		dev_warn(intf->si_dev,
			 PFX "Event queue full, discarding incoming events\n");
			 "Event queue full, discarding incoming events\n");
		intf->event_msg_printed = 1;
	}

@@ -4094,7 +4091,7 @@ static int handle_bmc_rsp(struct ipmi_smi *intf,
	recv_msg = (struct ipmi_recv_msg *) msg->user_data;
	if (recv_msg == NULL) {
		dev_warn(intf->si_dev,
			 "IPMI message received with no owner. This could be because of a malformed message, or because of a hardware error.  Contact your hardware vender for assistance\n");
			 "IPMI message received with no owner. This could be because of a malformed message, or because of a hardware error.  Contact your hardware vendor for assistance.\n");
		return 0;
	}

@@ -4130,7 +4127,7 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
	if (msg->rsp_size < 2) {
		/* Message is too small to be correct. */
		dev_warn(intf->si_dev,
			 PFX "BMC returned to small a message for netfn %x cmd %x, got %d bytes\n",
			 "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n",
			 (msg->data[0] >> 2) | 1, msg->data[1], msg->rsp_size);

		/* Generate an error response for the message. */
@@ -4145,7 +4142,7 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
		 * marginally correct.
		 */
		dev_warn(intf->si_dev,
			 PFX "BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n",
			 "BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n",
			 (msg->data[0] >> 2) | 1, msg->data[1],
			 msg->rsp[0] >> 2, msg->rsp[1]);

@@ -5035,11 +5032,11 @@ static int ipmi_init_msghandler(void)

	rv = driver_register(&ipmidriver.driver);
	if (rv) {
		pr_err(PFX "Could not register IPMI driver\n");
		pr_err("Could not register IPMI driver\n");
		return rv;
	}

	pr_info("ipmi message handler version " IPMI_DRIVER_VERSION "\n");
	pr_info("version " IPMI_DRIVER_VERSION "\n");

	timer_setup(&ipmi_timer, ipmi_timeout, 0);
	mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
@@ -5086,10 +5083,10 @@ static void __exit cleanup_ipmi(void)
	/* Check for buffer leaks. */
	count = atomic_read(&smi_msg_inuse_count);
	if (count != 0)
		pr_warn(PFX "SMI message count %d at exit\n", count);
		pr_warn("SMI message count %d at exit\n", count);
	count = atomic_read(&recv_msg_inuse_count);
	if (count != 0)
		pr_warn(PFX "recv message count %d at exit\n", count);
		pr_warn("recv message count %d at exit\n", count);
}
module_exit(cleanup_ipmi);