* [PATCH 16/16] s390/char/con3270: use tty_port_tty guard()
[not found] <20250814072456.182853-1-jirislaby@kernel.org>
@ 2025-08-14 7:24 ` Jiri Slaby (SUSE)
2025-08-14 8:19 ` Heiko Carstens
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Slaby (SUSE) @ 2025-08-14 7:24 UTC (permalink / raw)
To: gregkh
Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
Sven Schnelle, linux-s390
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@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
---
Cc: linux-s390@vger.kernel.org
---
drivers/s390/char/con3270.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index b78b86e8f281..a367f95c7c53 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -970,8 +970,6 @@ static void tty3270_resize(struct raw3270_view *view,
char **old_rcl_lines, **new_rcl_lines;
char *old_prompt, *new_prompt;
char *old_input, *new_input;
- struct tty_struct *tty;
- struct winsize ws;
size_t prompt_sz;
int new_allocated, old_allocated = tp->allocated_lines;
@@ -1023,14 +1021,14 @@ static void tty3270_resize(struct raw3270_view *view,
kfree(old_prompt);
tty3270_free_recall(old_rcl_lines);
tty3270_set_timer(tp, 1);
- /* Informat tty layer about new size */
- 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);
+ }
return;
out_screen:
tty3270_free_screen(screen, new_rows);
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 16/16] s390/char/con3270: use tty_port_tty guard()
2025-08-14 7:24 ` [PATCH 16/16] s390/char/con3270: use tty_port_tty guard() Jiri Slaby (SUSE)
@ 2025-08-14 8:19 ` Heiko Carstens
0 siblings, 0 replies; 2+ messages in thread
From: Heiko Carstens @ 2025-08-14 8:19 UTC (permalink / raw)
To: Jiri Slaby (SUSE)
Cc: gregkh, linux-serial, linux-kernel, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
linux-s390
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@kernel.org>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> ---
> Cc: linux-s390@vger.kernel.org
> ---
> 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@linux.ibm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-14 8:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250814072456.182853-1-jirislaby@kernel.org>
2025-08-14 7:24 ` [PATCH 16/16] s390/char/con3270: use tty_port_tty guard() Jiri Slaby (SUSE)
2025-08-14 8:19 ` Heiko Carstens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox