mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Aleksander Morgado <aleksander@aleksander.es>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] ratp: fix sending data that won't fit in a single RATP packet
Date: Fri, 31 Aug 2018 08:42:10 +0200	[thread overview]
Message-ID: <20180831064210.tg2s35a25kyvlcp3@pengutronix.de> (raw)
In-Reply-To: <20180830223720.25801-1-aleksander@aleksander.es>

On Fri, Aug 31, 2018 at 12:37:20AM +0200, Aleksander Morgado wrote:
> We need to advance the input buffer used to create messages when the
> data doesn't fit in a single RATP packet.
> 
> Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
> ---

Applied, thanks

Sascha

>  include/ratp.h | 2 +-
>  lib/ratp.c     | 6 ++++--
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/include/ratp.h b/include/ratp.h
> index 6f4cf8a6f..d2a819235 100644
> --- a/include/ratp.h
> +++ b/include/ratp.h
> @@ -11,7 +11,7 @@ int ratp_establish(struct ratp *ratp, bool active, int timeout_ms);
>  void ratp_close(struct ratp *ratp);
>  int ratp_recv(struct ratp *ratp, void **data, size_t *len);
>  int ratp_send(struct ratp *ratp, const void *data, size_t len);
> -int ratp_send_complete(struct ratp *ratp, const void *data, size_t len,
> +int ratp_send_complete(struct ratp *ratp, const uint8_t *data, size_t len,
>  		   void (*complete)(void *ctx, int status), void *complete_ctx);
>  int ratp_poll(struct ratp *ratp);
>  bool ratp_closed(struct ratp *ratp);
> diff --git a/lib/ratp.c b/lib/ratp.c
> index 4c5c748b4..7801cae51 100644
> --- a/lib/ratp.c
> +++ b/lib/ratp.c
> @@ -1734,11 +1734,12 @@ void ratp_close(struct ratp *ratp)
>   *
>   * Return: 0 if successful, a negative error code otherwise.
>   */
> -int ratp_send_complete(struct ratp *ratp, const void *data, size_t len,
> +int ratp_send_complete(struct ratp *ratp, const uint8_t *data, size_t len,
>  		   void (*complete)(void *ctx, int status), void *complete_ctx)
>  {
>  	struct ratp_internal *ri = ratp->internal;
>  	struct ratp_message *msg;
> +	int sent = 0;
> 
>  	if (!ri || ri->state != RATP_STATE_ESTABLISHED)
>  		return -ENETDOWN;
> @@ -1754,11 +1755,12 @@ int ratp_send_complete(struct ratp *ratp, const void *data, size_t len,
>  		msg = xzalloc(sizeof(*msg));
>  		msg->buf = xzalloc(sizeof(struct ratp_header) + now + 2);
>  		msg->len = now;
> -		memcpy(msg->buf + sizeof(struct ratp_header), data, now);
> +		memcpy(msg->buf + sizeof(struct ratp_header), data + sent, now);
> 
>  		list_add_tail(&msg->list, &ri->sendmsg);
> 
>  		len -= now;
> +		sent += now;
>  	}
> 
>  	msg->eor = 1;
> --
> 2.18.0
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

      reply	other threads:[~2018-08-31  6:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 22:37 Aleksander Morgado
2018-08-31  6:42 ` Sascha Hauer [this message]

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=20180831064210.tg2s35a25kyvlcp3@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=aleksander@aleksander.es \
    --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