Package of the day - MCS9865 MosChip PCI to Serial/Parallel driver

Over a year ago I packaged up this for a forum user, now a new user had issues on this thread;

11.4: How to get parallel interface card with MCS9865 driver work?

So after a qucik cleanup of the spec file and building with the latest release, sure enough, same error;


/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c: In function 'receive_chars':
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:644:6: warning: comparison of distinct pointer types lacks a cast
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c: At top level:
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:1993:8: warning: type defaults to 'int' in declaration of 'DECLARE_MUTEX'
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:1993:1: warning: parameter names (without types) in function declaration
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c: In function 'serial9865_register_port':
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:2040:8: error: 'serial9865_sem' undeclared (first use in this function)
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:2040:8: note: each undeclared identifier is reported only once for each function it appears in
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c: In function 'serial9865_remove_one':
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:2151:9: error: 'serial9865_sem' undeclared (first use in this function)
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c: At top level:
/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.c:1993:8: warning: 'DECLARE_MUTEX' declared 'static' but never defined
make[3]: *** [/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default/mcs9865.o] Error 1
make[2]: *** [_module_/usr/src/packages/BUILD/MCS9865_V1.0.0.9/obj/default] Error 2
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/usr/src/linux-2.6.37.1-1.2-obj/x86_64/default'
error: Bad exit status from /var/tmp/rpm-tmp.i5pdsF (%build)

So there had been some changes with the 2.6.37 kernel but what?

So off to google with “DECLARE_MUTEX” first hit show it’s changed to DEFINE_SEMAPHORE, well that was easy :slight_smile:

Now to modify the code and produce a patch, since I’m building for earlier releases I need to add a #if statement in the mcs9865.c file;


#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
static DECLARE_MUTEX(serial9865_sem);
#else
static DEFINE_SEMAPHORE(serial9865_sem);
#endif

Now a diff -Naur on the modified file will produce our patch;


diff -Naur mcs9865.c mcs9865.c.orig

--- mcs9865.c	2010-05-18 01:30:28.000000000 -0500
+++ mcs9865.c.orig	2011-10-25 09:08:11.000000000 -0500
@@ -1990,7 +1990,11 @@
 		return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
 static DECLARE_MUTEX(serial9865_sem);
+#else
+static DEFINE_SEMAPHORE(serial9865_sem);
+#endif
 
 static struct uart_driver mcs9865_serial_driver = {
         .owner                  = THIS_MODULE,


Patch done and added to the spec file and we are good to go :slight_smile:

Build information here;
https://build.opensuse.org/package/show?package=MCS9865&project=home%3Amalcolmlewis%3AKMP

packages for all distributions are here (Slow at the moment to publish as factory is busy with 12.1);
software.opensuse.org: Search Results