Re: [Query] serial: AT91: Add SIM Driver

From: Alan Cox
Date: Fri Apr 27 2012 - 10:49:17 EST


On Fri, 27 Apr 2012 11:19:18 +0000
"Chen, Bo" <Bo.Chen@xxxxxxxxx> wrote:

> Hi Alan,
>
> > One way would be to make ISO7816 a line discipline (the layer which sits about the tty).
>
> >Your user space interface would then be
>
> > int ldisc = N_ISO7816;
> > ioctl(tty_fd, TIOCSETD, &ldisc);
>
> Make ISO7816 a line discipline would register it in driver(atmel_serial.c or a new named driver) via tty_register_ldisc(N_ISO7816, &tty_ldisc_ops)

Yes

> If I use ioctl(tty_fd, TIOCSETD, &ldisc), it will close current line discipline and open a new line discipline related to ISO7816 (tty_register_ldisc(N_ISO7816, &tty_ldisc_ops))?

Yes

> > at which point the read/write/ioctl etc calls on your tty will also be > routed via your ldisc so you can manage them and provide ISO7816 sensible > interfaces
>
> Does it mean when I call read/write/ioctl in user space, it will call tty_ldisc_ops functions (ISO7816 line discipline has been opened) such as gsmld_read/gsmld_write/gsmld_ioctl in N_gsm.c? What I need to do is to implement the interface in tty_ldisc_ops?

Yes. The read and write methods get called with the user buffer and size
requested being passed. The ioctl handler is called as well as part of the
standard tty handlers so that a line discipline can implement its own
ioctls.

> What is the reasonable way to add this line discipline, in atmel_serial.c or create a new driver (build as a module and dynamically load)? Would it be accepted by kernel mainline?

Probably as a separate driver. That makes it easier to test and to review.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/