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.
......
......@@ -3,25 +3,22 @@
* 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.
*
*/
#define DBG(format, arg...) do { \
printk(KERN_DEBUG __FUNCTION__ ": " format "\n" , ## arg); \
} while (0)
#define CONFIG_AVMB1_COMPAT
#include <linux/config.h>
#include "kcapi.h"
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/tqueue.h>
#include <linux/capi.h>
......@@ -30,7 +27,6 @@ printk(KERN_DEBUG __FUNCTION__ ": " format "\n" , ## arg); \
#include <asm/uaccess.h>
#include <linux/isdn/capicmd.h>
#include <linux/isdn/capiutil.h>
#include <linux/isdn/capilli.h>
#ifdef CONFIG_AVMB1_COMPAT
#include <linux/b1lli.h>
#endif
......@@ -39,12 +35,6 @@ static char *revision = "$Revision: 1.21.6.8 $";
/* ------------------------------------------------------------- */
#define CARD_DETECTED 1
#define CARD_LOADING 2
#define CARD_RUNNING 3
/* ------------------------------------------------------------- */
static int showcapimsgs = 0;
MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer");
......@@ -70,14 +60,15 @@ static char capi_manufakturer[64] = "AVM Berlin";
#define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f)
static struct capi20_appl *applications[CAPI_MAXAPPL];
static struct capi_ctr *cards[CAPI_MAXCONTR];
LIST_HEAD(capi_drivers);
spinlock_t capi_drivers_lock = SPIN_LOCK_UNLOCKED;
struct capi20_appl *capi_applications[CAPI_MAXAPPL];
struct capi_ctr *capi_cards[CAPI_MAXCONTR];
static int ncards;
static struct sk_buff_head recv_queue;
static LIST_HEAD(drivers);
static spinlock_t drivers_lock = SPIN_LOCK_UNLOCKED;
static struct tq_struct tq_state_notify;
static struct tq_struct tq_recv_notify;
......@@ -86,8 +77,8 @@ static struct tq_struct tq_recv_notify;
static inline struct capi_ctr *
capi_ctr_get(struct capi_ctr *card)
{
if (card->driver->owner) {
if (try_inc_mod_count(card->driver->owner)) {
if (card->owner) {
if (try_inc_mod_count(card->owner)) {
DBG("MOD_COUNT INC");
return card;
} else
......@@ -100,8 +91,8 @@ capi_ctr_get(struct capi_ctr *card)
static inline void
capi_ctr_put(struct capi_ctr *card)
{
if (card->driver->owner)
__MOD_DEC_USE_COUNT(card->driver->owner);
if (card->owner)
__MOD_DEC_USE_COUNT(card->owner);
DBG("MOD_COUNT DEC");
}
......@@ -112,7 +103,7 @@ static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
if (contr - 1 >= CAPI_MAXCONTR)
return NULL;
return cards[contr - 1];
return capi_cards[contr - 1];
}
static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
......@@ -120,21 +111,11 @@ static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
if (applid - 1 >= CAPI_MAXAPPL)
return NULL;
return applications[applid - 1];
return capi_applications[applid - 1];
}
/* -------- util functions ------------------------------------ */
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 "???";
}
}
static inline int capi_cmd_valid(u8 cmd)
{
switch (cmd) {
......@@ -170,244 +151,13 @@ static inline int capi_subcmd_valid(u8 subcmd)
return 0;
}
/* -------- /proc functions ----------------------------------- */
/*
* /proc/capi/applications:
* applid l3cnt dblkcnt dblklen #ncci recvqueuelen
*/
static int proc_applications_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capi20_appl *ap;
int i;
int len = 0;
for (i=1; i <= CAPI_MAXAPPL; i++) {
ap = get_capi_appl_by_nr(i);
if (!ap) continue;
len += sprintf(page+len, "%u %d %d %d\n",
ap->applid,
ap->rparam.level3cnt,
ap->rparam.datablkcnt,
ap->rparam.datablklen);
if (len <= off) {
off -= len;
len = 0;
} else {
if (len-off > count)
goto endloop;
}
}
endloop:
*start = page+off;
if (len < count)
*eof = 1;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
/*
* /proc/capi/driver:
* driver ncontroller
*/
static int proc_driver_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct list_head *l;
struct capi_driver *driver;
int len = 0;
spin_lock(&drivers_lock);
list_for_each(l, &drivers) {
driver = list_entry(l, struct capi_driver, driver_list);
len += sprintf(page+len, "%-32s %d %s\n",
driver->name,
driver->ncontroller,
driver->revision);
if (len <= off) {
off -= len;
len = 0;
} else {
if (len-off > count)
goto endloop;
}
}
endloop:
spin_unlock(&drivers_lock);
*start = page+off;
if (len < count)
*eof = 1;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
/*
* /proc/capi/controller:
* cnr driver cardstate name driverinfo
*/
static int proc_controller_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capi_ctr *cp;
int i;
int len = 0;
for (i=0; i < CAPI_MAXCONTR; i++) {
cp = cards[i];
if (!cp)
continue;
len += sprintf(page+len, "%d %-10s %-8s %-16s %s\n",
cp->cnr, cp->driver->name,
cardstate2str(cp->cardstate),
cp->name,
cp->driver->procinfo ? cp->driver->procinfo(cp) : ""
);
if (len <= off) {
off -= len;
len = 0;
} else {
if (len-off > count)
goto endloop;
}
}
endloop:
*start = page+off;
if (len < count)
*eof = 1;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
/*
* /proc/capi/applstats:
* applid nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt
*/
static int proc_applstats_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capi20_appl *ap;
int i;
int len = 0;
for (i=1; i <= CAPI_MAXAPPL; i++) {
ap = get_capi_appl_by_nr(i);
if (!ap) continue;
len += sprintf(page+len, "%u %lu %lu %lu %lu\n",
ap->applid,
ap->nrecvctlpkt,
ap->nrecvdatapkt,
ap->nsentctlpkt,
ap->nsentdatapkt);
if (len <= off) {
off -= len;
len = 0;
} else {
if (len-off > count)
goto endloop;
}
}
endloop:
*start = page+off;
if (len < count)
*eof = 1;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
/*
* /proc/capi/contrstats:
* cnr nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt
*/
static int proc_contrstats_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capi_ctr *cp;
int i;
int len = 0;
for (i=0; i < CAPI_MAXCONTR; i++) {
cp = cards[i];
if (!cp)
continue;
len += sprintf(page+len, "%d %lu %lu %lu %lu\n",
cp->cnr,
cp->nrecvctlpkt,
cp->nrecvdatapkt,
cp->nsentctlpkt,
cp->nsentdatapkt);
if (len <= off) {
off -= len;
len = 0;
} else {
if (len-off > count)
goto endloop;
}
}
endloop:
*start = page+off;
if (len < count)
*eof = 1;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
static struct procfsentries {
char *name;
mode_t mode;
int (*read_proc)(char *page, char **start, off_t off,
int count, int *eof, void *data);
struct proc_dir_entry *procent;
} procfsentries[] = {
{ "capi", S_IFDIR, 0 },
{ "capi/applications", 0 , proc_applications_read_proc },
{ "capi/driver", 0 , proc_driver_read_proc },
{ "capi/controller", 0 , proc_controller_read_proc },
{ "capi/applstats", 0 , proc_applstats_read_proc },
{ "capi/contrstats", 0 , proc_contrstats_read_proc },
{ "capi/drivers", S_IFDIR, 0 },
{ "capi/controllers", S_IFDIR, 0 },
};
static void proc_capi_init(void)
{
int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]);
int i;
for (i=0; i < nelem; i++) {
struct procfsentries *p = procfsentries + i;
p->procent = create_proc_entry(p->name, p->mode, 0);
if (p->procent) p->procent->read_proc = p->read_proc;
}
}
static void proc_capi_exit(void)
{
int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]);
int i;
for (i=nelem-1; i >= 0; i--) {
struct procfsentries *p = procfsentries + i;
if (p->procent) {
remove_proc_entry(p->name, 0);
p->procent = 0;
}
}
}
/* ------------------------------------------------------------ */
static void register_appl(struct capi_ctr *card, u16 applid, capi_register_params *rparam)
{
card = capi_ctr_get(card);
card->driver->register_appl(card, applid, rparam);
card->register_appl(card, applid, rparam);
}
......@@ -415,7 +165,7 @@ static void release_appl(struct capi_ctr *card, u16 applid)
{
DBG("applid %#x", applid);
card->driver->release_appl(card, applid);
card->release_appl(card, applid);
capi_ctr_put(card);
}
......@@ -574,8 +324,7 @@ static void recv_handler(void *dummy)
}
}
static void controllercb_handle_capimsg(struct capi_ctr * card,
u16 appl, struct sk_buff *skb)
void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb)
{
int showctl = 0;
u8 cmd, subcmd;
......@@ -618,7 +367,9 @@ static void controllercb_handle_capimsg(struct capi_ctr * card,
kfree_skb(skb);
}
static void controllercb_ready(struct capi_ctr * card)
EXPORT_SYMBOL(capi_ctr_handle_message);
void capi_ctr_ready(struct capi_ctr * card)
{
u16 appl;
struct capi20_appl *ap;
......@@ -637,7 +388,9 @@ static void controllercb_ready(struct capi_ctr * card)
notify_push(KCI_CONTRUP, card->cnr, 0, 0);
}
static void controllercb_reseted(struct capi_ctr * card)
EXPORT_SYMBOL(capi_ctr_ready);
void capi_ctr_reseted(struct capi_ctr * card)
{
u16 appl;
......@@ -666,7 +419,9 @@ static void controllercb_reseted(struct capi_ctr * card)
notify_push(KCI_CONTRDOWN, card->cnr, 0, 0);
}
static void controllercb_suspend_output(struct capi_ctr *card)
EXPORT_SYMBOL(capi_ctr_reseted);
void capi_ctr_suspend_output(struct capi_ctr *card)
{
if (!card->blocked) {
printk(KERN_DEBUG "kcapi: card %d suspend\n", card->cnr);
......@@ -674,7 +429,9 @@ static void controllercb_suspend_output(struct capi_ctr *card)
}
}
static void controllercb_resume_output(struct capi_ctr *card)
EXPORT_SYMBOL(capi_ctr_suspend_output);
void capi_ctr_resume_output(struct capi_ctr *card)
{
if (card->blocked) {
printk(KERN_DEBUG "kcapi: card %d resume\n", card->cnr);
......@@ -682,149 +439,71 @@ static void controllercb_resume_output(struct capi_ctr *card)
}
}
/* ------------------------------------------------------------- */
EXPORT_SYMBOL(capi_ctr_resume_output);
/* ------------------------------------------------------------- */
struct capi_ctr *
attach_capi_ctr(struct capi_driver *driver, char *name, void *driverdata)
int
attach_capi_ctr(struct capi_ctr *card)
{
struct capi_ctr *card;
int i;
for (i=0; i < CAPI_MAXCONTR; i++) {
if (cards[i] == NULL)
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (capi_cards[i] == NULL)
break;
}
if (i == CAPI_MAXCONTR) {
printk(KERN_ERR "kcapi: out of controller slots\n");
return NULL;
return -EBUSY;
}
card = kmalloc(sizeof(*card), GFP_KERNEL);
if (!card)
return NULL;
capi_cards[i] = card;
cards[i] = card;
memset(card, 0, sizeof(struct capi_ctr));
card->driver = driver;
card->nrecvctlpkt = 0;
card->nrecvdatapkt = 0;
card->nsentctlpkt = 0;
card->nsentdatapkt = 0;
card->cnr = i + 1;
strncpy(card->name, name, sizeof(card->name));
card->cardstate = CARD_DETECTED;
card->blocked = 0;
card->driverdata = driverdata;
card->traceflag = showcapimsgs;
card->ready = controllercb_ready;
card->reseted = controllercb_reseted;
card->suspend_output = controllercb_suspend_output;
card->resume_output = controllercb_resume_output;
card->handle_capimsg = controllercb_handle_capimsg;
list_add_tail(&card->driver_list, &driver->contr_head);
driver->ncontroller++;
sprintf(card->procfn, "capi/controllers/%d", card->cnr);
card->procent = create_proc_entry(card->procfn, 0, 0);
if (card->procent) {
card->procent->read_proc =
(int (*)(char *,char **,off_t,int,int *,void *))
driver->ctr_read_proc;
card->ctr_read_proc;
card->procent->data = card;
}
ncards++;
printk(KERN_NOTICE "kcapi: Controller %d: %s attached\n",
card->cnr, card->name);
return card;
return 0;
}
EXPORT_SYMBOL(attach_capi_ctr);
int detach_capi_ctr(struct capi_ctr *card)
{
struct capi_driver *driver = card->driver;
if (card->cardstate != CARD_DETECTED)
controllercb_reseted(card);
capi_ctr_reseted(card);
list_del(&card->driver_list);
driver->ncontroller--;
ncards--;
if (card->procent) {
remove_proc_entry(card->procfn, 0);
card->procent = 0;
}
cards[card->cnr - 1] = NULL;
capi_cards[card->cnr - 1] = NULL;
printk(KERN_NOTICE "kcapi: Controller %d: %s unregistered\n",
card->cnr, card->name);
kfree(card);
return 0;
}
EXPORT_SYMBOL(detach_capi_ctr);
/* ------------------------------------------------------------- */
/* fallback if no driver read_proc function defined by driver */
static int driver_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capi_driver *driver = (struct capi_driver *)data;
int len = 0;
len += sprintf(page+len, "%-16s %s\n", "name", driver->name);
len += sprintf(page+len, "%-16s %s\n", "revision", driver->revision);
if (len < off)
return 0;
*eof = 1;
*start = page + off;
return ((count < len-off) ? count : len-off);
}
/* ------------------------------------------------------------- */
void attach_capi_driver(struct capi_driver *driver)
{
INIT_LIST_HEAD(&driver->contr_head);
spin_lock(&drivers_lock);
list_add_tail(&driver->driver_list, &drivers);
spin_unlock(&drivers_lock);
printk(KERN_NOTICE "kcapi: driver %s attached\n", driver->name);
sprintf(driver->procfn, "capi/drivers/%s", driver->name);
driver->procent = create_proc_entry(driver->procfn, 0, 0);
if (driver->procent) {
if (driver->driver_read_proc) {
driver->procent->read_proc =
(int (*)(char *,char **,off_t,int,int *,void *))
driver->driver_read_proc;
} else {
driver->procent->read_proc = driver_read_proc;
}
driver->procent->data = driver;
}
}
EXPORT_SYMBOL(attach_capi_driver);
void detach_capi_driver(struct capi_driver *driver)
{
spin_lock(&drivers_lock);
list_del(&driver->driver_list);
spin_unlock(&drivers_lock);
printk(KERN_NOTICE "kcapi: driver %s detached\n", driver->name);
if (driver->procent) {
remove_proc_entry(driver->procfn, 0);
driver->procent = 0;
}
}
EXPORT_SYMBOL(detach_capi_driver);
/* ------------------------------------------------------------- */
/* -------- CAPI2.0 Interface ---------------------------------- */
/* ------------------------------------------------------------- */
......@@ -833,7 +512,7 @@ u16 capi20_isinstalled(void)
{
int i;
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (cards[i] && cards[i]->cardstate == CARD_RUNNING)
if (capi_cards[i] && capi_cards[i]->cardstate == CARD_RUNNING)
return CAPI_NOERROR;
}
return CAPI_REGNOTINSTALLED;
......@@ -852,14 +531,14 @@ u16 capi20_register(struct capi20_appl *ap)
return CAPI_LOGBLKSIZETOSMALL;
for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
if (applications[applid - 1] == NULL)
if (capi_applications[applid - 1] == NULL)
break;
}
if (applid > CAPI_MAXAPPL)
return CAPI_TOOMANYAPPLS;
ap->applid = applid;
applications[applid - 1] = ap;
capi_applications[applid - 1] = ap;
ap->nrecvctlpkt = 0;
ap->nrecvdatapkt = 0;
......@@ -868,9 +547,9 @@ u16 capi20_register(struct capi20_appl *ap)
ap->callback = 0;
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (!cards[i] || cards[i]->cardstate != CARD_RUNNING)
if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING)
continue;
register_appl(cards[i], applid, &ap->rparam);
register_appl(capi_cards[i], applid, &ap->rparam);
}
printk(KERN_DEBUG "kcapi: appl %d up\n", applid);
......@@ -886,11 +565,11 @@ u16 capi20_release(struct capi20_appl *ap)
DBG("applid %#x", ap->applid);
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (!cards[i] || cards[i]->cardstate != CARD_RUNNING)
if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING)
continue;
release_appl(cards[i], ap->applid);
release_appl(capi_cards[i], ap->applid);
}
applications[ap->applid - 1] = NULL;
capi_applications[ap->applid - 1] = NULL;
printk(KERN_DEBUG "kcapi: appl %d down\n", ap->applid);
return CAPI_NOERROR;
......@@ -950,7 +629,7 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)
}
}
return card->driver->send_message(card, skb);
return card->send_message(card, skb);
}
EXPORT_SYMBOL(capi20_put_message);
......@@ -1028,28 +707,11 @@ u16 capi20_get_profile(u32 contr, struct capi_profile *profp)
EXPORT_SYMBOL(capi20_get_profile);
static struct capi_driver *find_driver(char *name)
{
struct list_head *l;
struct capi_driver *dp;
spin_lock(&drivers_lock);
list_for_each(l, &drivers) {
dp = list_entry(l, struct capi_driver, driver_list);
if (strcmp(dp->name, name) == 0)
goto found;
}
dp = NULL;
found:
spin_unlock(&drivers_lock);
return dp;
}
#ifdef CONFIG_AVMB1_COMPAT
static int old_capi_manufacturer(unsigned int cmd, void *data)
{
avmb1_loadandconfigdef ldef;
avmb1_resetdef rdef;
avmb1_getdef gdef;
struct capi_ctr *card;
capiloaddata ldata;
int retval;
......@@ -1073,8 +735,8 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
card = capi_ctr_get(card);
if (!card)
return -ESRCH;
if (card->driver->load_firmware == 0) {
printk(KERN_DEBUG "kcapi: load: driver \%s\" has no load function\n", card->driver->name);
if (card->load_firmware == 0) {
printk(KERN_DEBUG "kcapi: load: no load function\n");
return -ESRCH;
}
......@@ -1100,7 +762,7 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
}
card->cardstate = CARD_LOADING;
retval = card->driver->load_firmware(card, &ldata);
retval = card->load_firmware(card, &ldata);
if (retval) {
card->cardstate = CARD_DETECTED;
......@@ -1131,7 +793,7 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
if (card->cardstate == CARD_DETECTED)
return 0;
card->driver->reset_ctr(card);
card->reset_ctr(card);
while (card->cardstate > CARD_DETECTED) {
......@@ -1143,23 +805,6 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
}
return 0;
case AVMB1_GET_CARDINFO:
if (copy_from_user((void *)&gdef, data, sizeof(avmb1_getdef)))
return -EFAULT;
card = get_capi_ctr_by_nr(gdef.contr);
if (!card)
return -ESRCH;
gdef.cardstate = card->cardstate;
if (card->driver == find_driver("t1isa"))
gdef.cardtype = AVM_CARDTYPE_T1;
else gdef.cardtype = AVM_CARDTYPE_B1;
if (copy_to_user(data, (void *)&gdef, sizeof(avmb1_getdef)))
return -EFAULT;
return 0;
}
return -EINVAL;
}
......@@ -1228,8 +873,6 @@ static int __init kcapi_init(void)
char *p;
char rev[32];
MOD_INC_USE_COUNT;
skb_queue_head_init(&recv_queue);
tq_state_notify.routine = notify_handler;
......@@ -1238,7 +881,7 @@ static int __init kcapi_init(void)
tq_recv_notify.routine = recv_handler;
tq_recv_notify.data = 0;
proc_capi_init();
kcapi_proc_init();
if ((p = strchr(revision, ':')) != 0 && p[1]) {
strncpy(rev, p + 2, sizeof(rev));
......@@ -1248,30 +891,14 @@ static int __init kcapi_init(void)
} else
strcpy(rev, "1.0");
#ifdef MODULE
printk(KERN_NOTICE "CAPI-driver Rev %s: loaded\n", rev);
#else
printk(KERN_NOTICE "CAPI-driver Rev %s: started\n", rev);
#endif
MOD_DEC_USE_COUNT;
printk(KERN_NOTICE "CAPI Subsystem Rev %s\n", rev);
return 0;
}
static void __exit kcapi_exit(void)
{
char rev[10];
char *p;
if ((p = strchr(revision, ':'))) {
strcpy(rev, p + 1);
p = strchr(rev, '$');
*p = 0;
} else {
strcpy(rev, "1.0");
}
proc_capi_exit();
printk(KERN_NOTICE "CAPI-driver Rev%s: unloaded\n", rev);
kcapi_proc_exit();
}
module_init(kcapi_init);
......
/*
* 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);
......
......@@ -26,8 +26,6 @@
#include <linux/isdn/capilli.h>
#include "avmcard.h"
static char *revision = "$Revision: 1.1.4.1.2.1 $";
/* ------------------------------------------------------------- */
static struct pci_device_id b1pci_pci_tbl[] __devinitdata = {
......@@ -60,9 +58,7 @@ static char *b1pci_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static int b1pci_probe(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *pdev)
static int b1pci_probe(struct capicardparams *p, struct pci_dev *pdev)
{
avmcard *card;
avmctrl_info *cinfo;
......@@ -70,7 +66,7 @@ static int b1pci_probe(struct capi_driver *driver,
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "b1pci: no memory.\n");
retval = -ENOMEM;
goto err;
}
......@@ -82,17 +78,16 @@ static int b1pci_probe(struct capi_driver *driver,
card->cardtype = avm_b1pci;
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 "b1pci: ports 0x%03x-0x%03x in use.\n",
card->port, card->port + AVMB1_PORTLEN);
retval = -EBUSY;
goto err_free;
}
b1_reset(card->port);
retval = b1_detect(card->port, card->cardtype);
if (retval) {
printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n",
driver->name, card->port, retval);
printk(KERN_NOTICE "b1pci: NO card at 0x%x (%d)\n",
card->port, retval);
retval = -ENODEV;
goto err_release_region;
}
......@@ -101,28 +96,35 @@ static int b1pci_probe(struct capi_driver *driver,
retval = request_irq(card->irq, b1_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 "b1pci: unable to get IRQ %d.\n", card->irq);
retval = -EBUSY;
goto err_release_region;
}
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 = "b1pci";
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 = b1pci_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 "b1pci: attach controller failed.\n");
goto err_free_irq;
}
if (card->revision >= 4) {
printk(KERN_INFO
"%s: AVM B1 PCI V4 at i/o %#x, irq %d, revision %d (no dma)\n",
driver->name, card->port, card->irq, card->revision);
printk(KERN_INFO "b1pci: AVM B1 PCI V4 at i/o %#x, irq %d, revision %d (no dma)\n",
card->port, card->irq, card->revision);
} else {
printk(KERN_INFO
"%s: AVM B1 PCI at i/o %#x, irq %d, revision %d\n",
driver->name, card->port, card->irq, card->revision);
printk(KERN_INFO "b1pci: AVM B1 PCI at i/o %#x, irq %d, revision %d\n",
card->port, card->irq, card->revision);
}
pci_set_drvdata(pdev, card);
......@@ -147,29 +149,12 @@ static void b1pci_remove(struct pci_dev *pdev)
b1_reset(port);
b1_reset(port);
detach_capi_ctr(cinfo->capi_ctrl);
detach_capi_ctr(&cinfo->capi_ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
}
/* ------------------------------------------------------------- */
static struct capi_driver b1pci_driver = {
owner: THIS_MODULE,
name: "b1pci",
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: b1pci_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
/* ------------------------------------------------------------- */
......@@ -192,9 +177,7 @@ static char *b1pciv4_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static int b1pciv4_probe(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *pdev)
static int b1pciv4_probe(struct capicardparams *p, struct pci_dev *pdev)
{
avmcard *card;
avmctrl_info *cinfo;
......@@ -202,14 +185,14 @@ static int b1pciv4_probe(struct capi_driver *driver,
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "b1pci: no memory.\n");
retval = -ENOMEM;
goto err;
}
card->dma = avmcard_dma_alloc(driver->name, pdev, 2048+128, 2048+128);
card->dma = avmcard_dma_alloc("b1pci", pdev, 2048+128, 2048+128);
if (!card->dma) {
printk(KERN_WARNING "%s: dma alloc.\n", driver->name);
printk(KERN_WARNING "b1pci: dma alloc.\n");
retval = -ENOMEM;
goto err_free;
}
......@@ -222,17 +205,16 @@ static int b1pciv4_probe(struct capi_driver *driver,
card->cardtype = avm_b1pci;
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 "b1pci: 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 "b1pci: can't remap memory at 0x%lx\n",
card->membase);
retval = -ENOMEM;
goto err_release_region;
}
......@@ -241,8 +223,8 @@ static int b1pciv4_probe(struct capi_driver *driver,
retval = b1pciv4_detect(card);
if (retval) {
printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n",
driver->name, card->port, retval);
printk(KERN_NOTICE "b1pci: NO card at 0x%x (%d)\n",
card->port, retval);
retval = -ENODEV;
goto err_unmap;
}
......@@ -251,24 +233,33 @@ static int b1pciv4_probe(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 "b1pci: 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);
retval = -EBUSY;
cinfo->capi_ctrl.driver_name = "b1pciv4";
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 = b1pciv4_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 "b1pci: attach controller failed.\n");
goto err_free_irq;
}
card->cardnr = cinfo->capi_ctrl->cnr;
card->cardnr = cinfo->capi_ctrl.cnr;
printk(KERN_INFO
"%s: AVM B1 PCI V4 at i/o %#x, irq %d, mem %#lx, revision %d (dma)\n",
driver->name, card->port, card->irq,
card->membase, card->revision);
printk(KERN_INFO "b1pci: AVM B1 PCI V4 at i/o %#x, irq %d, mem %#lx, revision %d (dma)\n",
card->port, card->irq, card->membase, card->revision);
pci_set_drvdata(pdev, card);
return 0;
......@@ -295,7 +286,7 @@ static void b1pciv4_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);
......@@ -303,74 +294,48 @@ static void b1pciv4_remove(struct pci_dev *pdev)
b1_free_card(card);
}
/* ------------------------------------------------------------- */
static struct capi_driver b1pciv4_driver = {
owner: THIS_MODULE,
name: "b1pciv4",
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: b1pciv4_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
#endif /* CONFIG_ISDN_DRV_AVMB1_B1PCIV4 */
static int __devinit b1pci_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct capi_driver *driver = &b1pci_driver;
struct capicardparams param;
int retval;
if (pci_enable_device(pdev) < 0) {
printk(KERN_ERR "%s: failed to enable AVM-B1\n",
driver->name);
printk(KERN_ERR "b1pci: failed to enable AVM-B1\n");
return -ENODEV;
}
param.irq = pdev->irq;
if (pci_resource_start(pdev, 2)) { /* B1 PCI V4 */
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
driver = &b1pciv4_driver;
pci_set_master(pdev);
#endif
param.membase = pci_resource_start(pdev, 0);
param.port = pci_resource_start(pdev, 2);
printk(KERN_INFO
"%s: PCI BIOS reports AVM-B1 V4 at i/o %#x, irq %d, mem %#x\n",
driver->name, param.port, param.irq, param.membase);
printk(KERN_INFO "b1pci: PCI BIOS reports AVM-B1 V4 at i/o %#x, irq %d, mem %#x\n",
param.port, param.irq, param.membase);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
retval = b1pciv4_probe(driver, &param, pdev);
retval = b1pciv4_probe(&param, pdev);
#else
retval = b1pci_probe(driver, &param, pdev);
retval = b1pci_probe(&param, pdev);
#endif
if (retval != 0) {
printk(KERN_ERR
"%s: no AVM-B1 V4 at i/o %#x, irq %d, mem %#x detected\n",
driver->name, param.port, param.irq, param.membase);
printk(KERN_ERR "b1pci: no AVM-B1 V4 at i/o %#x, irq %d, mem %#x detected\n",
param.port, param.irq, param.membase);
}
} else {
param.membase = 0;
param.port = pci_resource_start(pdev, 1);
printk(KERN_INFO
"%s: PCI BIOS reports AVM-B1 at i/o %#x, irq %d\n",
driver->name, param.port, param.irq);
retval = b1pci_probe(driver, &param, pdev);
printk(KERN_INFO "b1pci: PCI BIOS reports AVM-B1 at i/o %#x, irq %d\n",
param.port, param.irq);
retval = b1pci_probe(&param, pdev);
if (retval != 0) {
printk(KERN_ERR
"%s: no AVM-B1 at i/o %#x, irq %d detected\n",
driver->name, param.port, param.irq);
printk(KERN_ERR "b1pci: no AVM-B1 at i/o %#x, irq %d detected\n",
param.port, param.irq);
}
}
return retval;
......@@ -395,42 +360,12 @@ static struct pci_driver b1pci_pci_driver = {
static int __init b1pci_init(void)
{
int retval;
b1_set_revision(&b1pci_driver, revision);
attach_capi_driver(&b1pci_driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
b1_set_revision(&b1pciv4_driver, revision);
attach_capi_driver(&b1pciv4_driver);
#endif
retval = pci_module_init(&b1pci_pci_driver);
if (retval < 0)
goto err;
printk(KERN_INFO "%s: %d B1-PCI card(s) detected\n",
b1pci_driver.name, retval);
retval = 0;
goto out;
err:
detach_capi_driver(&b1pci_driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
detach_capi_driver(&b1pciv4_driver);
#endif
out:
return retval;
return pci_module_init(&b1pci_pci_driver);
}
static void __exit b1pci_exit(void)
{
pci_unregister_driver(&b1pci_pci_driver);
detach_capi_driver(&b1pci_driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
detach_capi_driver(&b1pciv4_driver);
#endif
}
module_init(b1pci_init);
......
......@@ -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,9 +49,11 @@ static void b1pcmcia_remove_ctr(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static int b1pcmcia_add_card(struct capi_driver *driver,
unsigned int port,
unsigned irq,
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;
......@@ -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);
......@@ -29,8 +29,6 @@
#include <linux/isdn/capilli.h>
#include "avmcard.h"
static char *revision = "$Revision: 1.1.4.1.2.1 $";
#undef CONFIG_C4_DEBUG
#undef CONFIG_C4_POLLDEBUG
......@@ -523,7 +521,7 @@ static void c4_handle_rx(avmcard *card)
DataB3Len = _get_slice(&p, card->databuf);
cidx = CAPIMSG_CONTROLLER(card->msgbuf)-card->cardnr;
if (cidx >= card->nlogcontr) cidx = 0;
ctrl = card->ctrlinfo[cidx].capi_ctrl;
ctrl = &card->ctrlinfo[cidx].capi_ctrl;
if (MsgLen < 30) { /* not CAPI 64Bit */
memset(card->msgbuf+MsgLen, 0, 30-MsgLen);
......@@ -536,7 +534,7 @@ static void c4_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;
......@@ -547,7 +545,7 @@ static void c4_handle_rx(avmcard *card)
cidx = CAPIMSG_CONTROLLER(card->msgbuf)-card->cardnr;
if (cidx >= card->nlogcontr) cidx = 0;
cinfo = &card->ctrlinfo[cidx];
ctrl = card->ctrlinfo[cidx].capi_ctrl;
ctrl = &card->ctrlinfo[cidx].capi_ctrl;
if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) {
printk(KERN_ERR "%s: incoming packet dropped\n",
......@@ -559,7 +557,7 @@ static void c4_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;
......@@ -593,39 +591,37 @@ static void c4_handle_rx(avmcard *card)
#endif
if (!suppress_pollack)
queue_pollack(card);
for (cidx=0; cidx < 4; cidx++) {
ctrl = card->ctrlinfo[cidx].capi_ctrl;
if (ctrl)
ctrl->resume_output(ctrl);
for (cidx=0; cidx < card->nr_controllers; cidx++) {
ctrl = &card->ctrlinfo[cidx].capi_ctrl;
capi_ctr_resume_output(ctrl);
}
break;
case RECEIVE_STOP:
for (cidx=0; cidx < 4; cidx++) {
ctrl = card->ctrlinfo[cidx].capi_ctrl;
if (ctrl)
ctrl->suspend_output(ctrl);
for (cidx=0; cidx < card->nr_controllers; cidx++) {
ctrl = &card->ctrlinfo[cidx].capi_ctrl;
capi_ctr_suspend_output(ctrl);
}
break;
case RECEIVE_INIT:
cidx = card->nlogcontr;
if (cidx >= 4 || !card->ctrlinfo[cidx].capi_ctrl) {
if (cidx >= card->nr_controllers) {
printk(KERN_ERR "%s: card with %d controllers ??\n",
card->name, cidx+1);
break;
}
card->nlogcontr++;
cinfo = &card->ctrlinfo[cidx];
ctrl = cinfo->capi_ctrl;
ctrl = &cinfo->capi_ctrl;
cinfo->versionlen = _get_slice(&p, cinfo->versionbuf);
b1_parse_version(cinfo);
printk(KERN_INFO "%s: %s-card (%s) now active\n",
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(cinfo->capi_ctrl);
capi_ctr_ready(&cinfo->capi_ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -673,12 +669,11 @@ static void c4_handle_interrupt(avmcard *card)
if (card->nlogcontr == 0)
return;
printk(KERN_ERR "%s: unexpected reset\n", card->name);
for (i=0; i < 4; i++) {
for (i=0; i < card->nr_controllers; i++) {
avmctrl_info *cinfo = &card->ctrlinfo[i];
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
if (cinfo->capi_ctrl)
cinfo->capi_ctrl->reseted(cinfo->capi_ctrl);
capi_ctr_reseted(&cinfo->capi_ctrl);
}
card->nlogcontr = 0;
return;
......@@ -888,11 +883,10 @@ void c4_reset_ctr(struct capi_ctr *ctrl)
c4_reset(card);
for (i=0; i < 4; i++) {
for (i=0; i < card->nr_controllers; i++) {
cinfo = &card->ctrlinfo[i];
memset(cinfo->version, 0, sizeof(cinfo->version));
if (cinfo->capi_ctrl)
cinfo->capi_ctrl->reseted(cinfo->capi_ctrl);
capi_ctr_reseted(&cinfo->capi_ctrl);
}
card->nlogcontr = 0;
}
......@@ -905,12 +899,9 @@ static void c4_remove(struct pci_dev *pdev)
c4_reset(card);
for (i=0; i < 4; i++) {
for (i=0; i < card->nr_controllers; i++) {
cinfo = &card->ctrlinfo[i];
if (cinfo->capi_ctrl) {
detach_capi_ctr(cinfo->capi_ctrl);
cinfo->capi_ctrl = NULL;
}
detach_capi_ctr(&cinfo->capi_ctrl);
}
free_irq(card->irq, card);
......@@ -1104,9 +1095,7 @@ static int c4_read_proc(char *page, char **start, off_t off,
/* ------------------------------------------------------------- */
static int c4_add_card(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *dev,
static int c4_add_card(struct capicardparams *p, struct pci_dev *dev,
int nr_controllers)
{
avmcard *card;
......@@ -1116,43 +1105,42 @@ static int c4_add_card(struct capi_driver *driver,
card = b1_alloc_card(nr_controllers);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "c4: no memory.\n");
retval = -ENOMEM;
goto err;
}
card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128);
card->dma = avmcard_dma_alloc("c4", dev, 2048+128, 2048+128);
if (!card->dma) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
printk(KERN_WARNING "c4: no memory.\n");
retval = -ENOMEM;
goto err_free;
}
sprintf(card->name, "%s-%x", driver->name, p->port);
sprintf(card->name, "c%d-%x", nr_controllers, p->port);
card->port = p->port;
card->irq = p->irq;
card->membase = p->membase;
card->cardtype = (nr_controllers == 4) ? avm_c4 : avm_c2;
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 "c4: 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, 128);
if (card->mbase == 0) {
printk(KERN_NOTICE "%s: can't remap memory at 0x%lx\n",
driver->name, card->membase);
printk(KERN_NOTICE "c4: can't remap memory at 0x%lx\n",
card->membase);
retval = -EIO;
goto err_release_region;
}
retval = c4_detect(card);
if (retval != 0) {
printk(KERN_NOTICE "%s: NO card at 0x%x (%d)\n",
driver->name, card->port, retval);
printk(KERN_NOTICE "c4: NO card at 0x%x (%d)\n",
card->port, retval);
retval = -EIO;
goto err_unmap;
}
......@@ -1160,30 +1148,40 @@ static int c4_add_card(struct capi_driver *driver,
retval = request_irq(card->irq, c4_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 "c4: unable to get IRQ %d.\n",card->irq);
retval = -EBUSY;
goto err_unmap;
}
for (i=0; i < nr_controllers ; i++) {
cinfo = &card->ctrlinfo[i];
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed (%d).\n",
driver->name, i);
cinfo->capi_ctrl.driver_name = "c4";
cinfo->capi_ctrl.driverdata = cinfo;
cinfo->capi_ctrl.register_appl = c4_register_appl;
cinfo->capi_ctrl.release_appl = c4_release_appl;
cinfo->capi_ctrl.send_message = c4_send_message;
cinfo->capi_ctrl.load_firmware = c4_load_firmware;
cinfo->capi_ctrl.reset_ctr = c4_reset_ctr;
cinfo->capi_ctrl.procinfo = c4_procinfo;
cinfo->capi_ctrl.ctr_read_proc = c4_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 "c4: attach controller failed (%d).\n", i);
for (i--; i >= 0; i--) {
cinfo = &card->ctrlinfo[i];
detach_capi_ctr(cinfo->capi_ctrl);
detach_capi_ctr(&cinfo->capi_ctrl);
}
goto err_free_irq;
}
if (i == 0)
card->cardnr = cinfo->capi_ctrl->cnr;
card->cardnr = cinfo->capi_ctrl.cnr;
}
printk(KERN_INFO "%s: AVM C%d at i/o %#x, irq %d, mem %#lx\n",
driver->name, nr_controllers, card->port, card->irq,
printk(KERN_INFO "c4: AVM C%d at i/o %#x, irq %d, mem %#lx\n",
nr_controllers, card->port, card->irq,
card->membase);
return 0;
......@@ -1204,47 +1202,15 @@ static int c4_add_card(struct capi_driver *driver,
/* ------------------------------------------------------------- */
static struct capi_driver c2_driver = {
owner: THIS_MODULE,
name: "c2",
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
static struct capi_driver c4_driver = {
owner: THIS_MODULE,
name: "c4",
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
};
static int __devinit c4_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
int nr = ent->driver_data;
struct capi_driver *driver = (nr == 2) ? &c2_driver : &c4_driver;
int retval = 0;
struct capicardparams param;
if (pci_enable_device(dev) < 0) {
printk(KERN_ERR "%s: failed to enable AVM-C%d\n",
driver->name, nr);
printk(KERN_ERR "c4: failed to enable AVM-C%d\n", nr);
return -ENODEV;
}
pci_set_master(dev);
......@@ -1253,15 +1219,13 @@ static int __devinit c4_probe(struct pci_dev *dev,
param.irq = dev->irq;
param.membase = pci_resource_start(dev, 0);
printk(KERN_INFO
"%s: PCI BIOS reports AVM-C%d at i/o %#x, irq %d, mem %#x\n",
driver->name, nr, param.port, param.irq, param.membase);
printk(KERN_INFO "c4: PCI BIOS reports AVM-C%d at i/o %#x, irq %d, mem %#x\n",
nr, param.port, param.irq, param.membase);
retval = c4_add_card(driver, &param, dev, nr);
retval = c4_add_card(&param, dev, nr);
if (retval != 0) {
printk(KERN_ERR
"%s: no AVM-C%d at i/o %#x, irq %d detected, mem %#x\n",
driver->name, nr, param.port, param.irq, param.membase);
printk(KERN_ERR "c4: no AVM-C%d at i/o %#x, irq %d detected, mem %#x\n",
nr, param.port, param.irq, param.membase);
return -ENODEV;
}
return 0;
......@@ -1276,36 +1240,12 @@ static struct pci_driver c4_pci_driver = {
static int __init c4_init(void)
{
int retval;
b1_set_revision(&c2_driver, revision);
attach_capi_driver(&c2_driver);
b1_set_revision(&c4_driver, revision);
attach_capi_driver(&c4_driver);
retval = pci_module_init(&c4_pci_driver);
if (retval < 0)
goto err;
printk(KERN_INFO "%s: %d C4/C2 card(s) detected\n",
c4_driver.name, retval);
retval = 0;
goto out;
err:
detach_capi_driver(&c2_driver);
detach_capi_driver(&c4_driver);
out:
return retval;
return pci_module_init(&c4_pci_driver);
}
static void __exit c4_exit(void)
{
pci_unregister_driver(&c4_pci_driver);
detach_capi_driver(&c2_driver);
detach_capi_driver(&c4_driver);
}
module_init(c4_init);
......
......@@ -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;
t1_disable_irq(port);
b1_reset(port);
b1_reset(port);
t1_reset(port);
if (!cinfo)
return;
card = cinfo->card;
t1_disable_irq(card->port);
b1_reset(card->port);
b1_reset(card->port);
t1_reset(card->port);
detach_capi_ctr(cinfo->capi_ctrl);
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 = &cinfo->capi_ctrl;
/* ctrl->suspend_output(ctrl); */
ctrl->reseted(ctrl);
} else {
printk(KERN_NOTICE "hycapi_capi_stop: cinfo but no capi_ctrl\n");
}
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) {
ctrl = &card->hyctrlinfo->capi_ctrl;
hycapi_fill_profile(card);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
hycapi_restart_internal(ctrl);
/* ctrl->resume_output(ctrl); */
} else {
printk(KERN_WARNING "HYSDN: No ctrl???? How come?\n");
}
}
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 */
/* filled in before calling attach_capi_ctr */
struct module *owner;
void *driverdata; /* driver specific */
char name[32]; /* name of controller */
volatile unsigned short cardstate; /* controller state */
volatile int blocked; /* output blocked */
int traceflag; /* capi trace */
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);
void *driverdata; /* driver specific */
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];
};
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);
int cnr; /* controller number */
volatile unsigned short cardstate; /* controller state */
volatile int blocked; /* output blocked */
int traceflag; /* capi trace */
/* 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];
};
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