Commit 25880f7d authored by Joe Perches's avatar Joe Perches Committed by Corey Minyard
Browse files

ipmi: Use more common logging styles



Add and use #define pr_fmt/dev_fmt, and remove #define PFX

This also prefixes some messages that were not previously prefixed.

Miscellanea:

o Convert printk(KERN_<level> to pr_<level>(
o Use %s, __func__ where appropriate

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

#define pr_fmt(fmt) "IPMI poweroff: " fmt

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/proc_fs.h>
@@ -21,8 +24,6 @@
#include <linux/ipmi.h>
#include <linux/ipmi_smi.h>

#define PFX "IPMI poweroff: "

static void ipmi_po_smi_gone(int if_num);
static void ipmi_po_new_smi(int if_num, struct device *device);

@@ -192,7 +193,7 @@ static void pps_poweroff_atca(struct ipmi_user *user)
	smi_addr.channel = IPMI_BMC_CHANNEL;
	smi_addr.lun = 0;

	printk(KERN_INFO PFX "PPS powerdown hook used");
	pr_info("PPS powerdown hook used\n");

	send_msg.netfn = IPMI_NETFN_OEM;
	send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART;
@@ -201,10 +202,9 @@ static void pps_poweroff_atca(struct ipmi_user *user)
	rv = ipmi_request_in_rc_mode(user,
				     (struct ipmi_addr *) &smi_addr,
				     &send_msg);
	if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
		printk(KERN_ERR PFX "Unable to send ATCA ,"
		       " IPMI error 0x%x\n", rv);
	}
	if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE)
		pr_err("Unable to send ATCA, IPMI error 0x%x\n", rv);

	return;
}

@@ -234,12 +234,10 @@ static int ipmi_atca_detect(struct ipmi_user *user)
					    (struct ipmi_addr *) &smi_addr,
					    &send_msg);

	printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n",
	       mfg_id, prod_id);
	pr_info("ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id);
	if ((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID)
	    && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) {
		printk(KERN_INFO PFX
		       "Installing Pigeon Point Systems Poweroff Hook\n");
		pr_info("Installing Pigeon Point Systems Poweroff Hook\n");
		atca_oem_poweroff_hook = pps_poweroff_atca;
	}
	return !rv;
@@ -259,7 +257,7 @@ static void ipmi_poweroff_atca(struct ipmi_user *user)
	smi_addr.channel = IPMI_BMC_CHANNEL;
	smi_addr.lun = 0;

	printk(KERN_INFO PFX "Powering down via ATCA power command\n");
	pr_info("Powering down via ATCA power command\n");

	/*
	 * Power down
@@ -282,8 +280,8 @@ static void ipmi_poweroff_atca(struct ipmi_user *user)
	 * return code
	 */
	if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
		printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
		       " IPMI error 0x%x\n", rv);
		pr_err("Unable to send ATCA powerdown message, IPMI error 0x%x\n",
		       rv);
		goto out;
	}

@@ -334,7 +332,7 @@ static void ipmi_poweroff_cpi1(struct ipmi_user *user)
	smi_addr.channel = IPMI_BMC_CHANNEL;
	smi_addr.lun = 0;

	printk(KERN_INFO PFX "Powering down via CPI1 power command\n");
	pr_info("Powering down via CPI1 power command\n");

	/*
	 * Get IPMI ipmb address
@@ -482,7 +480,7 @@ static void ipmi_poweroff_chassis(struct ipmi_user *user)
	smi_addr.lun = 0;

 powercyclefailed:
	printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n",
	pr_info("Powering %s via IPMI chassis control command\n",
		(poweroff_powercycle ? "cycle" : "down"));

	/*
@@ -502,14 +500,14 @@ static void ipmi_poweroff_chassis(struct ipmi_user *user)
	if (rv) {
		if (poweroff_powercycle) {
			/* power cycle failed, default to power down */
			printk(KERN_ERR PFX "Unable to send chassis power " \
			       "cycle message, IPMI error 0x%x\n", rv);
			pr_err("Unable to send chassis power cycle message, IPMI error 0x%x\n",
			       rv);
			poweroff_powercycle = 0;
			goto powercyclefailed;
		}

		printk(KERN_ERR PFX "Unable to send chassis power " \
		       "down message, IPMI error 0x%x\n", rv);
		pr_err("Unable to send chassis power down message, IPMI error 0x%x\n",
		       rv);
	}
}

