Commit 711f6f98 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://linux-isdn.bkbits.net/linux-2.5.isdn

into home.transmeta.com:/home/torvalds/v2.5/linux
parents 3a8d92d1 b5919c97
......@@ -15,7 +15,9 @@ obj-$(CONFIG_ISDN_CAPI_CAPIFS) += capifs.o
# Multipart objects.
kernelcapi-objs := kcapi.o capiutil.o capilib.o
kernelcapi-y := kcapi.o capiutil.o capilib.o
kernelcapi-$(CONFIG_PROC_FS) += kcapi_proc.o
kernelcapi-objs := $(kernelcapi-y)
# The global Rules.make.
......
This diff is collapsed.
/*
* Kernel CAPI 2.0 Module
*
* Copyright 1999 by Carsten Paeth <calle@calle.de>
* Copyright 2002 by Kai Germaschewski <kai@germaschewski.name>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
*/
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/isdn/capilli.h>
#define DBG(format, arg...) do { \
printk(KERN_INFO __FUNCTION__ ": " format "\n" , ## arg); \
} while (0)
enum {
CARD_DETECTED = 1,
CARD_LOADING = 2,
CARD_RUNNING = 3,
};
extern struct list_head capi_drivers;
extern spinlock_t capi_drivers_lock;
extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
extern struct capi_ctr *capi_cards[CAPI_MAXCONTR];
#ifdef CONFIG_PROC_FS
void kcapi_proc_init(void);
void kcapi_proc_exit(void);
#else
static inline void kcapi_proc_init(void) { };
static inline void kcapi_proc_exit(void) { };
#endif
/*
* Kernel CAPI 2.0 Module - /proc/capi handling
*
* Copyright 1999 by Carsten Paeth <calle@calle.de>
* Copyright 2002 by Kai Germaschewski <kai@germaschewski.name>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
*/
#include "kcapi.h"
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
static char *
cardstate2str(unsigned short cardstate)
{
switch (cardstate) {
case CARD_DETECTED: return "detected";
case CARD_LOADING: return "loading";
case CARD_RUNNING: return "running";
default: return "???";
}
}
// /proc/capi
// ===========================================================================
// /proc/capi/controller:
// cnr driver cardstate name driverinfo
// /proc/capi/contrstats:
// cnr nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt
// ---------------------------------------------------------------------------
static void *controller_start(struct seq_file *seq, loff_t *pos)
{
if (*pos < CAPI_MAXCONTR)
return &capi_cards[*pos];
return NULL;
}
static void *controller_next(struct seq_file *seq, void *v, loff_t *pos)
{
++*pos;
if (*pos < CAPI_MAXCONTR)
return &capi_cards[*pos];
return NULL;
}
static void controller_stop(struct seq_file *seq, void *v)
{
}
static int controller_show(struct seq_file *seq, void *v)
{
struct capi_ctr *ctr = *(struct capi_ctr **) v;
if (!ctr)
return 0;
seq_printf(seq, "%d %-10s %-8s %-16s %s\n",
ctr->cnr, ctr->driver_name,
cardstate2str(ctr->cardstate),
ctr->name,
ctr->procinfo ? ctr->procinfo(ctr) : "");
return 0;
}
static int contrstats_show(struct seq_file *seq, void *v)
{
struct capi_ctr *ctr = *(struct capi_ctr **) v;
if (!ctr)
return 0;
seq_printf(seq, "%d %lu %lu %lu %lu\n",
ctr->cnr,
ctr->nrecvctlpkt,
ctr->nrecvdatapkt,
ctr->nsentctlpkt,
ctr->nsentdatapkt);
return 0;
}
struct seq_operations seq_controller_ops = {
start: controller_start,
next: controller_next,
stop: controller_stop,
show: controller_show,
};
struct seq_operations seq_contrstats_ops = {
start: controller_start,
next: controller_next,
stop: controller_stop,
show: contrstats_show,
};
static int seq_controller_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_controller_ops);
}
static int seq_contrstats_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_contrstats_ops);
}
static struct file_operations proc_controller_ops = {
open: seq_controller_open,
read: seq_read,
llseek: seq_lseek,
release: seq_release,
};
static struct file_operations proc_contrstats_ops = {
open: seq_contrstats_open,
read: seq_read,
llseek: seq_lseek,
release: seq_release,
};
// /proc/capi/applications:
// applid l3cnt dblkcnt dblklen #ncci recvqueuelen
// /proc/capi/applstats:
// applid nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt
// ---------------------------------------------------------------------------
static void *
applications_start(struct seq_file *seq, loff_t *pos)
{
if (*pos < CAPI_MAXAPPL)
return &capi_applications[*pos];
return NULL;
}
static void *
applications_next(struct seq_file *seq, void *v, loff_t *pos)
{
++*pos;
if (*pos < CAPI_MAXAPPL)
return &capi_applications[*pos];
return NULL;
}
static void
applications_stop(struct seq_file *seq, void *v)
{
}
static int
applications_show(struct seq_file *seq, void *v)
{
struct capi20_appl *ap = *(struct capi20_appl **) v;
if (!ap)
return 0;
seq_printf(seq, "%u %d %d %d\n",
ap->applid,
ap->rparam.level3cnt,
ap->rparam.datablkcnt,
ap->rparam.datablklen);
return 0;
}
static int
applstats_show(struct seq_file *seq, void *v)
{
struct capi20_appl *ap = *(struct capi20_appl **) v;
if (!ap)
return 0;
seq_printf(seq, "%u %lu %lu %lu %lu\n",
ap->applid,
ap->nrecvctlpkt,
ap->nrecvdatapkt,
ap->nsentctlpkt,
ap->nsentdatapkt);
return 0;
}
struct seq_operations seq_applications_ops = {
start: applications_start,
next: applications_next,
stop: applications_stop,
show: applications_show,
};
struct seq_operations seq_applstats_ops = {
start: applications_start,
next: applications_next,
stop: applications_stop,
show: applstats_show,
};
static int
seq_applications_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_applications_ops);
}
static int
seq_applstats_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_applstats_ops);
}
static struct file_operations proc_applications_ops = {
open: seq_applications_open,
read: seq_read,
llseek: seq_lseek,
release: seq_release,
};
static struct file_operations proc_applstats_ops = {
open: seq_applstats_open,
read: seq_read,
llseek: seq_lseek,
release: seq_release,
};
static void
create_seq_entry(char *name, mode_t mode, struct file_operations *f)
{
struct proc_dir_entry *entry;
entry = create_proc_entry(name, mode, NULL);
if (entry)
entry->proc_fops = f;
}
// ---------------------------------------------------------------------------
void __init
kcapi_proc_init(void)
{
proc_mkdir("capi", NULL);
proc_mkdir("capi/controllers", NULL);
proc_mkdir("capi/drivers", NULL);
create_seq_entry("capi/controller", 0, &proc_controller_ops);
create_seq_entry("capi/contrstats", 0, &proc_contrstats_ops);
create_seq_entry("capi/applications", 0, &proc_applications_ops);
create_seq_entry("capi/applstats", 0, &proc_applstats_ops);
}
void __exit
kcapi_proc_exit(void)
{
remove_proc_entry("capi/driver", NULL);
remove_proc_entry("capi/controller", NULL);
remove_proc_entry("capi/contrstats", NULL);
remove_proc_entry("capi/applications", NULL);
remove_proc_entry("capi/applstats", NULL);
remove_proc_entry("capi/drivers", NULL);
remove_proc_entry("capi/controllers", NULL);
remove_proc_entry("capi", NULL);
}
......@@ -11,6 +11,7 @@
#define _AVMCARD_H_
#include <linux/spinlock.h>
#include <linux/list.h>
#define AVMB1_PORTLEN 0x1f
#define AVM_MAXVERSION 8
......@@ -67,7 +68,7 @@ typedef struct avmctrl_info {
char infobuf[128]; /* for function procinfo */
struct avmcard *card;
struct capi_ctr *capi_ctrl;
struct capi_ctr capi_ctrl;
struct list_head ncci_head;
} avmctrl_info;
......@@ -93,7 +94,9 @@ typedef struct avmcard {
struct avmctrl_info *ctrlinfo;
int nr_controllers;
int nlogcontr;
struct list_head list;
} avmcard;
extern int b1_irq_table[16];
......@@ -537,7 +540,6 @@ static inline void b1_setinterrupt(unsigned int base, unsigned irq,
}
/* b1.c */
void b1_set_revision(struct capi_driver *driver, char *rev);
avmcard *b1_alloc_card(int nr_controllers);
void b1_free_card(avmcard *card);
int b1_detect(unsigned int base, enum avmcardtype cardtype);
......
......@@ -59,21 +59,6 @@ int b1_irq_table[16] =
/* ------------------------------------------------------------- */
void b1_set_revision(struct capi_driver *driver, char *rev)
{
char *p;
if ((p = strchr(rev, ':')) != 0 && p[1]) {
strncpy(driver->revision, p + 2, sizeof(driver->revision));
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
}
/* ------------------------------------------------------------- */
avmcard *b1_alloc_card(int nr_controllers)
{
avmcard *card;
......@@ -99,6 +84,7 @@ avmcard *b1_alloc_card(int nr_controllers)
cinfo[i].card = card;
}
spin_lock_init(&card->lock);
card->nr_controllers = nr_controllers;
return card;
}
......@@ -344,7 +330,7 @@ void b1_reset_ctr(struct capi_ctr *ctrl)
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
void b1_register_appl(struct capi_ctr *ctrl,
......@@ -433,7 +419,7 @@ u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
void b1_parse_version(avmctrl_info *cinfo)
{
struct capi_ctr *ctrl = cinfo->capi_ctrl;
struct capi_ctr *ctrl = &cinfo->capi_ctrl;
avmcard *card = cinfo->card;
capi_profile *profp;
u8 *dversion;
......@@ -509,7 +495,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
{
avmcard *card = devptr;
avmctrl_info *cinfo = &card->ctrlinfo[0];
struct capi_ctr *ctrl = cinfo->capi_ctrl;
struct capi_ctr *ctrl = &cinfo->capi_ctrl;
unsigned char b1cmd;
struct sk_buff *skb;
......@@ -543,7 +529,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -561,7 +547,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -587,11 +573,11 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
case RECEIVE_START:
/* b1_put_byte(card->port, SEND_POLLACK); */
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
break;
case RECEIVE_STOP:
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
break;
case RECEIVE_INIT:
......@@ -602,7 +588,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -774,7 +760,6 @@ EXPORT_SYMBOL(avmcard_dma_free);
EXPORT_SYMBOL(b1_irq_table);
EXPORT_SYMBOL(b1_set_revision);
EXPORT_SYMBOL(b1_alloc_card);
EXPORT_SYMBOL(b1_free_card);
EXPORT_SYMBOL(b1_detect);
......
......@@ -447,7 +447,7 @@ static void b1dma_handle_rx(avmcard *card)
{
avmctrl_info *cinfo = &card->ctrlinfo[0];
avmcard_dmainfo *dma = card->dma;
struct capi_ctr *ctrl = cinfo->capi_ctrl;
struct capi_ctr *ctrl = &cinfo->capi_ctrl;
struct sk_buff *skb;
void *p = dma->recvbuf.dmabuf+4;
u32 ApplId, MsgLen, DataB3Len, NCCI, WindowSize;
......@@ -475,7 +475,7 @@ static void b1dma_handle_rx(avmcard *card)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -493,7 +493,7 @@ static void b1dma_handle_rx(avmcard *card)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -523,11 +523,11 @@ static void b1dma_handle_rx(avmcard *card)
#endif
if (!suppress_pollack)
queue_pollack(card);
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
break;
case RECEIVE_STOP:
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
break;
case RECEIVE_INIT:
......@@ -538,7 +538,7 @@ static void b1dma_handle_rx(avmcard *card)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -740,7 +740,7 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl)
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
......
......@@ -25,8 +25,6 @@
#include <linux/isdn/capilli.h>
#include "avmcard.h"
static char *revision = "$Revision: 1.10.6.6 $";
/* ------------------------------------------------------------- */
MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM B1 ISA card");
......@@ -35,18 +33,20 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver b1isa_driver;
static void b1isa_remove(struct pci_dev *pdev)
{
avmctrl_info *cinfo = pci_get_drvdata(pdev);
avmcard *card = cinfo->card;
unsigned int port = cinfo->card->port;
avmcard *card;
if (!cinfo)
return;
b1_reset(port);
b1_reset(port);
card = cinfo->card;
detach_capi_ctr(cinfo->capi_ctrl);
b1_reset(card->port);
b1_reset(card->port);
detach_capi_ctr(&cinfo->capi_ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
......@@ -54,6 +54,8 @@ static void b1isa_remove(struct pci_dev *pdev)
/* ------------------------------------------------------------- */
static char *b1isa_procinfo(struct capi_ctr *ctrl);
static int __init b1isa_probe(struct pci_dev *pdev)
{
avmctrl_info *cinfo;
......@@ -106,16 +108,26 @@ static int __init b1isa_probe(struct pci_dev *pdev)
b1_reset(card->port);
b1_getrevision(card);
cinfo->capi_ctrl = attach_capi_ctr(&b1isa_driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
cinfo->capi_ctrl.driver_name = "b1isa";
cinfo->capi_ctrl.driverdata = cinfo;
cinfo->capi_ctrl.register_appl = b1_register_appl;
cinfo->capi_ctrl.release_appl = b1_release_appl;
cinfo->capi_ctrl.send_message = b1_send_message;
cinfo->capi_ctrl.load_firmware = b1_load_firmware;
cinfo->capi_ctrl.reset_ctr = b1_reset_ctr;
cinfo->capi_ctrl.procinfo = b1isa_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
printk(KERN_ERR "b1isa: attach controller failed.\n");
retval = -EBUSY;
goto err_free_irq;
}
printk(KERN_INFO
"%s: AVM B1 ISA at i/o %#x, irq %d, revision %d\n",
b1isa_driver.name, card->port, card->irq, card->revision);
printk(KERN_INFO "b1isa: AVM B1 ISA at i/o %#x, irq %d, revision %d\n",
card->port, card->irq, card->revision);
pci_set_drvdata(pdev, cinfo);
return 0;
......@@ -148,21 +160,6 @@ static char *b1isa_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1isa_driver = {
owner: THIS_MODULE,
name: "b1isa",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1isa_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
#define MAX_CARDS 4
static struct pci_dev isa_dev[MAX_CARDS];
static int io[MAX_CARDS];
......@@ -175,12 +172,9 @@ MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
static int __init b1isa_init(void)
{
int i, retval;
int i;
int found = 0;
b1_set_revision(&b1isa_driver, revision);
attach_capi_driver(&b1isa_driver);
for (i = 0; i < MAX_CARDS; i++) {
if (!io[i])
break;
......@@ -191,17 +185,10 @@ static int __init b1isa_init(void)
if (b1isa_probe(&isa_dev[i]) == 0)
found++;
}
if (found == 0) {
retval = -ENODEV;
goto err;
}
retval = 0;
goto out;
if (found == 0)
return -ENODEV;
err:
detach_capi_driver(&b1isa_driver);
out:
return retval;
return 0;
}
static void __exit b1isa_exit(void)
......@@ -214,7 +201,6 @@ static void __exit b1isa_exit(void)
b1isa_remove(&isa_dev[i]);
}
detach_capi_driver(&b1isa_driver);
}
module_init(b1isa_init);
......
This diff is collapsed.
......@@ -25,8 +25,6 @@
#include <linux/isdn/capilli.h>
#include "avmcard.h"
static char *revision = "$Revision: 1.12.6.5 $";
/* ------------------------------------------------------------- */
MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM PCMCIA cards");
......@@ -51,10 +49,12 @@ static void b1pcmcia_remove_ctr(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static int b1pcmcia_add_card(struct capi_driver *driver,
unsigned int port,
unsigned irq,
enum avmcardtype cardtype)
static LIST_HEAD(cards);
static char *b1pcmcia_procinfo(struct capi_ctr *ctrl);
static int b1pcmcia_add_card(unsigned int port, unsigned irq,
enum avmcardtype cardtype)
{
avmctrl_info *cinfo;
avmcard *card;
......@@ -63,7 +63,7 @@ static int b1pcmcia_add_card(struct capi_driver *driver,
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "b1pcmcia: no memory.\n");
retval = -ENOMEM;
goto err;
}
......@@ -80,26 +80,36 @@ static int b1pcmcia_add_card(struct capi_driver *driver,
retval = request_irq(card->irq, b1_interrupt, 0, card->name, card);
if (retval) {
printk(KERN_ERR "%s: unable to get IRQ %d.\n",
driver->name, card->irq);
printk(KERN_ERR "b1pcmcia: unable to get IRQ %d.\n",
card->irq);
retval = -EBUSY;
goto err_free;
}
b1_reset(card->port);
if ((retval = b1_detect(card->port, card->cardtype)) != 0) {
printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n",
driver->name, card->port, retval);
printk(KERN_NOTICE "b1pcmcia: NO card at 0x%x (%d)\n",
card->port, retval);
retval = -ENODEV;
goto err_free_irq;
}
b1_reset(card->port);
b1_getrevision(card);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n",
driver->name);
retval = -EBUSY;
cinfo->capi_ctrl.driver_name = "b1pcmcia";
cinfo->capi_ctrl.driverdata = cinfo;
cinfo->capi_ctrl.register_appl = b1_register_appl;
cinfo->capi_ctrl.release_appl = b1_release_appl;
cinfo->capi_ctrl.send_message = b1_send_message;
cinfo->capi_ctrl.load_firmware = b1_load_firmware;
cinfo->capi_ctrl.reset_ctr = b1_reset_ctr;
cinfo->capi_ctrl.procinfo = b1pcmcia_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
printk(KERN_ERR "b1pcmcia: attach controller failed.\n");
goto err_free_irq;
}
switch (cardtype) {
......@@ -108,11 +118,11 @@ static int b1pcmcia_add_card(struct capi_driver *driver,
default : cardname = "B1 PCMCIA"; break;
}
printk(KERN_INFO
"%s: AVM %s at i/o %#x, irq %d, revision %d\n",
driver->name, cardname, card->port, card->irq, card->revision);
printk(KERN_INFO "b1pcmcia: AVM %s at i/o %#x, irq %d, revision %d\n",
cardname, card->port, card->irq, card->revision);
return cinfo->capi_ctrl->cnr;
list_add(&card->list, &cards);
return cinfo->capi_ctrl.cnr;
err_free_irq:
free_irq(card->irq, card);
......@@ -142,49 +152,30 @@ static char *b1pcmcia_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1pcmcia_driver = {
owner: THIS_MODULE,
name: "b1pcmcia",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1pcmcia_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
/* ------------------------------------------------------------- */
int b1pcmcia_addcard_b1(unsigned int port, unsigned irq)
{
return b1pcmcia_add_card(&b1pcmcia_driver, port, irq, avm_b1pcmcia);
return b1pcmcia_add_card(port, irq, avm_b1pcmcia);
}
int b1pcmcia_addcard_m1(unsigned int port, unsigned irq)
{
return b1pcmcia_add_card(&b1pcmcia_driver, port, irq, avm_m1);
return b1pcmcia_add_card(port, irq, avm_m1);
}
int b1pcmcia_addcard_m2(unsigned int port, unsigned irq)
{
return b1pcmcia_add_card(&b1pcmcia_driver, port, irq, avm_m2);
return b1pcmcia_add_card(port, irq, avm_m2);
}
int b1pcmcia_delcard(unsigned int port, unsigned irq)
{
struct list_head *l;
struct capi_ctr *ctrl;
avmcard *card;
list_for_each(l, &b1pcmcia_driver.contr_head) {
ctrl = list_entry(l, struct capi_ctr, driver_list);
card = ((avmctrl_info *)(ctrl->driverdata))->card;
list_for_each(l, &cards) {
card = list_entry(l, avmcard, list);
if (card->port == port && card->irq == irq) {
b1pcmcia_remove_ctr(ctrl);
b1pcmcia_remove_ctr(&card->ctrlinfo[0].capi_ctrl);
return 0;
}
}
......@@ -195,21 +186,3 @@ EXPORT_SYMBOL(b1pcmcia_addcard_b1);
EXPORT_SYMBOL(b1pcmcia_addcard_m1);
EXPORT_SYMBOL(b1pcmcia_addcard_m2);
EXPORT_SYMBOL(b1pcmcia_delcard);
/* ------------------------------------------------------------- */
static int __init b1pcmcia_init(void)
{
b1_set_revision(&b1pcmcia_driver, revision);
attach_capi_driver(&b1pcmcia_driver);
return 0;
}
static void __exit b1pcmcia_exit(void)
{
detach_capi_driver(&b1pcmcia_driver);
}
module_init(b1pcmcia_init);
module_exit(b1pcmcia_exit);
This diff is collapsed.
......@@ -27,8 +27,6 @@
#include <linux/isdn/capilli.h>
#include "avmcard.h"
static char *revision = "$Revision: 1.16.6.7 $";
/* ------------------------------------------------------------- */
MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM T1 HEMA ISA card");
......@@ -37,8 +35,6 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver t1isa_driver;
static int hema_irq_table[16] =
{0,
0,
......@@ -132,7 +128,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
{
avmcard *card = devptr;
avmctrl_info *cinfo = &card->ctrlinfo[0];
struct capi_ctr *ctrl = cinfo->capi_ctrl;
struct capi_ctr *ctrl = &cinfo->capi_ctrl;
unsigned char b1cmd;
struct sk_buff *skb;
......@@ -165,7 +161,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -183,7 +179,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -209,11 +205,11 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
case RECEIVE_START:
b1_put_byte(card->port, SEND_POLLACK);
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
break;
case RECEIVE_STOP:
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
break;
case RECEIVE_INIT:
......@@ -224,7 +220,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -323,21 +319,25 @@ void t1isa_reset_ctr(struct capi_ctr *ctrl)
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
static void t1isa_remove(struct pci_dev *pdev)
{
avmctrl_info *cinfo = pci_get_drvdata(pdev);
avmcard *card = cinfo->card;
unsigned int port = card->port;
avmcard *card;
if (!cinfo)
return;
t1_disable_irq(port);
b1_reset(port);
b1_reset(port);
t1_reset(port);
card = cinfo->card;
detach_capi_ctr(cinfo->capi_ctrl);
t1_disable_irq(card->port);
b1_reset(card->port);
b1_reset(card->port);
t1_reset(card->port);
detach_capi_ctr(&cinfo->capi_ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
......@@ -345,6 +345,9 @@ static void t1isa_remove(struct pci_dev *pdev)
/* ------------------------------------------------------------- */
static u16 t1isa_send_message(struct capi_ctr *ctrl, struct sk_buff *skb);
static char *t1isa_procinfo(struct capi_ctr *ctrl);
static int __init t1isa_probe(struct pci_dev *pdev, int cardnr)
{
avmctrl_info *cinfo;
......@@ -353,7 +356,7 @@ static int __init t1isa_probe(struct pci_dev *pdev, int cardnr)
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", t1isa_driver.name);
printk(KERN_WARNING "t1isa: no memory.\n");
retval = -ENOMEM;
goto err;
}
......@@ -366,50 +369,57 @@ static int __init t1isa_probe(struct pci_dev *pdev, int cardnr)
sprintf(card->name, "t1isa-%x", card->port);
if (!(((card->port & 0x7) == 0) && ((card->port & 0x30) != 0x30))) {
printk(KERN_WARNING "%s: illegal port 0x%x.\n",
t1isa_driver.name, card->port);
printk(KERN_WARNING "t1isa: illegal port 0x%x.\n", card->port);
retval = -EINVAL;
goto err_free;
}
if (hema_irq_table[card->irq & 0xf] == 0) {
printk(KERN_WARNING "%s: irq %d not valid.\n",
t1isa_driver.name, card->irq);
printk(KERN_WARNING "t1isa: irq %d not valid.\n", card->irq);
retval = -EINVAL;
goto err_free;
}
if (!request_region(card->port, AVMB1_PORTLEN, card->name)) {
printk(KERN_INFO "%s: ports 0x%03x-0x%03x in use.\n",
t1isa_driver.name, card->port, card->port + AVMB1_PORTLEN);
printk(KERN_INFO "t1isa: ports 0x%03x-0x%03x in use.\n",
card->port, card->port + AVMB1_PORTLEN);
retval = -EBUSY;
goto err_free;
}
retval = request_irq(card->irq, t1isa_interrupt, 0, card->name, card);
if (retval) {
printk(KERN_INFO "%s: unable to get IRQ %d.\n",
t1isa_driver.name, card->irq);
printk(KERN_INFO "t1isa: unable to get IRQ %d.\n", card->irq);
retval = -EBUSY;
goto err_release_region;
}
if ((retval = t1_detectandinit(card->port, card->irq, card->cardnr)) != 0) {
printk(KERN_INFO "%s: NO card at 0x%x (%d)\n",
t1isa_driver.name, card->port, retval);
printk(KERN_INFO "t1isa: NO card at 0x%x (%d)\n",
card->port, retval);
retval = -ENODEV;
goto err_free_irq;
}
t1_disable_irq(card->port);
b1_reset(card->port);
cinfo->capi_ctrl = attach_capi_ctr(&t1isa_driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_INFO "%s: attach controller failed.\n",
t1isa_driver.name);
retval = -EBUSY;
cinfo->capi_ctrl.driver_name = "t1isa";
cinfo->capi_ctrl.driverdata = cinfo;
cinfo->capi_ctrl.register_appl = b1_register_appl;
cinfo->capi_ctrl.release_appl = b1_release_appl;
cinfo->capi_ctrl.send_message = t1isa_send_message;
cinfo->capi_ctrl.load_firmware = t1isa_load_firmware;
cinfo->capi_ctrl.reset_ctr = t1isa_reset_ctr;
cinfo->capi_ctrl.procinfo = t1isa_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
printk(KERN_INFO "t1isa: attach controller failed.\n");
goto err_free_irq;
}
printk(KERN_INFO "%s: AVM T1 ISA at i/o %#x, irq %d, card %d\n",
t1isa_driver.name, card->port, card->irq, card->cardnr);
printk(KERN_INFO "t1isa: AVM T1 ISA at i/o %#x, irq %d, card %d\n",
card->port, card->irq, card->cardnr);
pci_set_drvdata(pdev, cinfo);
return 0;
......@@ -485,21 +495,6 @@ static char *t1isa_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver t1isa_driver = {
owner: THIS_MODULE,
name: "t1isa",
revision: "0.0",
load_firmware: t1isa_load_firmware,
reset_ctr: t1isa_reset_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: t1isa_send_message,
procinfo: t1isa_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
#define MAX_CARDS 4
static struct pci_dev isa_dev[MAX_CARDS];
static int io[MAX_CARDS];
......@@ -515,12 +510,9 @@ MODULE_PARM_DESC(cardnr, "Card number(s) (as jumpered)");
static int __init t1isa_init(void)
{
int i, retval;
int i;
int found = 0;
b1_set_revision(&t1isa_driver, revision);
attach_capi_driver(&t1isa_driver);
for (i = 0; i < MAX_CARDS; i++) {
if (!io[i])
break;
......@@ -531,17 +523,10 @@ static int __init t1isa_init(void)
if (t1isa_probe(&isa_dev[i], cardnr[i]) == 0)
found++;
}
if (found == 0) {
retval = -ENODEV;
goto err;
}
retval = 0;
goto out;
if (found == 0)
return -ENODEV;
err:
detach_capi_driver(&t1isa_driver);
out:
return retval;
return 0;
}
static void __exit t1isa_exit(void)
......@@ -554,7 +539,6 @@ static void __exit t1isa_exit(void)
t1isa_remove(&isa_dev[i]);
}
detach_capi_driver(&t1isa_driver);
}
module_init(t1isa_init);
......
......@@ -26,8 +26,6 @@
#include <linux/isdn/capilli.h>
#include "avmcard.h"
static char *revision = "$Revision: 1.1.4.1.2.1 $";
#undef CONFIG_T1PCI_DEBUG
#undef CONFIG_T1PCI_POLLDEBUG
......@@ -45,9 +43,9 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static int t1pci_add_card(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *pdev)
static char *t1pci_procinfo(struct capi_ctr *ctrl);
static int t1pci_add_card(struct capicardparams *p, struct pci_dev *pdev)
{
avmcard *card;
avmctrl_info *cinfo;
......@@ -55,14 +53,14 @@ static int t1pci_add_card(struct capi_driver *driver,
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "t1pci: no memory.\n");
retval = -ENOMEM;
goto err;
}
card->dma = avmcard_dma_alloc(driver->name, pdev, 2048+128, 2048+128);
card->dma = avmcard_dma_alloc("t1pci", pdev, 2048+128, 2048+128);
if (!card->dma) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "t1pci: no memory.\n");
retval = -ENOMEM;
goto err_free;
}
......@@ -75,17 +73,16 @@ static int t1pci_add_card(struct capi_driver *driver,
card->cardtype = avm_t1pci;
if (!request_region(card->port, AVMB1_PORTLEN, card->name)) {
printk(KERN_WARNING
"%s: ports 0x%03x-0x%03x in use.\n",
driver->name, card->port, card->port + AVMB1_PORTLEN);
printk(KERN_WARNING "t1pci: ports 0x%03x-0x%03x in use.\n",
card->port, card->port + AVMB1_PORTLEN);
retval = -EBUSY;
goto err_free_dma;
}
card->mbase = ioremap_nocache(card->membase, 64);
if (!card->mbase) {
printk(KERN_NOTICE "%s: can't remap memory at 0x%lx\n",
driver->name, card->membase);
printk(KERN_NOTICE "t1pci: can't remap memory at 0x%lx\n",
card->membase);
retval = -EIO;
goto err_release_region;
}
......@@ -95,11 +92,11 @@ static int t1pci_add_card(struct capi_driver *driver,
retval = t1pci_detect(card);
if (retval != 0) {
if (retval < 6)
printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n",
driver->name, card->port, retval);
printk(KERN_NOTICE "t1pci: NO card at 0x%x (%d)\n",
card->port, retval);
else
printk(KERN_NOTICE "%s: card at 0x%x, but cabel not connected or T1 has no power (%d)\n",
driver->name, card->port, retval);
printk(KERN_NOTICE "t1pci: card at 0x%x, but cable not connected or T1 has no power (%d)\n",
card->port, retval);
retval = -EIO;
goto err_unmap;
}
......@@ -107,23 +104,33 @@ static int t1pci_add_card(struct capi_driver *driver,
retval = request_irq(card->irq, b1dma_interrupt, SA_SHIRQ, card->name, card);
if (retval) {
printk(KERN_ERR "%s: unable to get IRQ %d.\n",
driver->name, card->irq);
printk(KERN_ERR "t1pci: unable to get IRQ %d.\n", card->irq);
retval = -EBUSY;
goto err_unmap;
}
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n", driver->name);
cinfo->capi_ctrl.driver_name = "t1pci";
cinfo->capi_ctrl.driverdata = cinfo;
cinfo->capi_ctrl.register_appl = b1dma_register_appl;
cinfo->capi_ctrl.release_appl = b1dma_release_appl;
cinfo->capi_ctrl.send_message = b1dma_send_message;
cinfo->capi_ctrl.load_firmware = b1dma_load_firmware;
cinfo->capi_ctrl.reset_ctr = b1dma_reset_ctr;
cinfo->capi_ctrl.procinfo = t1pci_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1dmactl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
printk(KERN_ERR "t1pci: attach controller failed.\n");
retval = -EBUSY;
goto err_free_irq;
}
card->cardnr = cinfo->capi_ctrl->cnr;
card->cardnr = cinfo->capi_ctrl.cnr;
printk(KERN_INFO
"%s: AVM T1 PCI at i/o %#x, irq %d, mem %#lx\n",
driver->name, card->port, card->irq, card->membase);
printk(KERN_INFO "t1pci: AVM T1 PCI at i/o %#x, irq %d, mem %#lx\n",
card->port, card->irq, card->membase);
pci_set_drvdata(pdev, card);
return 0;
......@@ -151,7 +158,7 @@ static void t1pci_remove(struct pci_dev *pdev)
b1dma_reset(card);
detach_capi_ctr(cinfo->capi_ctrl);
detach_capi_ctr(&cinfo->capi_ctrl);
free_irq(card->irq, card);
iounmap(card->mbase);
release_region(card->port, AVMB1_PORTLEN);
......@@ -179,33 +186,14 @@ static char *t1pci_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver t1pci_driver = {
owner: THIS_MODULE,
name: "t1pci",
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
procinfo: t1pci_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
/* ------------------------------------------------------------- */
static int __devinit t1pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
struct capi_driver *driver = &t1pci_driver;
struct capicardparams param;
int retval;
if (pci_enable_device(dev) < 0) {
printk(KERN_ERR "%s: failed to enable AVM-T1-PCI\n",
driver->name);
printk(KERN_ERR "t1pci: failed to enable AVM-T1-PCI\n");
return -ENODEV;
}
pci_set_master(dev);
......@@ -214,15 +202,13 @@ static int __devinit t1pci_probe(struct pci_dev *dev,
param.irq = dev->irq;
param.membase = pci_resource_start(dev, 0);
printk(KERN_INFO
"%s: PCI BIOS reports AVM-T1-PCI at i/o %#x, irq %d, mem %#x\n",
driver->name, param.port, param.irq, param.membase);
printk(KERN_INFO "t1pci: PCI BIOS reports AVM-T1-PCI at i/o %#x, irq %d, mem %#x\n",
param.port, param.irq, param.membase);
retval = t1pci_add_card(driver, &param, dev);
retval = t1pci_add_card(&param, dev);
if (retval != 0) {
printk(KERN_ERR
"%s: no AVM-T1-PCI at i/o %#x, irq %d detected, mem %#x\n",
driver->name, param.port, param.irq, param.membase);
printk(KERN_ERR "t1pci: no AVM-T1-PCI at i/o %#x, irq %d detected, mem %#x\n",
param.port, param.irq, param.membase);
return -ENODEV;
}
return 0;
......@@ -237,30 +223,12 @@ static struct pci_driver t1pci_pci_driver = {
static int __init t1pci_init(void)
{
int retval;
b1_set_revision(&t1pci_driver, revision);
attach_capi_driver(&t1pci_driver);
retval = pci_register_driver(&t1pci_pci_driver);
if (retval < 0)
goto err;
printk(KERN_INFO "%s: %d T1-PCI card(s) detected\n",
t1pci_driver.name, retval);
retval = 0;
goto out;
err:
detach_capi_driver(&t1pci_driver);
out:
return retval;
return pci_module_init(&t1pci_pci_driver);
}
static void __exit t1pci_exit(void)
{
pci_unregister_driver(&t1pci_pci_driver);
detach_capi_driver(&t1pci_driver);
}
module_init(t1pci_init);
......
......@@ -53,8 +53,6 @@ static inline int _hycapi_appCheck(int app_id, int ctrl_no)
return ((hycapi_applications[app_id-1].ctrl_mask & (1 << (ctrl_no-1))) != 0);
}
struct capi_driver_interface *hy_di = NULL;
/******************************
Kernel-Capi callback reset_ctr
******************************/
......@@ -68,7 +66,7 @@ hycapi_reset_ctr(struct capi_ctr *ctrl)
printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n");
#endif
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
/******************************
......@@ -94,7 +92,7 @@ hycapi_remove_ctr(struct capi_ctr *ctrl)
return;
}
card = cinfo->card;
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
for(i=0; i<CAPI_MAXAPPL;i++) {
if(hycapi_applications[i].listen_req[ctrl->cnr-1]) {
kfree_skb(hycapi_applications[i].listen_req[ctrl->cnr-1]);
......@@ -133,7 +131,7 @@ hycapi_sendmsg_internal(struct capi_ctr *ctrl, struct sk_buff *skb)
/* inform upper layers we're full */
printk(KERN_ERR "HYSDN Card%d: CAPI-buffer overrun!\n",
card->myid);
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
}
cinfo->tx_skb = skb;
spin_unlock_irq(&cinfo->lock);
......@@ -334,7 +332,7 @@ int hycapi_capi_release(hysdn_card *card)
printk(KERN_NOTICE "hycapi_capi_release\n");
#endif
if(cinfo) {
ctrl = cinfo->capi_ctrl;
ctrl = &cinfo->capi_ctrl;
hycapi_remove_ctr(ctrl);
}
return 0;
......@@ -354,14 +352,9 @@ int hycapi_capi_stop(hysdn_card *card)
printk(KERN_NOTICE "hycapi_capi_stop\n");
#endif
if(cinfo) {
if(cinfo->capi_ctrl) {
ctrl = cinfo->capi_ctrl;
/* ctrl->suspend_output(ctrl); */
ctrl->reseted(ctrl);
} else {
printk(KERN_NOTICE "hycapi_capi_stop: cinfo but no capi_ctrl\n");
}
ctrl = &cinfo->capi_ctrl;
/* ctrl->suspend_output(ctrl); */
capi_ctr_reseted(ctrl);
}
return 0;
}
......@@ -552,11 +545,7 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
if(!cinfo) {
return;
}
ctrl = cinfo->capi_ctrl;
if(!ctrl)
{
return;
}
ctrl = &cinfo->capi_ctrl;
if(len < CAPI_MSG_BASELEN) {
printk(KERN_ERR "HYSDN Card%d: invalid CAPI-message, lenght %d!\n",
card->myid, len);
......@@ -635,7 +624,7 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
default:
break;
}
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
/******************************************************************
......@@ -662,7 +651,7 @@ void hycapi_tx_capiack(hysdn_card * card)
cinfo->out_idx = 0; /* wrap around */
if (cinfo->sk_count-- == HYSDN_MAX_CAPI_SKB) /* dec usage count */
cinfo->capi_ctrl->resume_output(cinfo->capi_ctrl);
capi_ctr_resume_output(&cinfo->capi_ctrl);
spin_unlock_irq(&cinfo->lock);
}
......@@ -687,22 +676,6 @@ hycapi_tx_capiget(hysdn_card *card)
}
static struct capi_driver hycapi_driver = {
owner: THIS_MODULE,
name: "hysdn",
revision: "0.0",
load_firmware: hycapi_load_firmware,
reset_ctr: hycapi_reset_ctr,
register_appl: hycapi_register_appl,
release_appl: hycapi_release_appl,
send_message: hycapi_send_message,
procinfo: hycapi_procinfo,
ctr_read_proc: hycapi_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
/**********************************************************
int hycapi_init()
......@@ -712,16 +685,11 @@ attach the capi-driver to the kernel-capi.
int hycapi_init()
{
struct capi_driver *driver;
int i;
if(hy_di) {
printk(KERN_NOTICE "HyDI allready set\n");
return 0;
}
driver = &hycapi_driver;
printk(KERN_NOTICE "HYSDN: Attaching capi-driver\n");
attach_capi_driver(driver);
for(i=0;i<CAPI_MAXAPPL;i++) {
memset(&(hycapi_applications[i]), 0, sizeof(hycapi_appl));
}
......@@ -738,16 +706,6 @@ free some more ressources. Do that later.
void
hycapi_cleanup(void)
{
struct capi_driver *driver;
driver = &hycapi_driver;
if (!hy_di) {
printk(KERN_ERR "HYSDN: no capi-driver to detach (?)\n");
return;
}
printk(KERN_NOTICE "HYSDN: Detaching capi-driver\n");
detach_capi_driver(driver);
hy_di = 0;
return;
}
/********************************************************************
......@@ -762,8 +720,7 @@ static void hycapi_fill_profile(hysdn_card *card)
struct capi_ctr *ctrl = NULL;
cinfo = card->hyctrlinfo;
if(!cinfo) return;
ctrl = cinfo->capi_ctrl;
if(!ctrl) return;
ctrl = &cinfo->capi_ctrl;
strcpy(ctrl->manu, "Hypercope");
ctrl->version.majorversion = 2;
ctrl->version.minorversion = 0;
......@@ -791,6 +748,7 @@ hycapi_capi_create(hysdn_card *card)
{
hycapictrl_info *cinfo = NULL;
struct capi_ctr *ctrl = NULL;
int retval;
#ifdef HYCAPI_PRINTFNAMES
printk(KERN_NOTICE "hycapi_capi_create\n");
#endif
......@@ -818,28 +776,34 @@ hycapi_capi_create(hysdn_card *card)
default: strcpy(cinfo->cardname,"HYSDN ???"); break;
}
cinfo->capi_ctrl = attach_capi_ctr(&hycapi_driver,
cinfo->cardname, cinfo);
ctrl = cinfo->capi_ctrl;
if (!ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n",
hycapi_driver.name);
ctrl = &cinfo->capi_ctrl;
ctrl->driver_name = "hycapi";
ctrl->driverdata = cinfo;
ctrl->register_appl = hycapi_register_appl;
ctrl->release_appl = hycapi_release_appl;
ctrl->send_message = hycapi_send_message;
ctrl->load_firmware = hycapi_load_firmware;
ctrl->reset_ctr = hycapi_reset_ctr;
ctrl->procinfo = hycapi_procinfo;
ctrl->ctr_read_proc = hycapi_read_proc;
strcpy(ctrl->name, cinfo->cardname);
SET_MODULE_OWNER(ctrl);
retval = attach_capi_ctr(ctrl);
if (retval) {
printk(KERN_ERR "hycapi: attach controller failed.\n");
return -EBUSY;
}
/* fill in the blanks: */
hycapi_fill_profile(card);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
} else {
/* resume output on stopped ctrl */
ctrl = card->hyctrlinfo->capi_ctrl;
if(ctrl) {
hycapi_fill_profile(card);
ctrl->ready(ctrl);
hycapi_restart_internal(ctrl);
/* ctrl->resume_output(ctrl); */
} else {
printk(KERN_WARNING "HYSDN: No ctrl???? How come?\n");
}
ctrl = &card->hyctrlinfo->capi_ctrl;
hycapi_fill_profile(card);
capi_ctr_ready(ctrl);
hycapi_restart_internal(ctrl);
/* ctrl->resume_output(ctrl); */
}
return 0;
}
......@@ -208,7 +208,7 @@ typedef struct HYSDN_CARD {
char infobuf[128]; /* for function procinfo */
struct HYSDN_CARD *card;
struct capi_ctr *capi_ctrl;
struct capi_ctr capi_ctrl;
struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB];
int in_idx, out_idx; /* indexes to buffer ring */
int sk_count; /* number of buffers currently in ring */
......
......@@ -36,32 +36,28 @@ typedef struct capicardparams {
unsigned int membase;
} capicardparams;
struct capi_driver;
struct capi_ctr {
struct list_head driver_list; /* contrs by driver */
struct capi_driver *driver;
int cnr; /* controller number */
char name[32]; /* name of controller */
volatile unsigned short cardstate; /* controller state */
volatile int blocked; /* output blocked */
int traceflag; /* capi trace */
/* filled in before calling attach_capi_ctr */
struct module *owner;
void *driverdata; /* driver specific */
char name[32]; /* name of controller */
char *driver_name; /* name of driver */
int (*load_firmware)(struct capi_ctr *, capiloaddata *);
void (*reset_ctr)(struct capi_ctr *);
void (*register_appl)(struct capi_ctr *, u16 appl,
capi_register_params *);
void (*release_appl)(struct capi_ctr *, u16 appl);
u16 (*send_message)(struct capi_ctr *, struct sk_buff *skb);
char *(*procinfo)(struct capi_ctr *);
int (*ctr_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_ctr *card);
/* filled before calling ready callback */
__u8 manu[CAPI_MANUFACTURER_LEN]; /* CAPI_GET_MANUFACTURER */
/* filled in before calling ready callback */
u8 manu[CAPI_MANUFACTURER_LEN]; /* CAPI_GET_MANUFACTURER */
capi_version version; /* CAPI_GET_VERSION */
capi_profile profile; /* CAPI_GET_PROFILE */
__u8 serial[CAPI_SERIAL_LEN]; /* CAPI_GET_SERIAL */
/* functions */
void (*ready)(struct capi_ctr * card);
void (*reseted)(struct capi_ctr * card);
void (*suspend_output)(struct capi_ctr * card);
void (*resume_output)(struct capi_ctr * card);
void (*handle_capimsg)(struct capi_ctr * card,
__u16 appl, struct sk_buff *skb);
u8 serial[CAPI_SERIAL_LEN]; /* CAPI_GET_SERIAL */
/* management information for kcapi */
......@@ -70,42 +66,23 @@ struct capi_ctr {
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
struct proc_dir_entry *procent;
char procfn[128];
};
int cnr; /* controller number */
volatile unsigned short cardstate; /* controller state */
volatile int blocked; /* output blocked */
int traceflag; /* capi trace */
struct capi_driver {
struct module *owner;
char name[32]; /* driver name */
char revision[32];
int (*load_firmware)(struct capi_ctr *, capiloaddata *);
void (*reset_ctr)(struct capi_ctr *);
void (*register_appl)(struct capi_ctr *, __u16 appl,
capi_register_params *);
void (*release_appl)(struct capi_ctr *, __u16 appl);
u16 (*send_message)(struct capi_ctr *, struct sk_buff *skb);
char *(*procinfo)(struct capi_ctr *);
int (*ctr_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_ctr *card);
int (*driver_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_driver *driver);
/* intitialized by kcapi */
struct list_head contr_head; /* list of controllers */
struct list_head driver_list;
int ncontroller;
struct proc_dir_entry *procent;
char procfn[128];
char procfn[128];
};
void attach_capi_driver(struct capi_driver *driver);
void detach_capi_driver(struct capi_driver *driver);
struct capi_ctr *attach_capi_ctr(struct capi_driver *driver, char *name, void *data);
int attach_capi_ctr(struct capi_ctr *);
int detach_capi_ctr(struct capi_ctr *);
void capi_ctr_ready(struct capi_ctr * card);
void capi_ctr_reseted(struct capi_ctr * card);
void capi_ctr_suspend_output(struct capi_ctr * card);
void capi_ctr_resume_output(struct capi_ctr * card);
void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb);
// ---------------------------------------------------------------------------
// library functions for use by hardware controller drivers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment