You are not logged in.

#1 2012-12-29 15:01:12

Registered: 2012-11-03
Posts: 20

Porting an old kernel module/driver to latest kernel

Hello everyone,

i'm currently trying to port an old (2006) driver for an PCI ADSL modem (Bewan ADSL PCI ST, lspci : "ATM network controller: STMicroelectronics ST70137 [Unicorn] ADSL DMT Transceiver (rev 10)") to the latest kernel linux-3.6.10-1-ARCH (on x86_64),
here's the original driver : … -0.9.3.tgz, or : … -0.9.3.tgz,

i think i did everything right on unicorn_pci/unicorn_pcidrv.c (the PCI driver/kernel module), i'm not getting any errors when compiling, only warnings; however i can't test it yet (see below), here's a patch with my modifications (apply it to the original unicorn_pcidrv.c) : (or get the complete file here ),
but now there's another file, msw/linrapi.c (don't know what it does it looks like some software to handle the ATM stuff) which uses "kernel locks" like "lock_kernel()" and "unlock_kernel()", i've read that kernel locks are deprecated and we should use "mutex" instead, however i'm a beginner at programming and i don't really know how to do that (it doesn't look like a slight syntax change but rather a complete rewrite of the source code), here's a patch of what i've done so far (apply it to the original linrapi.c) : (or get the complete file here ) and here are the errors i get when i do "make modules" :

for i in libm unicorn_pci ; do make -C $i modules MODDIR=/root/unicorn/$i ; done
make[1]: Entering directory `/root/unicorn/libm'
make[1]: Nothing to be done for `modules'.
make[1]: Leaving directory `/root/unicorn/libm'
make[1]: Entering directory `/root/unicorn/unicorn_pci'
make CC=gcc -C /usr/src/linux-3.6.10-1-ARCH SUBDIRS=/root/unicorn/unicorn_pci modules
make[2]: Entering directory `/usr/src/linux-3.6.10-1-ARCH'
  CC [M]  /root/unicorn/unicorn_pci/../msw/linrapi.o
In file included from /root/unicorn/unicorn_pci/../msw/linrapi.c:32:0:
/root/unicorn/unicorn_pci/../include/debug.h:36:0: warning: "WARN" redefined [enabled by default]
In file included from /usr/src/linux-3.6.10-1-ARCH/arch/x86/include/asm/bug.h:38:0,
                 from include/linux/bug.h:4,
                 from include/linux/thread_info.h:11,
                 from include/linux/preempt.h:9,
                 from include/linux/spinlock.h:50,
                 from include/linux/semaphore.h:13,
                 from /root/unicorn/unicorn_pci/../msw/linrapi.c:16:
include/asm-generic/bug.h:94:0: note: this is the location of the previous definition
/root/unicorn/unicorn_pci/../msw/linrapi.c: In function ‘__builtin_vec_new’:
/root/unicorn/unicorn_pci/../msw/linrapi.c:225:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat]
/root/unicorn/unicorn_pci/../msw/linrapi.c: In function ‘start_fn’:
/root/unicorn/unicorn_pci/../msw/linrapi.c:864:2: error: implicit declaration of function ‘lock_kernel’ [-Werror=implicit-function-declaration]
/root/unicorn/unicorn_pci/../msw/linrapi.c:875:2: error: implicit declaration of function ‘unlock_kernel’ [-Werror=implicit-function-declaration]
/root/unicorn/unicorn_pci/../msw/linrapi.c: In function ‘xt_start’:
/root/unicorn/unicorn_pci/../msw/linrapi.c:914:2: error: implicit declaration of function ‘find_task_by_pid’ [-Werror=implicit-function-declaration]
/root/unicorn/unicorn_pci/../msw/linrapi.c:914:12: warning: assignment makes pointer from integer without a cast [enabled by default]
/root/unicorn/unicorn_pci/../msw/linrapi.c: In function ‘xq_create’:
/root/unicorn/unicorn_pci/../msw/linrapi.c:1144:18: error: ‘SPIN_LOCK_UNLOCKED’ undeclared (first use in this function)
/root/unicorn/unicorn_pci/../msw/linrapi.c:1144:18: note: each undeclared identifier is reported only once for each function it appears in
/root/unicorn/unicorn_pci/../msw/linrapi.c: In function ‘rapi_init’:
/root/unicorn/unicorn_pci/../msw/linrapi.c:1532:2: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [/root/unicorn/unicorn_pci/../msw/linrapi.o] Error 1
make[2]: *** [_module_/root/unicorn/unicorn_pci] Error 2
make[2]: Leaving directory `/usr/src/linux-3.6.10-1-ARCH'
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/root/unicorn/unicorn_pci'
make: *** [modules] Error 2

(ignore the spinlock and init_mutex errors, i know how to fix them)

as you can see, linrapi.c still has some problems and i don't know how to fix that, can anyone help me please ?

Thanks and have a nice day.


Board footer

Powered by FluxBB