@@ -571,8 +569,7 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
	rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL,
			      &ipmi_user);
	if (rv) {
		printk(KERN_ERR PFX "could not create IPMI user, error %d\n",
		       rv);
		pr_err("could not create IPMI user, error %d\n", rv);
		return;
	}

@@ -594,14 +591,13 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
					    (struct ipmi_addr *) &smi_addr,
					    &send_msg);
	if (rv) {
		printk(KERN_ERR PFX "Unable to send IPMI get device id info,"
		       " IPMI error 0x%x\n", rv);
		pr_err("Unable to send IPMI get device id info, IPMI error 0x%x\n",
		       rv);
		goto out_err;
	}

	if (halt_recv_msg.msg.data_len < 12) {
		printk(KERN_ERR PFX "(chassis) IPMI get device id info too,"
		       " short, was %d bytes, needed %d bytes\n",
		pr_err("(chassis) IPMI get device id info too short, was %d bytes, needed %d bytes\n",
		       halt_recv_msg.msg.data_len, 12);
		goto out_err;
	}
@@ -622,13 +618,12 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
	}

 out_err:
	printk(KERN_ERR PFX "Unable to find a poweroff function that"
	       " will work, giving up\n");
	pr_err("Unable to find a poweroff function that will work, giving up\n");
	ipmi_destroy_user(ipmi_user);
	return;

 found:
	printk(KERN_INFO PFX "Found a %s style poweroff function\n",
	pr_info("Found a %s style poweroff function\n",
		poweroff_functions[i].platform_type);
	specific_poweroff_func = poweroff_functions[i].poweroff_func;
	old_poweroff_func = pm_power_off;
@@ -692,16 +687,15 @@ static int __init ipmi_poweroff_init(void)
{
	int rv;

	printk(KERN_INFO "Copyright (C) 2004 MontaVista Software -"
	       " IPMI Powerdown via sys_reboot.\n");
	pr_info("Copyright (C) 2004 MontaVista Software - IPMI Powerdown via sys_reboot\n");

	if (poweroff_powercycle)
		printk(KERN_INFO PFX "Power cycle is enabled.\n");
		pr_info("Power cycle is enabled\n");

#ifdef CONFIG_PROC_FS
	ipmi_table_header = register_sysctl_table(ipmi_root_table);
	if (!ipmi_table_header) {
		printk(KERN_ERR PFX "Unable to register powercycle sysctl\n");
		pr_err("Unable to register powercycle sysctl\n");
		rv = -ENOMEM;
		goto out_err;
	}
@@ -712,7 +706,7 @@ static int __init ipmi_poweroff_init(void)
#ifdef CONFIG_PROC_FS
	if (rv) {
		unregister_sysctl_table(ipmi_table_header);
		printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
		pr_err("Unable to register SMI watcher: %d\n", rv);
		goto out_err;
	}

@@ -735,8 +729,7 @@ static void __exit ipmi_poweroff_cleanup(void)
	if (ready) {
		rv = ipmi_destroy_user(ipmi_user);
		if (rv)
			printk(KERN_ERR PFX "could not cleanup the IPMI"
			       " user: 0x%x\n", rv);
			pr_err("could not cleanup the IPMI user: 0x%x\n", rv);
		pm_power_off = old_poweroff_func;
	}
}
+5 −4
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0+

#define pr_fmt(fmt) "ipmi_hardcode: " fmt

#include <linux/moduleparam.h>
#include "ipmi_si.h"

#define PFX "ipmi_hardcode: "
/*
 * There can be 4 IO ports passed in (with or without IRQs), 4 addresses,
 * a default IO port, and 1 ACPI/SPMI address.  That sets SI_MAX_DRIVERS.
@@ -100,7 +101,7 @@ int ipmi_si_hardcode_find_bmc(void)
			continue;

		io.addr_source = SI_HARDCODED;
		pr_info(PFX "probing via hardcoded address\n");
		pr_info("probing via hardcoded address\n");

		if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) {
			io.si_type = SI_KCS;
@@ -109,7 +110,7 @@ int ipmi_si_hardcode_find_bmc(void)
		} else if (strcmp(si_type[i], "bt") == 0) {
			io.si_type = SI_BT;
		} else {
			pr_warn(PFX "Interface type specified for interface %d, was invalid: %s\n",
			pr_warn("Interface type specified for interface %d, was invalid: %s\n",
				i, si_type[i]);
			continue;
		}
@@ -123,7 +124,7 @@ int ipmi_si_hardcode_find_bmc(void)
			io.addr_data = addrs[i];
			io.addr_type = IPMI_MEM_ADDR_SPACE;
		} else {
			pr_warn(PFX "Interface type specified for interface %d, but port and address were not set or set to zero.\n",
			pr_warn("Interface type specified for interface %d, but port and address were not set or set to zero\n",
				i);
			continue;
		}
+9 −8
Original line number Diff line number Diff line
@@ -5,12 +5,13 @@
 * Handling for dynamically adding/removing IPMI devices through
 * a module parameter (and thus sysfs).
 */

#define pr_fmt(fmt) "ipmi_hotmod: " fmt

#include <linux/moduleparam.h>
#include <linux/ipmi.h>
#include "ipmi_si.h"

#define PFX "ipmi_hotmod: "

static int hotmod_handler(const char *val, const struct kernel_param *kp);

module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
@@ -61,7 +62,7 @@ static int parse_str(const struct hotmod_vals *v, int *val, char *name,

	s = strchr(*curr, ',');
	if (!s) {
		pr_warn(PFX "No hotmod %s given.\n", name);
		pr_warn("No hotmod %s given\n", name);
		return -EINVAL;
	}
	*s = '\0';
@@ -74,7 +75,7 @@ static int parse_str(const struct hotmod_vals *v, int *val, char *name,
		}
	}

	pr_warn(PFX "Invalid hotmod %s '%s'\n", name, *curr);
	pr_warn("Invalid hotmod %s '%s'\n", name, *curr);
	return -EINVAL;
}

