summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose A. Deniz <odicha@hotmail.com>2009-08-07 05:08:57 +0000
committerTzafrir Cohen <tzafrir@cohens.org.il>2010-01-05 20:46:30 +0200
commite370c33c882d52375334a654465e922f9e3860fe (patch)
tree26200f3160afcf79b18f83f6de6a26948fed1be2
parent68336b33f33424c243ea99b5560cfcc984334291 (diff)
Refformating code. Some minor fixes in defs.
git-svn-id: http://zaphfc.googlecode.com/svn/branches/2.2@3 6b77f504-82de-11de-a8c8-95b3e4aa02d0
-rw-r--r--drivers/dahdi/zaphfc/Kbuild2
-rw-r--r--drivers/dahdi/zaphfc/base.c755
-rw-r--r--drivers/dahdi/zaphfc/fifo.c116
-rw-r--r--drivers/dahdi/zaphfc/fifo.h32
-rw-r--r--drivers/dahdi/zaphfc/zaphfc.h51
5 files changed, 571 insertions, 385 deletions
diff --git a/drivers/dahdi/zaphfc/Kbuild b/drivers/dahdi/zaphfc/Kbuild
index d28d113..960fb3a 100644
--- a/drivers/dahdi/zaphfc/Kbuild
+++ b/drivers/dahdi/zaphfc/Kbuild
@@ -2,7 +2,7 @@ obj-m += zaphfc.o
EXTRA_CFLAGS := -I$(src)/.. -Wno-undef
-zaphfc-objs := base.o fifo.o
+zaphfc-objs := base.o fifo.o
$(obj)/base.o: $(src)/zaphfc.h
$(obj)/fifo.o: $(src)/fifo.h
diff --git a/drivers/dahdi/zaphfc/base.c b/drivers/dahdi/zaphfc/base.c
index 0ec8b60..64e7d22 100644
--- a/drivers/dahdi/zaphfc/base.c
+++ b/drivers/dahdi/zaphfc/base.c
@@ -1,9 +1,10 @@
/*
- * zaphfc.c - Zaptel driver for HFC-S PCI A based ISDN BRI cards
- *
- * Rewrite of d_chans in hardhdlc mode - May 2009
+ * zaphfc.c - Dahdi driver for HFC-S PCI A based ISDN BRI cards
+ *
+ * Dahdi rewrite in hardhdlc mode
* Jose A. Deniz <odicha@hotmail.com>
*
+ * Copyright (C) 2009, Jose A. Deniz
* Copyright (C) 2006, headiisue GmbH; Jens Wilke
* Copyright (C) 2004 Daniele Orlandi
* Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
@@ -11,7 +12,7 @@
* Jens Wilke <jw_vzaphfc@headissue.com>
*
* Original author of this code is
- * Daniele "Vihai" Orlandi <daniele@orlandi.com>
+ * Daniele "Vihai" Orlandi <daniele@orlandi.com>
*
* Major rewrite of the driver made by
* Klaus-Peter Junghanns <kpj@junghanns.net>
@@ -49,26 +50,25 @@
#define B1 1
#define B2 2
-static int modes = 0; // all TE
+/*
+ * Mode Te for all
+ */
+static int modes;
static int nt_modes[hfc_MAX_BOARDS];
static int nt_modes_count;
-static int force_l1_up = 0;
+static int force_l1_up;
static struct proc_dir_entry *hfc_proc_zaphfc_dir;
#ifdef DEBUG
-int debug_level = 0;
+int debug_level;
#endif
-#ifndef NULL
-#define NULL 0
-#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
-#endif
-
+#endif
static struct pci_device_id hfc_pci_ids[] = {
{PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_2BD0,
@@ -122,7 +122,7 @@ static int __devinit hfc_probe(struct pci_dev *dev
, const struct pci_device_id *ent);
static void __devexit hfc_remove(struct pci_dev *dev);
-struct pci_driver hfc_driver = {
+static struct pci_driver hfc_driver = {
.name = hfc_DRIVER_NAME,
.id_table = hfc_pci_ids,
.probe = hfc_probe,
@@ -140,37 +140,46 @@ static void hfc_softreset(struct hfc_card *card)
"resetting\n",
card->cardnum);
- hfc_outb(card, hfc_CIRM, hfc_CIRM_RESET); // softreset on
- udelay(6); // wait at least 5.21us
- hfc_outb(card, hfc_CIRM, 0); // softreset off
+/*
+ * Softreset procedure. Put it on, wait and off again
+ */
+ hfc_outb(card, hfc_CIRM, hfc_CIRM_RESET);
+ udelay(6);
+ hfc_outb(card, hfc_CIRM, 0);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((hfc_RESET_DELAY * HZ) / 1000); // wait 20 ms
+ schedule_timeout((hfc_RESET_DELAY * HZ) / 1000);
}
-void hfc_resetCard(struct hfc_card *card)
+static void hfc_resetCard(struct hfc_card *card)
{
card->regs.m1 = 0;
- hfc_outb(card, hfc_INT_M1, card->regs.m1); // no ints
+ hfc_outb(card, hfc_INT_M1, card->regs.m1);
card->regs.m2 = 0;
- hfc_outb(card, hfc_INT_M2, card->regs.m2); // not at all
+ hfc_outb(card, hfc_INT_M2, card->regs.m2);
hfc_softreset(card);
card->regs.trm = 0;
hfc_outb(card, hfc_TRM, card->regs.trm);
- // Select the non-capacitive line mode for the S/T interface */
+ /*
+ * Select the non-capacitive line mode for the S/T interface
+ */
card->regs.sctrl = hfc_SCTRL_NONE_CAP;
if (card->nt_mode) {
- // ST-Bit delay for NT-Mode
+ /*
+ * ST-Bit delay for NT-Mode
+ */
hfc_outb(card, hfc_CLKDEL, hfc_CLKDEL_NT);
card->regs.sctrl |= hfc_SCTRL_MODE_NT;
} else {
- // ST-Bit delay for TE-Mode
+ /*
+ * ST-Bit delay for TE-Mode
+ */
hfc_outb(card, hfc_CLKDEL, hfc_CLKDEL_TE);
card->regs.sctrl |= hfc_SCTRL_MODE_TE;
@@ -178,18 +187,26 @@ void hfc_resetCard(struct hfc_card *card)
hfc_outb(card, hfc_SCTRL, card->regs.sctrl);
- // S/T Auto awake
+ /*
+ * S/T Auto awake
+ */
card->regs.sctrl_e = hfc_SCTRL_E_AUTO_AWAKE;
hfc_outb(card, hfc_SCTRL_E, card->regs.sctrl_e);
- // No B-channel enabled at startup
+ /*
+ * No B-channel enabled at startup
+ */
card->regs.sctrl_r = 0;
hfc_outb(card, hfc_SCTRL_R, card->regs.sctrl_r);
- // HFC Master Mode
+ /*
+ * HFC Master Mode
+ */
hfc_outb(card, hfc_MST_MODE, hfc_MST_MODE_MASTER);
- // Connect internal blocks
+ /*
+ * Connect internal blocks
+ */
card->regs.connect =
hfc_CONNECT_B1_HFC_from_ST |
hfc_CONNECT_B1_ST_from_HFC |
@@ -199,42 +216,58 @@ void hfc_resetCard(struct hfc_card *card)
hfc_CONNECT_B2_GCI_from_HFC;
hfc_outb(card, hfc_CONNECT, card->regs.connect);
- // All bchans are HDLC by default, not useful, actually
- // since mode is set during open()
+ /*
+ * All bchans are HDLC by default, not useful, actually
+ * since mode is set during open()
+ */
hfc_outb(card, hfc_CTMT, 0);
- // bit order
+ /*
+ * bit order
+ */
hfc_outb(card, hfc_CIRM, 0);
- // Enable D-rx FIFO. At least one FIFO must be enabled (by specs)
+ /*
+ * Enable D-rx FIFO. At least one FIFO must be enabled (by specs)
+ */
card->regs.fifo_en = hfc_FIFOEN_DRX;
hfc_outb(card, hfc_FIFO_EN, card->regs.fifo_en);
- card->late_irqs=0;
+ card->late_irqs = 0;
- // Clear already pending ints
+ /*
+ * Clear already pending ints
+ */
hfc_inb(card, hfc_INT_S1);
hfc_inb(card, hfc_INT_S2);
- // Enable IRQ output
+ /*
+ * Enable IRQ output
+ */
card->regs.m1 = hfc_INTS_DREC | hfc_INTS_L1STATE | hfc_INTS_TIMER;
hfc_outb(card, hfc_INT_M1, card->regs.m1);
card->regs.m2 = hfc_M2_IRQ_ENABLE;
hfc_outb(card, hfc_INT_M2, card->regs.m2);
- // Unlocks the states machine
+ /*
+ * Unlocks the states machine
+ */
hfc_outb(card, hfc_STATES, 0);
- // There's no need to explicitly activate L1 now.
- // Activation is managed inside the interrupt routine.
+ /*
+ * There's no need to explicitly activate L1 now.
+ * Activation is managed inside the interrupt routine.
+ */
}
static void hfc_update_fifo_state(struct hfc_card *card)
{
- // I'm not sure if irqsave is needed but there could be a race
- // condition since hfc_update_fifo_state could be called from
- // both the IRQ handler and the *_(open|close) functions
+ /*
+ * I'm not sure if irqsave is needed but there could be a race
+ * condition since hfc_update_fifo_state could be called from
+ * both the IRQ handler and the *_(open|close) functions
+ */
unsigned long flags;
spin_lock_irqsave(&card->chans[B1].lock, flags);
@@ -242,19 +275,19 @@ static void hfc_update_fifo_state(struct hfc_card *card)
(card->chans[B1].status == open_framed ||
card->chans[B1].status == open_voice)) {
- if(!(card->regs.fifo_en & hfc_FIFOEN_B1RX)) {
+ if (!(card->regs.fifo_en & hfc_FIFOEN_B1RX)) {
card->regs.fifo_en |= hfc_FIFOEN_B1RX;
hfc_clear_fifo_rx(&card->chans[B1].rx);
}
- if(!(card->regs.fifo_en & hfc_FIFOEN_B1TX)) {
+ if (!(card->regs.fifo_en & hfc_FIFOEN_B1TX)) {
card->regs.fifo_en |= hfc_FIFOEN_B1TX;
hfc_clear_fifo_tx(&card->chans[B1].tx);
}
} else {
- if(card->regs.fifo_en & hfc_FIFOEN_B1RX)
+ if (card->regs.fifo_en & hfc_FIFOEN_B1RX)
card->regs.fifo_en &= ~hfc_FIFOEN_B1RX;
- if(card->regs.fifo_en & hfc_FIFOEN_B1TX)
+ if (card->regs.fifo_en & hfc_FIFOEN_B1TX)
card->regs.fifo_en &= ~hfc_FIFOEN_B1TX;
}
spin_unlock_irqrestore(&card->chans[B1].lock, flags);
@@ -265,19 +298,19 @@ static void hfc_update_fifo_state(struct hfc_card *card)
card->chans[B2].status == open_voice ||
card->chans[B2].status == sniff_aux)) {
- if(!(card->regs.fifo_en & hfc_FIFOEN_B2RX)) {
+ if (!(card->regs.fifo_en & hfc_FIFOEN_B2RX)) {
card->regs.fifo_en |= hfc_FIFOEN_B2RX;
hfc_clear_fifo_rx(&card->chans[B2].rx);
}
- if(!(card->regs.fifo_en & hfc_FIFOEN_B2TX)) {
+ if (!(card->regs.fifo_en & hfc_FIFOEN_B2TX)) {
card->regs.fifo_en |= hfc_FIFOEN_B2TX;
hfc_clear_fifo_tx(&card->chans[B2].tx);
}
} else {
- if(card->regs.fifo_en & hfc_FIFOEN_B2RX)
+ if (card->regs.fifo_en & hfc_FIFOEN_B2RX)
card->regs.fifo_en &= ~hfc_FIFOEN_B2RX;
- if(card->regs.fifo_en & hfc_FIFOEN_B2TX)
+ if (card->regs.fifo_en & hfc_FIFOEN_B2TX)
card->regs.fifo_en &= ~hfc_FIFOEN_B2TX;
}
spin_unlock_irqrestore(&card->chans[B2].lock, flags);
@@ -286,14 +319,14 @@ static void hfc_update_fifo_state(struct hfc_card *card)
if (!card->fifo_suspended &&
card->chans[D].status == open_framed) {
- if(!(card->regs.fifo_en & hfc_FIFOEN_DTX)) {
+ if (!(card->regs.fifo_en & hfc_FIFOEN_DTX)) {
card->regs.fifo_en |= hfc_FIFOEN_DTX;
card->chans[D].tx.ugly_framebuf_size = 0;
card->chans[D].tx.ugly_framebuf_off = 0;
}
} else {
- if(card->regs.fifo_en & hfc_FIFOEN_DTX)
+ if (card->regs.fifo_en & hfc_FIFOEN_DTX)
card->regs.fifo_en &= ~hfc_FIFOEN_DTX;
}
spin_unlock_irqrestore(&card->chans[D].lock, flags);
@@ -307,10 +340,12 @@ static inline void hfc_suspend_fifo(struct hfc_card *card)
hfc_update_fifo_state(card);
- // When L1 goes down D rx receives garbage; it is nice to
- // clear it to avoid a CRC error on reactivation
- // udelay is needed because the FIFO deactivation happens
- // in 250us
+ /*
+ * When L1 goes down D rx receives garbage; it is nice to
+ * clear it to avoid a CRC error on reactivation
+ * udelay is needed because the FIFO deactivation happens
+ * in 250us
+ */
udelay(250);
hfc_clear_fifo_rx(&card->chans[D].rx);
@@ -342,22 +377,25 @@ static inline void hfc_resume_fifo(struct hfc_card *card)
static void hfc_check_l1_up(struct hfc_card *card)
{
- if ((!card->nt_mode && card->l1_state != 7) ||
- (card->nt_mode && card->l1_state != 3)) {
-// 0 because this is quite verbose when an inferface is unconnected, jaw
+ if ((!card->nt_mode && card->l1_state != 7)
+ || (card->nt_mode && card->l1_state != 3)) {
+
+ hfc_outb(card, hfc_STATES, hfc_STATES_DO_ACTION |
+ hfc_STATES_ACTIVATE|
+ hfc_STATES_NT_G2_G3);
+
+ /*
+ * 0 because this is quite verbose when an inferface is unconnected, jaw
+ */
#if 0
- if(debug_level >= 1) {
+ if (debug_level >= 1) {
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"L1 is down, bringing up L1.\n",
card->cardnum);
}
#endif
-
- hfc_outb(card, hfc_STATES, hfc_STATES_DO_ACTION |
- hfc_STATES_ACTIVATE|
- hfc_STATES_NT_G2_G3);
- }
+ }
}
@@ -373,59 +411,67 @@ static int hfc_zap_open(struct dahdi_chan *zaptel_chan)
spin_lock(&chan->lock);
switch (chan->number) {
- case D:
- if (chan->status != free &&
- chan->status != open_framed) {
- spin_unlock(&chan->lock);
- return -EBUSY;
- }
-
- chan->status = open_framed;
- break;
-
- case B1:
- case B2:
- if (chan->status != free) {
- spin_unlock(&chan->lock);
- return -EBUSY;
- }
-
- chan->status = open_voice;
- break;
+ case D:
+ if (chan->status != free &&
+ chan->status != open_framed) {
+ spin_unlock(&chan->lock);
+ return -EBUSY;
+ }
+ chan->status = open_framed;
+ break;
+
+ case B1:
+ case B2:
+ if (chan->status != free) {
+ spin_unlock(&chan->lock);
+ return -EBUSY;
+ }
+ chan->status = open_voice;
+ break;
}
chan->open_by_zaptel = TRUE;
-
try_module_get(THIS_MODULE);
-
spin_unlock(&chan->lock);
switch (chan->number) {
- case D:
- break;
-
- case B1:
- // B1
- card->regs.m2 |= hfc_M2_PROC_TRANS;
- card->regs.ctmt |= hfc_CTMT_TRANSB1; // Enable transparent mode
- card->regs.cirm |= hfc_CIRM_B1_REV; // Reversed bit order
- card->regs.sctrl |= hfc_SCTRL_B1_ENA; // Enable transmission
- card->regs.sctrl_r |= hfc_SCTRL_R_B1_ENA; // Enable reception
- break;
-
- case B2:
- // B2
- card->regs.m2 |= hfc_M2_PROC_TRANS;
- card->regs.ctmt |= hfc_CTMT_TRANSB2; // Enable transparent mode
- card->regs.cirm |= hfc_CIRM_B2_REV; // Reversed bit order
- card->regs.sctrl |= hfc_SCTRL_B2_ENA; // Enable transmission
- card->regs.sctrl_r |= hfc_SCTRL_R_B2_ENA; // Enable reception
- break;
+ case D:
+ break;
+
+ case B1:
+ card->regs.m2 |= hfc_M2_PROC_TRANS;
+ /*
+ * Enable transparent mode
+ */
+ card->regs.ctmt |= hfc_CTMT_TRANSB1;
+ /*
+ * Reversed bit order
+ */
+ card->regs.cirm |= hfc_CIRM_B1_REV;
+ /*
+ * Enable transmission
+ */
+ card->regs.sctrl |= hfc_SCTRL_B1_ENA;
+ /*
+ * Enable reception
+ */
+ card->regs.sctrl_r |= hfc_SCTRL_R_B1_ENA;
+ break;
+
+ case B2:
+ card->regs.m2 |= hfc_M2_PROC_TRANS;
+ card->regs.ctmt |= hfc_CTMT_TRANSB2;
+ card->regs.cirm |= hfc_CIRM_B2_REV;
+ card->regs.sctrl |= hfc_SCTRL_B2_ENA;
+ card->regs.sctrl_r |= hfc_SCTRL_R_B2_ENA;
+ break;
}
- // If not already enabled, enable processing transition (8KHz)
- // interrupt
+ /*
+ * If not already enabled, enable processing transition (8KHz)
+ * interrupt
+ */
hfc_outb(card, hfc_INT_M2, card->regs.m2);
hfc_outb(card, hfc_CTMT, card->regs.ctmt);
hfc_outb(card, hfc_CIRM, card->regs.cirm);
@@ -468,24 +514,22 @@ static int hfc_zap_close(struct dahdi_chan *zaptel_chan)
spin_unlock(&chan->lock);
switch (chan->number) {
- case D:
- break;
-
- case B1:
- // B1
- card->regs.ctmt &= ~hfc_CTMT_TRANSB1;
- card->regs.cirm &= ~hfc_CIRM_B1_REV;
- card->regs.sctrl &= ~hfc_SCTRL_B1_ENA;
- card->regs.sctrl_r &= ~hfc_SCTRL_R_B1_ENA;
- break;
-
- case B2:
- // B2
- card->regs.ctmt &= ~hfc_CTMT_TRANSB2;
- card->regs.cirm &= ~hfc_CIRM_B2_REV;
- card->regs.sctrl &= ~hfc_SCTRL_B2_ENA;
- card->regs.sctrl_r &= ~hfc_SCTRL_R_B2_ENA;
- break;
+ case D:
+ break;
+
+ case B1:
+ card->regs.ctmt &= ~hfc_CTMT_TRANSB1;
+ card->regs.cirm &= ~hfc_CIRM_B1_REV;
+ card->regs.sctrl &= ~hfc_SCTRL_B1_ENA;
+ card->regs.sctrl_r &= ~hfc_SCTRL_R_B1_ENA;
+ break;
+
+ case B2:
+ card->regs.ctmt &= ~hfc_CTMT_TRANSB2;
+ card->regs.cirm &= ~hfc_CIRM_B2_REV;
+ card->regs.sctrl &= ~hfc_SCTRL_B2_ENA;
+ card->regs.sctrl_r &= ~hfc_SCTRL_R_B2_ENA;
+ break;
}
if (card->chans[B1].status == free &&
@@ -517,11 +561,13 @@ static int hfc_zap_rbsbits(struct dahdi_chan *chan, int bits)
return 0;
}
-static int hfc_zap_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data)
+static int hfc_zap_ioctl(struct dahdi_chan *chan,
+ unsigned int cmd, unsigned long data)
{
- switch(cmd) {
- default:
- return -ENOTTY;
+ switch (cmd) {
+
+ default:
+ return -ENOTTY;
}
return 0;
@@ -531,16 +577,17 @@ static void hfc_hdlc_hard_xmit(struct dahdi_chan *d_chan)
{
struct hfc_chan_duplex *chan = d_chan->pvt;
struct hfc_card *card = chan->card;
- struct dahdi_hfc *hfccard = card->ztdev;
-
+ struct dahdi_hfc *hfccard = card->ztdev;
+
atomic_inc(&hfccard->hdlc_pending);
-
-}
-static int hfc_zap_startup(struct dahdi_span *span) {
+}
+
+static int hfc_zap_startup(struct dahdi_span *span)
+{
struct dahdi_hfc *zthfc = span->pvt;
struct hfc_card *hfctmp = zthfc->card;
- int alreadyrunning;
+ int alreadyrunning;
if (!hfctmp) {
printk(KERN_INFO hfc_DRIVER_PREFIX
@@ -551,9 +598,8 @@ static int hfc_zap_startup(struct dahdi_span *span) {
alreadyrunning = span->flags & DAHDI_FLAG_RUNNING;
- if (!alreadyrunning) {
+ if (!alreadyrunning)
span->flags |= DAHDI_FLAG_RUNNING;
- }
return 0;
}
@@ -572,10 +618,12 @@ static int hfc_zap_chanconfig(struct dahdi_chan *d_chan, int sigtype)
{
struct hfc_chan_duplex *chan = d_chan->pvt;
struct hfc_card *card = chan->card;
- struct dahdi_hfc *hfccard = card->ztdev;
+ struct dahdi_hfc *hfccard = card->ztdev;
if ((sigtype == DAHDI_SIG_HARDHDLC) || (hfccard->sigchan == d_chan)) {
- hfccard->sigchan = (sigtype == DAHDI_SIG_HARDHDLC) ? d_chan : NULL;
+ hfccard->sigchan = (sigtype == DAHDI_SIG_HARDHDLC)
+ ? d_chan : NULL;
+
hfccard->sigactive = 0;
atomic_set(&hfccard->hdlc_pending, 0);
}
@@ -583,14 +631,16 @@ static int hfc_zap_chanconfig(struct dahdi_chan *d_chan, int sigtype)
return 0;
}
-static int hfc_zap_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc)
+static int hfc_zap_spanconfig(struct dahdi_span *span,
+ struct dahdi_lineconfig *lc)
{
span->lineconfig = lc->lineconfig;
return 0;
}
-static int hfc_zap_initialize(struct dahdi_hfc *hfccard){
+static int hfc_zap_initialize(struct dahdi_hfc *hfccard)
+{
struct hfc_card *hfctmp = hfccard->card;
int i;
@@ -599,8 +649,8 @@ static int hfc_zap_initialize(struct dahdi_hfc *hfccard){
sprintf(hfccard->span.desc,
"HFC-S PCI A ISDN card %d [%s] ",
hfctmp->cardnum,
- hfctmp->nt_mode?"NT":"TE");
- hfccard->span.spantype = hfctmp->nt_mode?"NT":"TE";
+ hfctmp->nt_mode ? "NT" : "TE");
+ hfccard->span.spantype = hfctmp->nt_mode ? "NT" : "TE";
hfccard->span.manufacturer = "Cologne Chips";
hfccard->span.spanconfig = hfc_zap_spanconfig;
hfccard->span.chanconfig = hfc_zap_chanconfig;
@@ -611,18 +661,20 @@ static int hfc_zap_initialize(struct dahdi_hfc *hfccard){
hfccard->span.open = hfc_zap_open;
hfccard->span.close = hfc_zap_close;
hfccard->span.ioctl = hfc_zap_ioctl;
- hfccard->span.hdlc_hard_xmit = hfc_hdlc_hard_xmit;
+ hfccard->span.hdlc_hard_xmit = hfc_hdlc_hard_xmit;
hfccard->span.flags = 0;
- hfccard->span.irq = hfctmp->pcidev->irq;
- dahdi_copy_string(hfccard->span.devicetype, "HFC-S PCI-A ISDN", sizeof(hfccard->span.devicetype));
+ hfccard->span.irq = hfctmp->pcidev->irq;
+ dahdi_copy_string(hfccard->span.devicetype, "HFC-S PCI-A ISDN",
+ sizeof(hfccard->span.devicetype));
sprintf(hfccard->span.location, "PCI Bus %02d Slot %02d",
- hfctmp->pcidev->bus->number, PCI_SLOT(hfctmp->pcidev->devfn) + 1);
+ hfctmp->pcidev->bus->number,
+ PCI_SLOT(hfctmp->pcidev->devfn) + 1);
hfccard->span.chans = hfccard->_chans;
hfccard->span.channels = 3;
for (i = 0; i < hfccard->span.channels; i++)
- hfccard->_chans[i] = &hfccard->chans[i];
+ hfccard->_chans[i] = &hfccard->chans[i];
hfccard->span.deflaw = DAHDI_LAW_ALAW;
- hfccard->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_CCS; // <--- this is really BS
+ hfccard->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_CCS;
hfccard->span.offset = 0;
init_waitqueue_head(&hfccard->span.maintq);
hfccard->span.pvt = hfccard;
@@ -644,27 +696,40 @@ static int hfc_zap_initialize(struct dahdi_hfc *hfccard){
hfccard->chans[i].sigcap = DAHDI_SIG_HARDHDLC;
hfccard->sigchan = &hfccard->chans[D];
hfccard->sigactive = 0;
- atomic_set(&hfccard->hdlc_pending, 0);
+ atomic_set(&hfccard->hdlc_pending, 0);
} else {
- hfccard->chans[i].sigcap = DAHDI_SIG_CLEAR | DAHDI_SIG_DACS;
- }
+ hfccard->chans[i].sigcap =
+ DAHDI_SIG_CLEAR | DAHDI_SIG_DACS;
+ }
- hfccard->chans[i].chanpos = i + 1;
+ hfccard->chans[i].chanpos = i + 1;
}
- hfccard->chans[DAHDI_D].readchunk = hfctmp->chans[D].rx.zaptel_buffer;
- hfccard->chans[DAHDI_D].writechunk = hfctmp->chans[D].tx.zaptel_buffer;
+ hfccard->chans[DAHDI_D].readchunk =
+ hfctmp->chans[D].rx.zaptel_buffer;
+
+ hfccard->chans[DAHDI_D].writechunk =
+ hfctmp->chans[D].tx.zaptel_buffer;
+
hfccard->chans[DAHDI_D].pvt = &hfctmp->chans[D];
- hfccard->chans[DAHDI_B1].readchunk = hfctmp->chans[B1].rx.zaptel_buffer;
- hfccard->chans[DAHDI_B1].writechunk = hfctmp->chans[B1].tx.zaptel_buffer;
+ hfccard->chans[DAHDI_B1].readchunk =
+ hfctmp->chans[B1].rx.zaptel_buffer;
+
+ hfccard->chans[DAHDI_B1].writechunk =
+ hfctmp->chans[B1].tx.zaptel_buffer;
+
hfccard->chans[DAHDI_B1].pvt = &hfctmp->chans[B1];
- hfccard->chans[DAHDI_B2].readchunk = hfctmp->chans[B2].rx.zaptel_buffer;
- hfccard->chans[DAHDI_B2].writechunk = hfctmp->chans[B2].tx.zaptel_buffer;
+ hfccard->chans[DAHDI_B2].readchunk =
+ hfctmp->chans[B2].rx.zaptel_buffer;
+
+ hfccard->chans[DAHDI_B2].writechunk =
+ hfctmp->chans[B2].tx.zaptel_buffer;
+
hfccard->chans[DAHDI_B2].pvt = &hfctmp->chans[B2];
- if (dahdi_register(&hfccard->span,0)) {
+ if (dahdi_register(&hfccard->span, 0)) {
printk(KERN_CRIT "unable to register zaptel device!\n");
return -1;
}
@@ -692,7 +757,7 @@ static void hfc_handle_processing_interrupt(struct hfc_card *card);
static void hfc_frame_arrived(struct hfc_chan_duplex *chan);
static void hfc_handle_voice(struct hfc_card *card);
-#if (KERNEL_VERSION(2,6,24) < LINUX_VERSION_CODE)
+#if (KERNEL_VERSION(2, 6, 24) < LINUX_VERSION_CODE)
static irqreturn_t hfc_interrupt(int irq, void *dev_id)
#else
static irqreturn_t hfc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -700,7 +765,7 @@ static irqreturn_t hfc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
struct hfc_card *card = dev_id;
unsigned long flags;
- u8 status,s1,s2;
+ u8 status, s1, s2;
if (!card) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
@@ -712,8 +777,10 @@ static irqreturn_t hfc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
spin_lock_irqsave(&card->lock, flags);
status = hfc_inb(card, hfc_STATUS);
if (!(status & hfc_STATUS_ANYINT)) {
- // maybe we are sharing the irq
- spin_unlock_irqrestore(&card->lock,flags);
+ /*
+ * maybe we are sharing the irq
+ */
+ spin_unlock_irqrestore(&card->lock, flags);
return IRQ_NONE;
}
@@ -745,62 +812,83 @@ static irqreturn_t hfc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
if (s1 != 0) {
if (s1 & hfc_INTS_TIMER) {
- // timer (bit 7)
+ /*
+ * timer (bit 7)
+ */
hfc_handle_timer_interrupt(card);
}
if (s1 & hfc_INTS_L1STATE) {
- // state machine (bit 6)
+ /*
+ * state machine (bit 6)
+ */
hfc_handle_state_interrupt(card);
}
if (s1 & hfc_INTS_DREC) {
- // D chan RX (bit 5)
+ /*
+ * D chan RX (bit 5)
+ */
hfc_frame_arrived(&card->chans[D]);
}
if (s1 & hfc_INTS_B1REC) {
- // B1 chan RX (bit 3)
+ /*
+ * B1 chan RX (bit 3)
+ */
hfc_frame_arrived(&card->chans[B1]);
}
if (s1 & hfc_INTS_B2REC) {
- // B2 chan RX (bit 4)
+ /*
+ * B2 chan RX (bit 4)
+ */
hfc_frame_arrived(&card->chans[B2]);
}
if (s1 & hfc_INTS_DTRANS) {
- // D chan TX (bit 2)
+ /*
+ * D chan TX (bit 2)
+ */
}
if (s1 & hfc_INTS_B1TRANS) {
- // B1 chan TX (bit 0)
+ /*
+ * B1 chan TX (bit 0)
+ */
}
if (s1 & hfc_INTS_B2TRANS) {
- // B2 chan TX (bit 1)
+ /*
+ * B2 chan TX (bit 1)
+ */
}
}
if (s2 != 0) {
if (s2 & hfc_M2_PMESEL) {
- // kaboom irq (bit 7)
-
- /* CologneChip says:
+ /*
+ * kaboom irq (bit 7)
+ *
+ * CologneChip says:
*
- * the meaning of this fatal error bit is that HFC-S PCI as PCI
- * master could not access the PCI bus within 125us to finish its
- * data processing. If this happens only very seldom it does not
- * cause big problems but of course some B-channel or D-channel
+ * the meaning of this fatal error bit is that HFC-S
+ * PCI as PCI master could not access the PCI bus
+ * within 125us to finish its data processing. If this
+ * happens only very seldom it does not cause big
+ * problems but of course some B-channel or D-channel
* data will be corrupted due to this event.
*
- * Unfortunately this bit is only set once after the problem occurs
- * and can only be reseted by a software reset. That means it is not
- * easily possible to check how often this fatal error happens.
+ * Unfortunately this bit is only set once after the
+ * problem occurs and can only be reseted by a
+ * software reset. That means it is not easily
+ * possible to check how often this fatal error
+ * happens.
+ *
*/
- if(!card->sync_loss_reported) {
+ if (!card->sync_loss_reported) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
"sync lost, pci performance too low!\n",
@@ -811,28 +899,34 @@ static irqreturn_t hfc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
}
if (s2 & hfc_M2_GCI_MON_REC) {
- // RxR monitor channel (bit 2)
+ /*
+ * RxR monitor channel (bit 2)
+ */
}
if (s2 & hfc_M2_GCI_I_CHG) {
- // GCI I-change (bit 1)
+ /*
+ * GCI I-change (bit 1)
+ */
}
- if (s2 & hfc_M2_PROC_TRANS){
- // processing/non-processing transition (bit 0)
+ if (s2 & hfc_M2_PROC_TRANS) {
+ /*
+ * processing/non-processing transition (bit 0)
+ */
hfc_handle_processing_interrupt(card);
}
}
- spin_unlock_irqrestore(&card->lock,flags);
+ spin_unlock_irqrestore(&card->lock, flags);
return IRQ_HANDLED;
}
static void hfc_handle_timer_interrupt(struct hfc_card *card)
{
- if(card->ignore_first_timer_interrupt) {
+ if (card->ignore_first_timer_interrupt) {
card->ignore_first_timer_interrupt = FALSE;
return;
}
@@ -849,7 +943,7 @@ static void hfc_handle_timer_interrupt(struct hfc_card *card)
static void hfc_handle_state_interrupt(struct hfc_card *card)
{
- u8 new_state = hfc_inb(card,hfc_STATES) & hfc_STATES_STATE_MASK;
+ u8 new_state = hfc_inb(card, hfc_STATES) & hfc_STATES_STATE_MASK;
#ifdef DEBUG
if (debug_level >= 1) {
@@ -857,30 +951,36 @@ static void hfc_handle_state_interrupt(struct hfc_card *card)
"card %d: "
"layer 1 state = %c%d\n",
card->cardnum,
- card->nt_mode?'G':'F',
+ card->nt_mode ? 'G' : 'F',
new_state);
}
#endif
if (card->nt_mode) {
- // NT mode
+ /*
+ * NT mode
+ */
if (new_state == 3) {
- // fix to G3 state (see specs)
+ /*
+ * fix to G3 state (see specs)
+ */
hfc_outb(card, hfc_STATES, hfc_STATES_LOAD_STATE | 3);
}
- if (new_state == 3 && card->l1_state != 3) {
+ if (new_state == 3 && card->l1_state != 3)
hfc_resume_fifo(card);
- }
- if (new_state != 3 && card->l1_state == 3) {
+ if (new_state != 3 && card->l1_state == 3)
hfc_suspend_fifo(card);
- }
+
} else {
if (new_state == 3) {
- // Keep L1 up... zaptel & libpri expects a always up L1...
- // Enable only when using an unpatched libpri
+ /*
+ * Keep L1 up... zaptel & libpri expects
+ * a always up L1...
+ * Enable only when using an unpatched libpri
+ */
if (force_l1_up) {
hfc_outb(card, hfc_STATES,
@@ -891,19 +991,27 @@ static void hfc_handle_state_interrupt(struct hfc_card *card)
}
if (new_state == 7 && card->l1_state != 7) {
- // TE is now active, schedule FIFO activation after
- // some time, otherwise the first frames are lost
+ /*
+ * TE is now active, schedule FIFO activation after
+ * some time, otherwise the first frames are lost
+ */
- card->regs.ctmt |= hfc_CTMT_TIMER_50 | hfc_CTMT_TIMER_CLEAR;
+ card->regs.ctmt |= hfc_CTMT_TIMER_50 |
+ hfc_CTMT_TIMER_CLEAR;
hfc_outb(card, hfc_CTMT, card->regs.ctmt);
- // Activating the timer firest an interrupt immediately, we
- // obviously need to ignore it
+ /*
+ * Activating the timer firest an
+ * interrupt immediately, we
+ * obviously need to ignore it
+ */
card->ignore_first_timer_interrupt = TRUE;
}
if (new_state != 7 && card->l1_state == 7) {
- // TE has become inactive, disable FIFO
+ /*
+ * TE has become inactive, disable FIFO
+ */
hfc_suspend_fifo(card);
}
}
@@ -913,12 +1021,14 @@ static void hfc_handle_state_interrupt(struct hfc_card *card)
static void hfc_handle_processing_interrupt(struct hfc_card *card)
{
- int available_bytes=0;
+ int available_bytes = 0;
- // Synchronize with the first enabled channel
- if(card->regs.fifo_en & hfc_FIFOEN_B1RX)
+ /*
+ * Synchronize with the first enabled channel
+ */
+ if (card->regs.fifo_en & hfc_FIFOEN_B1RX)
available_bytes = hfc_fifo_used_rx(&card->chans[B1].rx);
- if(card->regs.fifo_en & hfc_FIFOEN_B2RX)
+ if (card->regs.fifo_en & hfc_FIFOEN_B2RX)
available_bytes = hfc_fifo_used_rx(&card->chans[B2].rx);
else
available_bytes = -1;
@@ -929,7 +1039,9 @@ static void hfc_handle_processing_interrupt(struct hfc_card *card)
if (available_bytes > DAHDI_CHUNKSIZE*2 + hfc_RX_FIFO_PRELOAD) {
card->late_irqs++;
- // we are out of sync, clear fifos, jaw
+ /*
+ * we are out of sync, clear fifos, jaw
+ */
hfc_clear_fifo_rx(&card->chans[B1].rx);
hfc_clear_fifo_tx(&card->chans[B1].tx);
hfc_clear_fifo_rx(&card->chans[B2].rx);
@@ -974,27 +1086,34 @@ static void hfc_handle_voice(struct hfc_card *card)
if (card->regs.fifo_en & hfc_FIFOEN_B2TX)
hfc_zap_transmit(&card->chans[B2].tx);
-// dahdi hdlc frame tx
+ /*
+ * dahdi hdlc frame tx
+ */
if (atomic_read(&hfccard->hdlc_pending)) {
hfc_check_l1_up(card);
res = dahdi_hdlc_getbuf(hfccard->sigchan, buf, &size);
if (size > 0) {
hfccard->sigactive = 1;
- memcpy(card->chans[D].tx.ugly_framebuf +
- card->chans[D].tx.ugly_framebuf_size, buf, size);
+ memcpy(card->chans[D].tx.ugly_framebuf +
+ card->chans[D].tx.ugly_framebuf_size,
+ buf, size);
card->chans[D].tx.ugly_framebuf_size += size;
- if (res != 0) {
+ if (res != 0) {
hfc_fifo_put_frame(&card->chans[D].tx,
- card->chans[D].tx.ugly_framebuf,
- card->chans[D].tx.ugly_framebuf_size);
+ card->chans[D].tx.ugly_framebuf,
+ card->chans[D].tx.ugly_framebuf_size);
++hfccard->frames_out;
hfccard->sigactive = 0;
- card->chans[D].tx.ugly_framebuf_size = 0;
+ card->chans[D].tx.ugly_framebuf_size
+ = 0;
atomic_dec(&hfccard->hdlc_pending);
}
}
- } // frame tx done
+ }
+ /*
+ * dahdi hdlc frame tx done
+ */
if (card->regs.fifo_en & hfc_FIFOEN_B1RX)
hfc_zap_receive(&card->chans[B1].rx);
@@ -1008,7 +1127,9 @@ static void hfc_handle_voice(struct hfc_card *card)
memset(&card->chans[B2].rx.zaptel_buffer, 0x7f,
sizeof(card->chans[B1].rx.zaptel_buffer));
- // Echo cancellation
+ /*
+ * Echo cancellation
+ */
dahdi_ec_chunk(&hfccard->chans[DAHDI_B1],
card->chans[B1].rx.zaptel_buffer,
card->chans[B1].tx.zaptel_buffer);
@@ -1016,29 +1137,39 @@ static void hfc_handle_voice(struct hfc_card *card)
card->chans[B2].rx.zaptel_buffer,
card->chans[B2].tx.zaptel_buffer);
- // dahdi hdlc frame rx
- if (hfc_fifo_has_frames(&card->chans[D].rx)) {
- hfc_frame_arrived(&card->chans[D]);
- }
-
- if (card->chans[D].rx.ugly_framebuf_size) {
- frame_left = card->chans[D].rx.ugly_framebuf_size - card->chans[D].rx.ugly_framebuf_off ;
- if (frame_left > hfc_HDLC_BUF_LEN){
- dahdi_hdlc_putbuf(hfccard->sigchan, card->chans[D].rx.ugly_framebuf+
- card->chans[D].rx.ugly_framebuf_off, hfc_HDLC_BUF_LEN);
- card->chans[D].rx.ugly_framebuf_off += hfc_HDLC_BUF_LEN;
- }else{
- dahdi_hdlc_putbuf(hfccard->sigchan, card->chans[D].rx.ugly_framebuf+
- card->chans[D].rx.ugly_framebuf_off, frame_left);
+ /*
+ * dahdi hdlc frame rx
+ */
+ if (hfc_fifo_has_frames(&card->chans[D].rx))
+ hfc_frame_arrived(&card->chans[D]);
+
+ if (card->chans[D].rx.ugly_framebuf_size) {
+ frame_left = card->chans[D].rx.ugly_framebuf_size -
+ card->chans[D].rx.ugly_framebuf_off ;
+ if (frame_left > hfc_HDLC_BUF_LEN) {
+ dahdi_hdlc_putbuf(hfccard->sigchan,
+ card->chans[D].rx.ugly_framebuf +
+ card->chans[D].rx.ugly_framebuf_off,
+ hfc_HDLC_BUF_LEN);
+ card->chans[D].rx.ugly_framebuf_off +=
+ hfc_HDLC_BUF_LEN;
+ } else {
+ dahdi_hdlc_putbuf(hfccard->sigchan,
+ card->chans[D].rx.ugly_framebuf +
+ card->chans[D].rx.ugly_framebuf_off,
+ frame_left);
dahdi_hdlc_finish(hfccard->sigchan);
card->chans[D].rx.ugly_framebuf_size = 0;
card->chans[D].rx.ugly_framebuf_off = 0;
}
- } //frame rx done
+ }
+ /*
+ * dahdi hdlc frame rx done
+ */
- if (hfccard->span.flags & DAHDI_FLAG_RUNNING) {
+ if (hfccard->span.flags & DAHDI_FLAG_RUNNING)
dahdi_receive(&hfccard->span);
- }
+
}
static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
@@ -1046,17 +1177,18 @@ static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
struct hfc_card *card = chan->card;
int antiloop = 16;
struct sk_buff *skb;
-
- while(hfc_fifo_has_frames(&chan->rx) && --antiloop) {
+
+ while (hfc_fifo_has_frames(&chan->rx) && --antiloop) {
int frame_size = hfc_fifo_get_frame_size(&chan->rx);
if (frame_size < 3) {
#ifdef DEBUG
- if (debug_level>=2)
+ if (debug_level >= 2)
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
- "invalid frame received, just %d bytes\n",
+ "invalid frame received, "
+ "just %d bytes\n",
card->cardnum,
chan->name,
frame_size);
@@ -1066,9 +1198,9 @@ static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
continue;
- } else if(frame_size == 3) {
+ } else if (frame_size == 3) {
#ifdef DEBUG
- if (debug_level>=2)
+ if (debug_level >= 2)
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -1085,10 +1217,13 @@ static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
if (chan->open_by_zaptel &&
card->chans[D].rx.ugly_framebuf_size) {
- // We have to wait for Dahdi to transmit the
- // frame... wait for next time
- break;
+ /*
+ * We have to wait for Dahdi to transmit the
+ * frame... wait for next time
+ */
+
+ break;
}
skb = dev_alloc_skb(frame_size - 3);
@@ -1108,7 +1243,9 @@ static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
}
- // HFC does the checksum
+ /*
+ * HFC does the checksum
+ */
#ifndef CHECKSUM_HW
skb->ip_summed = CHECKSUM_COMPLETE;
#else
@@ -1138,7 +1275,7 @@ static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
}
}
- if (!antiloop)
+ if (!antiloop)
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
"Infinite loop detected\n",
@@ -1152,7 +1289,7 @@ static void hfc_frame_arrived(struct hfc_chan_duplex *chan)
static int __devinit hfc_probe(struct pci_dev *pci_dev,
const struct pci_device_id *ent)
{
- static int cardnum=0;
+ static int cardnum;
int err;
int i;
@@ -1173,11 +1310,12 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
pci_set_drvdata(pci_dev, card);
- if ((err = pci_enable_device(pci_dev))) {
+ err = pci_enable_device(pci_dev);
+ if (err)
goto err_pci_enable_device;
- }
- if ((err = pci_set_dma_mask(pci_dev, PCI_DMA_32BIT))) {
+ err = pci_set_dma_mask(pci_dev, PCI_DMA_32BIT);
+ if (err) {
printk(KERN_ERR hfc_DRIVER_PREFIX
"card %d: "
"No suitable DMA configuration available.\n",
@@ -1186,8 +1324,8 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
}
pci_write_config_word(pci_dev, PCI_COMMAND, PCI_COMMAND_MEMORY);
-
- if((err = pci_request_regions(pci_dev, hfc_DRIVER_NAME))) {
+ err = pci_request_regions(pci_dev, hfc_DRIVER_NAME);
+ if (err) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
"cannot request I/O memory region\n",
@@ -1206,7 +1344,7 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
goto err_noirq;
}
- card->io_bus_mem = pci_resource_start(pci_dev,1);
+ card->io_bus_mem = pci_resource_start(pci_dev, 1);
if (!card->io_bus_mem) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
@@ -1216,7 +1354,8 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
goto err_noiobase;
}
- if(!(card->io_mem = ioremap(card->io_bus_mem, hfc_PCI_MEM_SIZE))) {
+ card->io_mem = ioremap(card->io_bus_mem, hfc_PCI_MEM_SIZE);
+ if (!(card->io_mem)) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
"cannot ioremap I/O memory\n",
@@ -1225,8 +1364,12 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
goto err_ioremap;
}
- // pci_alloc_consistent guarantees alignment (Documentation/DMA-mapping.txt)
- card->fifo_mem = pci_alloc_consistent(pci_dev, hfc_FIFO_SIZE, &card->fifo_bus_mem);
+ /*
+ * pci_alloc_consistent guarantees alignment
+ * (Documentation/DMA-mapping.txt)
+ */
+ card->fifo_mem = pci_alloc_consistent(pci_dev,
+ hfc_FIFO_SIZE, &card->fifo_bus_mem);
if (!card->fifo_mem) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
@@ -1242,14 +1385,15 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
pci_write_config_dword(card->pcidev, hfc_PCI_MWBA, card->fifo_bus_mem);
- if ((err = request_irq(card->pcidev->irq, &hfc_interrupt,
+ err = request_irq(card->pcidev->irq, &hfc_interrupt,
-#if (KERNEL_VERSION(2,6,23) < LINUX_VERSION_CODE)
- IRQF_SHARED, hfc_DRIVER_NAME, card))) {
+#if (KERNEL_VERSION(2, 6, 23) < LINUX_VERSION_CODE)
+ IRQF_SHARED, hfc_DRIVER_NAME, card);
#else
- SA_SHIRQ, hfc_DRIVER_NAME, card))) {
+ SA_SHIRQ, hfc_DRIVER_NAME, card);
#endif
+ if (err) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"card %d: "
"unable to register irq\n",
@@ -1262,12 +1406,14 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
if (modes & (1 << card->cardnum))
card->nt_mode = TRUE;
- for (i=0; i<nt_modes_count; i++) {
+ for (i = 0; i < nt_modes_count; i++) {
if (nt_modes[i] == card->cardnum)
- card->nt_mode=TRUE;
+ card->nt_mode = TRUE;
}
-//---------------------------------- D
+ /*
+ * D Channel
+ */
card->chans[D].card = card;
card->chans[D].name = "D";
card->chans[D].status = free;
@@ -1285,8 +1431,10 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
card->chans[D].rx.f_max = 0x1F;
card->chans[D].rx.f1 = card->fifos + 0x60a0;
card->chans[D].rx.f2 = card->fifos + 0x60a1;
- card->chans[D].rx.fifo_size = card->chans[D].rx.z_max - card->chans[D].rx.z_min + 1;
- card->chans[D].rx.f_num = card->chans[D].rx.f_max - card->chans[D].rx.f_min + 1;
+ card->chans[D].rx.fifo_size = card->chans[D].rx.z_max
+ - card->chans[D].rx.z_min + 1;
+ card->chans[D].rx.f_num = card->chans[D].rx.f_max
+ - card->chans[D].rx.f_min + 1;
card->chans[D].tx.chan = &card->chans[D];
card->chans[D].tx.fifo_base = card->fifos + 0x0000;
@@ -1299,11 +1447,14 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
card->chans[D].tx.f_max = 0x1F;
card->chans[D].tx.f1 = card->fifos + 0x20a0;
card->chans[D].tx.f2 = card->fifos + 0x20a1;
- card->chans[D].tx.fifo_size = card->chans[D].tx.z_max - card->chans[D].tx.z_min + 1;
- card->chans[D].tx.f_num = card->chans[D].tx.f_max - card->chans[D].tx.f_min + 1;
-
+ card->chans[D].tx.fifo_size = card->chans[D].tx.z_max -
+ card->chans[D].tx.z_min + 1;
+ card->chans[D].tx.f_num = card->chans[D].tx.f_max -
+ card->chans[D].tx.f_min + 1;
-//---------------------------------- B1
+ /*
+ * B1 Channel
+ */
card->chans[B1].card = card;
card->chans[B1].name = "B1";
card->chans[B1].status = free;
@@ -1322,8 +1473,10 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
card->chans[B1].rx.f_max = 0x1F;
card->chans[B1].rx.f1 = card->fifos + 0x6080;
card->chans[B1].rx.f2 = card->fifos + 0x6081;
- card->chans[B1].rx.fifo_size = card->chans[B1].rx.z_max - card->chans[B1].rx.z_min + 1;
- card->chans[B1].rx.f_num = card->chans[B1].rx.f_max - card->chans[B1].rx.f_min + 1;
+ card->chans[B1].rx.fifo_size = card->chans[B1].rx.z_max -
+ card->chans[B1].rx.z_min + 1;
+ card->chans[B1].rx.f_num = card->chans[B1].rx.f_max -
+ card->chans[B1].rx.f_min + 1;
card->chans[B1].tx.chan = &card->chans[B1];
card->chans[B1].tx.fifo_base = card->fifos + 0x0200;
@@ -1336,10 +1489,14 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
card->chans[B1].tx.f_max = 0x1F;
card->chans[B1].tx.f1 = card->fifos + 0x2080;
card->chans[B1].tx.f2 = card->fifos + 0x2081;
- card->chans[B1].tx.fifo_size = card->chans[B1].tx.z_max - card->chans[B1].tx.z_min + 1;
- card->chans[B1].tx.f_num = card->chans[B1].tx.f_max - card->chans[B1].tx.f_min + 1;
+ card->chans[B1].tx.fifo_size = card->chans[B1].tx.z_max -
+ card->chans[B1].tx.z_min + 1;
+ card->chans[B1].tx.f_num = card->chans[B1].tx.f_max -
+ card->chans[B1].tx.f_min + 1;
-//---------------------------------- B2
+ /*
+ * B2 Channel
+ */
card->chans[B2].card = card;
card->chans[B2].name = "B2";
card->chans[B2].status = free;
@@ -1358,8 +1515,10 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
card->chans[B2].rx.f_max = 0x1F;
card->chans[B2].rx.f1 = card->fifos + 0x6180;
card->chans[B2].rx.f2 = card->fifos + 0x6181;
- card->chans[B2].rx.fifo_size = card->chans[B2].rx.z_max - card->chans[B2].rx.z_min + 1;
- card->chans[B2].rx.f_num = card->chans[B2].rx.f_max - card->chans[B2].rx.f_min + 1;
+ card->chans[B2].rx.fifo_size = card->chans[B2].rx.z_max -
+ card->chans[B2].rx.z_min + 1;
+ card->chans[B2].rx.f_num = card->chans[B2].rx.f_max -
+ card->chans[B2].rx.f_min + 1;
card->chans[B2].tx.chan = &card->chans[B2];
card->chans[B2].tx.fifo_base = card->fifos + 0x2200;
@@ -1372,12 +1531,16 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
card->chans[B2].tx.f_max = 0x1F;
card->chans[B2].tx.f1 = card->fifos + 0x2180;
card->chans[B2].tx.f2 = card->fifos + 0x2181;
- card->chans[B2].tx.fifo_size = card->chans[B2].tx.z_max - card->chans[B2].tx.z_min + 1;
- card->chans[B2].tx.f_num = card->chans[B2].tx.f_max - card->chans[B2].tx.f_min + 1;
+ card->chans[B2].tx.fifo_size = card->chans[B2].tx.z_max -
+ card->chans[B2].tx.z_min + 1;
+ card->chans[B2].tx.f_num = card->chans[B2].tx.f_max -
+ card->chans[B2].tx.f_min + 1;
-// -------------------------------------------------------
+ /*
+ * All done
+ */
- zthfc = kmalloc(sizeof(struct dahdi_hfc),GFP_KERNEL);
+ zthfc = kmalloc(sizeof(struct dahdi_hfc), GFP_KERNEL);
if (!zthfc) {
printk(KERN_CRIT hfc_DRIVER_PREFIX
"unable to kmalloc!\n");
@@ -1387,7 +1550,7 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
zthfc->card = card;
hfc_zap_initialize(zthfc);
- card->ztdev = zthfc;
+ card->ztdev = zthfc;
snprintf(card->proc_dir_name,
sizeof(card->proc_dir_name),
@@ -1400,10 +1563,10 @@ static int __devinit hfc_probe(struct pci_dev *pci_dev,
printk(KERN_INFO hfc_DRIVER_PREFIX
"card %d configured for %s mode at mem %#lx (0x%p) IRQ %u\n",
card->cardnum,
- card->nt_mode?"NT":"TE",
+ card->nt_mode ? "NT" : "TE",
card->io_bus_mem,
card->io_mem,
- card->pcidev->irq);
+ card->pcidev->irq);
cardnum++;
@@ -1431,9 +1594,6 @@ static void __devexit hfc_remove(struct pci_dev *pci_dev)
struct hfc_card *card = pci_get_drvdata(pci_dev);
-// unsigned long flags;
-// spin_lock_irqsave(&card->lock,flags);
-
printk(KERN_INFO hfc_DRIVER_PREFIX
"card %d: "
"shutting down card at %p.\n",
@@ -1445,11 +1605,11 @@ static void __devexit hfc_remove(struct pci_dev *pci_dev)
dahdi_unregister(&card->ztdev->span);
- // disable memio and bustmaster
+ /*
+ * disable memio and bustmaster
+ */
pci_write_config_word(pci_dev, PCI_COMMAND, 0);
-// spin_unlock_irqrestore(&card->lock,flags);
-
remove_proc_entry("bufs", card->proc_dir);
remove_proc_entry("fifos", card->proc_dir);
remove_proc_entry("info", card->proc_dir);
@@ -1480,10 +1640,10 @@ static int __init hfc_init_module(void)
printk(KERN_INFO hfc_DRIVER_PREFIX
hfc_DRIVER_STRING " loading\n");
-#if (KERNEL_VERSION(2,6,26) <= LINUX_VERSION_CODE)
- hfc_proc_zaphfc_dir = proc_mkdir(hfc_DRIVER_NAME, NULL);
+#if (KERNEL_VERSION(2, 6, 26) <= LINUX_VERSION_CODE)
+ hfc_proc_zaphfc_dir = proc_mkdir(hfc_DRIVER_NAME, NULL);
#else
- hfc_proc_zaphfc_dir = proc_mkdir(hfc_DRIVER_NAME, proc_root_driver);
+ hfc_proc_zaphfc_dir = proc_mkdir(hfc_DRIVER_NAME, proc_root_driver);
#endif
ret = dahdi_pci_module(&hfc_driver);
@@ -1496,7 +1656,7 @@ static void __exit hfc_module_exit(void)
{
pci_unregister_driver(&hfc_driver);
-#if (KERNEL_VERSION(2,6,26) <= LINUX_VERSION_CODE)
+#if (KERNEL_VERSION(2, 6, 26) <= LINUX_VERSION_CODE)
remove_proc_entry(hfc_DRIVER_NAME, NULL);
#else
remove_proc_entry(hfc_DRIVER_NAME, proc_root_driver);
@@ -1511,7 +1671,9 @@ module_exit(hfc_module_exit);
#endif
MODULE_DESCRIPTION(hfc_DRIVER_DESCR);
-MODULE_AUTHOR("Jens Wilke <jw_vzaphfc@headissue.com>, Daniele (Vihai) Orlandi <daniele@orlandi.com>");
+MODULE_AUTHOR("Jens Wilke <jw_vzaphfc@headissue.com>, "
+ "Daniele (Vihai) Orlandi <daniele@orlandi.com>, "
+ "Jose A. Deniz <odicha@hotmail.com>");
#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
#endif
@@ -1519,7 +1681,7 @@ MODULE_LICENSE("GPL");
module_param(modes, int, 0444);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
module_param_array(nt_modes, int, &nt_modes_count, 0444);
#else
module_param_array(nt_modes, int, nt_modes_count, 0444);
@@ -1531,7 +1693,8 @@ module_param(debug_level, int, 0444);
#endif
MODULE_PARM_DESC(modes, "[Deprecated] bit-mask to configure NT mode");
-MODULE_PARM_DESC(nt_modes, "Comma-separated list of card IDs to configure in NT mode");
+MODULE_PARM_DESC(nt_modes,
+ "Comma-separated list of card IDs to configure in NT mode");
MODULE_PARM_DESC(force_l1_up, "Don't allow L1 to go down");
#ifdef DEBUG
MODULE_PARM_DESC(debug_level, "Debug verbosity level");
diff --git a/drivers/dahdi/zaphfc/fifo.c b/drivers/dahdi/zaphfc/fifo.c
index fa25f9a..8c23fa3 100644
--- a/drivers/dahdi/zaphfc/fifo.c
+++ b/drivers/dahdi/zaphfc/fifo.c
@@ -29,7 +29,9 @@ static void hfc_fifo_mem_read(struct hfc_chan_simplex *chan,
chan->z_base + z_start,
size);
} else {
- // Buffer wrap
+ /*
+ * Buffer wrap
+ */
memcpy(data,
chan->z_base + z_start,
bytes_to_boundary);
@@ -49,7 +51,9 @@ static void hfc_fifo_mem_write(struct hfc_chan_simplex *chan,
data,
size);
} else {
- // FIFO wrap
+ /*
+ * FIFO wrap
+ */
memcpy(chan->z_base + *Z1_F1(chan),
data,
@@ -66,13 +70,17 @@ int hfc_fifo_get(struct hfc_chan_simplex *chan,
{
int available_bytes;
- // Some useless statistic
+ /*
+ * Some useless statistic
+ */
chan->bytes += size;
available_bytes = hfc_fifo_used_rx(chan);
if (available_bytes < size && !chan->fifo_underrun++) {
- // print the warning only once
+ /*
+ * print the warning only once
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -88,26 +96,6 @@ int hfc_fifo_get(struct hfc_chan_simplex *chan,
return available_bytes - size;
}
-/*
-static void hfc_fifo_drop(struct hfc_chan_simplex *chan, int size)
-{
- int available_bytes = hfc_fifo_used_rx(chan);
- if (available_bytes + 1 < size) {
- printk(KERN_WARNING hfc_DRIVER_PREFIX
- "card %d: "
- "chan %s: "
- "RX FIFO not enough (%d) bytes to drop!\n",
- chan->chan->card->cardnum,
- chan->chan->name,
- available_bytes);
-
- return;
- }
-
- *Z2_F2(chan) = Z_inc(chan, *Z2_F2(chan), size);
-}
-*/
-
void hfc_fifo_put(struct hfc_chan_simplex *chan,
void *data, int size)
{
@@ -116,7 +104,9 @@ void hfc_fifo_put(struct hfc_chan_simplex *chan,
int free_bytes = hfc_fifo_free_tx(chan);
if (!used_bytes && !chan->fifo_underrun++) {
- // print warning only once, to make timing not worse
+ /*
+ * print warning only once, to make timing not worse
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -144,9 +134,11 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
{
int frame_size;
u16 newz2 ;
-
+
if (*chan->f1 == *chan->f2) {
- // nothing received, strange uh?
+ /*
+ * nothing received, strange uh?
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -157,11 +149,13 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
return -1;
}
- // frame_size includes CRC+CRC+STAT
+ /*
+ * frame_size includes CRC+CRC+STAT
+ */
frame_size = hfc_fifo_get_frame_size(chan);
#ifdef DEBUG
- if(debug_level == 3) {
+ if (debug_level == 3) {
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -169,7 +163,7 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
chan->chan->card->cardnum,
chan->chan->name,
frame_size);
- } else if(debug_level >= 4) {
+ } else if (debug_level >= 4) {
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -180,14 +174,14 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
frame_size);
}
- if(debug_level >= 3) {
+ if (debug_level >= 3) {
int i;
- for (i=0; i < frame_size; i++) {
+ for (i = 0; i < frame_size; i++) {
printk("%02x", hfc_fifo_u8(chan,
Z_inc(chan, *Z2_F2(chan), i)));
}
- printk("\n");
+ printk("\n");
}
#endif
@@ -207,22 +201,30 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
return -1;
}
- // STAT is not really received
+ /*
+ * STAT is not really received
+ */
chan->bytes += frame_size - 1;
- // Calculate beginning of the next frame
+ /*
+ * Calculate beginning of the next frame
+ */
newz2 = Z_inc(chan, *Z2_F2(chan), frame_size);
- // We cannot use hfc_fifo_get because of different semantic of
- // "available bytes" and to avoid useless increment of Z2
+ /*
+ * We cannot use hfc_fifo_get because of different semantic of
+ * "available bytes" and to avoid useless increment of Z2
+ */
hfc_fifo_mem_read(chan, *Z2_F2(chan), data,
frame_size < max_size ? frame_size : max_size);
if (hfc_fifo_u8(chan, Z_inc(chan, *Z2_F2(chan),
frame_size - 1)) != 0x00) {
- // CRC not ok, frame broken, skipping
+ /*
+ * CRC not ok, frame broken, skipping
+ */
#ifdef DEBUG
- if(debug_level >= 2) {
+ if (debug_level >= 2) {
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -242,7 +244,9 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
*chan->f2 = F_inc(chan, *chan->f2, 1);
- // Set Z2 for the next frame we're going to receive
+ /*
+ * Set Z2 for the next frame we're going to receive
+ */
*Z2_F2(chan) = newz2;
return frame_size;
@@ -254,7 +258,9 @@ void hfc_fifo_drop_frame(struct hfc_chan_simplex *chan)
u16 newz2;
if (*chan->f1 == *chan->f2) {
- // nothing received, strange eh?
+ /*
+ * nothing received, strange eh?
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -265,16 +271,18 @@ void hfc_fifo_drop_frame(struct hfc_chan_simplex *chan)
return;
}
-// chan->drops++;
-
available_bytes = hfc_fifo_used_rx(chan) + 1;
- // Calculate beginning of the next frame
+ /*
+ * Calculate beginning of the next frame
+ */
newz2 = Z_inc(chan, *Z2_F2(chan), available_bytes);
*chan->f2 = F_inc(chan, *chan->f2, 1);
- // Set Z2 for the next frame we're going to receive
+ /*
+ * Set Z2 for the next frame we're going to receive
+ */
*Z2_F2(chan) = newz2;
}
@@ -306,8 +314,8 @@ void hfc_fifo_put_frame(struct hfc_chan_simplex *chan,
if (debug_level >= 3) {
int i;
- for (i=0; i<size; i++)
- printk("%02x",((u8 *)data)[i]);
+ for (i = 0; i < size; i++)
+ printk("%02x", ((u8 *)data)[i]);
printk("\n");
}
@@ -351,12 +359,14 @@ void hfc_clear_fifo_tx(struct hfc_chan_simplex *chan)
*Z1_F1(chan) = *Z2_F1(chan);
if (chan->chan->status == open_voice) {
- // Make sure that at least hfc_TX_FIFO_PRELOAD bytes are
- // present in the TX FIFOs
-
- // Create hfc_TX_FIFO_PRELOAD bytes of empty data
- // (0x7f is mute audio)
- u8 empty_fifo[hfc_TX_FIFO_PRELOAD + DAHDI_CHUNKSIZE + hfc_RX_FIFO_PRELOAD];
+ /*
+ * Make sure that at least hfc_TX_FIFO_PRELOAD bytes are
+ * present in the TX FIFOs
+ * Create hfc_TX_FIFO_PRELOAD bytes of empty data
+ * (0x7f is mute audio)
+ */
+ u8 empty_fifo[hfc_TX_FIFO_PRELOAD +
+ DAHDI_CHUNKSIZE + hfc_RX_FIFO_PRELOAD];
memset(empty_fifo, 0x7f, sizeof(empty_fifo));
hfc_fifo_put(chan, empty_fifo, sizeof(empty_fifo));
diff --git a/drivers/dahdi/zaphfc/fifo.h b/drivers/dahdi/zaphfc/fifo.h
index 08edb1e..1866f30 100644
--- a/drivers/dahdi/zaphfc/fifo.h
+++ b/drivers/dahdi/zaphfc/fifo.h
@@ -1,10 +1,10 @@
/*
- * zaphfc.c - Zaptel driver for HFC-S PCI A based ISDN BRI cards
+ * fifo.h - Dahdi driver for HFC-S PCI A based ISDN BRI cards
*
* Copyright (C) 2004 Daniele Orlandi
* Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
*
- * Daniele "Vihai" Orlandi <daniele@orlandi.com>
+ * Daniele "Vihai" Orlandi <daniele@orlandi.com>
*
* Major rewrite of the driver made by
* Klaus-Peter Junghanns <kpj@junghanns.net>
@@ -41,7 +41,9 @@ static inline u16 *Z2_F2(struct hfc_chan_simplex *chan)
static inline u16 Z_inc(struct hfc_chan_simplex *chan, u16 z, u16 inc)
{
- // declared as u32 in order to manage overflows
+ /*
+ * declared as u32 in order to manage overflows
+ */
u32 newz = z + inc;
if (newz > chan->z_max)
newz -= chan->fifo_size;
@@ -51,7 +53,9 @@ static inline u16 Z_inc(struct hfc_chan_simplex *chan, u16 z, u16 inc)
static inline u8 F_inc(struct hfc_chan_simplex *chan, u8 f, u8 inc)
{
- // declared as u16 in order to manage overflows
+ /*
+ * declared as u16 in order to manage overflows
+ */
u16 newf = f + inc;
if (newf > chan->f_max)
newf -= chan->f_num;
@@ -61,15 +65,18 @@ static inline u8 F_inc(struct hfc_chan_simplex *chan, u8 f, u8 inc)
static inline u16 hfc_fifo_used_rx(struct hfc_chan_simplex *chan)
{
- return (*Z1_F2(chan) - *Z2_F2(chan) + chan->fifo_size) % chan->fifo_size;
+ return (*Z1_F2(chan) - *Z2_F2(chan) +
+ chan->fifo_size) % chan->fifo_size;
}
static inline u16 hfc_fifo_get_frame_size(struct hfc_chan_simplex *chan)
{
- // This +1 is needed because in frame mode the available bytes are Z2-Z1+1
- // while in transparent mode I wouldn't consider the byte pointed by Z2 to
- // be available, otherwise, the FIFO would always contain one byte, even
- // when Z1==Z2
+ /*
+ * This +1 is needed because in frame mode the available bytes are Z2-Z1+1
+ * while in transparent mode I wouldn't consider the byte pointed by Z2 to
+ * be available, otherwise, the FIFO would always contain one byte, even
+ * when Z1==Z2
+ */
return hfc_fifo_used_rx(chan) + 1;
}
@@ -81,12 +88,13 @@ static inline u8 hfc_fifo_u8(struct hfc_chan_simplex *chan, u16 z)
static inline u16 hfc_fifo_used_tx(struct hfc_chan_simplex *chan)
{
- return (*Z1_F1(chan) - *Z2_F1(chan) + chan->fifo_size) % chan->fifo_size;
+ return (*Z1_F1(chan) - *Z2_F1(chan) +
+ chan->fifo_size) % chan->fifo_size;
}
static inline u16 hfc_fifo_free_rx(struct hfc_chan_simplex *chan)
{
- u16 free_bytes=*Z2_F1(chan) - *Z1_F1(chan);
+ u16 free_bytes = *Z2_F1(chan) - *Z1_F1(chan);
if (free_bytes > 0)
return free_bytes;
@@ -96,7 +104,7 @@ static inline u16 hfc_fifo_free_rx(struct hfc_chan_simplex *chan)
static inline u16 hfc_fifo_free_tx(struct hfc_chan_simplex *chan)
{
- u16 free_bytes=*Z2_F1(chan) - *Z1_F1(chan);
+ u16 free_bytes = *Z2_F1(chan) - *Z1_F1(chan);
if (free_bytes > 0)
return free_bytes;
diff --git a/drivers/dahdi/zaphfc/zaphfc.h b/drivers/dahdi/zaphfc/zaphfc.h
index efa897b..c9353cc 100644
--- a/drivers/dahdi/zaphfc/zaphfc.h
+++ b/drivers/dahdi/zaphfc/zaphfc.h
@@ -1,14 +1,17 @@
/*
- * zaphfc.c - Zaptel driver for HFC-S PCI A based ISDN BRI cards
+ * zaphfc.h - Dahdi driver for HFC-S PCI A based ISDN BRI cards
*
+ * Dahdi port by Jose A. Deniz <odicha@hotmail.com>
+ *
+ * Copyright (C) 2009 Jose A. Deniz
* Copyright (C) 2006 headissue GmbH; Jens Wilke
* Copyright (C) 2004 Daniele Orlandi
* Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
*
* Jens Wilke <jw_vzaphfc@headissue.com>
- *
+ *
* Orginal author of this code is
- * Daniele "Vihai" Orlandi <daniele@orlandi.com>
+ * Daniele "Vihai" Orlandi <daniele@orlandi.com>
*
* Major rewrite of the driver made by
* Klaus-Peter Junghanns <kpj@junghanns.net>
@@ -120,7 +123,7 @@
/* bits in status register (READ) */
#define hfc_STATUS_PCI_PROC 0x02
-#define hfc_STATUS_NBUSY 0x04
+#define hfc_STATUS_NBUSY 0x04
#define hfc_STATUS_TIMER_ELAP 0x10
#define hfc_STATUS_STATINT 0x20
#define hfc_STATUS_FRAMEINT 0x40
@@ -243,11 +246,12 @@
#define hfc_UGLY_FRAMEBUF 0x2000
-#define hfc_TX_FIFO_PRELOAD DAHDI_CHUNKSIZE + 2
+#define hfc_TX_FIFO_PRELOAD (DAHDI_CHUNKSIZE + 2)
#define hfc_RX_FIFO_PRELOAD 4
/* HDLC STUFF */
-#define hfc_HDLC_BUF_LEN 32 /* arbitrary, just the max # of byts we will send to DAHDI per call */
+#define hfc_HDLC_BUF_LEN 32
+/* arbitrary, just the max # of byts we will send to DAHDI per call */
/* NOTE: FIFO pointers are not declared volatile because accesses to the
@@ -269,18 +273,18 @@ struct hfc_chan_simplex {
int ugly_framebuf_size;
u16 ugly_framebuf_off;
- void *z1_base,*z2_base;
+ void *z1_base, *z2_base;
void *fifo_base;
void *z_base;
u16 z_min;
u16 z_max;
u16 fifo_size;
- u8 *f1,*f2;
+ u8 *f1, *f2;
u8 f_min;
u8 f_max;
u8 f_num;
-
+
unsigned long long frames;
unsigned long long bytes;
unsigned long long fifo_full;
@@ -327,7 +331,7 @@ typedef struct hfc_card {
struct proc_dir_entry *proc_bufs;
unsigned long io_bus_mem;
- void *io_mem;
+ void __iomem *io_mem;
dma_addr_t fifo_bus_mem;
void *fifo_mem;
@@ -360,14 +364,14 @@ typedef struct hfc_card {
int debug_event;
-
+
spinlock_t lock;
unsigned int irq;
unsigned int iomem;
- int ticks;
- int clicks;
+ int ticks;
+ int clicks;
unsigned char *pci_io;
- void *fifomem; // start of the shared mem
+ void *fifomem; /* start of the shared mem */
unsigned int pcibus;
unsigned int pcidevfn;
@@ -375,10 +379,8 @@ typedef struct hfc_card {
int drecinframe;
unsigned char cardno;
- struct hfc_card *next;
-
+ struct hfc_card *next;
-
} hfc_card;
typedef struct dahdi_hfc {
@@ -387,14 +389,17 @@ typedef struct dahdi_hfc {
struct dahdi_chan chans[3];
struct dahdi_chan *_chans[3];
struct hfc_card *card;
- struct dahdi_chan *sigchan; /* pointer to the signalling channel for this span */
- int sigactive; /* nonzero means we're in the middle of sending an HDLC frame */
- atomic_t hdlc_pending; /* hdlc_hard_xmit() increments, hdlc_tx_frame() decrements */
- int frames_out;
- int frames_in;
-} dahdi_hfc;
+ /* pointer to the signalling channel for this span */
+ struct dahdi_chan *sigchan;
+ /* nonzero means we're in the middle of sending an HDLC frame */
+ int sigactive;
+ /* hdlc_hard_xmit() increments, hdlc_tx_frame() decrements */
+ atomic_t hdlc_pending;
+ int frames_out;
+ int frames_in;
+} dahdi_hfc;
static inline u8 hfc_inb(struct hfc_card *card, int offset)
{