mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Daniel Glöckner" <dg@emlix.com>
To: barebox@lists.infradead.org
Cc: "Daniel Glöckner" <dg@emlix.com>
Subject: [PATCH v2 05/10] ratp: use poller to run ratp commands
Date: Thu, 14 May 2020 20:21:53 +0200	[thread overview]
Message-ID: <23e433773ad942f3d2374c1befd1084fb3592f59.1589477005.git.dg@emlix.com> (raw)
In-Reply-To: <cover.1589477005.git.dg@emlix.com>
In-Reply-To: <cover.1589477005.git.dg@emlix.com>

With the new idle slice there is no longer a need to have a dedicated hook
for RATP inside readline. Switch to a poller that depends on the idle
slice to execute the commands received over RATP.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
---
 common/ratp/ratp.c | 12 +++++++++++-
 include/ratp_bb.h  |  1 -
 lib/Kconfig        |  1 +
 lib/readline.c     |  9 +--------
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index 9625a31b1..9b3ea0f98 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -53,6 +53,7 @@ struct ratp_ctx {
 	struct ratp_bb_pkt *fs_rx;
 
 	struct poller_struct poller;
+	struct poller_struct execution_poller;
 };
 
 static int compare_ratp_command(struct list_head *a, struct list_head *b)
@@ -302,7 +303,7 @@ static int ratp_console_register(struct ratp_ctx *ctx)
 	return 0;
 }
 
-void barebox_ratp_command_run(void)
+static void barebox_ratp_command_run(struct poller_struct *poller)
 {
 	int ret;
 
@@ -336,6 +337,7 @@ static void ratp_console_unregister(struct ratp_ctx *ctx)
 	int ret;
 
 	console_set_active(&ctx->ratp_console, 0);
+	poller_unregister(&ctx->execution_poller);
 	poller_unregister(&ctx->poller);
 	ratp_close(&ctx->ratp);
 	console_set_active(ctx->cdev, ctx->old_active);
@@ -436,6 +438,7 @@ int barebox_ratp(struct console_device *cdev)
 		ctx->console_recv_fifo = kfifo_alloc(512);
 		ctx->console_transmit_fifo = kfifo_alloc(SZ_128K);
 		ctx->poller.func = ratp_poller;
+		ctx->execution_poller.func = barebox_ratp_command_run;
 		ratp_console_register(ctx);
 	}
 
@@ -458,11 +461,18 @@ int barebox_ratp(struct console_device *cdev)
 	if (ret)
 		goto out1;
 
+	ret = poller_register(&ctx->execution_poller, "ratp-exec");
+	if (ret)
+		goto out2;
+
+	slice_add(&ctx->execution_poller.slice, &idle_slice);
 	console_set_active(&ctx->ratp_console, CONSOLE_STDOUT | CONSOLE_STDERR |
 			CONSOLE_STDIN);
 
 	return 0;
 
+out2:
+	poller_unregister(&ctx->poller);
 out1:
 	ratp_close(ratp);
 out:
diff --git a/include/ratp_bb.h b/include/ratp_bb.h
index a4f28c642..b710f99bf 100644
--- a/include/ratp_bb.h
+++ b/include/ratp_bb.h
@@ -41,7 +41,6 @@ struct ratp_bb_pkt {
 };
 
 int  barebox_ratp(struct console_device *cdev);
-void barebox_ratp_command_run(void);
 int  barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx);
 int  barebox_ratp_fs_mount(const char *path);
 
diff --git a/lib/Kconfig b/lib/Kconfig
index 9a8078018..d60c6ce2d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -108,6 +108,7 @@ config RATP
 	select COMPILE_MEMORY
 	select COMMAND_SUPPORT
 	select POLLER
+	select IDLE_SLICE
 	depends on CONSOLE_FULL
 	depends on !SHELL_NONE
 	bool "RATP protocol support"
diff --git a/lib/readline.c b/lib/readline.c
index 709efb375..79bac6f42 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -4,7 +4,6 @@
 #include <libbb.h>
 #include <poller.h>
 #include <slice.h>
-#include <ratp_bb.h>
 #include <xfuncs.h>
 #include <complete.h>
 #include <linux/ctype.h>
@@ -202,14 +201,8 @@ int readline(const char *prompt, char *buf, int len)
 
 	while (1) {
 		idle_slice_release();
-		while (!tstc()) {
+		while (!tstc())
 			poller_call();
-			if (IS_ENABLED(CONFIG_CONSOLE_RATP)) {
-				idle_slice_acquire();
-				barebox_ratp_command_run();
-				idle_slice_release();
-			}
-		}
 		idle_slice_acquire();
 
 		ichar = read_key();
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-05-14 18:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 18:21 [PATCH v2 00/10] Support for Fastboot over UDP Daniel Glöckner
2020-05-14 18:21 ` [PATCH v2 01/10] Remove CONFIG_SLICE Daniel Glöckner
2020-05-14 18:21 ` [PATCH v2 02/10] net: fixed-link phys are never acquired Daniel Glöckner
2020-05-14 18:21 ` [PATCH v2 03/10] poller: adapt remaining users to API change Daniel Glöckner
2020-05-14 18:21 ` [PATCH v2 04/10] Introduce idle slice Daniel Glöckner
2020-05-20  6:03   ` Sascha Hauer
2020-05-14 18:21 ` Daniel Glöckner [this message]
2020-05-14 18:21 ` [PATCH v2 06/10] fastboot: split generic code from USB gadget Daniel Glöckner
2020-05-14 18:21 ` [PATCH v2 07/10] defconfigs: update renamed fastboot options Daniel Glöckner
2020-05-14 18:21 ` [PATCH v2 08/10] fastboot: rename usbgadget.fastboot_* variables to fastboot.* Daniel Glöckner
2020-05-20  4:55   ` Sascha Hauer
2020-05-14 18:21 ` [PATCH v2 09/10] fastboot net: implement fastboot over UDP Daniel Glöckner
2020-05-20  5:52   ` Sascha Hauer
2020-05-20  6:57     ` Daniel Glöckner
2020-05-20  8:14       ` Sascha Hauer
2020-05-20  8:17   ` Sascha Hauer
2020-05-14 18:21 ` [PATCH v2 10/10] fastboot: don't close fd 0 when downloading to ram Daniel Glöckner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23e433773ad942f3d2374c1befd1084fb3592f59.1589477005.git.dg@emlix.com \
    --to=dg@emlix.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox