summaryrefslogtreecommitdiff
path: root/xhfc/xhfc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xhfc/xhfc.c')
-rw-r--r--xhfc/xhfc.c168
1 files changed, 79 insertions, 89 deletions
diff --git a/xhfc/xhfc.c b/xhfc/xhfc.c
index b4f736d..ad92afc 100644
--- a/xhfc/xhfc.c
+++ b/xhfc/xhfc.c
@@ -191,7 +191,7 @@ int xhfc_config_pcm(struct xhfc *xhfc, int master_or_slave)
return 0;
}
-#define debug_fz(b4, fifo, prefix, buf) \
+#define debug_fz(fifo, prefix, buf) \
do { \
sprintf(buf, "%s(fifo %d): flen=%d, " \
"zlen=%d", prefix, fifo, flen, \
@@ -301,26 +301,21 @@ void xhfc_config_data_flow(struct xhfc* x)
*/
static void hdlc_signal_complete(struct xhfc_span *xhfc_span, u8 stat)
{
- struct xhfc *xhfc = xhfc_span->xhfc;
- struct dahdi_span *dahdi_span = &xhfc_span->span;
-
-/* if STAT != 0, indicates bad frame */
if (stat != 0x00) {
if (DBG_HDLC && DBG_SPAN(xhfc_span)) {
- xhfc_info(xhfc, "(span %d) STAT=0x%02x indicates "
- "frame problem: %s\n", dahdi_span->spanno,
+ printk(KERN_INFO DRIVER_NAME "(port %d) STAT=0x%02x indicates "
+ "frame problem: %s\n", portno(xhfc_span),
stat,
(0xff == stat) ? "HDLC Abort" : "Bad FCS");
}
dahdi_hdlc_abort(xhfc_span->sigchan, (0xff == stat) ?
DAHDI_EVENT_ABORT : DAHDI_EVENT_BADFCS);
-/* STAT == 0, means frame was OK */
} else {
if (DBG_HDLC && DBG_SPAN(xhfc_span)) {
- xhfc_info(xhfc,
- "(span %d) Frame " /*"%d" */ "is good!\n",
- dahdi_span->spanno
+ printk(KERN_INFO DRIVER_NAME
+ "(port %d) Frame " /*"%d" */ "is good!\n",
+ portno(xhfc_span)
/*, xhfc_span->frames_in */ );
}
dahdi_hdlc_finish(xhfc_span->sigchan);
@@ -346,25 +341,28 @@ static int hdlc_rx_frame(struct xhfc_span *xhfc_span)
fifo = dchan_fifo(xhfc_span);
if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span))
- xhfc_info(x, "%s(fifo %d): start\n", __func__, fifo);
+ printk(KERN_INFO DRIVER_NAME ": %s(fifo %d): start\n",
+ __func__, fifo);
xhfc_selfifo(x, fifo, RECEIVE);
flen = get_Flen(x);
zlen = get_Zlen(x);
- debug_fz(x, fifo, __func__, debugbuf);
+ debug_fz(fifo, __func__, debugbuf);
if (!flen && !zlen) {
if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span))
- xhfc_info(x, "%s, nothing to receive (%ld).\n", debugbuf, xhfc_span->non_rx_cnt);
+ printk(KERN_INFO DRIVER_NAME
+ ": %s, nothing to receive (%ld)\n",
+ debugbuf, xhfc_span->non_rx_cnt);
xhfc_span->non_rx_cnt++;
return 0;
}
xhfc_span->non_rx_cnt = 0;
if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span))
- xhfc_info(x, "%s\n", debugbuf);
+ printk(KERN_INFO DRIVER_NAME ": %s\n", debugbuf);
/* if we have at least one complete frame, increment zleft to include
* status byte */
@@ -389,10 +387,10 @@ static int hdlc_rx_frame(struct xhfc_span *xhfc_span)
zleft -= j;
- if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span)) {
- xhfc_info(x, "transmitted %d bytes to dahdi, "
- "zleft=%d\n", k, zleft);
- }
+ if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span))
+ printk(KERN_INFO DRIVER_NAME
+ ": transmitted %d bytes to dahdi, "
+ "zleft=%d\n", k, zleft);
if (DBG_HDLC && DBG_SPAN(xhfc_span)) {
dbglen = 0;
@@ -400,8 +398,9 @@ static int hdlc_rx_frame(struct xhfc_span *xhfc_span)
dbglen += sprintf(debugbuf+dbglen, "%02x ", buf[i]);
debugbuf[dbglen] = '\0';
- xhfc_info(x, "%s(fifo %d): zlen=%d, zleft=%d: %s\n",
- __func__, fifo, zlen, zleft, debugbuf);
+ printk(KERN_INFO DRIVER_NAME ": %s(fifo %d): "
+ "zlen=%d, zleft=%d: %s\n", __func__,
+ fifo, zlen, zleft, debugbuf);
}
} while (zleft > 0);
@@ -412,28 +411,19 @@ static int hdlc_rx_frame(struct xhfc_span *xhfc_span)
/* If this channel is not configured with a signalling span we don't
* need to notify the rest of dahdi about this frame. */
if (!xhfc_span->sigchan) {
- if (DBG_HDLC && DBG_SPAN(xhfc_span)) {
- xhfc_info(x, "hdlc_rx_frame(fifo %d): "
- "flen %d, early end.\n", fifo, flen);
- }
+ if (DBG_HDLC && DBG_SPAN(xhfc_span))
+ printk(KERN_INFO DRIVER_NAME
+ ": %s(fifo %d): flen %d, early end\n",
+ __func__, fifo, flen);
return flen;
}
- if (flen) {
-#if 0 /* disable < 3 check for now */
- if (zlen < 3) {
- if (DBG_HDLC && DBG_SPAN(xhfc_span))
- xhfc_info(x, "odd, zlen less then 3?\n");
- dahdi_hdlc_abort(xhfc_span->sigchan, DAHDI_EVENT_ABORT);
- } else
-#endif
+ if (flen)
hdlc_signal_complete(xhfc_span, buf[i - 1]);
- }
- if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span)) {
- xhfc_info(x, "hdlc_rx_frame(fifo %d): flen=%d end.\n",
- fifo, flen);
- }
+ if (DBG_VERBOSE_HDLC && DBG_SPAN(xhfc_span))
+ printk(KERN_INFO DRIVER_NAME ": %s(fifo %d): flen=%d end\n",
+ __func__, fifo, flen);
return flen;
}
@@ -469,12 +459,12 @@ static int hdlc_tx_frame(struct xhfc_span *xhfc_span)
xhfc_selfifo(x, fifo, TRANSMIT);
zlen = get_Zlen(x);
- debug_fz(x, fifo, __func__, debugbuf);
+ debug_fz(fifo, __func__, debugbuf);
/* TODO: check zlen, etc. */
if ((XHFC_ZMAX - zlen) < size) {
static int arg;
- xhfc_info(x, "xhfc: arg (%d), zlen (%d) < what we "
+ printk(KERN_INFO DRIVER_NAME ": arg (%d), zlen (%d) < what we "
"grabbed from DAHDI (%d)!\n", ++arg, zlen, size);
size = zlen;
dahdi_hdlc_abort(xhfc_span->sigchan, DAHDI_EVENT_OVERRUN);
@@ -495,22 +485,22 @@ static int hdlc_tx_frame(struct xhfc_span *xhfc_span)
}
if (DBG_HDLC && DBG_SPAN(xhfc_span)) {
- xhfc_info(xhfc_span->xhfc, "%s\n", debugbuf);
+ printk(KERN_INFO DRIVER_NAME ": %s\n", debugbuf);
dbglen = 0;
for (i = 0; i < size; i++)
dbglen += sprintf(debugbuf+dbglen, "%02x ", buf[i]);
debugbuf[dbglen] = '\0';
- xhfc_info(xhfc_span->xhfc,
- "hdlc_tx_frame(span %d): DAHDI gave %d "
+ printk(KERN_INFO DRIVER_NAME
+ ": hdlc_tx_frame(span %d): DAHDI gave %d "
"bytes for FIFO %d (res = %d): %s\n",
dahdi_span->spanno,
size, fifo, res, debugbuf);
if (size && res != 0)
- xhfc_info(xhfc_span->xhfc,
- "Transmitted frame %d on span %d\n",
+ printk(KERN_INFO DRIVER_NAME
+ ": Transmitted frame %d on span %d\n",
frames_out - 1, dahdi_span->spanno);
}
@@ -523,15 +513,13 @@ void xhfc_hdlc_hard_xmit(struct dahdi_chan *chan)
struct dahdi_span *dahdi_span = chan->span;
struct xhfc_span *xhfc_span =
container_of(dahdi_span, struct xhfc_span, span);
- struct xhfc *xhfc = xhfc_span->xhfc;
-
- if ((DBG_FOPS || DBG_HDLC) && DBG_SPAN(xhfc_span)) {
- xhfc_info(xhfc, "hdlc_hard_xmit on chan %s (%i/%i), " \
- "span=%i (sigchan=%p, chan=%p)\n", chan->name,
- chan->channo, chan->chanpos, dahdi_span->spanno,
- xhfc_span->sigchan, chan);
- }
+ if ((DBG_FOPS || DBG_HDLC) && DBG_SPAN(xhfc_span))
+ printk(KERN_INFO DRIVER_NAME ": %s on chan %s (%i/%i), "
+ "span=%i (sigchan=%p, chan=%p)\n",
+ __func__, chan->name, chan->channo,
+ chan->chanpos, dahdi_span->spanno,
+ xhfc_span->sigchan, chan);
/* Increment the hdlc_pending counter and trigger hdlc_tx_frame */
if (xhfc_span->sigchan == chan)
@@ -766,30 +754,34 @@ int xhfc_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc)
term = (lc->lineconfig & DAHDI_CONFIG_TERM) ? 1 : 0;
- xhfc_info(xhfc, "xhfc: Configuring port %d span %d in %s " \
- "mode with termination resistance %s\n", xhfc_span->port + 1,
- span->spanno, xhfc_span->nt ? "NT" : "TE",
- term ? "ENABLED" : "DISABLED");
+ printk(KERN_INFO DRIVER_NAME ": Configuring port %d span %d in %s mode"
+ " with termination resistance %s\n",
+ portno(xhfc_span), span->spanno,
+ xhfc_span->nt ? "NT" : "TE",
+ term ? "ENABLED" : "DISABLED");
/* TODO conf hardware interface w/ GPIO */
xhfc_config_st(xhfc, xhfc_span->port, xhfc_span->nt);
- xhfc_info(xhfc, "WARNING: This driver can't configure the ports yet, "
- "expect problems if port %d isn't configured in %s "
- "mode.\n", xhfc_span->port + 1, xhfc_span->nt ? "NT" : "TE");
+ printk(KERN_INFO DRIVER_NAME ": WARNING: This driver can't configure "
+ "the ports yet, expect problems if port %d isn't "
+ "configured in %s mode\n",
+ portno(xhfc_span), xhfc_span->nt ? "NT" : "TE");
if (lc->sync < 0) {
- xhfc_info(xhfc, "Span %d has invalid sync priority (%d), " \
- "removing from sync source list\n", span->spanno,
- lc->sync);
+ printk(KERN_INFO DRIVER_NAME
+ ": Span %d has invalid sync priority (%d), "
+ "removing from sync source list\n",
+ span->spanno, lc->sync);
lc->sync = 0;
}
if (xhfc_span->nt && lc->sync) {
- xhfc_info(xhfc, "NT Spans cannot be timing sources. " \
- "Span %d requested to be timing source of " \
- "priority %d. Changing priority to 0\n", span->offset,
- lc->sync);
+ printk(KERN_INFO DRIVER_NAME
+ ": NT Spans cannot be timing sources. "
+ "Span %d requested to be timing source of "
+ "priority %d. Changing priority to 0\n",
+ span->offset, lc->sync);
lc->sync = 0;
}
@@ -801,40 +793,38 @@ int xhfc_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc)
int xhfc_chanconfig(struct dahdi_chan *chan, int sigtype)
{
int alreadyrunning;
- struct xhfc_span *bspan = container_of(chan->span, struct xhfc_span, span);
- struct xhfc *b4 = bspan->xhfc;
+ struct xhfc_span *xhfc_span = container_of(chan->span, struct xhfc_span, span);
int res;
- alreadyrunning = bspan->span.flags & DAHDI_FLAG_RUNNING;
+ alreadyrunning = xhfc_span->span.flags & DAHDI_FLAG_RUNNING;
- if (DBG_FOPS) {
- xhfc_info(b4, "%s channel %d (%s) sigtype %08x\n",
- alreadyrunning ? "Reconfigured" : "Configured",
- chan->channo, chan->name, sigtype);
- }
+ if (DBG_FOPS)
+ printk(KERN_INFO DRIVER_NAME
+ ": %s channel %d (%s) sigtype %08x\n",
+ alreadyrunning ? "Reconfigured" : "Configured",
+ chan->channo, chan->name, sigtype);
switch (sigtype) {
case DAHDI_SIG_HARDHDLC:
/* xref1 */
- if (DBG_FOPS) {
- xhfc_info(b4, "%sonfiguring hardware HDLC on %s\n",
- ((sigtype == DAHDI_SIG_HARDHDLC) ? "C" :
- "Unc"), chan->name);
- }
- bspan->sigchan = chan;
- atomic_set(&bspan->hdlc_pending, 0);
+ if (DBG_FOPS)
+ printk(KERN_INFO DRIVER_NAME
+ ": Configuring hardware HDLC on %s\n",
+ chan->name);
+ xhfc_span->sigchan = chan;
+ atomic_set(&xhfc_span->hdlc_pending, 0);
res = 0;
break;
case DAHDI_SIG_HDLCFCS:
- xhfc_info(b4, "HDLCFCS not supported\n");
+ printk(KERN_INFO DRIVER_NAME ": HDLCFCS not supported\n");
res = -ENOSYS;
break;
case DAHDI_SIG_HDLCNET:
- xhfc_info(b4, "HDLCNET not supported\n");
+ printk(KERN_INFO DRIVER_NAME ": HDLCNET not supported\n");
res = -ENOSYS;
break;
case DAHDI_SIG_HDLCRAW:
- xhfc_info(b4, "HDLCRAW not supported\n");
+ printk(KERN_INFO DRIVER_NAME ": HDLCRAW not supported\n");
res = -ENOSYS;
break;
default:
@@ -973,7 +963,7 @@ int __devinit xhfc_init_one(struct pci_dev *pdev,
unsigned long base, size;
int rc = -ENOMEM;
- printk(KERN_DEBUG "entering xhfc_init_one.\n");
+ printk(KERN_DEBUG "entering xhfc_init_one\n");
/****************
@@ -1000,7 +990,7 @@ int __devinit xhfc_init_one(struct pci_dev *pdev,
if (rc)
goto err_enable_device;
- printk(KERN_DEBUG "pci_enable_device succeeded.\n");
+ printk(KERN_DEBUG "pci_enable_device succeeded\n");
rc = pci_request_regions(pdev, DRIVER_NAME);
if (rc)
@@ -1103,7 +1093,7 @@ int __devinit xhfc_init_one(struct pci_dev *pdev,
for (span = 0; span < SPANS_PER_CHIP; span++)
if ((rc = dahdi_register(&pi->xhfc.spans[span].span, /*prefmaster*/ 1)) < 0) {
- printk(KERN_WARNING "%s %s: couldn't register spans.\n", pi->name, __func__);
+ printk(KERN_WARNING "%s %s: couldn't register spans\n", pi->name, __func__);
goto err_in_dahdi_register;
}
@@ -1174,7 +1164,7 @@ void __devexit xhfc_remove_one(struct pci_dev *pdev)
pci_set_drvdata(pdev, NULL);
kfree(pi);
- printk(KERN_DEBUG "%s: bye-bye.\n", __func__);
+ printk(KERN_DEBUG "%s: bye-bye\n", __func__);
}
/***************/