@@ -85,12 +86,12 @@ static int check_hotmod_int_op(const char *curr, const char *option,

	if (strcmp(curr, name) == 0) {
		if (!option) {
			pr_warn(PFX "No option given for '%s'\n", curr);
			pr_warn("No option given for '%s'\n", curr);
			return -EINVAL;
		}
		*val = simple_strtoul(option, &n, 0);
		if ((*n != '\0') || (*option == '\0')) {
			pr_warn(PFX "Bad option given for '%s'\n", curr);
			pr_warn("Bad option given for '%s'\n", curr);
			return -EINVAL;
		}
		return 1;
@@ -160,7 +161,7 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp)
		}
		addr = simple_strtoul(curr, &n, 0);
		if ((*n != '\0') || (*curr == '\0')) {
			pr_warn(PFX "Invalid hotmod address '%s'\n", curr);
			pr_warn("Invalid hotmod address '%s'\n", curr);
			break;
		}

@@ -203,7 +204,7 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp)
				continue;

			rv = -EINVAL;
			pr_warn(PFX "Invalid hotmod option '%s'\n", curr);
			pr_warn("Invalid hotmod option '%s'\n", curr);
			goto out;
		}

+11 −11
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
 * and drives the real SMI state machine.
 */

#define pr_fmt(fmt) "ipmi_si: " fmt

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/sched.h>
@@ -41,8 +43,6 @@
#include <linux/string.h>
#include <linux/ctype.h>

#define PFX "ipmi_si: "

/* Measure times between events in the driver. */
#undef DEBUG_TIMING

@@ -1530,7 +1530,7 @@ static int try_enable_event_buffer(struct smi_info *smi_info)

	rv = wait_for_msg_done(smi_info);
	if (rv) {
		pr_warn(PFX "Error getting response from get global enables command, the event buffer is not enabled.\n");
		pr_warn("Error getting response from get global enables command, the event buffer is not enabled\n");
		goto out;
	}

@@ -1541,7 +1541,7 @@ static int try_enable_event_buffer(struct smi_info *smi_info)
			resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
			resp[1] != IPMI_GET_BMC_GLOBAL_ENABLES_CMD   ||
			resp[2] != 0) {
		pr_warn(PFX "Invalid return from get global enables command, cannot enable the event buffer.\n");
		pr_warn("Invalid return from get global enables command, cannot enable the event buffer\n");
		rv = -EINVAL;
		goto out;
	}
