From: Sharat Masetty <smasetty@codeaurora.org>
To: freedreno@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
chris@chris-wilson.co.uk, jcrouse@codeaurora.org,
robdclark@gmail.com, linux-kernel@vger.kernel.org,
Sharat Masetty <smasetty@codeaurora.org>
Subject: [PATCH 2/3] include/linux/ascii85: Add ascii85_encode_to_buf()
Date: Tue, 6 Nov 2018 11:40:05 +0530 [thread overview]
Message-ID: <1541484606-20813-2-git-send-email-smasetty@codeaurora.org> (raw)
In-Reply-To: <1541484606-20813-1-git-send-email-smasetty@codeaurora.org>
Add a new function which, in addition to ascii85 encoding to buffer
also returns the length of the encoded string. The length return enables
iteration over the output buffer space. This helps with efficient encoding
of larger buffers, since we avoid an additional memcpy/scnprintf.
Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
---
include/linux/ascii85.h | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/linux/ascii85.h b/include/linux/ascii85.h
index 4cc4020..3665899 100644
--- a/include/linux/ascii85.h
+++ b/include/linux/ascii85.h
@@ -23,8 +23,12 @@
{
int i;
- if (in == 0)
- return "z";
+ if (in == 0) {
+ out[0] = 'z';
+ out[1] = '\0';
+
+ return out;
+ }
out[5] = '\0';
for (i = 5; i--; ) {
@@ -35,4 +39,15 @@
return out;
}
+static inline size_t
+ascii85_encode_to_buf(u32 in, char *out)
+{
+ ascii85_encode(in, out);
+
+ if (in == 0)
+ return 1;
+
+ return 5;
+}
+
#endif
--
1.9.1
next prev parent reply other threads:[~2018-11-06 6:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-06 6:10 [PATCH 1/3] drm/msm: use kvmalloc for ring data in gpu crashstate Sharat Masetty
2018-11-06 6:10 ` Sharat Masetty [this message]
2018-11-06 6:10 ` [PATCH 3/3] drm/msm: Optimize adreno_show_object() Sharat Masetty
2018-11-06 17:07 ` Jordan Crouse
2018-11-06 16:52 ` [PATCH 1/3] drm/msm: use kvmalloc for ring data in gpu crashstate Jordan Crouse
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=1541484606-20813-2-git-send-email-smasetty@codeaurora.org \
--to=smasetty@codeaurora.org \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jcrouse@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robdclark@gmail.com \
/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