Re: [PATCH 16/16] s390/char/con3270: use tty_port_tty guard()

From: Heiko Carstens
Date: Thu Aug 14 2025 - 04:20:08 EST


On Thu, Aug 14, 2025 at 09:24:56AM +0200, Jiri Slaby (SUSE) wrote:
> Having the new tty_port_tty guard, use it in tty3270_resize(). This
> makes the code easier to read. The winsize is now defined in the
> scope and initialized immediately, so that it's obvious.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx>
> Cc: Heiko Carstens <hca@xxxxxxxxxxxxx>
> Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx>
> Cc: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
> Cc: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>
> Cc: Sven Schnelle <svens@xxxxxxxxxxxxx>
> ---
> Cc: linux-s390@xxxxxxxxxxxxxxx
> ---
> drivers/s390/char/con3270.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)

...

> - tty = tty_port_tty_get(&tp->port);
> - if (!tty)
> - return;
> - ws.ws_row = tty3270_tty_rows(tp);
> - ws.ws_col = tp->view.cols;
> - tty_do_resize(tty, &ws);
> - tty_kref_put(tty);
> + /* Inform the tty layer about new size */
> + scoped_guard(tty_port_tty, &tp->port) {
> + struct winsize ws = {
> + .ws_row = tty3270_tty_rows(tp),
> + .ws_col = tp->view.cols,
> + };
> + tty_do_resize(scoped_tty(), &ws);
> + }

This generates worse code compared to before, since an extra not needed
"if (IS_ERR(...))" check is added implicitly. For this particular code
it doesn't matter.
Just wanted to mention it, since this is not stated anywhere.

In any case:
Acked-by: Heiko Carstens <hca@xxxxxxxxxxxxx>