s390/raw3270: add raw3270_start_request() helper
authorSven Schnelle <svens@linux.ibm.com>
Mon, 28 Nov 2022 18:42:28 +0000 (19:42 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 9 Jan 2023 13:33:59 +0000 (14:33 +0100)
There are a few places (and there would be more with the following commits)
like this:

raw3270_request_reset(cp->kreset);
raw3270_request_set_cmd(cp->kreset, TC_WRITE);
raw3270_request_add_data(cp->kreset, &kreset_data, 1);
raw3270_start(&cp->view, cp->kreset);

i.e reset a request, setting the command, adding payload, and starting the
request. Add a helper raw3270_start_request() which takes a command and
the payload as argument and calls the approppriate functions.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/char/con3270.c
drivers/s390/char/raw3270.c
drivers/s390/char/raw3270.h

index 0dea178c0f56c03dd45fec9e2de0f46f52df4e40..88e96957cbb2865b6cea0ec929428886d174e7df 100644 (file)
@@ -591,10 +591,7 @@ static void tty3270_read_tasklet(unsigned long data)
        spin_unlock_irq(&tp->view.lock);
 
        /* Start keyboard reset command. */
-       raw3270_request_reset(tp->kreset);
-       raw3270_request_set_cmd(tp->kreset, TC_WRITE);
-       raw3270_request_add_data(tp->kreset, &kreset_data, 1);
-       raw3270_start(&tp->view, tp->kreset);
+       raw3270_start_request(&tp->view, tp->kreset, TC_WRITE, &kreset_data, 1);
 
        while (len-- > 0)
                kbd_keycode(tp->kbd, *input++);
index f1a817cfe624ef83f9d14037f2144c6f1eae553b..68a6c7390c4c2c0cf3d540fd3b969e46febd0ef2 100644 (file)
@@ -264,6 +264,19 @@ int raw3270_start(struct raw3270_view *view, struct raw3270_request *rq)
        return rc;
 }
 
+int raw3270_start_request(struct raw3270_view *view, struct raw3270_request *rq,
+                         int cmd, void *data, size_t len)
+{
+       int rc;
+
+       raw3270_request_reset(rq);
+       raw3270_request_set_cmd(rq, cmd);
+       rc = raw3270_request_add_data(rq, data, len);
+       if (rc)
+               return rc;
+       return raw3270_start(view, rq);
+}
+
 int raw3270_start_locked(struct raw3270_view *view, struct raw3270_request *rq)
 {
        struct raw3270 *rp;
@@ -1272,6 +1285,7 @@ EXPORT_SYMBOL(raw3270_find_view);
 EXPORT_SYMBOL(raw3270_activate_view);
 EXPORT_SYMBOL(raw3270_deactivate_view);
 EXPORT_SYMBOL(raw3270_start);
+EXPORT_SYMBOL(raw3270_start_request);
 EXPORT_SYMBOL(raw3270_start_locked);
 EXPORT_SYMBOL(raw3270_start_irq);
 EXPORT_SYMBOL(raw3270_reset);
index 7e0c88e9c3c215d45f2dd30b533cbd22b8da10bf..c8e7a596051f6c436b855fb5ffcee551fb023562 100644 (file)
@@ -180,6 +180,8 @@ int raw3270_start_irq(struct raw3270_view *, struct raw3270_request *);
 int raw3270_reset(struct raw3270_view *);
 struct raw3270_view *raw3270_view(struct raw3270_view *);
 int raw3270_view_active(struct raw3270_view *);
+int raw3270_start_request(struct raw3270_view *view, struct raw3270_request *rq,
+                         int cmd, void *data, size_t len);
 
 /* Reference count inliner for view structures. */
 static inline void