From: Alexander Wilhelm <alexander.wilhelm@westermo.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements
Date: Wed, 19 Nov 2025 09:10:12 +0100 [thread overview]
Message-ID: <aR17ZFbEJknzsdn-@FUE-ALEWI-WINX> (raw)
In-Reply-To: <gsjo45cfnhonmstce4egjtid7u43klgxydmxf6z55n4wniv7xt@nqarkxghs3na>
On Wed, Nov 19, 2025 at 10:03:41AM +0200, Dmitry Baryshkov wrote:
> On Tue, Nov 18, 2025 at 07:53:40AM +0100, Alexander Wilhelm wrote:
> > Extend the QMI byte encoding and decoding logic to support multiple basic
> > data type sizes (u8, u16, u32, u64) using existing macros. Ensure correct
> > handling of data sizes and proper byte order conversion on big-endian
> > platforms by consistently applying these macros during encoding and
> > decoding of basic elements.
> >
> > Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> > ---
> > drivers/soc/qcom/qmi_encdec.c | 46 +++++++++++++++++++++++------------
> > 1 file changed, 30 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
> > index 1f9091458d72..90a48fa7ecf4 100644
> > --- a/drivers/soc/qcom/qmi_encdec.c
> > +++ b/drivers/soc/qcom/qmi_encdec.c
> > @@ -23,13 +23,6 @@
> > *p_length |= ((u8)*p_src) << 8; \
> > } while (0)
> >
> > -#define QMI_ENCDEC_ENCODE_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)
> > -
> > #define QMI_ENCDEC_ENCODE_U8(p_dst, p_src) \
> > do { \
> > memcpy(p_dst, p_src, sizeof(u8)); \
> > @@ -58,13 +51,6 @@ do { \
> > p_src = (u8 *)p_src + sizeof(u64); \
> > } 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)
> > -
> > #define QMI_ENCDEC_DECODE_U8(p_dst, p_src) \
> > do { \
> > memcpy(p_dst, p_src, sizeof(u8)); \
> > @@ -225,7 +211,21 @@ static int qmi_encode_basic_elem(void *buf_dst, const void *buf_src,
> > u32 i, rc = 0;
> >
> > for (i = 0; i < elem_len; i++) {
> > - QMI_ENCDEC_ENCODE_N_BYTES(buf_dst, buf_src, elem_size);
> > + switch (elem_size) {
> > + case sizeof(u8):
> > + QMI_ENCDEC_ENCODE_U8(buf_dst, buf_src);
> > + break;
> > + case sizeof(u16):
> > + QMI_ENCDEC_ENCODE_U16(buf_dst, buf_src);
> > + break;
> > + case sizeof(u32):
> > + QMI_ENCDEC_ENCODE_U32(buf_dst, buf_src);
> > + break;
> > + case sizeof(u64):
> > + QMI_ENCDEC_ENCODE_U64(buf_dst, buf_src);
> > + break;
>
> default: scream?
Okay, I'll fix that in the next version. What would be the recommended default
approach? The QMI protocol only uses the sizes mentioned above, and previously
the data was simple memcpy'ed.
Best regards
Alexander Wilhelm
next prev parent reply other threads:[~2025-11-19 8:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 6:53 [PATCH v4 RESEND 0/3] soc: qcom: extend interface for big endian support Alexander Wilhelm
2025-11-18 6:53 ` [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros Alexander Wilhelm
2025-11-19 8:04 ` Dmitry Baryshkov
2025-11-19 8:11 ` Alexander Wilhelm
2025-11-18 6:53 ` [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements Alexander Wilhelm
2025-11-19 8:03 ` Dmitry Baryshkov
2025-11-19 8:10 ` Alexander Wilhelm [this message]
2025-11-18 6:53 ` [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN Alexander Wilhelm
2025-11-19 9:06 ` Dmitry Baryshkov
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=aR17ZFbEJknzsdn-@FUE-ALEWI-WINX \
--to=alexander.wilhelm@westermo.com \
--cc=andersson@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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