@@ -1559,7 +1559,7 @@ static int try_enable_event_buffer(struct smi_info *smi_info)

	rv = wait_for_msg_done(smi_info);
	if (rv) {
		pr_warn(PFX "Error getting response from set global, enables command, the event buffer is not enabled.\n");
		pr_warn("Error getting response from set global, enables command, the event buffer is not enabled\n");
		goto out;
	}

@@ -1569,7 +1569,7 @@ static int try_enable_event_buffer(struct smi_info *smi_info)
	if (resp_len < 3 ||
			resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
			resp[1] != IPMI_SET_BMC_GLOBAL_ENABLES_CMD) {
		pr_warn(PFX "Invalid return from get global, enables command, not enable the event buffer.\n");
		pr_warn("Invalid return from get global, enables command, not enable the event buffer\n");
		rv = -EINVAL;
		goto out;
	}
@@ -1900,7 +1900,7 @@ int ipmi_si_add_smi(struct si_sm_io *io)
		}
	}

	pr_info(PFX "Adding %s-specified %s state machine\n",
	pr_info("Adding %s-specified %s state machine\n",
		ipmi_addr_src_to_str(new_smi->io.addr_source),
		si_to_str[new_smi->io.si_type]);

@@ -1924,7 +1924,7 @@ static int try_smi_init(struct smi_info *new_smi)
	int i;
	char *init_name = NULL;

	pr_info(PFX "Trying %s-specified %s state machine at %s address 0x%lx, slave address 0x%x, irq %d\n",
	pr_info("Trying %s-specified %s state machine at %s address 0x%lx, slave address 0x%x, irq %d\n",
		ipmi_addr_src_to_str(new_smi->io.addr_source),
		si_to_str[new_smi->io.si_type],
		addr_space_to_str[new_smi->io.addr_type],
@@ -1964,7 +1964,7 @@ static int try_smi_init(struct smi_info *new_smi)
		new_smi->pdev = platform_device_alloc("ipmi_si",
						      new_smi->si_num);
		if (!new_smi->pdev) {
			pr_err(PFX "Unable to allocate platform device\n");
			pr_err("Unable to allocate platform device\n");
			rv = -ENOMEM;
			goto out_err;
		}
@@ -2097,7 +2097,7 @@ static int init_ipmi_si(void)
	if (initialized)
		return 0;

	pr_info("IPMI System Interface driver.\n");
	pr_info("IPMI System Interface driver\n");

	/* If the user gave us a device, they presumably want us to use it */
	if (!ipmi_si_hardcode_find_bmc())
@@ -2151,7 +2151,7 @@ static int init_ipmi_si(void)
	if (unload_when_empty && list_empty(&smi_infos)) {
		mutex_unlock(&smi_infos_lock);
		cleanup_ipmi_si();
		pr_warn(PFX "Unable to find any System Interface(s)\n");
		pr_warn("Unable to find any System Interface(s)\n");
		return -ENODEV;
	} else {
		mutex_unlock(&smi_infos_lock);
+6 −6
Original line number Diff line number Diff line
@@ -4,12 +4,13 @@
 *
 * Handling for IPMI devices on the PCI bus.
 */

#define pr_fmt(fmt) "ipmi_pci: " fmt

#include <linux/module.h>
#include <linux/pci.h>
#include "ipmi_si.h"

#define PFX "ipmi_pci: "

static bool pci_registered;

static bool si_trypci = true;
@@ -40,8 +41,7 @@ static int ipmi_pci_probe_regspacing(struct si_sm_io *io)
		for (regspacing = DEFAULT_REGSPACING; regspacing <= 16;) {
			io->regspacing = regspacing;
			if (io->io_setup(io)) {
				dev_err(io->dev,
					"Could not setup I/O space\n");
				dev_err(io->dev, "Could not setup I/O space\n");
				return DEFAULT_REGSPACING;
			}
			/* write invalid cmd */
@@ -161,7 +161,7 @@ void ipmi_si_pci_init(void)
	if (si_trypci) {
		int rv = pci_register_driver(&ipmi_pci_driver);
		if (rv)
			pr_err(PFX "Unable to register PCI driver: %d\n", rv);
			pr_err("Unable to register PCI driver: %d\n", rv);
		else
			pci_registered = true;
	}
Loading