From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org, s.hauer@pengutronix.de
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH v3 4/9] ratp: implement ping as a standard ratp command
Date: Sat, 24 Feb 2018 16:01:16 +0100 [thread overview]
Message-ID: <20180224150121.28309-5-aleksander@aleksander.es> (raw)
In-Reply-To: <20180224150121.28309-1-aleksander@aleksander.es>
Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
---
common/ratp/Makefile | 1 +
common/ratp/ping.c | 40 ++++++++++++++++++++++++++++++++++++++++
common/ratp/ratp.c | 24 ------------------------
3 files changed, 41 insertions(+), 24 deletions(-)
create mode 100644 common/ratp/ping.c
diff --git a/common/ratp/Makefile b/common/ratp/Makefile
index cab14c6fb..acad61ee5 100644
--- a/common/ratp/Makefile
+++ b/common/ratp/Makefile
@@ -1 +1,2 @@
obj-y += ratp.o
+obj-y += ping.o
diff --git a/common/ratp/ping.c b/common/ratp/ping.c
new file mode 100644
index 000000000..cc29ea36c
--- /dev/null
+++ b/common/ratp/ping.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * RATP ping
+ */
+
+#include <common.h>
+#include <ratp_bb.h>
+#include <malloc.h>
+
+static int ratp_cmd_ping(const struct ratp_bb *req, int req_len,
+ struct ratp_bb **rsp, int *rsp_len)
+{
+ /* Just build response */
+ *rsp_len = sizeof(struct ratp_bb);
+ *rsp = xzalloc(*rsp_len);
+ (*rsp)->type = cpu_to_be16(BB_RATP_TYPE_PONG);
+ return 0;
+}
+
+BAREBOX_RATP_CMD_START(PING)
+ .request_id = BB_RATP_TYPE_PING,
+ .response_id = BB_RATP_TYPE_PONG,
+ .cmd = ratp_cmd_ping
+BAREBOX_RATP_CMD_END
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index 7c8a2f6f5..965c67a0a 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -189,25 +189,6 @@ static int ratp_bb_send_command_return(struct ratp_ctx *ctx, uint32_t errno)
return ret;
}
-static int ratp_bb_send_pong(struct ratp_ctx *ctx)
-{
- void *buf;
- struct ratp_bb *rbb;
- int len = sizeof(*rbb);
- int ret;
-
- buf = xzalloc(len);
- rbb = buf;
-
- rbb->type = cpu_to_be16(BB_RATP_TYPE_PONG);
-
- ret = ratp_send(&ctx->ratp, buf, len);
-
- free(buf);
-
- return ret;
-}
-
static int ratp_bb_send_getenv_return(struct ratp_ctx *ctx, const char *val)
{
void *buf;
@@ -270,7 +251,6 @@ static int ratp_bb_dispatch(struct ratp_ctx *ctx, const void *buf, int len)
break;
case BB_RATP_TYPE_COMMAND_RETURN:
- case BB_RATP_TYPE_PONG:
break;
case BB_RATP_TYPE_CONSOLEMSG:
@@ -280,10 +260,6 @@ static int ratp_bb_dispatch(struct ratp_ctx *ctx, const void *buf, int len)
kfifo_put(ctx->console_recv_fifo, rbb->data, dlen);
break;
- case BB_RATP_TYPE_PING:
- ret = ratp_bb_send_pong(ctx);
- break;
-
case BB_RATP_TYPE_GETENV:
varname = xmemdup_add_zero(&rbb->data, dlen);
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-02-24 15:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-24 15:01 [PATCH v3 0/9] ratp: new generic RATP command support Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 1/9] ratp: implement generic " Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 2/9] ratp: moved logic to its own subdirectory Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 3/9] ratp: allow building without full console support Aleksander Morgado
2018-02-24 15:01 ` Aleksander Morgado [this message]
2018-02-24 15:01 ` [PATCH v3 5/9] ratp: implement getenv as a standard ratp command Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 6/9] ratp: use xstrndup() instead of a custom xmemdup_add_zero() Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 7/9] ratp: new md and mw commands Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 8/9] ratp: new reset command Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 9/9] docs: add reference to libratp-barebox in the remote-control docs Aleksander Morgado
2018-03-01 8:48 ` [PATCH v3 0/9] ratp: new generic RATP command support Sascha Hauer
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=20180224150121.28309-5-aleksander@aleksander.es \
--to=aleksander@aleksander.es \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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