I'm developing my UART driver based on ttySx existing driver in Linux
Kernel.
Everything was ok, before I tried to add my ioctls
ioctls are added in uart_ops structure:
static struct uart_ops uart_ops = {
.tx_empty = uart_tx_empty,
.get_mctrl = uart_get_mctrl,
.set_mctrl = uart_set_mctrl,
.start_tx = uart_start_tx,
.stop_tx = uart_stop_tx,
.stop_rx = uart_stop_rx,
.enable_ms = uart_enable_ms,
.break_ctl = uart_break_ctl,
.startup = uart_startup,
.shutdown = uart_shutdown,
.set_termios = uart_set_termios,
.type = uart_type,
.release_port = uart_release_port,
.request_port = uart_request_port,
.config_port = uart_config_port,
.verify_port = uart_verify_port,
.pm = uart_pm,
.ioctl = uart_ioctl,
};
ioctl goes like this:
static int uart_ioctl(struct uart_port *port, unsigned int cmd,
unsigned long arg )
{
unsigned long flags;
unsigned int old_ies = 0;
switch (cmd)
{
/* returns msr and mcr state*/
case TIOCMGET:
{
unsigned int result = 0;
unsigned int msr = UART_GetMsr(port->line);
unsigned int mcr = UART_GetMcr(port->line);
result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR: 0)
| ((mcr & UART_MCR_RTS) ? TIOCM_RTS: 0)
| ((mcr & UART_MCR_OUT1) ? TIOCM_OUT1: 0)
| ((mcr & UART_MCR_OUT2) ? TIOCM_OUT2: 0)
| ((mcr & UART_MCR_LOOP) ? TIOCM_LOOP: 0)
| ((msr & UART_CTS_CURRENT) ? TIOCM_CTS: 0)
| ((msr & UART_DSR_CURRENT) ? TIOCM_DSR: 0)
| ((msr & UART_RI_CURRENT) ? TIOCM_RI: 0)
| ((msr & UART_DCD_CURRENT) ? TIOCM_CD: 0);
if (copy_to_user((unsigned int*)arg, &result,
sizeof(unsigned int)))
return -EFAULT;
}
break;
/* for setting drt, rts, loop, out1 and out2 bits in mcr
register */
case TIOCMBIS: /* turn on selected MCR bits */
case TIOCMBIC: /* turn off selected MCR bits */
case TIOCMSET: /* turn off all MCR bits and set their selected
value */
{
.......
TIOCMGET is defined in linux-kernel/include/asm-mips/ioctls.h like
#define TIOCMGET 0x741d /* get all modem bits */
anyway when I try to do something like this:
ioctl(fd, TIOCMGET, &mcheck);
in ioctl function as a command I get 0x540d instead of 0x741d?
Does anyone has an idea about this?
Cheers
Aleksandar