};
static struct board_id dgap_ids[] = {
- { PPCM, PCI_DEV_XEM_NAME, 64, (T_PCXM|T_PCLITE|T_PCIBUS) },
- { PCX, PCI_DEV_CX_NAME, 128, (T_CX|T_PCIBUS) },
- { PCX, PCI_DEV_CX_IBM_NAME, 128, (T_CX|T_PCIBUS) },
- { PEPC, PCI_DEV_EPCJ_NAME, 224, (T_EPC|T_PCIBUS) },
- { APORT2_920P, PCI_DEV_920_2_NAME, 2, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { APORT4_920P, PCI_DEV_920_4_NAME, 4, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { APORT8_920P, PCI_DEV_920_8_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PAPORT8, PCI_DEV_XR_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PAPORT8, PCI_DEV_XRJ_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PAPORT8, PCI_DEV_XR_422_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PAPORT8, PCI_DEV_XR_IBM_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PAPORT8, PCI_DEV_XR_SAIP_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PAPORT8, PCI_DEV_XR_BULL_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { APORT8_920P, PCI_DEV_920_8_HP_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
- { PPCM, PCI_DEV_XEM_HP_NAME, 64, (T_PCXM|T_PCLITE|T_PCIBUS) },
+ {PPCM, PCI_DEV_XEM_NAME, 64, (T_PCXM | T_PCLITE | T_PCIBUS)},
+ {PCX, PCI_DEV_CX_NAME, 128, (T_CX | T_PCIBUS) },
+ {PCX, PCI_DEV_CX_IBM_NAME, 128, (T_CX | T_PCIBUS) },
+ {PEPC, PCI_DEV_EPCJ_NAME, 224, (T_EPC | T_PCIBUS) },
+ {APORT2_920P, PCI_DEV_920_2_NAME, 2, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {APORT4_920P, PCI_DEV_920_4_NAME, 4, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {APORT8_920P, PCI_DEV_920_8_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PAPORT8, PCI_DEV_XR_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PAPORT8, PCI_DEV_XRJ_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PAPORT8, PCI_DEV_XR_422_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PAPORT8, PCI_DEV_XR_IBM_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PAPORT8, PCI_DEV_XR_SAIP_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PAPORT8, PCI_DEV_XR_BULL_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {APORT8_920P, PCI_DEV_920_8_HP_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS)},
+ {PPCM, PCI_DEV_XEM_HP_NAME, 64, (T_PCXM | T_PCLITE | T_PCIBUS)},
{0,} /* 0 terminated list. */
};
{ BEGIN, "config_begin" },
{ END, "config_end" },
{ BOARD, "board" },
- { IO, "io" },
{ PCIINFO, "pciinfo" },
{ LINE, "line" },
{ CONC, "conc" },
{ 0, NULL }
};
-
-/*
- * dgap_sindex: much like index(), but it looks for a match of any character in
- * the group, and returns that position. If the first character is a ^, then
- * this will match the first occurrence not in that group.
- */
-static char *dgap_sindex(char *string, char *group)
-{
- char *ptr;
-
- if (!string || !group)
- return NULL;
-
- if (*group == '^') {
- group++;
- for (; *string; string++) {
- for (ptr = group; *ptr; ptr++) {
- if (*ptr == *string)
- break;
- }
- if (*ptr == '\0')
- return string;
- }
- } else {
- for (; *string; string++) {
- for (ptr = group; *ptr; ptr++) {
- if (*ptr == *string)
- return string;
- }
- }
- }
-
- return NULL;
-}
-
/*
* get a word from the input stream, also keep track of current line number.
* words are separated by whitespace.
{
char *ret_ptr = *in;
- char *ptr = dgap_sindex(*in, " \t\n");
+ char *ptr = strpbrk(*in, " \t\n");
/* If no word found, return null */
if (!ptr)
if (strstr(dgap_cword, "board")) {
w = dgap_getword(in);
+ if (!w)
+ return 0;
snprintf(dgap_cword, MAXCWORD, "%s", w);
for (t = dgap_brdtype; t->token != 0; t++) {
if (!strcmp(w, t->string))
return 0;
for (p = bd->bd_config; p; p = p->next) {
-
switch (p->type) {
case BNODE:
/*
}
for (p = bd->bd_config; p; p = p->next) {
-
switch (p->type) {
case LNODE:
*ptr = '\0';
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
break;
- case IO: /* i/o port */
- if (p->type != BNODE) {
- pr_err("IO port only valid for boards");
- return -1;
- }
- s = dgap_getword(in);
- if (!s) {
- pr_err("unexpected end of file");
- return -1;
- }
- p->u.board.portstr = kstrdup(s, GFP_KERNEL);
- if (kstrtol(s, 0, &p->u.board.port)) {
- pr_err("bad number for IO port");
- return -1;
- }
- p->u.board.v_port = 1;
- break;
-
case MEM: /* memory address */
if (p->type != BNODE) {
pr_err("memory address only valid for boards");
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.board.addrstr);
p->u.board.addrstr = kstrdup(s, GFP_KERNEL);
if (kstrtoul(s, 0, &p->u.board.addr)) {
pr_err("bad number for memory address");
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.board.pcibusstr);
p->u.board.pcibusstr = kstrdup(s, GFP_KERNEL);
if (kstrtoul(s, 0, &p->u.board.pcibus)) {
pr_err("bad number for pci bus");
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.board.pcislotstr);
p->u.board.pcislotstr = kstrdup(s, GFP_KERNEL);
if (kstrtoul(s, 0, &p->u.board.pcislot)) {
pr_err("bad number for pci slot");
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.board.method);
p->u.board.method = kstrdup(s, GFP_KERNEL);
p->u.board.v_method = 1;
break;
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.board.status);
p->u.board.status = kstrdup(s, GFP_KERNEL);
break;
pr_err("unexpected end of file");
return -1;
}
-
+ kfree(p->u.board.status);
p->u.board.status = kstrdup(s, GFP_KERNEL);
if (p->type == CNODE) {
+ kfree(p->u.conc.id);
p->u.conc.id = kstrdup(s, GFP_KERNEL);
p->u.conc.v_id = 1;
} else if (p->type == MNODE) {
+ kfree(p->u.module.id);
p->u.module.id = kstrdup(s, GFP_KERNEL);
p->u.module.v_id = 1;
} else {
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = TNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = CUNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = LNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = CNODE;
brd->u.board.conc1++;
conc_type = dgap_gettok(in);
- if (conc_type == 0 || (conc_type != CX &&
- conc_type != EPC)) {
+ if (conc_type == 0 ||
+ (conc_type != CX && conc_type != EPC)) {
pr_err("failed to set a type of concentratros");
return -1;
}
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = MNODE;
brd->u.board.module1++;
module_type = dgap_gettok(in);
- if (module_type == 0 || (module_type != PORTS &&
- module_type != MODEM)) {
+ if (module_type == 0 ||
+ (module_type != PORTS && module_type != MODEM)) {
pr_err("failed to set a type of module");
return -1;
}
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.line.cable);
p->u.line.cable = kstrdup(s, GFP_KERNEL);
p->u.line.v_cable = 1;
}
pr_err("unexpected end of file");
return -1;
}
+ kfree(p->u.conc.connect);
p->u.conc.connect = kstrdup(s, GFP_KERNEL);
p->u.conc.v_connect = 1;
}
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = PNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = JNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = ANODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = INTRNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = TSNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = CSNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = BSNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = USNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = FSNODE;
p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next)
- return -1;
+ return -ENOMEM;
p = p->next;
p->type = VSNODE;
switch (p->type) {
case BNODE:
- kfree(p->u.board.portstr);
kfree(p->u.board.addrstr);
kfree(p->u.board.pcibusstr);
kfree(p->u.board.pcislotstr);
if (!request_mem_region(brd->membase, 0x200000, "dgap"))
return -ENOMEM;
- if (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000,
- "dgap"))
+ if (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000, "dgap"))
goto err_req_mem;
brd->re_map_membase = ioremap(brd->membase, 0x200000);
* the Linux line discipline way.
*/
static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf,
- unsigned char *fbuf, int *len)
+ unsigned char *fbuf, int *len)
{
int l = *len;
int count = 0;
case 0:
/* No FF seen yet */
- if (c == (unsigned char) '\377')
+ if (c == (unsigned char)'\377')
/* delete this character from stream */
ch->pscan_state = 1;
else {
case 1:
/* first FF seen */
- if (c == (unsigned char) '\377') {
+ if (c == (unsigned char)'\377') {
/* doubled ff, transform to single ff */
*cout++ = c;
*fout++ = TTY_NORMAL;
*cout++ = c;
if (ch->pscan_savechar == 0x0) {
-
if (c == 0x0) {
ch->ch_err_break++;
*fout++ = TTY_BREAK;
rmask = ch->ch_rsize - 1;
- head = readw(&(bs->rx_head));
+ head = readw(&bs->rx_head);
head &= rmask;
- tail = readw(&(bs->rx_tail));
+ tail = readw(&bs->rx_tail);
tail &= rmask;
data_len = (head - tail) & rmask;
if (data_len == 0) {
- writeb(1, &(bs->idata));
+ writeb(1, &bs->idata);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
return;
!(ch->ch_tun.un_flags & UN_ISOPEN) ||
!(tp->termios.c_cflag & CREAD) ||
(ch->ch_tun.un_flags & UN_CLOSING)) {
-
- writew(head, &(bs->rx_tail));
- writeb(1, &(bs->idata));
+ writew(head, &bs->rx_tail);
+ writeb(1, &bs->idata);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
return;
* If we are throttled, simply don't read any data.
*/
if (ch->ch_flags & CH_RXBLOCK) {
- writeb(1, &(bs->idata));
+ writeb(1, &bs->idata);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
return;
/*
* Ignore oruns.
*/
- tmpchar = readb(&(bs->orun));
+ tmpchar = readb(&bs->orun);
if (tmpchar) {
ch->ch_err_overrun++;
- writeb(0, &(bs->orun));
+ writeb(0, &bs->orun);
}
/* Decide how much data we can send into the tty layer */
* space to put the data right now.
*/
if (!ld->ops->receive_buf) {
- writew(head, &(bs->rx_tail));
+ writew(head, &bs->rx_tail);
len = 0;
}
}
if (len <= 0) {
- writeb(1, &(bs->idata));
+ writeb(1, &bs->idata);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
if (ld)
* of data the card actually has pending...
*/
while (n) {
-
s = ((head >= tail) ? head : ch->ch_rsize) - tail;
s = min(s, n);
tail &= rmask;
}
- writew(tail, &(bs->rx_tail));
- writeb(1, &(bs->idata));
+ writew(tail, &bs->rx_tail);
+ writeb(1, &bs->idata);
ch->ch_rxcount += len;
/*
len = tty_buffer_request_room(tp->port, len);
tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf,
- ch->ch_bd->flipflagbuf, len);
+ ch->ch_bd->flipflagbuf, len);
} else {
len = tty_buffer_request_room(tp->port, len);
tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len);
if (ld)
tty_ldisc_deref(ld);
-
}
static void dgap_write_wakeup(struct board_t *bd, struct channel_t *ch,
* Test for a VIRTUAL carrier transition to HIGH.
*/
if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) {
-
/*
* When carrier rises, wake any threads waiting
* for carrier in the open routine.
* Test for a PHYSICAL carrier transition to HIGH.
*/
if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) {
-
/*
* When carrier rises, wake any threads waiting
* for carrier in the open routine.
if ((virt_carrier == 0) &&
((ch->ch_flags & CH_CD) != 0) &&
(phys_carrier == 0)) {
-
/*
* When carrier drops:
*
int port;
int reason;
int modem;
- int b1;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return -EIO;
return -EIO;
}
- eaddr = (struct ev_t __iomem *) (vaddr + EVBUF);
+ eaddr = (struct ev_t __iomem *)(vaddr + EVBUF);
/* Get our head and tail */
- head = readw(&(eaddr->ev_head));
- tail = readw(&(eaddr->ev_tail));
+ head = readw(&eaddr->ev_head);
+ tail = readw(&eaddr->ev_tail);
/*
* Forget it if pointers out of range.
* Loop to process all the events in the buffer.
*/
while (tail != head) {
-
/*
* Get interrupt information.
*/
port = ioread8(event);
reason = ioread8(event + 1);
modem = ioread8(event + 2);
- b1 = ioread8(event + 3);
+ ioread8(event + 3);
/*
* Make sure the interrupt is valid.
* Process received data.
*/
if (reason & IFDATA) {
-
/*
* ALL LOCKS *MUST* BE DROPPED BEFORE CALLING INPUT!
* input could send some data to ld, which in turn
if (ch->ch_flags & CH_RACTIVE)
ch->ch_flags |= CH_RENABLE;
else
- writeb(1, &(bs->idata));
+ writeb(1, &bs->idata);
if (ch->ch_flags & CH_RWAIT) {
ch->ch_flags &= ~CH_RWAIT;
* Process break.
*/
if (reason & IFBREAK) {
-
if (ch->ch_tun.un_tty) {
/* A break has been indicated */
ch->ch_err_break++;
tail = (tail + 4) & (EVMAX - EVSTART - 4);
}
- writew(tail, &(eaddr->ev_tail));
+ writew(tail, &eaddr->ev_tail);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
return 0;
*/
static void dgap_poll_tasklet(unsigned long data)
{
- struct board_t *bd = (struct board_t *) data;
+ struct board_t *bd = (struct board_t *)data;
ulong lock_flags;
char __iomem *vaddr;
u16 head, tail;
* If board is ready, parse deeper to see if there is anything to do.
*/
if (bd->state == BOARD_READY) {
-
struct ev_t __iomem *eaddr;
if (!bd->re_map_membase) {
if (!bd->nasync)
goto out;
- eaddr = (struct ev_t __iomem *) (vaddr + EVBUF);
+ eaddr = (struct ev_t __iomem *)(vaddr + EVBUF);
/* Get our head and tail */
- head = readw(&(eaddr->ev_head));
- tail = readw(&(eaddr->ev_tail));
+ head = readw(&eaddr->ev_head);
+ tail = readw(&eaddr->ev_tail);
/*
* If there is an event pending. Go service it.
/*
* If board is doing interrupts, ACK the interrupt.
*/
- if (bd && bd->intr_running)
+ if (bd->intr_running)
readb(bd->re_map_port + 2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
/* init our poll helper tasklet */
tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet,
- (unsigned long) brd);
+ (unsigned long)brd);
ret = dgap_remap(brd);
if (ret)
*/
if ((dgap_numboards == 1) || (num_online_cpus() <= 1)) {
for (i = 0; i < dgap_numboards; i++) {
-
brd = dgap_board[i];
if (brd->state == BOARD_FAILED)
continue;
if (!brd->intr_running)
/* Call the real board poller directly */
- dgap_poll_tasklet((unsigned long) brd);
+ dgap_poll_tasklet((unsigned long)brd);
}
} else {
/*
new_time = dgap_poll_time - jiffies;
- if ((ulong) new_time >= 2 * dgap_poll_tick) {
+ if ((ulong)new_time >= 2 * dgap_poll_tick) {
dgap_poll_time =
jiffies + dgap_jiffies_from_ms(dgap_poll_tick);
}
*
*=======================================================================*/
static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1,
- u8 byte2, uint ncmds)
+ u8 byte2, uint ncmds)
{
char __iomem *vaddr;
struct __iomem cm_t *cm_addr;
if (!vaddr)
return;
- cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF);
- head = readw(&(cm_addr->cm_head));
+ cm_addr = (struct cm_t __iomem *)(vaddr + CMDBUF);
+ head = readw(&cm_addr->cm_head);
/*
* Forget it if pointers out of range.
* Put the data in the circular command buffer.
*/
writeb(cmd, (vaddr + head + CMDSTART + 0));
- writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1));
+ writeb((u8)ch->ch_portnum, (vaddr + head + CMDSTART + 1));
writeb(byte1, (vaddr + head + CMDSTART + 2));
writeb(byte2, (vaddr + head + CMDSTART + 3));
head = (head + 4) & (CMDMAX - CMDSTART - 4);
- writew(head, &(cm_addr->cm_head));
+ writew(head, &cm_addr->cm_head);
/*
* Wait if necessary before updating the head
* is outlandish, declare the FEP dead.
*/
for (count = dgap_count ;;) {
-
- head = readw(&(cm_addr->cm_head));
- tail = readw(&(cm_addr->cm_tail));
+ head = readw(&cm_addr->cm_head);
+ tail = readw(&cm_addr->cm_tail);
n = (head - tail) & (CMDMAX - CMDSTART - 4);
if (!vaddr)
return;
- cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF);
- head = readw(&(cm_addr->cm_head));
+ cm_addr = (struct cm_t __iomem *)(vaddr + CMDBUF);
+ head = readw(&cm_addr->cm_head);
/*
* Forget it if pointers out of range.
* Put the data in the circular command buffer.
*/
writeb(cmd, (vaddr + head + CMDSTART + 0));
- writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1));
- writew((u16) word, (vaddr + head + CMDSTART + 2));
+ writeb((u8)ch->ch_portnum, (vaddr + head + CMDSTART + 1));
+ writew((u16)word, (vaddr + head + CMDSTART + 2));
head = (head + 4) & (CMDMAX - CMDSTART - 4);
- writew(head, &(cm_addr->cm_head));
+ writew(head, &cm_addr->cm_head);
/*
* Wait if necessary before updating the head
* is outlandish, declare the FEP dead.
*/
for (count = dgap_count ;;) {
-
- head = readw(&(cm_addr->cm_head));
- tail = readw(&(cm_addr->cm_tail));
+ head = readw(&cm_addr->cm_head);
+ tail = readw(&cm_addr->cm_tail);
n = (head - tail) & (CMDMAX - CMDSTART - 4);
if (!vaddr)
return;
- cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF);
- head = readw(&(cm_addr->cm_head));
+ cm_addr = (struct cm_t __iomem *)(vaddr + CMDBUF);
+ head = readw(&cm_addr->cm_head);
/*
* Forget it if pointers out of range.
*/
/* Write an FF to tell the FEP that we want an extended command */
- writeb((u8) 0xff, (vaddr + head + CMDSTART + 0));
+ writeb((u8)0xff, (vaddr + head + CMDSTART + 0));
- writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1));
- writew((u16) cmd, (vaddr + head + CMDSTART + 2));
+ writeb((u8)ch->ch_portnum, (vaddr + head + CMDSTART + 1));
+ writew((u16)cmd, (vaddr + head + CMDSTART + 2));
/*
* If the second part of the command won't fit,
* put it at the beginning of the circular buffer.
*/
if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03)))
- writew((u16) word, (vaddr + CMDSTART));
+ writew((u16)word, (vaddr + CMDSTART));
else
- writew((u16) word, (vaddr + head + CMDSTART + 4));
+ writew((u16)word, (vaddr + head + CMDSTART + 4));
head = (head + 8) & (CMDMAX - CMDSTART - 4);
- writew(head, &(cm_addr->cm_head));
+ writew(head, &cm_addr->cm_head);
/*
* Wait if necessary before updating the head
* is outlandish, declare the FEP dead.
*/
for (count = dgap_count ;;) {
-
- head = readw(&(cm_addr->cm_head));
- tail = readw(&(cm_addr->cm_tail));
+ head = readw(&cm_addr->cm_head);
+ tail = readw(&cm_addr->cm_tail);
n = (head - tail) & (CMDMAX - CMDSTART - 4);
* dgap_wmove - Write data to FEP buffer.
*
* ch - Pointer to channel structure.
- * buf - Poiter to characters to be moved.
+ * buf - Pointer to characters to be moved.
* cnt - Number of characters to move.
*
*=======================================================================*/
* Check parameters.
*/
bs = ch->ch_bs;
- head = readw(&(bs->tx_head));
+ head = readw(&bs->tx_head);
/*
* If pointers are out of range, just return.
memcpy_toio(taddr, buf, n);
head += cnt;
- writew(head, &(bs->tx_head));
+ writew(head, &bs->tx_head);
}
/*
* If baud rate is zero, flush queues, and set mval to drop DTR.
*/
if ((ch->ch_c_cflag & (CBAUD)) == 0) {
-
/* flush rx */
- head = readw(&(ch->ch_bs->rx_head));
- writew(head, &(ch->ch_bs->rx_tail));
+ head = readw(&ch->ch_bs->rx_head);
+ writew(head, &ch->ch_bs->rx_tail);
/* flush tx */
- head = readw(&(ch->ch_bs->tx_head));
- writew(head, &(ch->ch_bs->tx_tail));
+ head = readw(&ch->ch_bs->tx_head);
+ writew(head, &ch->ch_bs->tx_tail);
ch->ch_flags |= (CH_BAUD0);
/* Drop RTS and DTR */
- ch->ch_mval &= ~(D_RTS(ch)|D_DTR(ch));
+ ch->ch_mval &= ~(D_RTS(ch) | D_DTR(ch));
mval = D_DTR(ch) | D_RTS(ch);
ch->ch_baud_info = 0;
/* Handle transition from B0 */
if (ch->ch_flags & CH_BAUD0) {
ch->ch_flags &= ~(CH_BAUD0);
- ch->ch_mval |= (D_RTS(ch)|D_DTR(ch));
+ ch->ch_mval |= (D_RTS(ch) | D_DTR(ch));
}
mval = D_DTR(ch) | D_RTS(ch);
cflag &= 0xffff;
if (cflag != ch->ch_fepcflag) {
- ch->ch_fepcflag = (u16) (cflag & 0xffff);
+ ch->ch_fepcflag = (u16)(cflag & 0xffff);
/*
* Okay to have channel and board
* locks held calling this
*/
- dgap_cmdw(ch, SCFLAG, (u16) cflag, 0);
+ dgap_cmdw(ch, SCFLAG, (u16)cflag, 0);
}
/* Handle transition from B0 */
if (ch->ch_flags & CH_BAUD0) {
ch->ch_flags &= ~(CH_BAUD0);
- ch->ch_mval |= (D_RTS(ch)|D_DTR(ch));
+ ch->ch_mval |= (D_RTS(ch) | D_DTR(ch));
}
mval = D_DTR(ch) | D_RTS(ch);
}
ch->ch_fepiflag = iflag;
/* Okay to have channel and board locks held calling this */
- dgap_cmdw(ch, SIFLAG, (u16) ch->ch_fepiflag, 0);
+ dgap_cmdw(ch, SIFLAG, (u16)ch->ch_fepiflag, 0);
}
/*
ch->ch_hflow = hflow;
/* Okay to have channel and board locks held calling this */
- dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0);
+ dgap_cmdb(ch, SHFLOW, (u8)hflow, 0xff, 0);
}
/*
ch->ch_mostat = mval;
/* Okay to have channel and board locks held calling this */
- dgap_cmdb(ch, SMODEM, (u8) mval, D_RTS(ch)|D_DTR(ch), 0);
+ dgap_cmdb(ch, SMODEM, (u8)mval, D_RTS(ch) | D_DTR(ch), 0);
}
/*
* Read modem signals, and then call carrier function.
*/
- ch->ch_mistat = readb(&(ch->ch_bs->m_stat));
+ ch->ch_mistat = readb(&ch->ch_bs->m_stat);
dgap_carrier(ch);
/*
int sleep_on_un_flags;
if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
- ch->magic != DGAP_CHANNEL_MAGIC)
+ ch->magic != DGAP_CHANNEL_MAGIC)
return -EIO;
un = tty->driver_data;
/* Loop forever */
while (1) {
-
sleep_on_un_flags = 0;
/*
*/
if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) &
UN_CLOSING)) {
-
/*
* Our conditions to leave cleanly and happily:
* 1) NONBLOCKING on the tty is set.
spin_lock_irqsave(&ch->ch_lock, lock_flags2);
ch->ch_flags &= ~CH_STOP;
- head = readw(&(ch->ch_bs->tx_head));
- dgap_cmdw(ch, FLUSHTX, (u16) head, 0);
+ head = readw(&ch->ch_bs->tx_head);
+ dgap_cmdw(ch, FLUSHTX, (u16)head, 0);
dgap_cmdw(ch, RESUMETX, 0, 0);
- if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) {
- ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY);
+ if (ch->ch_tun.un_flags & (UN_LOW | UN_EMPTY)) {
+ ch->ch_tun.un_flags &= ~(UN_LOW | UN_EMPTY);
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
}
- if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) {
- ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY);
+ if (ch->ch_pun.un_flags & (UN_LOW | UN_EMPTY)) {
+ ch->ch_pun.un_flags &= ~(UN_LOW | UN_EMPTY);
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
}
tmask = (ch->ch_tsize - 1);
/* Get Transmit queue pointers */
- thead = readw(&(bs->tx_head)) & tmask;
- ttail = readw(&(bs->tx_tail)) & tmask;
+ thead = readw(&bs->tx_head) & tmask;
+ ttail = readw(&bs->tx_tail) & tmask;
/* Get tbusy flag */
- tbusy = readb(&(bs->tbusy));
+ tbusy = readb(&bs->tbusy);
/* Get Command queue pointers */
- chead = readw(&(ch->ch_cm->cm_head));
- ctail = readw(&(ch->ch_cm->cm_tail));
+ chead = readw(&ch->ch_cm->cm_head);
+ ctail = readw(&ch->ch_cm->cm_tail);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
if (tbusy != 0) {
spin_lock_irqsave(&ch->ch_lock, lock_flags);
un->un_flags |= UN_EMPTY;
- writeb(1, &(bs->iempty));
+ writeb(1, &bs->iempty);
spin_unlock_irqrestore(&ch->ch_lock,
lock_flags);
}
/* Loop until data is drained */
while (count != 0) {
-
count = dgap_tty_chars_in_buffer(tty);
if (count == 0)
/* Set flag waiting for drain */
spin_lock_irqsave(&ch->ch_lock, lock_flags);
un->un_flags |= UN_EMPTY;
- writeb(1, &(bs->iempty));
+ writeb(1, &bs->iempty);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
/* Go to sleep till we get woken up */
if ((event & UN_LOW) != 0) {
if ((un->un_flags & UN_LOW) == 0) {
un->un_flags |= UN_LOW;
- writeb(1, &(bs->ilow));
+ writeb(1, &bs->ilow);
}
}
if ((event & UN_LOW) != 0) {
if ((un->un_flags & UN_EMPTY) == 0) {
un->un_flags |= UN_EMPTY;
- writeb(1, &(bs->iempty));
+ writeb(1, &bs->iempty);
}
}
}
spin_lock_irqsave(&ch->ch_lock, lock_flags);
tmask = ch->ch_tsize - 1;
- head = readw(&(bs->tx_head)) & tmask;
- tail = readw(&(bs->tx_tail)) & tmask;
+ head = readw(&bs->tx_head) & tmask;
+ tail = readw(&bs->tx_tail) & tmask;
ret = tail - head - 1;
if (ret < 0)
* In here exists all the Transparent Print magic as well.
*/
static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf,
- int count)
+ int count)
{
struct channel_t *ch;
struct un_t *un;
*/
if ((un->un_type == DGAP_PRINT) && !(ch->ch_flags & CH_PRON)) {
dgap_wmove(ch, ch->ch_digi.digi_onstr,
- (int) ch->ch_digi.digi_onlen);
- head = readw(&(bs->tx_head)) & tmask;
+ (int)ch->ch_digi.digi_onlen);
+ head = readw(&bs->tx_head) & tmask;
ch->ch_flags |= CH_PRON;
}
*/
if ((un->un_type != DGAP_PRINT) && (ch->ch_flags & CH_PRON)) {
dgap_wmove(ch, ch->ch_digi.digi_offstr,
- (int) ch->ch_digi.digi_offlen);
- head = readw(&(bs->tx_head)) & tmask;
+ (int)ch->ch_digi.digi_offlen);
+ head = readw(&bs->tx_head) & tmask;
ch->ch_flags &= ~CH_PRON;
}
n -= remain;
vaddr = ch->ch_taddr + head;
- memcpy_toio(vaddr, (u8 *) buf, remain);
+ memcpy_toio(vaddr, (u8 *)buf, remain);
head = ch->ch_tstart;
buf += remain;
}
if (n > 0) {
-
/*
* Move rest of data.
*/
vaddr = ch->ch_taddr + head;
remain = n;
- memcpy_toio(vaddr, (u8 *) buf, remain);
+ memcpy_toio(vaddr, (u8 *)buf, remain);
head += remain;
-
}
if (count) {
ch->ch_txcount += count;
head &= tmask;
- writew(head, &(bs->tx_head));
+ writew(head, &bs->tx_head);
}
dgap_set_firmware_event(un, UN_LOW | UN_EMPTY);
* Otherwise turn it off right now.
*/
if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON)) {
- tail = readw(&(bs->tx_tail)) & tmask;
+ tail = readw(&bs->tx_tail) & tmask;
if (tail != head) {
un->un_flags |= UN_EMPTY;
- writeb(1, &(bs->iempty));
+ writeb(1, &bs->iempty);
} else {
dgap_wmove(ch, ch->ch_digi.digi_offstr,
- (int) ch->ch_digi.digi_offlen);
- head = readw(&(bs->tx_head)) & tmask;
+ (int)ch->ch_digi.digi_offlen);
+ head = readw(&bs->tx_head) & tmask;
ch->ch_flags &= ~CH_PRON;
}
}
spin_lock_irqsave(&ch->ch_lock, lock_flags);
- mstat = readb(&(ch->ch_bs->m_stat));
+ mstat = readb(&ch->ch_bs->m_stat);
/* Append any outbound signals that might be pending... */
mstat |= ch->ch_mostat;
* Set modem signals, called by ld.
*/
static int dgap_tty_tiocmset(struct tty_struct *tty,
- unsigned int set, unsigned int clear)
+ unsigned int set, unsigned int clear)
{
struct board_t *bd;
struct channel_t *ch;
#if 0
dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0);
#endif
- dgap_cmdw(ch, SBREAK, (u16) msec, 0);
+ dgap_cmdw(ch, SBREAK, (u16)msec, 0);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&ch->ch_lock, lock_flags);
- mstat = readb(&(ch->ch_bs->m_stat));
+ mstat = readb(&ch->ch_bs->m_stat);
/* Append any outbound signals that might be pending... */
mstat |= ch->ch_mostat;
break;
case TIOCMSET:
- ch->ch_mforce = D_DTR(ch)|D_RTS(ch);
+ ch->ch_mforce = D_DTR(ch) | D_RTS(ch);
if (arg & TIOCM_RTS)
ch->ch_mval |= D_RTS(ch);
memset(&tmp, 0, sizeof(tmp));
spin_lock_irqsave(&ch->ch_lock, lock_flags);
- tmp = readw(&(ch->ch_bs->edelay));
+ tmp = readw(&ch->ch_bs->edelay);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
spin_lock_irqsave(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&ch->ch_lock, lock_flags2);
- writew((u16) new_digi, &(ch->ch_bs->edelay));
+ writew((u16)new_digi, &ch->ch_bs->edelay);
dgap_param(ch, bd, un->un_type);
return -EFAULT;
if (bd->bd_flags & BD_FEP5PLUS) {
-
spin_lock_irqsave(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&ch->ch_lock, lock_flags2);
* dgap_set_termios()
*/
static void dgap_tty_set_termios(struct tty_struct *tty,
- struct ktermios *old_termios)
+ struct ktermios *old_termios)
{
struct board_t *bd;
struct channel_t *ch;
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
-
}
static void dgap_tty_unthrottle(struct tty_struct *tty)
* sleep waiting for it to happen or they cancel the open.
*/
rc = wait_event_interruptible(brd->state_wait,
- (brd->state & BOARD_READY));
+ (brd->state & BOARD_READY));
if (rc)
return rc;
* Initialize if neither terminal or printer is open.
*/
if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) {
-
ch->ch_mforce = 0;
ch->ch_mval = 0;
/*
* Flush input queue.
*/
- head = readw(&(bs->rx_head));
- writew(head, &(bs->rx_tail));
+ head = readw(&bs->rx_head);
+ writew(head, &bs->rx_tail);
ch->ch_flags = 0;
ch->pscan_state = 0;
*/
static void dgap_tty_close(struct tty_struct *tty, struct file *file)
{
- struct ktermios *ts;
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- ts = &tty->termios;
-
spin_lock_irqsave(&ch->ch_lock, lock_flags);
/*
*/
if ((ch->ch_open_count == 0) &&
!(ch->ch_digi.digi_flags & DIGI_PRINTER)) {
-
ch->ch_flags &= ~(CH_RXBLOCK);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
* If we have HUPCL set, lower DTR and RTS
*/
if (ch->ch_c_cflag & HUPCL) {
- ch->ch_mostat &= ~(D_RTS(ch)|D_DTR(ch));
- dgap_cmdb(ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0);
+ ch->ch_mostat &= ~(D_RTS(ch) | D_DTR(ch));
+ dgap_cmdb(ch, SMODEM, 0, D_DTR(ch) | D_RTS(ch), 0);
/*
* Go to sleep to ensure RTS/DTR
* have been dropped for modems to see it.
*/
spin_unlock_irqrestore(&ch->ch_lock,
- lock_flags);
+ lock_flags);
/* .25 second delay for dropping RTS/DTR */
schedule_timeout_interruptible(msecs_to_jiffies(250));
ch->pscan_state = 0;
ch->pscan_savechar = 0;
ch->ch_baud_info = 0;
-
}
/*
*/
if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON)) {
dgap_wmove(ch, ch->ch_digi.digi_offstr,
- (int) ch->ch_digi.digi_offlen);
+ (int)ch->ch_digi.digi_offlen);
ch->ch_flags &= ~CH_PRON;
}
* The usual assortment of ioctl's
*/
static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
- unsigned long arg)
+ unsigned long arg)
{
struct board_t *bd;
struct channel_t *ch;
u16 head;
ulong lock_flags = 0;
ulong lock_flags2 = 0;
- void __user *uarg = (void __user *) arg;
+ void __user *uarg = (void __user *)arg;
if (!tty || tty->magic != TTY_MAGIC)
return -ENODEV;
}
switch (cmd) {
-
/* Here are all the standard ioctl's that we MUST implement */
-
case TCSBRK:
/*
* TCSBRK is SVID version: non-zero arg --> no break
spin_lock_irqsave(&ch->ch_lock, lock_flags2);
if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP))
- dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0);
+ dgap_cmdw(ch, SBREAK, (u16)SBREAK_TIME, 0);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&ch->ch_lock, lock_flags2);
- dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0);
+ dgap_cmdw(ch, SBREAK, (u16)SBREAK_TIME, 0);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&bd->bd_lock, lock_flags);
spin_lock_irqsave(&ch->ch_lock, lock_flags2);
- dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0);
+ dgap_cmdw(ch, SBREAK, (u16)SBREAK_TIME, 0);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
- rc = put_user(C_CLOCAL(tty) ? 1 : 0,
- (unsigned long __user *) arg);
- return rc;
+ return put_user(C_CLOCAL(tty) ? 1 : 0,
+ (unsigned long __user *)arg);
case TIOCSSOFTCAR:
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
- rc = get_user(arg, (unsigned long __user *) arg);
+ rc = get_user(arg, (unsigned long __user *)arg);
if (rc)
return rc;
if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) {
if (!(un->un_type == DGAP_PRINT)) {
- head = readw(&(ch->ch_bs->rx_head));
- writew(head, &(ch->ch_bs->rx_tail));
- writeb(0, &(ch->ch_bs->orun));
+ head = readw(&ch->ch_bs->rx_head);
+ writew(head, &ch->ch_bs->rx_tail);
+ writeb(0, &ch->ch_bs->orun);
}
}
}
ch->ch_flags &= ~CH_STOP;
- head = readw(&(ch->ch_bs->tx_head));
- dgap_cmdw(ch, FLUSHTX, (u16) head, 0);
+ head = readw(&ch->ch_bs->tx_head);
+ dgap_cmdw(ch, FLUSHTX, (u16)head, 0);
dgap_cmdw(ch, RESUMETX, 0, 0);
- if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) {
- ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY);
+ if (ch->ch_tun.un_flags & (UN_LOW | UN_EMPTY)) {
+ ch->ch_tun.un_flags &= ~(UN_LOW | UN_EMPTY);
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
}
- if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) {
- ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY);
+ if (ch->ch_pun.un_flags & (UN_LOW | UN_EMPTY)) {
+ ch->ch_pun.un_flags &= ~(UN_LOW | UN_EMPTY);
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
}
if (waitqueue_active(&tty->write_wait))
if (cmd == TCSETSF) {
/* flush rx */
ch->ch_flags &= ~CH_STOP;
- head = readw(&(ch->ch_bs->rx_head));
- writew(head, &(ch->ch_bs->rx_tail));
+ head = readw(&ch->ch_bs->rx_head);
+ writew(head, &ch->ch_bs->rx_tail);
}
/* now wait for all the output to drain */
}
switch (arg) {
-
case TCOON:
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
/* set information for ditty */
if (cmd == (DIGI_SETAW)) {
-
spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
rc = dgap_wait_for_drain(tty);
cn = ch->ch_portnum;
for (cptr = bd->bd_config; cptr; cptr = cptr->next) {
-
if ((cptr->type == BNODE) &&
((cptr->u.board.type == APORT2_920P) ||
(cptr->u.board.type == APORT4_920P) ||
(cptr->u.board.type == APORT8_920P) ||
(cptr->u.board.type == PAPORT4) ||
(cptr->u.board.type == PAPORT8))) {
-
found = TRUE;
if (cptr->u.board.v_start)
starto = cptr->u.board.start;
}
if (cptr->type == CNODE) {
-
for (i = 0; i < cptr->u.conc.nport; i++) {
if (cn != (i + ncount))
continue;
}
if (cptr->type == MNODE) {
-
for (i = 0; i < cptr->u.module.nport; i++) {
if (cn != (i + ncount))
continue;
static void dgap_create_ports_sysfiles(struct board_t *bd)
{
dev_set_drvdata(&bd->pdev->dev, bd);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_state);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount);
- device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_state);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_baud);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_msignals);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_iflag);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_cflag);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_oflag);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_lflag);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_digi_flag);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_rxcount);
+ device_create_file(&bd->pdev->dev, &dev_attr_ports_txcount);
}
/* removes all the sys files created for that port */
static void dgap_remove_ports_sysfiles(struct board_t *bd)
{
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount);
- device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_state);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_baud);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_msignals);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_iflag);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_cflag);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_oflag);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_lflag);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_digi_flag);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_rxcount);
+ device_remove_file(&bd->pdev->dev, &dev_attr_ports_txcount);
}
/*
brd->wait_for_bios = 0;
while (brd->wait_for_bios < 1000) {
/* Check to see if BIOS thinks board is good. (GD). */
- if (word == *(u16 *) "GD")
+ if (word == *(u16 *)"GD")
return 0;
msleep_interruptible(10);
brd->wait_for_bios++;
err1 = readw(addr + SEQUENCE);
err2 = readw(addr + ERROR);
dev_warn(&brd->pdev->dev, "%s failed diagnostics. Error #(%x,%x).\n",
- brd->name, err1, err2);
+ brd->name, err1, err2);
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOBIOS;
writel(0xbfc01004, (addr + 0xc34));
writel(0x3, (addr + 0xc30));
-
}
/*
brd->wait_for_fep = 0;
while (brd->wait_for_fep < 500) {
/* Check to see if FEP is up and running now. */
- if (word == *(u16 *) "OS") {
+ if (word == *(u16 *)"OS") {
/*
* Check to see if the board can support FEP5+ commands.
*/
word = readw(addr + FEP5_PLUS);
- if (word == *(u16 *) "5A")
+ if (word == *(u16 *)"5A")
brd->bd_flags |= BD_FEP5PLUS;
return 0;
if (check == FEPRST)
break;
udelay(10);
-
}
if (i > 1000) {
dev_warn(&brd->pdev->dev,
vaddr = brd->re_map_membase;
- offset = readw((u16 *) (vaddr + DOWNREQ));
- to_dp = (struct downld_t *) (vaddr + (int) offset);
+ offset = readw((u16 *)(vaddr + DOWNREQ));
+ to_dp = (struct downld_t *)(vaddr + (int)offset);
memcpy_toio(to_dp, uaddr, len);
/* Tell card we have data for it */
* the first 2 bytes (header) should be 0x55, 0xAA
*/
if (byte1 == 0x55 && byte2 == 0xAA) {
-
base_offset = 0;
/*
* for the VPD offset.
*/
while (base_offset <= EXPANSION_ROM_SIZE) {
-
/*
* Lots of magic numbers here.
*
return;
dev_set_drvdata(c, un);
-
}
static void dgap_remove_tty_sysfs(struct device *c)
ch = brd->channels[0];
for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) {
-
struct device *classp;
classp = tty_port_register_device(&brd->serial_ports[i],
* Set up our interrupt handler if we are set to do interrupts.
*/
if (dgap_config_get_useintr(brd) && brd->irq) {
-
rc = request_irq(brd->irq, dgap_intr, IRQF_SHARED, "DGAP", brd);
if (!rc)
if (fw_info[card_type].conf_name) {
ret = request_firmware(&fw, fw_info[card_type].conf_name,
- &pdev->dev);
+ &pdev->dev);
if (ret) {
dev_err(&pdev->dev, "config file %s not found\n",
fw_info[card_type].conf_name);
if (fw_info[card_type].bios_name) {
ret = request_firmware(&fw, fw_info[card_type].bios_name,
- &pdev->dev);
+ &pdev->dev);
if (ret) {
dev_err(&pdev->dev, "bios file %s not found\n",
fw_info[card_type].bios_name);
if (fw_info[card_type].fep_name) {
ret = request_firmware(&fw, fw_info[card_type].fep_name,
- &pdev->dev);
+ &pdev->dev);
if (ret) {
dev_err(&pdev->dev, "dgap: fep file %s not found\n",
fw_info[card_type].fep_name);
* is requesting a concentrator image from us.
*/
if ((bd->type == PCX) || (bd->type == PEPC)) {
- chk_addr = (u16 *) (vaddr + DOWNREQ);
+ chk_addr = (u16 *)(vaddr + DOWNREQ);
/* Nonzero if FEP is requesting concentrator image. */
check = readw(chk_addr);
vaddr = brd->re_map_membase;
if (fw_info[card_type].con_name && check && vaddr) {
ret = request_firmware(&fw, fw_info[card_type].con_name,
- &pdev->dev);
+ &pdev->dev);
if (ret) {
dev_err(&pdev->dev, "conc file %s not found\n",
fw_info[card_type].con_name);
return ret;
}
/* Put concentrator firmware loading code here */
- offset = readw((u16 *) (vaddr + DOWNREQ));
+ offset = readw((u16 *)(vaddr + DOWNREQ));
memcpy_toio(offset, fw->data, fw->size);
dgap_do_conc_load(brd, (char *)fw->data, fw->size)
ch = brd->channels[0];
vaddr = brd->re_map_membase;
- bs = (struct bs_t __iomem *) ((ulong) vaddr + CHANBUF);
- cm = (struct cm_t __iomem *) ((ulong) vaddr + CMDBUF);
+ bs = (struct bs_t __iomem *)((ulong)vaddr + CHANBUF);
+ cm = (struct cm_t __iomem *)((ulong)vaddr + CMDBUF);
brd->bd_bs = bs;
/* Set up channel variables */
for (i = 0; i < brd->nasync; i++, ch = brd->channels[i], bs++) {
-
spin_lock_init(&ch->ch_lock);
/* Store all our magic numbers */
ch->ch_dsr = DM_DSR;
}
- ch->ch_taddr = vaddr + (ioread16(&(ch->ch_bs->tx_seg)) << 4);
- ch->ch_raddr = vaddr + (ioread16(&(ch->ch_bs->rx_seg)) << 4);
+ ch->ch_taddr = vaddr + (ioread16(&ch->ch_bs->tx_seg) << 4);
+ ch->ch_raddr = vaddr + (ioread16(&ch->ch_bs->rx_seg) << 4);
ch->ch_tx_win = 0;
ch->ch_rx_win = 0;
- ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1;
- ch->ch_rsize = readw(&(ch->ch_bs->rx_max)) + 1;
+ ch->ch_tsize = readw(&ch->ch_bs->tx_max) + 1;
+ ch->ch_rsize = readw(&ch->ch_bs->rx_max) + 1;
ch->ch_tstart = 0;
ch->ch_rstart = 0;
dgap_cmdw(ch, SRHIGH, 7 * ch->ch_rsize / 8, 0);
- ch->ch_mistat = readb(&(ch->ch_bs->m_stat));
+ ch->ch_mistat = readb(&ch->ch_bs->m_stat);
init_waitqueue_head(&ch->ch_flags_wait);
init_waitqueue_head(&ch->ch_tun.un_flags_wait);
/* Turn on all modem interrupts for now */
modem = (DM_CD | DM_DSR | DM_CTS | DM_RI);
- writeb(modem, &(ch->ch_bs->m_int));
+ writeb(modem, &ch->ch_bs->m_int);
/*
* Set edelay to 0 if interrupts are turned on,
* otherwise set edelay to the usual 100.
*/
if (brd->intr_used)
- writew(0, &(ch->ch_bs->edelay));
+ writew(0, &ch->ch_bs->edelay);
else
- writew(100, &(ch->ch_bs->edelay));
+ writew(100, &ch->ch_bs->edelay);
- writeb(1, &(ch->ch_bs->idata));
+ writeb(1, &ch->ch_bs->idata);
}
return 0;
return rc;
}
+/*
+ * dgap_cleanup_board()
+ *
+ * Free all the memory associated with a board
+ */
+static void dgap_cleanup_board(struct board_t *brd)
+{
+ unsigned int i;
+
+ if (!brd || brd->magic != DGAP_BOARD_MAGIC)
+ return;
+
+ dgap_free_irq(brd);
+
+ tasklet_kill(&brd->helper_tasklet);
+
+ dgap_unmap(brd);
+
+ /* Free all allocated channels structs */
+ for (i = 0; i < MAXPORTS ; i++)
+ kfree(brd->channels[i]);
+
+ kfree(brd->flipbuf);
+ kfree(brd->flipflagbuf);
+
+ dgap_board[brd->boardnum] = NULL;
+
+ kfree(brd);
+}
+
+static void dgap_stop(bool removesys, struct pci_driver *drv)
+{
+ unsigned long lock_flags;
+
+ spin_lock_irqsave(&dgap_poll_lock, lock_flags);
+ dgap_poll_stop = 1;
+ spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
+
+ del_timer_sync(&dgap_poll_timer);
+ if (removesys)
+ dgap_remove_driver_sysfiles(drv);
+
+ device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
+ class_destroy(dgap_class);
+ unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
+}
+
static void dgap_remove_one(struct pci_dev *dev)
{
- /* Do Nothing */
+ unsigned int i;
+ struct pci_driver *drv = to_pci_driver(dev->dev.driver);
+
+ dgap_stop(true, drv);
+ for (i = 0; i < dgap_numboards; ++i) {
+ dgap_remove_ports_sysfiles(dgap_board[i]);
+ dgap_cleanup_tty(dgap_board[i]);
+ dgap_cleanup_board(dgap_board[i]);
+ }
+
+ dgap_cleanup_nodes();
}
static struct pci_driver dgap_driver = {
}
device = device_create(dgap_class, NULL,
- MKDEV(DIGI_DGAP_MAJOR, 0),
- NULL, "dgap_mgmt");
+ MKDEV(DIGI_DGAP_MAJOR, 0),
+ NULL, "dgap_mgmt");
if (IS_ERR(device)) {
rc = PTR_ERR(device);
goto failed_device;
return rc;
}
-static void dgap_stop(void)
-{
- unsigned long lock_flags;
-
- spin_lock_irqsave(&dgap_poll_lock, lock_flags);
- dgap_poll_stop = 1;
- spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
-
- del_timer_sync(&dgap_poll_timer);
-
- device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
- class_destroy(dgap_class);
- unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
-}
-
-/*
- * dgap_cleanup_board()
- *
- * Free all the memory associated with a board
- */
-static void dgap_cleanup_board(struct board_t *brd)
-{
- unsigned int i;
-
- if (!brd || brd->magic != DGAP_BOARD_MAGIC)
- return;
-
- dgap_free_irq(brd);
-
- tasklet_kill(&brd->helper_tasklet);
-
- dgap_unmap(brd);
-
- /* Free all allocated channels structs */
- for (i = 0; i < MAXPORTS ; i++)
- kfree(brd->channels[i]);
-
- kfree(brd->flipbuf);
- kfree(brd->flipflagbuf);
-
- dgap_board[brd->boardnum] = NULL;
-
- kfree(brd);
-}
-
-
/************************************************************************
*
* Driver load/unload functions
return rc;
rc = pci_register_driver(&dgap_driver);
- if (rc)
- goto err_stop;
+ if (rc) {
+ dgap_stop(false, NULL);
+ return rc;
+ }
rc = dgap_create_driver_sysfiles(&dgap_driver);
if (rc)
err_unregister:
pci_unregister_driver(&dgap_driver);
-err_stop:
- dgap_stop();
-
return rc;
}
*/
static void dgap_cleanup_module(void)
{
- unsigned int i;
- ulong lock_flags;
-
- spin_lock_irqsave(&dgap_poll_lock, lock_flags);
- dgap_poll_stop = 1;
- spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
-
- /* Turn off poller right away. */
- del_timer_sync(&dgap_poll_timer);
-
- dgap_remove_driver_sysfiles(&dgap_driver);
-
- device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
- class_destroy(dgap_class);
- unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
-
- for (i = 0; i < dgap_numboards; ++i) {
- dgap_remove_ports_sysfiles(dgap_board[i]);
- dgap_cleanup_tty(dgap_board[i]);
- dgap_cleanup_board(dgap_board[i]);
- }
-
- dgap_cleanup_nodes();
-
if (dgap_numboards)
pci_unregister_driver(&dgap_driver);
}