From: Joe Perches <joe@perches.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Andy Gross <andy.gross@linaro.org>,
Ohad Ben-Cohen <ohad@wizery.com>
Cc: Arun Kumar Neelakantam <aneela@codeaurora.org>,
Chris Lew <clew@codeaurora.org>,
Philippe Ombredanne <pombredanne@nexb.com>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-soc@vger.kernel.org, linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH v5 1/5] soc: qcom: Introduce QMI encoder/decoder
Date: Tue, 05 Dec 2017 14:03:33 -0800 [thread overview]
Message-ID: <1512511413.6321.94.camel@perches.com> (raw)
In-Reply-To: <20171205174310.15799-2-bjorn.andersson@linaro.org>
On Tue, 2017-12-05 at 09:43 -0800, Bjorn Andersson wrote:
> Add the helper library for encoding and decoding QMI encoded messages.
> The implementation is taken from lib/qmi_encdec.c of the Qualcomm kernel
> (msm-3.18).
>
> Modifications has been made to the public API, source buffers has been
> made const and the debug-logging part was omitted, for now.
[]
> diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
[]
> +#define QMI_ENCDEC_ENCODE_TLV(type, length, p_dst) do { \
> + *p_dst++ = type; \
> + *p_dst++ = ((u8)((length) & 0xFF)); \
> + *p_dst++ = ((u8)(((length) >> 8) & 0xFF)); \
> +} while (0)
> +
> +#define QMI_ENCDEC_DECODE_TLV(p_type, p_length, p_src) do { \
> + *p_type = (u8)*p_src++; \
> + *p_length = (u8)*p_src++; \
> + *p_length |= ((u8)*p_src) << 8; \
> +} while (0)
>
> +#define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
> +do { \
> + memcpy(p_dst, p_src, size); \
> + p_dst = (u8 *)p_dst + size; \
> + p_src = (u8 *)p_src + size; \
> +} while (0)
> +
I dislike the asymmetric use of
p_dst being incremented by 3 and
p_src being incremented by 2 here
Is it really useful to have these macros do
any increments of arguments?
Why not a static inline and use a variant of
__be16_to_cpu/cpu_to_be16
> +static int qmi_encode_basic_elem(void *buf_dst, const void *buf_src,
> + u32 elem_len, u32 elem_size)
> +{
> + u32 i, rc = 0;
> +
> + for (i = 0; i < elem_len; i++) {
> + QMI_ENCDEC_ENCODE_N_BYTES(buf_dst, buf_src, elem_size);
> + rc += elem_size;
> + }
I find this use obscure where buf_dst and buf_src are
both modified with an addition by the macro.
next prev parent reply other threads:[~2017-12-05 22:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 17:43 [PATCH v5 0/5] In-kernel QMI helpers and sysmon Bjorn Andersson
2017-12-05 17:43 ` [PATCH v5 1/5] soc: qcom: Introduce QMI encoder/decoder Bjorn Andersson
2017-12-05 22:03 ` Joe Perches [this message]
2017-12-05 17:43 ` [PATCH v5 2/5] soc: qcom: Introduce QMI helpers Bjorn Andersson
2017-12-05 17:43 ` [PATCH v5 3/5] remoteproc: Pass type of shutdown to subdev remove Bjorn Andersson
2017-12-05 17:43 ` [PATCH v5 4/5] remoteproc: qcom: Introduce sysmon Bjorn Andersson
2018-03-02 13:48 ` Jitendra Sharma
2017-12-05 17:43 ` [PATCH v5 5/5] samples: Introduce Qualcomm QMI sample client Bjorn Andersson
2017-12-07 10:20 ` [PATCH v5 0/5] In-kernel QMI helpers and sysmon Philippe Ombredanne
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=1512511413.6321.94.camel@perches.com \
--to=joe@perches.com \
--cc=andy.gross@linaro.org \
--cc=aneela@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=clew@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-soc@vger.kernel.org \
--cc=ohad@wizery.com \
--cc=pombredanne@nexb.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
Powered by JetHome