Moxa driver causes compile-time errors
PATCH 1/1 Moxa driver causes compile-time errors
Hi,
latest -ac tree patch ac2 replaces some obsolete save_flags()/cli() with spin_lock_irqsave() but there are compile time errors caused by seems-like-forgotten-to-add-but-used spinlock_t member in moxa_str structure. Attached diff file fixes this error and several other warnings.
[newbie_mode ON]
Also, there are two more save_flags()/cli() calls in moxa.c. Are they missed or kept for a specific reason? Attached patch also replaces them with spin_lock_irqsave().
[newbie_mode OFF]
fix_moxa_str_structure_and_several_warnings.patch
o Add spinlock_t member `lock' to moxa_str structure
o Remove unused variable `page' from moxa_open()
o Replaces obsolete save_flags()/cli() pair in block_till_ready() and receive_data() with spin_lock_irqsave()
o Remove inclusion of linux/interrupt.h since remaining two save_flags()/cli() calls are removed
diffstat output:
----------------
moxa.c | 13 5 + 8 - 0 !
1 files changed, 5 insertions(+), 8 deletions(-)
Relevant .config lines:
-----------------------
1370:CONFIG_MOXA_INTELLIO=m
1371:CONFIG_MOXA_SMARTIO=m
I can send my .config file on request.
Relevant build output:
----------------------
gcc -Wp,-MD,drivers/char/.moxa.o.d -nostdinc -iwithprefix include
-D__KERNEL__ -Iinclude -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O2 -fno-omit-frame-pointer -pipe -msoft-float -mpreferred-stack-boundary=2 -march=i686 -Iinclude/asm-i386/mach-default -DMODULE -DKBUILD_BASENAME=moxa -DKBUILD_MODNAME=moxa -c -o drivers/char/.tmp_moxa.o drivers/char/moxa.cdrivers/char/moxa.c: In function `moxa_open':drivers/char/moxa.c:519: warning: unused variable page' drivers/char/moxa.c: In function moxa_write':drivers/char/moxa.c:632: structure has no member named lock' drivers/char/moxa.c:635: structure has no member named lock' drivers/char/moxa.c: In function `moxa_put_char':drivers/char/moxa.c:705: structure has no member named lock' drivers/char/moxa.c:709: structure has no member named lock' drivers/char/moxa.c: In function `block_till_ready':drivers/char/moxa.c:1007: warning: implicit declaration of function save_flags' drivers/char/moxa.c:1008: warning: implicit declaration of function cli' drivers/char/moxa.c:1011: warning: implicit declaration of function restore_flags' drivers/char/moxa.c: In function setup_empty_event':drivers/char/moxa.c:1057: structure has no member named lock' drivers/char/moxa.c:1064: structure has no member named lock' make[2]: *** [drivers/char/moxa.o] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2
After applying attached patch gcc(-3.2.3) does not complain about drivers/char/moxa.c anymore.
Signature · 11 lines
M.Baris Demiray
DOS: n., A small annoying boot virus that causes random spontaneous
system crashes, usually just before saving a massive project.
Easily cured by UNIX. See also MS-DOS, IBM-DOS, DR-DOS.
----
You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
Morpheusdrivers/char/moxa.c renamed from drivers/char/moxa.c.orig +5 -8
@@ -38,7 +38,6 @@#include <linux/signal.h> #include <linux/sched.h> #include <linux/timer.h> -#include <linux/interrupt.h> #include <linux/tty.h> #include <linux/tty_flip.h> #include <linux/major.h>
@@ -153,6 +152,7 @@int blocked_open;long event;/* long req'd for set_bit --RR */ int asyncflags; +spinlock_t lock;unsigned long statusflags;struct tty_struct *tty;int cflag;
@@ -516,7 +516,6 @@struct moxa_str *ch;int port;int retval; -unsigned long page; port =PORTNO (tty);if (port ==MAX_PORTS ) {
@@ -1004,11 +1003,10 @@printk ("block_til_ready before block: ttys%d, count = %d\n" , ch->line, ch->count);#endif -save_flags (flags); -cli (); +spin_lock_irqsave (&ch->lock, flags);if (!tty_hung_up_p (filp)) ch->count--; -restore_flags (flags); +spin_unlock_irqrestore (&ch->lock, flags); ch->blocked_open++;while (1 ) {set_current_state (TASK_INTERRUPTIBLE );
@@ -1129,10 +1127,9 @@ charptr = tp->flip.char_buf_ptr; flagptr = tp->flip.flag_buf_ptr; rc = tp->flip.count; -save_flags (flags); -cli (); +spin_lock_irqsave (&ch->lock, flags); count =MoxaPortReadData (ch->port, charptr, space); -restore_flags (flags); +spin_unlock_irqrestore (&ch->lock, flags);for (i =0 ; i < count; i++) *flagptr++ =0 ; charptr += count;
begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Ideal Teknoloji
adr:;;Teknokent Silikon Bina No:24 ODTU;Ankara;;06531;Turkiye email;internet:[email protected] title:Yazilim Gelistirici
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE url:http://www.idealteknoloji.com
version:2.1
end:vcard
Quoted 6 lines · M.Baris Demiray
Hi,
latest -ac tree patch ac2 replaces some obsolete save_flags()/cli() withspin_lock_irqsave()but there are compile time errors caused by seems-like-forgotten-to-add-but-usedspinlock_tmember inmoxa_strstructure. Attached diff file fixes this error and several other warnings.
Its still a work in progress. The moxa driver has been defunct since 2.4 and it's not trivial to ressurrect. The majority of moxa hardware uses mxser which is now happy. Your changes mostly look sane although they are not enough.