mct_u232: IOCTL implementation
Pete,
My apology, reading Greg's post I realized that 2.6.35 (distributed with Fedora 14) is indeed outdated. I just checked out 2.6.37-rc7 tree and saw references to get_icount function. I will definetely address your concern,
Thank you again,
Vadim.
Quoted 154 lines · Tsozik
From: Tsozik <[email protected]>
Subject: Re: [PATCH 1/1]mct_u232: IOCTL implementation
To: "Pete Zaitcev" <[email protected]>
Cc: "Greg Kroah-Hartman" <[email protected]>, [email protected], [email protected]
Date: Sunday, December 26, 2010, 2:41 PM
Pete,Many thanks for your comment/concern. I borrowed an TIOCGICOUNT implementation from
usb/serial/io_ti.c:case TIOCGICOUNT:
dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d",__func__,
port->number,edge_port->icount.rx,edge_port->icount.tx); if
(copy_to_user((void__user*)arg,&edge_port->icount,sizeof(edge_port->icount)))
return-EFAULT;
return 0;
}There are 2 similar TIOCGICOUNT implementations listed in
ark3116.cio_edgeport.cio_ti.cmos7720.cmos7840.cti_usb_3410_5052.cfiles under usb/serial/ directory. One based on
io_ti.cand another based onio_edgeport.c. I borrowed one fromio_ti.c, since it looked more effecient to me. I searched for any mention ofget_icountfunction under linux-2.6.35 and didn't find any file which declared or called this function:[vtsozik@SR71 linux-2.6.35]$ find . -type f -name '*.[c,h]' | xargs grep
get_icount
[vtsozik@SR71 linux-2.6.35]$I'm wondering if you could give me a bit more information on this. Otherwise I would really prefer to proceed with something that already exists and tested. If by some reason you believe that alternative implementation from
io_edgeport.c(please see code snippet below) should be used please let me know. Again I didn't see any reason for extra copy.case TIOCGICOUNT:
cnow =edge_port->icount;memset(&icount, 0, sizeof(icount));
icount.cts = cnow.cts;
icount.dsr = cnow.dsr;
icount.rng = cnow.rng;
icount.dcd = cnow.dcd;
icount.rx = cnow.rx;
icount.tx = cnow.tx;
icount.frame = cnow.frame;
icount.overrun = cnow.overrun;
icount.parity = cnow.parity;
icount.brk = cnow.brk;
icount.buf_overrun = cnow.buf_overrun;
dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d",
__func__,port->number, icount.rx, icount.tx);
if
(copy_to_user((void__user*)arg, &icount,
sizeof(icount)))
return-EFAULT;
return 0;
}Thank you in advance,
Vadim.--- On Sun, 12/26/10, Pete Zaitcev <[email protected]>
Quoted 2 lines · wrote:
From: Pete Zaitcev <[email protected]>
Subject: Re: [PATCH 1/1]mct_u232: IOCTLimplementation
Quoted 2 lines
To: "Tsozik" <[email protected]>
Cc: "Greg Kroah-Hartman" <[email protected]>,[email protected],
[email protected]Quoted 9 lines
Date: Sunday, December 26, 2010, 12:49 PM
On Sat, 25 Dec 2010 21:39:39 -0800
(PST)
Tsozik <[email protected]>Quoted 1 line · wrote:
+++ mct_u232.c 2010-12-25 21:44:57.714640343
-0500
Quoted 1 line
+static int mct_u232_ioctl(struct
tty_structQuoted 8 lines
*tty, struct file *file,
Quoted 1 line
+
unsigned int cmd,
unsigned long arg)Quoted 3 lines
+{
+ case TIOCGICOUNT:
+dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d",
__func__,Quoted 3 lines
Quoted 1 line
+
port->number,mct_u232_port->icount.rx,
mct_u232_port->icount.tx);Quoted 9 lines
Quoted 1 line
+
if (copy_to_user((void
__user*)arg,&mct_u232_port->icount,Quoted 1 line
+
sizeof(mct_u232_port->icount)))Quoted 1 line
+
return
-EFAULT;This looks suspicious. Didn't we relocate the
machinery for
Quoted 2 lines
TIOCGICOUNT
into a generic place? Please examine how->get_icount
Quoted 5 lines
works before
hand-rolling the ioctl.-- Pete
Quoted 3 lines · On Sun, 26 Dec 2010 14:14:44 -0800 (PST) Tsozik <[email protected]> wrote:
My apology, reading Greg's post I realized that 2.6.35 (distributed with Fedora 14) is indeed outdated. I just checked out 2.6.37-rc7 tree and saw references to
get_icountfunction. I will definetely address your concern,
Thanks. I figured there was a reason for us to do this (if nothing else, to get rid of casts with __user). So, you might as well align the code with the current practice.
Please try to be more careful with spaces and tabs. I didn't want to focus on such small things right from beginning, but they are considered important.
Yours,
-- Pete