Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 knf, fix more error and debugging messages.
details: https://anonhg.NetBSD.org/src/rev/9615b8e3a7df
branches: trunk
changeset: 354561:9615b8e3a7df
user: christos <christos%NetBSD.org@localhost>
date: Wed Jun 21 21:55:07 2017 +0000
description:
knf, fix more error and debugging messages.
diffstat:
sys/arch/x86/x86/ipmi.c | 315 ++++++++++++++++++++++++-----------------------
1 files changed, 161 insertions(+), 154 deletions(-)
diffs (truncated from 924 to 300 lines):
diff -r 2625eb61ede3 -r 9615b8e3a7df sys/arch/x86/x86/ipmi.c
--- a/sys/arch/x86/x86/ipmi.c Wed Jun 21 21:40:36 2017 +0000
+++ b/sys/arch/x86/x86/ipmi.c Wed Jun 21 21:55:07 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $ */
+/* $NetBSD: ipmi.c,v 1.65 2017/06/21 21:55:07 christos Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.65 2017/06/21 21:55:07 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -268,14 +268,14 @@
{
switch (iftype) {
case IPMI_IF_KCS:
- return (&kcs_if);
+ return &kcs_if;
case IPMI_IF_SMIC:
- return (&smic_if);
+ return &smic_if;
case IPMI_IF_BT:
- return (&bt_if);
+ return &bt_if;
+ default:
+ return NULL;
}
-
- return (NULL);
}
/*
@@ -284,8 +284,8 @@
uint8_t
bmc_read(struct ipmi_softc *sc, int offset)
{
- return (bus_space_read_1(sc->sc_iot, sc->sc_ioh,
- offset * sc->sc_if_iospacing));
+ return bus_space_read_1(sc->sc_iot, sc->sc_ioh,
+ offset * sc->sc_if_iospacing);
}
void
@@ -344,7 +344,7 @@
delay(1);
}
- return (-1);
+ return -1;
}
@@ -385,11 +385,11 @@
int
bt_write(struct ipmi_softc *sc, int reg, uint8_t data)
{
- if (bmc_io_wait(sc, _BT_CTRL_REG, BT_BMC_BUSY, 0, "bt_write") < 0)
- return (-1);
+ if (bmc_io_wait(sc, _BT_CTRL_REG, BT_BMC_BUSY, 0, __func__) < 0)
+ return -1;
bmc_write(sc, reg, data);
- return (0);
+ return 0;
}
int
@@ -403,10 +403,10 @@
bt_write(sc, _BT_CTRL_REG, BT_HOST2BMC_ATN);
if (bmc_io_wait(sc, _BT_CTRL_REG, BT_HOST2BMC_ATN | BT_BMC_BUSY, 0,
- "bt_sendwait") < 0)
- return (-1);
+ __func__) < 0)
+ return -1;
- return (0);
+ return 0;
}
int
@@ -415,8 +415,8 @@
uint8_t len, v, i;
if (bmc_io_wait(sc, _BT_CTRL_REG, BT_BMC2HOST_ATN, BT_BMC2HOST_ATN,
- "bt_recvwait") < 0)
- return (-1);
+ __func__) < 0)
+ return -1;
bt_write(sc, _BT_CTRL_REG, BT_HOST_BUSY);
bt_write(sc, _BT_CTRL_REG, BT_BMC2HOST_ATN);
@@ -430,13 +430,13 @@
bt_write(sc, _BT_CTRL_REG, BT_HOST_BUSY);
*rxlen = len - 1;
- return (0);
+ return 0;
}
int
bt_reset(struct ipmi_softc *sc)
{
- return (-1);
+ return -1;
}
int
@@ -455,7 +455,7 @@
bmc_write(sc, _BT_INTMASK_REG, rv);
#if 0
- printf("bt_probe: %2x\n", v);
+ printf("%s: %2x\n", __func__, v);
printf(" WR : %2x\n", v & BT_CLR_WR_PTR);
printf(" RD : %2x\n", v & BT_CLR_RD_PTR);
printf(" H2B : %2x\n", v & BT_HOST2BMC_ATN);
@@ -464,7 +464,7 @@
printf(" HBSY : %2x\n", v & BT_HOST_BUSY);
printf(" BBSY : %2x\n", v & BT_BMC_BUSY);
#endif
- return (0);
+ return 0;
}
/*
@@ -509,14 +509,14 @@
int v;
/* Wait for expected flag bits */
- v = bmc_io_wait(sc, _SMIC_FLAG_REG, mask, val, "smicwait");
+ v = bmc_io_wait(sc, _SMIC_FLAG_REG, mask, val, __func__);
if (v < 0)
- return (-1);
+ return -1;
/* Return current status */
v = bmc_read(sc, _SMIC_CTRL_REG);
- dbg_printf(99, "smic_wait(%s) = %.2x\n", lbl, v);
- return (v);
+ dbg_printf(99, "%s(%s) = %#.2x\n", __func__, lbl, v);
+ return v;
}
int
@@ -524,11 +524,11 @@
{
int sts, v;
- dbg_printf(50, "smic_wcd: %.2x %.2x\n", cmd, data ? *data : -1);
+ dbg_printf(50, "%s: %#.2x %#.2x\n", __func__, cmd, data ? *data : -1);
sts = smic_wait(sc, SMIC_TX_DATA_RDY | SMIC_BUSY, SMIC_TX_DATA_RDY,
"smic_write_cmd_data ready");
if (sts < 0)
- return (sts);
+ return sts;
bmc_write(sc, _SMIC_CTRL_REG, cmd);
if (data)
@@ -538,7 +538,7 @@
v = bmc_read(sc, _SMIC_FLAG_REG);
bmc_write(sc, _SMIC_FLAG_REG, v | SMIC_BUSY);
- return (smic_wait(sc, SMIC_BUSY, 0, "smic_write_cmd_data busy"));
+ return smic_wait(sc, SMIC_BUSY, 0, __func__);
}
int
@@ -547,15 +547,15 @@
int sts;
sts = smic_wait(sc, SMIC_RX_DATA_RDY | SMIC_BUSY, SMIC_RX_DATA_RDY,
- "smic_read_data");
+ __func__);
if (sts >= 0) {
*data = bmc_read(sc, _SMIC_DATAIN_REG);
- dbg_printf(50, "smic_readdata: %.2x\n", *data);
+ dbg_printf(50, "%s: %#.2x\n", __func__, *data);
}
- return (sts);
+ return sts;
}
-#define ErrStat(a,b) if (a) printf(b);
+#define ErrStat(a, ...) if (a) printf(__VA_ARGS__);
int
smic_sendmsg(struct ipmi_softc *sc, int len, const uint8_t *data)
@@ -563,19 +563,19 @@
int sts, idx;
sts = smic_write_cmd_data(sc, SMS_CC_START_TRANSFER, &data[0]);
- ErrStat(sts != SMS_SC_WRITE_START, "smic_sendmsg: wstart");
+ ErrStat(sts != SMS_SC_WRITE_START, "%s: wstart", __func__);
for (idx = 1; idx < len - 1; idx++) {
sts = smic_write_cmd_data(sc, SMS_CC_NEXT_TRANSFER,
&data[idx]);
- ErrStat(sts != SMS_SC_WRITE_NEXT, "smic_sendmsg: write");
+ ErrStat(sts != SMS_SC_WRITE_NEXT, "%s: write", __func__);
}
sts = smic_write_cmd_data(sc, SMS_CC_END_TRANSFER, &data[idx]);
if (sts != SMS_SC_WRITE_END) {
- dbg_printf(50, "smic_sendmsg %d/%d = %.2x\n", idx, len, sts);
- return (-1);
+ dbg_printf(50, "%s: %d/%d = %#.2x\n", __func__, idx, len, sts);
+ return -1;
}
- return (0);
+ return 0;
}
int
@@ -584,35 +584,36 @@
int sts, idx;
*len = 0;
- sts = smic_wait(sc, SMIC_RX_DATA_RDY, SMIC_RX_DATA_RDY, "smic_recvmsg");
+ sts = smic_wait(sc, SMIC_RX_DATA_RDY, SMIC_RX_DATA_RDY, __func__);
if (sts < 0)
- return (-1);
+ return -1;
sts = smic_write_cmd_data(sc, SMS_CC_START_RECEIVE, NULL);
- ErrStat(sts != SMS_SC_READ_START, "smic_recvmsg: rstart");
+ ErrStat(sts != SMS_SC_READ_START, "%s: rstart", __func__);
for (idx = 0;; ) {
sts = smic_read_data(sc, &data[idx++]);
if (sts != SMS_SC_READ_START && sts != SMS_SC_READ_NEXT)
break;
smic_write_cmd_data(sc, SMS_CC_NEXT_RECEIVE, NULL);
}
- ErrStat(sts != SMS_SC_READ_END, "smic_recvmsg: rend");
+ ErrStat(sts != SMS_SC_READ_END, "%s: rend", __func__);
*len = idx;
sts = smic_write_cmd_data(sc, SMS_CC_END_RECEIVE, NULL);
if (sts != SMS_SC_READY) {
- dbg_printf(50, "smic_recvmsg %d/%d = %.2x\n", idx, maxlen, sts);
- return (-1);
+ dbg_printf(50, "%s: %d/%d = %#.2x\n",
+ __func__, idx, maxlen, sts);
+ return -1;
}
- return (0);
+ return 0;
}
int
smic_reset(struct ipmi_softc *sc)
{
- return (-1);
+ return -1;
}
int
@@ -620,9 +621,9 @@
{
/* Flag register should not be 0xFF on a good system */
if (bmc_read(sc, _SMIC_FLAG_REG) == 0xFF)
- return (-1);
+ return -1;
- return (0);
+ return 0;
}
/*
@@ -662,7 +663,7 @@
v = bmc_io_wait(sc, _KCS_STATUS_REGISTER, mask, value, lbl);
if (v < 0)
- return (v);
+ return v;
/* Check if output buffer full, read dummy byte */
if ((v & (KCS_OBF | KCS_STATE_MASK)) == (KCS_OBF | KCS_WRITE_STATE))
@@ -673,31 +674,31 @@
bmc_write(sc, _KCS_COMMAND_REGISTER, KCS_GET_STATUS);
while (bmc_read(sc, _KCS_STATUS_REGISTER) & KCS_IBF)
;
- aprint_error("ipmi: error code: %x\n",
+ aprint_error_dev(sc->sc_dev, "error code: %#x\n",
bmc_read(sc, _KCS_DATAIN_REGISTER));
}
- return (v & KCS_STATE_MASK);
+ return v & KCS_STATE_MASK;
}
int
kcs_write_cmd(struct ipmi_softc *sc, uint8_t cmd)
Home |
Main Index |
Thread Index |
Old Index