All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: m-karicheri2@ti.com
Cc: linux-media@vger.kernel.org, khilman@deeprootsystems.com,
	nsekhar@ti.com, hvaibhav@ti.com,
	davinci-linux-open-source@linux.davincidsp.com
Subject: Re: [PATCH - v1 4/6] V4L - vpfe_capture bug fix and enhancements
Date: Tue, 15 Dec 2009 22:20:41 +0100	[thread overview]
Message-ID: <200912152220.41459.hverkuil@xs4all.nl> (raw)
In-Reply-To: <200912152205.25491.hverkuil@xs4all.nl>

Note that the other patches from this series are fine as far as I am concerned.

One general note: I always have difficulties with constructions like this:

> +                     val = (bc->horz.win_count_calc &
> +                             ISIF_HORZ_BC_WIN_COUNT_MASK) |
> +                             ((!!bc->horz.base_win_sel_calc) <<
> +                             ISIF_HORZ_BC_WIN_SEL_SHIFT) |
> +                             ((!!bc->horz.clamp_pix_limit) <<
> +                             ISIF_HORZ_BC_PIX_LIMIT_SHIFT) |
> +                             ((bc->horz.win_h_sz_calc &
> +                             ISIF_HORZ_BC_WIN_H_SIZE_MASK) <<
> +                             ISIF_HORZ_BC_WIN_H_SIZE_SHIFT) |
> +                             ((bc->horz.win_v_sz_calc &
> +                             ISIF_HORZ_BC_WIN_V_SIZE_MASK) <<
> +                             ISIF_HORZ_BC_WIN_V_SIZE_SHIFT);

It's just about impossible for me to parse. And some of the patches in this
series are full of such constructs.

Unfortunately, I do not have a magic bullet solution. In some cases I suspect
that a static inline function can help.

In other cases it might help to split it up in smaller parts. For example:

u32 tmp;

val = bc->horz.win_count_calc &
	ISIF_HORZ_BC_WIN_COUNT_MASK;
val |= !!bc->horz.base_win_sel_calc <<
	ISIF_HORZ_BC_WIN_SEL_SHIFT;
val |= !!bc->horz.clamp_pix_limit <<
	ISIF_HORZ_BC_PIX_LIMIT_SHIFT;
tmp = bc->horz.win_h_sz_calc &
	ISIF_HORZ_BC_WIN_H_SIZE_MASK;
val |= tmp << ISIF_HORZ_BC_WIN_H_SIZE_SHIFT;
tmp = bc->horz.win_v_sz_calc &
	ISIF_HORZ_BC_WIN_V_SIZE_MASK;
val |= tmp << ISIF_HORZ_BC_WIN_V_SIZE_SHIFT;

Of course, in this particular piece of code from the function isif_config_bclamp()
I am also wondering why bc->horz.win_h_sz_calc and bc->horz.win_v_sz_calc need to
be ANDed anyway. I would expect that to happen when these values are set. But I
did not look at this in-depth, so I may well have missed some subtlety here.

It would be interesting to know if people know of good ways of making awkward
code like this more elegant (or at least less awkward).

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG

  reply	other threads:[~2009-12-15 21:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10 17:00 [PATCH - v1 6/6] DaVinci - Adding support for vpfe capture on DM365 m-karicheri2
2009-12-10 17:00 ` [PATCH - v1 2/6] V4L - vpfe capture - Adding DM365 ISIF driver - header files m-karicheri2
2009-12-10 17:00   ` [PATCH - v1 3/6] V4L-vpfe-capture-Adding ISIF driver for DM365 - source m-karicheri2
2009-12-10 17:00     ` [PATCH - v1 1/6] V4L - vpfe-capture : DM365 vpss enhancements m-karicheri2
2009-12-10 17:00       ` [PATCH - v1 5/6] V4L - vpfe capture - build environment for ISIF driver m-karicheri2
2009-12-10 17:00         ` [PATCH - v1 4/6] V4L - vpfe_capture bug fix and enhancements m-karicheri2
2009-12-15 21:05           ` Hans Verkuil
2009-12-15 21:20             ` Hans Verkuil [this message]
2009-12-15 23:37               ` Karicheri, Muralidharan
2009-12-16  7:41                 ` Hans Verkuil
2009-12-16 16:45                   ` Karicheri, Muralidharan
2009-12-18  5:13                   ` Nori, Sekhar
2009-12-10 17:38         ` [PATCH - v1 5/6] V4L - vpfe capture - build environment for ISIF driver Sergei Shtylyov
2009-12-11 20:50           ` Karicheri, Muralidharan
2009-12-15  7:57     ` [PATCH - v1 3/6] V4L-vpfe-capture-Adding ISIF driver for DM365 - source Hans Verkuil
2009-12-15  7:46   ` [PATCH - v1 2/6] V4L - vpfe capture - Adding DM365 ISIF driver - header files Hans Verkuil
2009-12-17 21:34     ` Karicheri, Muralidharan

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=200912152220.41459.hverkuil@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=hvaibhav@ti.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=nsekhar@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.