diff -ur usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/driver.c usr/src/kernel-modules/fritzcapi/fritz.pci/src/driver.c --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/driver.c 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/driver.c 2010-07-21 18:30:38.000000000 +0200 @@ -48,6 +48,8 @@ #include "defs.h" #include "lib.h" #include "driver.h" +#include +#include /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ @@ -99,7 +101,7 @@ static unsigned long crit_flags; static atomic_t scheduler_enabled = ATOMIC_INIT (0); static atomic_t scheduler_id = ATOMIC_INIT (-1); -static spinlock_t stack_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t sched_lock = SPIN_LOCK_UNLOCKED; #if !defined (__fcclassic__) static int card_id = 0; #endif @@ -107,11 +109,7 @@ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ static void scheduler (unsigned long data); -static irqreturn_t irq_handler (int irq, void * args -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) - , struct pt_regs * regs -#endif - ); +static irqreturn_t irq_handler (int irq, void * args); static DECLARE_TASKLET_DISABLED (scheduler_tasklet, scheduler, 0); @@ -198,7 +196,7 @@ } lib_strncpy (ctrl->serial, tmp, CAPI_SERIAL_LEN); lib_memcpy (&ctrl->profile, card->string[6], sizeof (capi_profile)); - strncpy (ctrl->manu, "AVM GmbH", CAPI_MANUFACTURER_LEN); + lib_strncpy (ctrl->manu, "AVM GmbH", CAPI_MANUFACTURER_LEN); ctrl->version.majorversion = 2; ctrl->version.minorversion = 0; tmp = card->string[0]; @@ -224,16 +222,6 @@ } /* kill_version */ /*---------------------------------------------------------------------------*\ -\*---------------------------------------------------------------------------*/ -static void pprintf (char * page, int * len, const char * fmt, ...) { - va_list args; - - va_start (args, fmt); - *len += vsprintf (page + *len, fmt, args); - va_end (args); -} /* pprintf */ - -/*---------------------------------------------------------------------------*\ \*-C-------------------------------------------------------------------------*/ static inline int in_critical (void) { @@ -378,9 +366,9 @@ card->irq, &irq_handler, #if defined (__fcpci__) || defined (__fcpcmcia__) - SA_INTERRUPT | SA_SHIRQ, + IRQF_DISABLED | IRQF_SHARED, #else - SA_INTERRUPT, + IRQF_DISABLED, #endif TARGET, card @@ -494,39 +482,34 @@ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ -static int __kcapi ctr_info ( - char * page, - char ** start, - off_t ofs, - int count, - int * eof, - struct capi_ctr * ctrl + +static int __kcapi ctr_info (struct seq_file *m, void *v ) { + struct capi_ctr *ctrl = m->private; card_t * card; char * temp; unsigned char flag; - int len = 0; assert (ctrl != NULL); card = (card_t *) ctrl->driverdata; assert (card != NULL); - pprintf (page, &len, "%-16s %s\n", "name", SHORT_LOGO); - pprintf (page, &len, "%-16s 0x%04x\n", "io", card->base); - pprintf (page, &len, "%-16s %d\n", "irq", card->irq); + seq_printf(m, "%-16s %s\n", "name", SHORT_LOGO); + seq_printf(m, "%-16s 0x%04x\n", "io", card->base); + seq_printf(m, "%-16s %d\n", "irq", card->irq); temp = card->version ? card->string[1] : "A1"; - pprintf (page, &len, "%-16s %s\n", "type", temp); + seq_printf(m, "%-16s %s\n", "type", temp); temp = card->version ? card->string[0] : "-"; #if defined (__fcclassic__) || defined (__fcpcmcia__) - pprintf (page, &len, "%-16s 0x%04x\n", "revision", card->info); + seq_printf(m, "%-16s 0x%04x\n", "revision", card->info); #elif defined (__fcpci__) - pprintf (page, &len, "%-16s %d\n", "class", card_id); + seq_printf(m, "%-16s %d\n", "class", card_id); #endif - pprintf (page, &len, "%-16s %s\n", "ver_driver", temp); - pprintf (page, &len, "%-16s %s\n", "ver_cardtype", SHORT_LOGO); + seq_printf(m, "%-16s %s\n", "ver_driver", temp); + seq_printf(m, "%-16s %s\n", "ver_cardtype", SHORT_LOGO); flag = ((unsigned char *) (ctrl->profile.manu))[3]; if (flag) { - pprintf(page, &len, "%-16s%s%s%s%s%s%s%s\n", "protocol", + seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", "protocol", (flag & 0x01) ? " DSS1" : "", (flag & 0x02) ? " CT1" : "", (flag & 0x04) ? " VN3" : "", @@ -538,21 +521,30 @@ } flag = ((unsigned char *) (ctrl->profile.manu))[5]; if (flag) { - pprintf(page, &len, "%-16s%s%s%s%s\n", "linetype", + seq_printf(m, "%-16s%s%s%s%s\n", "linetype", (flag & 0x01) ? " point to point" : "", (flag & 0x02) ? " point to multipoint" : "", (flag & 0x08) ? " leased line without D-channel" : "", (flag & 0x04) ? " leased line with D-channel" : "" ); } - if (len < ofs) { - return 0; - } - *eof = 1; - *start = page - ofs; - return ((count < len - ofs) ? count : len - ofs); + + return 0; } /* ctr_info */ +static int ctr_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, ctr_info, PDE(inode)->data); +} + +const struct file_operations ctr_proc_fops = { + .owner = THIS_MODULE, + .open = ctr_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ static void __kcapi reset_ctrl (struct capi_ctr * ctrl) { @@ -573,7 +565,7 @@ } } stop (card); - capi_ctr_reseted (ctrl); + capi_ctr_down (ctrl); #if defined (__fcpnp__) pnp_disable_dev (card->dev); #endif @@ -630,7 +622,7 @@ ctrl->release_appl = release_appl; ctrl->send_message = send_msg; ctrl->procinfo = proc_info; - ctrl->ctr_read_proc = ctr_info; + ctrl->proc_fops = &ctr_proc_fops; if (0 != (res = attach_capi_ctr (ctrl))) { dec_use_count (); stop (card); @@ -825,7 +817,7 @@ UNUSED_ARG (data); atomic_set (&scheduler_id, smp_processor_id ()); - if (spin_trylock (&stack_lock)) { + if (spin_trylock (&sched_lock)) { while (!atomic_read (&dont_sched)) { atomic_set (&dont_sched, 1); os_timer_poll (); @@ -833,32 +825,25 @@ scheduler_control (TRUE); } } - spin_unlock (&stack_lock); + spin_unlock (&sched_lock); } atomic_set (&scheduler_id, -1); } /* scheduler */ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ -static irqreturn_t irq_handler (int irq, void * args -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) - , struct pt_regs * regs -#endif - ) { +static irqreturn_t irq_handler (int irq, void * args) { int res = IRQ_NONE; UNUSED_ARG (irq); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) - UNUSED_ARG (regs); -#endif if (args != NULL) { assert (capi_lib->cm_handle_events != NULL); if (atomic_read (&scheduler_id) == smp_processor_id ()) { res = IRQ_RETVAL ((*capi_lib->cm_handle_events) ()); } else { - spin_lock (&stack_lock); + spin_lock (&sched_lock); res = IRQ_RETVAL ((*capi_lib->cm_handle_events) ()); - spin_unlock (&stack_lock); + spin_unlock (&sched_lock); } if (res == IRQ_HANDLED) { atomic_set (&dont_sched, 0); @@ -911,10 +896,10 @@ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ -int driver_init (void) { +int avm_driver_init (void) { return (NULL != (capi_lib = link_library (NULL))); -} /* driver_init */ +} /* avm_driver_init */ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/driver.h usr/src/kernel-modules/fritzcapi/fritz.pci/src/driver.h --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/driver.h 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/driver.h 2010-07-21 18:28:30.000000000 +0200 @@ -23,7 +23,6 @@ #ifndef __have_driver_h__ #define __have_driver_h__ -#include #include #include #include @@ -98,8 +97,8 @@ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ -extern int driver_init (void); +extern int avm_driver_init (void); extern void driver_exit (void); /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/lib.c usr/src/kernel-modules/fritzcapi/fritz.pci/src/lib.c --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/lib.c 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/lib.c 2005-07-07 00:00:00.000000000 +0200 @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include "main.h" @@ -362,8 +361,9 @@ static __attr void os_delay (unsigned msec) { assert (!in_interrupt ()); - set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout (msecs_to_jiffies (msec)); + info (msec > 9); + msec = (msec > 9) ? (msec / 10) * TEN_MSECS : TEN_MSECS; + wait_event_interruptible_timeout (delay, 0, msec); } /* os_delay */ #endif diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/libdefs.h usr/src/kernel-modules/fritzcapi/fritz.pci/src/libdefs.h --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/libdefs.h 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/libdefs.h 2005-07-07 00:00:00.000000000 +0200 @@ -59,9 +59,9 @@ \*---------------------------------------------------------------------------*/ typedef struct __lib { - void (__attr * init) (unsigned, void (__attr2 *) (void *, unsigned), + void (__attr * init) (unsigned, void (__attr2 *) (void *, unsigned), void (__attr2 *) (void *), - void (__attr2 *) (void)); + void (__attr2 *) (void)); char * (__attr * params) (void); @@ -92,7 +92,7 @@ void * (__attr * malloc2) (unsigned); #endif -#if defined (DRIVER_TYPE_DSL_RAP) || defined (DRIVER_TYPE_DSL_USB) +#if defined (DRIVER_TYPE_DSL_RAP) void (__attr * delay) (unsigned); #endif unsigned long (__attr * msec) (void); @@ -137,7 +137,7 @@ char * name; unsigned udata; void * pdata; -} lib_interface_t; +} lib_interface_t, * lib_interface_p; /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ @@ -205,7 +205,7 @@ int (__attr2 * cc_run) (void); #endif -} lib_callback_t; +} lib_callback_t, * lib_callback_p; /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/libstub.h usr/src/kernel-modules/fritzcapi/fritz.pci/src/libstub.h --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/libstub.h 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/libstub.h 2005-07-07 00:00:00.000000000 +0200 @@ -29,21 +29,10 @@ # undef NDEBUG #endif -#if defined (DRIVER_TYPE_DSL) -extern __attr2 lib_callback_t * avm_lib_attach (lib_interface_t *, void *); -#else extern __attr2 lib_callback_t * avm_lib_attach (lib_interface_t *); -#endif - extern __attr2 void avm_lib_detach (lib_interface_t *); -#if defined (DRIVER_TYPE_DSL_RAP) || defined (DRIVER_TYPE_DSL_TM) -extern __attr2 lib_interface_t * avm_get_interface (void); -#endif - -#if defined (DRIVER_TYPE_INTERN) extern volatile unsigned long avm_time_base; -#endif #endif diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/main.c usr/src/kernel-modules/fritzcapi/fritz.pci/src/main.c --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/main.c 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/main.c 2010-07-21 18:29:13.000000000 +0200 @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -205,7 +206,7 @@ NOTE(PRODUCT_LOGO " found: port 0x%04x, irq %u\n", pars.port, pars.irq); NOTE("Loading...\n"); - if (!driver_init ()) { + if (!avm_driver_init ()) { ERROR("Error: Driver library not available.\n"); ERROR("Not loaded.\n"); return res; @@ -270,7 +271,7 @@ NOTE (PRODUCT_LOGO " found: port 0x%04x, irq %u\n", pars.port, pars.irq); NOTE("Loading...\n"); - if (!driver_init ()) { + if (!avm_driver_init ()) { ERROR("Error: Driver library not available.\n"); ERROR("Not loaded.\n"); return -EBUSY; @@ -378,7 +379,7 @@ } return err; #elif defined (__fcpcmcia__) || defined (__fcclassic__) - if (!driver_init ()) { + if (!avm_driver_init ()) { ERROR("Error: Driver library not available.\n"); ERROR("Not loaded.\n"); return -EBUSY; diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/tables.c usr/src/kernel-modules/fritzcapi/fritz.pci/src/tables.c --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/tables.c 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/tables.c 2005-07-07 00:00:00.000000000 +0200 @@ -63,7 +63,6 @@ } tab->appl_count++; unlock (tab->lock); - LOG("Application CREATED, id %u (%u, %u, %u)\n", id, ncount, bcount, bsize); return appp; } /* create_appl */ @@ -90,7 +89,6 @@ nccip = appp->root; tab->appl_count--; unlock (tab->lock); - LOG("Application REMOVED, id %u\n", appp->id); while (nccip != NULL) { tmp = nccip->succ; remove_ncci (tab, appp, nccip); @@ -230,7 +228,7 @@ assert (msg != NULL); appl = CAPIMSG_APPID (msg->data); if (NULL == (appp = search_appl (tab, appl))) { - ERROR("Unknown application id #%u (%d)\n", appl, __LINE__); + ERROR("Unknown application id! (%u)\n", appl); ci = CAPI_ILLAPPNR; goto done; } @@ -483,7 +481,7 @@ assert (capi_card != NULL); MLOG("NEW NCCI(appl:%u,ncci:%lX)\n", appl_id, ncci); if (NULL == (appp = search_appl (capi_card->appls, appl_id))) { - ERROR("Unknown application id #%u (%d)\n", appl_id, __LINE__); + ERROR("Unknown application id #%u\n", appl_id); return; } nccip = create_ncci ( @@ -508,7 +506,7 @@ assert (capi_card != NULL); appp = search_appl (capi_card->appls, appl_id); if (NULL == appp) { - ERROR("Unknown application id #%u (%d)\n", appl_id, __LINE__); + ERROR("Unknown application id #%u\n", appl_id); return; } if (0xFFFFFFFF == ncci) { /* 2nd phase RELEASE */ @@ -536,7 +534,7 @@ assert (capi_card != NULL); appp = search_appl (capi_card->appls, appl_id); if (NULL == appp) { - ERROR("Unknown application id #%u (%d)\n", appl_id, __LINE__); + ERROR("Unknown application id #%u\n", appl_id); return NULL; } return ncci_data_buffer (capi_card->appls, appp, ncci, handle); @@ -559,11 +557,9 @@ } #endif info (capi_card->rel_func != NULL); - if (NULL == (appp = search_appl (capi_card->appls, appl))) { - LOG("Release failed... application id unknown!\n"); - return; - } if (capi_card->rel_func != NULL) { + appp = search_appl (capi_card->appls, appl); + assert (appp != NULL); (*capi_card->rel_func) (appp->data); } skb = make_0xfe_request (appl); diff -u usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/tools.h usr/src/kernel-modules/fritzcapi/fritz.pci/src/tools.h --- usr.orig/src/kernel-modules/fritzcapi/fritz.pci/src/tools.h 2011-03-16 09:39:36.000000000 +0100 +++ usr/src/kernel-modules/fritzcapi/fritz.pci/src/tools.h 2010-07-21 18:29:30.000000000 +0200 @@ -23,6 +23,7 @@ #ifndef __have_tools_h__ #define __have_tools_h__ +#include #include #include #include @@ -70,6 +71,16 @@ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ +//#ifndef atomic_xchg +//static inline unsigned long atomic_xchg ( +// volatile atomic_t * v, +// unsigned value +//) { +// return __xchg (value, &v->counter, sizeof (unsigned)); +//} /* atomic_xchg */ +//#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ #ifndef NDEBUG extern unsigned hallocated (void); extern int hvalid (void *);