patch-2.4.5 linux/drivers/char/moxa.c
Next file: linux/drivers/char/mxser.c
Previous file: linux/drivers/char/mixcomwd.c
Back to the patch index
Back to the overall index
- Lines: 41
- Date:
Tue May 22 10:23:16 2001
- Orig file:
v2.4.4/linux/drivers/char/moxa.c
- Orig date:
Wed Dec 6 12:06:18 2000
diff -u --recursive --new-file v2.4.4/linux/drivers/char/moxa.c linux/drivers/char/moxa.c
@@ -698,21 +698,32 @@
struct moxa_str *ch;
int len, port;
unsigned long flags;
- unsigned char *temp;
ch = (struct moxa_str *) tty->driver_data;
if (ch == NULL)
return (0);
port = ch->port;
save_flags(flags);
- cli();
if (from_user) {
- copy_from_user(moxaXmitBuff, buf, count);
- temp = moxaXmitBuff;
- } else
- temp = (unsigned char *) buf;
- len = MoxaPortWriteData(port, temp, count);
- restore_flags(flags);
+ if (count > PAGE_SIZE)
+ count = PAGE_SIZE;
+ down(&moxaBuffSem);
+ if (copy_from_user(moxaXmitBuff, buf, count)) {
+ len = -EFAULT;
+ } else {
+ cli();
+ len = MoxaPortWriteData(port, moxaXmitBuff, count);
+ restore_flags(flags);
+ }
+ up(&moxaBuffSem);
+ if (len < 0)
+ return len;
+ } else {
+ cli();
+ len = MoxaPortWriteData(port, (unsigned char *) buf, count);
+ restore_flags(flags);
+ }
+
/*********************************************
if ( !(ch->statusflags & LOWWAIT) &&
((len != count) || (MoxaPortTxFree(port) <= 100)) )
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)