public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: "K, Mythri P" <mythripk@ti.com>
Cc: linux-omap@vger.kernel.org
Subject: Re: [PATCH 3/4] OMAPDSS: HDMI: change the timing match logic
Date: Fri, 18 Nov 2011 09:16:15 +0200	[thread overview]
Message-ID: <1321600575.1814.14.camel@deskari> (raw)
In-Reply-To: <CAP5A+B_8fm7unbvb9_=SC62v=3+XFcoOKKA2JOttQugRTPLW8g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2036 bytes --]

On Wed, 2011-11-16 at 11:01 +0530, K, Mythri P wrote:
> On Mon, Nov 14, 2011 at 1:03 PM, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> > On Fri, 2011-11-11 at 18:39 +0530, mythripk@ti.com wrote:

> >> -static int get_timings_index(void)
> >> +static bool hdmi_find_code(const struct hdmi_config *timings_arr,
> >> +                     int len, struct hdmi_config *timing)
> >>  {
> >> -     int code;
> >> +     int i;
> >>
> >> -     if (hdmi.mode == 0)
> >> -             code = code_vesa[hdmi.code];
> >> -     else
> >> -             code = code_cea[hdmi.code];
> >> +     for (i = 0; i < len; i++) {
> >> +             if (timings_arr[i].cm.code == hdmi.code) {
> >> +                     *timing = timings_arr[i];
> >> +                     return true;
> >> +             }
> >> +     }
> >> +
> >> +     return false;
> >> +}
> >
> > You could return the hdmi_config pointer instead of making a copy and
> > returning a bool.
> In this function i'm passing the timing value and finally there needs
> to be one copy whether it is in this function or after the return,
> because the timings array is a const and dssdev->paneltimings and
> config timings are not, so do you see any benefit of doing that later
> or suggest any other method?

Well, I think it's just good design, even if it wouldn't help in this
particular case.

hdmi_find_code is a small utility function, and functions like that
should be designed to be usable in any situation. In this particular
situation you will anyway make a copy, and it doesn't matter if it's the
utility function that does the copy.

But in some other case you could perhaps be interested in only one value
in the hdmi_config that is found. In that case doing a copy is extra,
and it'd be better to return the const struct pointer.

Also, it is a standard design pattern that a "find" function returns
pointer to the found item, whereas your version returning a bool and
making a copy of the found item is not very standard.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2011-11-18  7:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 13:09 [PATCH 0/4] OMAPDSS: HDMI: Improve the timings logic in HDMI mythripk
2011-11-11 13:09 ` [PATCH 1/4] OMAPDSS: HDMI: remove duplicate video interface code mythripk
2011-11-11 13:09   ` [PATCH 2/4] OMAPDSS: HDMI: update static timing table mythripk
2011-11-11 13:09     ` [PATCH 3/4] OMAPDSS: HDMI: change the timing match logic mythripk
2011-11-11 13:09       ` [PATCH 4/4] OMAPDSS: HDMI: remove duplicate code and mode parameter mythripk
2011-11-14  7:33       ` [PATCH 3/4] OMAPDSS: HDMI: change the timing match logic Tomi Valkeinen
2011-11-16  5:31         ` K, Mythri P
2011-11-18  7:16           ` Tomi Valkeinen [this message]
2011-11-22 13:08             ` K, Mythri P
2011-11-14  7:20     ` [PATCH 2/4] OMAPDSS: HDMI: update static timing table Tomi Valkeinen
2011-11-16  5:13       ` K, Mythri P

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=1321600575.1814.14.camel@deskari \
    --to=tomi.valkeinen@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=mythripk@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox