linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Lars-Peter Clausen <lars@metafoo.de>
Cc: "Sergei Shtylyov" <sergei.shtylyov@cogentembedded.com>,
	"Vladimir Barinov" <vladimir.barinov@cogentembedded.com>,
	"Richard Röjfors" <richard.rojfors@mocean-labs.com>,
	"Federico Vaga" <federico.vaga@gmail.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v2 03/15] [media] adv7180: Use inline function instead of macro
Date: Mon, 02 Feb 2015 14:42:10 +0100	[thread overview]
Message-ID: <54CF7EB2.9020109@xs4all.nl> (raw)
In-Reply-To: <20150202113613.07673af0@recife.lan>

On 02/02/2015 02:36 PM, Mauro Carvalho Chehab wrote:
> Em Fri, 23 Jan 2015 16:52:22 +0100
> Lars-Peter Clausen <lars@metafoo.de> escreveu:
> 
>> Use a inline function instead of a macro for the container_of helper for
>> getting the driver's state struct from a control. A inline function has the
>> advantage that it is more typesafe and nicer in general.
> 
> I don't see any advantage on this.
> 
> See: container_of is already a macro, and it is written in a way that, if
> you use it with inconsistent values, the compilation will break.
> 
> Also, there's the risk that, for whatever reason, gcc to decide to not
> inline this.

For the record: I disagree with this. I think a static inline is more readable
than a macro. It is also consistent with other existing i2c subdev drivers since
they all use a static inline as well. And if in rare cases gcc might decide not
to inline this, then so what? You really won't notice any difference. It's an
i2c device, so it's slow as molasses anyway. Readability is much more important
IMHO.

On the other hand, it's not critical enough for me to make a big deal out of
it if this patch is dropped.

Regards,

	Hans

> 
> So, this doesn't sound a good idea.
> 
> Regards,
> Mauro
> 
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
>> ---
>>  drivers/media/i2c/adv7180.c | 13 +++++++------
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
>> index f424a4d..f2508abe 100644
>> --- a/drivers/media/i2c/adv7180.c
>> +++ b/drivers/media/i2c/adv7180.c
>> @@ -130,9 +130,11 @@ struct adv7180_state {
>>  	bool			powered;
>>  	u8			input;
>>  };
>> -#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler,		\
>> -					    struct adv7180_state,	\
>> -					    ctrl_hdl)->sd)
>> +
>> +static struct adv7180_state *ctrl_to_adv7180(struct v4l2_ctrl *ctrl)
>> +{
>> +	return container_of(ctrl->handler, struct adv7180_state, ctrl_hdl);
>> +}
>>  
>>  static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
>>  {
>> @@ -345,9 +347,8 @@ static int adv7180_s_power(struct v4l2_subdev *sd, int on)
>>  
>>  static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
>>  {
>> -	struct v4l2_subdev *sd = to_adv7180_sd(ctrl);
>> -	struct adv7180_state *state = to_state(sd);
>> -	struct i2c_client *client = v4l2_get_subdevdata(sd);
>> +	struct adv7180_state *state = ctrl_to_adv7180(ctrl);
>> +	struct i2c_client *client = v4l2_get_subdevdata(&state->sd);
>>  	int ret = mutex_lock_interruptible(&state->mutex);
>>  	int val;
>>  


  reply	other threads:[~2015-02-02 13:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 15:52 [PATCH v2 00/15] [media] adv7180: Add support for more chip variants Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 01/15] [media] adv7180: Do not request the IRQ again during resume Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 02/15] [media] adv7180: Pass correct flags to request_threaded_irq() Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 03/15] [media] adv7180: Use inline function instead of macro Lars-Peter Clausen
2015-02-02 13:36   ` Mauro Carvalho Chehab
2015-02-02 13:42     ` Hans Verkuil [this message]
2015-02-02 13:49     ` Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 04/15] [media] adv7180: Cleanup register define naming Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 05/15] [media] adv7180: Do implicit register paging Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 06/15] [media] adv7180: Reset the device before initialization Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 07/15] [media] adv7180: Add media controller support Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 08/15] [media] adv7180: Consolidate video mode setting Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 09/15] [media] adv7180: Prepare for multi-chip support Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 10/15] [media] adv7180: Add support for the adv7182 Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 11/15] [media] adv7180: Add support for the adv7280/adv7281/adv7282 Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 12/15] [media] adv7180: Add support for the adv7280-m/adv7281-m/adv7281-ma/adv7282-m Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 13/15] [media] adv7180: Add I2P support Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 14/15] [media] adv7180: Add fast switch support Lars-Peter Clausen
2015-01-23 15:52 ` [PATCH v2 15/15] [media] Add MAINTAINERS entry for the adv7180 Lars-Peter Clausen
2015-01-25 17:34 ` [PATCH v2 00/15] [media] adv7180: Add support for more chip variants Federico Vaga

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=54CF7EB2.9020109@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=federico.vaga@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=richard.rojfors@mocean-labs.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=vladimir.barinov@cogentembedded.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;
as well as URLs for NNTP newsgroup(s).