archive mirror
 help / color / mirror / Atom feed
From: Marc Gonzalez <>
To: "Jonathan Neuschäfer" <>,
	"Antti Palosaari" <>,
	"Mauro Carvalho Chehab" <>
Cc: linux-media <>,
	LKML <>,
	Bjorn Andersson <>,
	Brad Love <>
Subject: Re: [PATCH v1] media: si2168: Refactor command setup code
Date: Wed, 3 Jul 2019 16:15:35 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 03/07/2019 14:47, Marc Gonzalez wrote:

> Come to think of it, I'm really not a fan of "large" macro functions.
> I'll outline a different option in v2.

My idea is to use a trivial helper function to assign the 3 struct fields,
and then a trivial macro to invoke the helper:

static void cmd_setup(struct si2168_cmd *cmd, char *args, int wlen, int rlen)
	memcpy(cmd->args, args, wlen);
	cmd->wlen = wlen;
	cmd->rlen = rlen;

#define CMD_SETUP(cmd, args, rlen) \
	cmd_setup(cmd, args, sizeof(args) - 1, rlen)

I think this way addresses all of your comments:

- since we're using a real function, the compiler can perform type-checking,
and the function's prototype is self-documenting.
- no more funky __args and __rlen arguments
- no local variables

Note however, that drivers/media/tuners/si2157.c uses a different struct
(struct si2157_cmd). Therefore, if we wanted to apply the same changes
to si2157.c, we would have to define a common struct, and replace all
the uses of struct si2157_cmd and struct si2168_cmd. That seemed too
invasive to do without the maintainer's approval and guidance.

Antti, do you Ack this new approach?

It's not clear what HW is supported by drivers/media/dvb-frontends/si21xx.c
(that's a very generic name).


  reply	other threads:[~2019-07-03 14:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 11:44 Marc Gonzalez
2019-07-02  8:37 ` Marc Gonzalez
2019-07-02  9:51 ` Jonathan Neuschäfer
2019-07-03 12:47   ` Marc Gonzalez
2019-07-03 14:15     ` Marc Gonzalez [this message]
2019-07-03 16:35     ` Jonathan Neuschäfer

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v1] media: si2168: Refactor command setup code' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).