Re: [2/3]

Greg Ungerer
2004-01-18T23:23:57Z

Hi Russel,

Russell King wrote:
> On Sun, Jan 18, 2004 at 10:43:01PM +1000, Greg Ungerer wrote:
>>Looks good for mcfserial.c. The only additional change I would
>>make is to remove the "rts", "dtr", and "val" variables from the
>>ioctl function - removing the TIOCM* cases means these variables
>>are no longer used.
>
>
> I agree for "rts" and "dtr", however "val" is still used - in
> TIOC[SG]ET422. Here's a new patch for mcfserial.c

Oops, your right. This new patch looks good.

Regards
Greg

> ===== drivers/serial/mcfserial.c 1.17 vs edited =====
> --- 1.17/drivers/serial/mcfserial.c Thu Jul 3 02:18:07 2003
> +++ edited/drivers/serial/mcfserial.c Sun Jan 18 15:40:39 2004
> @@ -985,13 +985,49 @@
> local_irq_restore(flags);
> }
>
> +static int mcfrs_tiocmget(struct tty_struct *tty, struct file *file)
> +{
> + struct mcf_serial * info = (struct mcf_serial *)tty->driver_data;
> +
> + if (serial_paranoia_check(info, tty->name, __FUNCTION__))
> + return -ENODEV;
> + if (tty->flags & (1 << TTY_IO_ERROR))
> + return -EIO;
> +
> + return mcfrs_getsignals(info);
> +}
> +
> +static int mcfrs_tiocmset(struct tty_struct *tty, struct file *file,
> + unsigned int set, unsigned int clear)
> +{
> + struct mcf_serial * info = (struct mcf_serial *)tty->driver_data;
> + int rts = -1, dtr = -1;
> +
> + if (serial_paranoia_check(info, tty->name, __FUNCTION__))
> + return -ENODEV;
> + if (tty->flags & (1 << TTY_IO_ERROR))
> + return -EIO;
> +
> + if (set & TIOCM_RTS)
> + rts = 1;
> + if (set & TIOCM_DTR)
> + dtr = 1;
> + if (clear & TIOCM_RTS)
> + rts = 0;
> + if (clear & TIOCM_DTR)
> + dtr = 0;
> +
> + mcfrs_setsignals(info, dtr, rts);
> +
> + return 0;
> +}
> +
> static int mcfrs_ioctl(struct tty_struct *tty, struct file * file,
> unsigned int cmd, unsigned long arg)
> {
> struct mcf_serial * info = (struct mcf_serial *)tty->driver_data;
> unsigned int val;
> int retval, error;
> - int dtr, rts;
>
> if (serial_paranoia_check(info, tty->name, "mcfrs_ioctl"))
> return -ENODEV;
> @@ -1059,45 +1095,6 @@
> info, sizeof(struct mcf_serial));
> return 0;
>
> - case TIOCMGET:
> - if ((error = verify_area(VERIFY_WRITE, (void *) arg,
> - sizeof(unsigned int))))
> - return(error);
> - val = mcfrs_getsignals(info);
> - put_user(val, (unsigned int *) arg);
> - break;
> -
> - case TIOCMBIS:
> - if ((error = verify_area(VERIFY_WRITE, (void *) arg,
> - sizeof(unsigned int))))
> - return(error);
> -
> - get_user(val, (unsigned int *) arg);
> - rts = (val & TIOCM_RTS) ? 1 : -1;
> - dtr = (val & TIOCM_DTR) ? 1 : -1;
> - mcfrs_setsignals(info, dtr, rts);
> - break;
> -
> - case TIOCMBIC:
> - if ((error = verify_area(VERIFY_WRITE, (void *) arg,
> - sizeof(unsigned int))))
> - return(error);
> - get_user(val, (unsigned int *) arg);
> - rts = (val & TIOCM_RTS) ? 0 : -1;
> - dtr = (val & TIOCM_DTR) ? 0 : -1;
> - mcfrs_setsignals(info, dtr, rts);
> - break;
> -
> - case TIOCMSET:
> - if ((error = verify_area(VERIFY_WRITE, (void *) arg,
> - sizeof(unsigned int))))
> - return(error);
> - get_user(val, (unsigned int *) arg);
> - rts = (val & TIOCM_RTS) ? 1 : 0;
> - dtr = (val & TIOCM_DTR) ? 1 : 0;
> - mcfrs_setsignals(info, dtr, rts);
> - break;
> -
> #ifdef TIOCSET422
> case TIOCSET422:
> get_user(val, (unsigned int *) arg);
> @@ -1563,6 +1560,8 @@
> .start = mcfrs_start,
> .hangup = mcfrs_hangup,
> .read_proc = mcfrs_readproc,
> + .tiocmget = mcfrs_tiocmget,
> + .tiocmset = mcfrs_tiocmset,
> };
>
> /* mcfrs_init inits the driver */
>
>

--
------------------------------------------------------------------------
Greg Ungerer -- Chief Software Dude EMAIL: gerg@snapgear.com
SnapGear -- a CyberGuard Company PHONE: +61 7 3435 2888
825 Stanley St, FAX: +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia WEB: http://www.SnapGear.com