static int __init HiSax_inithardware(int *busy_flag) { int foundcards = 0; int i = 0; int t = ','; int flg = 0; char *id; char *next_id = HiSax_id; char ids[20]; if (strchr(HiSax_id, ',')) t = ','; else if (strchr(HiSax_id, '%')) t = '%'; while (i < nrcards) { if (cards[i].typ < 1) break; id = next_id; if ((next_id = strchr(id, t))) { *next_id++ = 0; strcpy(ids, id); flg = i + 1; } else { next_id = id; if (flg >= i) strcpy(ids, id); else sprintf(ids, "%s%d", id, i); } if (checkcard(i, ids, busy_flag, THIS_MODULE, hisax_cs_setup_card)) { foundcards++; i++; } else { /* make sure we don't oops the module */ if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) { printk(KERN_WARNING "HiSax: Card %s not installed !\n", CardType[cards[i].typ]); } HiSax_shiftcards(i); nrcards--; } } return foundcards; }
int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], char *name, int protocol) { int i, retval; char id[20]; struct IsdnCardState *cs; for (i = 0; i < HISAX_MAX_CARDS; i++) { if (!cards[i].typ) break; } if (i >= HISAX_MAX_CARDS) return -EBUSY; cards[i].typ = ISDN_CTYPE_DYNAMIC; cards[i].protocol = protocol; sprintf(id, "%s%d", name, i); nrcards++; retval = checkcard(i, id, NULL, hisax_d_if->owner, hisax_setup_card_dynamic); if (retval == 0) { // yuck cards[i].typ = 0; nrcards--; return -EINVAL; } cs = cards[i].cs; hisax_d_if->cs = cs; cs->hw.hisax_d_if = hisax_d_if; cs->cardmsg = hisax_cardmsg; INIT_WORK(&cs->tqueue, hisax_bh); cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1; for (i = 0; i < 2; i++) { cs->bcs[i].BC_SetStack = hisax_bc_setstack; cs->bcs[i].BC_Close = hisax_bc_close; b_if[i]->ifc.l1l2 = hisax_b_l1l2; hisax_d_if->b_if[i] = b_if[i]; } hisax_d_if->ifc.l1l2 = hisax_d_l1l2; skb_queue_head_init(&hisax_d_if->erq); clear_bit(0, &hisax_d_if->ph_state); return 0; }
int __devinit hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card) { u_char ids[16]; int ret = -1; cards[nrcards] = *card; if (nrcards) sprintf(ids, "HiSax%d", nrcards); else sprintf(ids, "HiSax"); if (!checkcard(nrcards, ids, busy_flag)) { return(-1); } ret = nrcards; nrcards++; return (ret); }
int __devinit HiSax_inithardware(int *busy_flag) { int foundcards = 0; int i = 0; int t = ','; int flg = 0; char *id; char *next_id = HiSax_id; char ids[20]; if (strchr(HiSax_id, ',')) t = ','; else if (strchr(HiSax_id, '%')) t = '%'; while (i < nrcards) { if (cards[i].typ < 1) break; id = next_id; if ((next_id = strchr(id, t))) { *next_id++ = 0; strcpy(ids, id); flg = i + 1; } else { next_id = id; if (flg >= i) strcpy(ids, id); else sprintf(ids, "%s%d", id, i); } if (checkcard(i, ids, busy_flag)) { foundcards++; i++; } else { printk(KERN_WARNING "HiSax: Card %s not installed !\n", CardType[cards[i].typ]); if (cards[i].cs) kfree((void *) cards[i].cs); cards[i].cs = NULL; HiSax_shiftcards(i); nrcards--; } } return foundcards; }
int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card) { u_char ids[16]; int ret = -1; cards[nrcards] = *card; if (nrcards) sprintf(ids, "HiSax%d", nrcards); else sprintf(ids, "HiSax"); if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE)) goto error; ret = nrcards; nrcards++; error: return ret; }
static long mixcomwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; int status; static const struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .firmware_version = 1, .identity = "MixCOM watchdog", }; switch (cmd) { case WDIOC_GETSUPPORT: if (copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; break; case WDIOC_GETSTATUS: status = mixcomwd_opened; if (!nowayout) status |= mixcomwd_timer_alive; return put_user(status, p); case WDIOC_GETBOOTSTATUS: return put_user(0, p); case WDIOC_KEEPALIVE: mixcomwd_ping(); break; default: return -ENOTTY; } return 0; } static const struct file_operations mixcomwd_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = mixcomwd_write, .unlocked_ioctl = mixcomwd_ioctl, .open = mixcomwd_open, .release = mixcomwd_release, }; static struct miscdevice mixcomwd_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &mixcomwd_fops, }; static int __init checkcard(int port, int card_id) { int id; if (!request_region(port, 1, "MixCOM watchdog")) return 0; id = inb_p(port); if (card_id == MIXCOM_ID) id &= 0x3f; if (id != card_id) { release_region(port, 1); return 0; } return 1; } static int __init mixcomwd_init(void) { int i, ret, found = 0; for (i = 0; !found && mixcomwd_io_info[i].ioport != 0; i++) { if (checkcard(mixcomwd_io_info[i].ioport, mixcomwd_io_info[i].id)) { found = 1; watchdog_port = mixcomwd_io_info[i].ioport; } } if (!found) { pr_err("No card detected, or port not available\n"); return -ENODEV; } ret = misc_register(&mixcomwd_miscdev); if (ret) { pr_err("cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto error_misc_register_watchdog; } pr_info("MixCOM watchdog driver v%s, watchdog port at 0x%3x\n", VERSION, watchdog_port); return 0; error_misc_register_watchdog: release_region(watchdog_port, 1); watchdog_port = 0x0000; return ret; }