* [PATCH] jsm: fixing termios structure to be compatible with stty application
@ 2009-09-30 16:18 leitao
2009-09-30 20:31 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: leitao @ 2009-09-30 16:18 UTC (permalink / raw)
To: linux-kernel
Currently stty returns "unable to perform all requested operations",
when it changes the speed of a jsm device.
It was happening because c_ispeed and c_ospeed were not set properly.
This patch just set them, so that when stty compare the requested
and the new mode(struct termios), they are the same.
Signed-off-by: Breno Leitão <leitao@linux.vnet.ibm.com>
---
drivers/serial/jsm/jsm_tty.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 00f4577..dd1ed76 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -321,6 +321,10 @@ static void jsm_tty_set_termios(struct uart_port *port,
channel->ch_bd->bd_ops->param(channel);
jsm_carrier(channel);
+
+ termios->c_ispeed = termios->c_cflag & CBAUD;
+ termios->c_ospeed = termios->c_cflag & CBAUD;
+
spin_unlock_irqrestore(&port->lock, lock_flags);
}
--
1.6.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] jsm: fixing termios structure to be compatible with stty application
2009-09-30 16:18 [PATCH] jsm: fixing termios structure to be compatible with stty application leitao
@ 2009-09-30 20:31 ` Alan Cox
2009-10-01 20:34 ` Breno Leitao
0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2009-09-30 20:31 UTC (permalink / raw)
To: leitao; +Cc: linux-kernel
> +
> + termios->c_ispeed = termios->c_cflag & CBAUD;
> + termios->c_ospeed = termios->c_cflag & CBAUD;
> +
NAK
termios->c_ispeed/ospeed are the actual baud rates not bit encodings, and
are used for devices that support arbitary speeds
Use
tty_termios_encode_baudrate(termios, ispeed, ospeed);
where ispeed/ospeed are actual input and output baud.
It does all the hard work and knows about
- keeping requests for traditional style B38400 type requests in their
native form (so a request for 38400 that comes out at 38100 will still
get encoded as B38400)
- Encoding arbitary rates using BOTHER
- Handling platforms that haven't been updated properly.
The patch you posted is a nonsense patch so if it helps it might be worth
looking harder as to why..
Alan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] jsm: fixing termios structure to be compatible with stty application
2009-09-30 20:31 ` Alan Cox
@ 2009-10-01 20:34 ` Breno Leitao
2009-10-01 21:10 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: Breno Leitao @ 2009-10-01 20:34 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
Alan Cox wrote:
> NAK
>
> termios->c_ispeed/ospeed are the actual baud rates not bit encodings
Well, c_flag & CBAUD is the baud rate encoded in the Bfoo format.
> Use
>
> tty_termios_encode_baudrate(termios, ispeed, ospeed);
Well, let me explain you what I want to do.
Actually stty.c source code do:
tcsetattr (STDIN_FILENO, TCSADRAIN, &mode)
tcgetattr (STDIN_FILENO, &new_mode)
...
if (memcmp (&mode, &new_mode, sizeof (mode)) != 0)
error (EXIT_FAILURE, 0,....)
When I run stty -F /dev/ttyn0 speed 9600, the mode structure is different
from new_mode, causing that error.
Debugging those structure, I found that ispeed and ospeed were not set in the
Bfoo format, as expected, since mode->[o|i]speed are set in Bfoo format.
Hence, I just assigned ospeed and ispeed with the requested speed in Bfoo
format (c_flag & CBAUD).
I also tested the tty_termios_encode_baud_rate(), and it will basically do what
I did:
termios->c_ispeed = ibaud;
termios->c_ospeed = obaud;
Thanks for the review, and sorry if I missed the point completely.
Breno
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] jsm: fixing termios structure to be compatible with stty application
2009-10-01 20:34 ` Breno Leitao
@ 2009-10-01 21:10 ` Alan Cox
0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2009-10-01 21:10 UTC (permalink / raw)
To: Breno Leitao; +Cc: linux-kernel
> Hence, I just assigned ospeed and ispeed with the requested speed in Bfoo
> format (c_flag & CBAUD).
The kernel ospeed and ispeed are not in Bfoo format, they are actual bit
rates. (I've no idea what glibc does, last time I checked it didn't even
support 2007 era Linux speed setting properly so apps still have to use
ioctls directly for them)
>
> I also tested the tty_termios_encode_baud_rate(), and it will basically do what
> I did:
>
> termios->c_ispeed = ibaud;
> termios->c_ospeed = obaud;
>
> Thanks for the review, and sorry if I missed the point completely.
ibaud != Bfoo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-01 21:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-30 16:18 [PATCH] jsm: fixing termios structure to be compatible with stty application leitao
2009-09-30 20:31 ` Alan Cox
2009-10-01 20:34 ` Breno Leitao
2009-10-01 21:10 ` Alan Cox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.