linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Corentin Chary <corentin.chary@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Tobias Schandinat <FlorianSchandinat@gmx.de>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	platform-driver-x86@vger.kernel.org,
	patches@opensource.wolfsonmicro.com, Florian@freedesktop.org,
	Dave@freedesktop.org, Richard Purdie <rpurdie@rpsys.net>,
	linux-fbdev@vger.kernel.org, Lars-Peter@freedesktop.org,
	Airlie <airlied@redhat.com>, Axel Lin <axel.lin@gmail.com>,
	linux-omap@vger.kernel.org, Matthew Garrett <mjg@redhat.com>
Subject: Re: [PATCH] backlight: initialize  struct backlight_properties properly
Date: Tue, 22 May 2012 20:59:02 +0000	[thread overview]
Message-ID: <20120522135902.90253d07.akpm@linux-foundation.org> (raw)
In-Reply-To: <1337585085-4891-1-git-send-email-corentin.chary@gmail.com>

On Mon, 21 May 2012 09:24:35 +0200
Corentin Chary <corentin.chary@gmail.com> wrote:

> In all these files, the .power field was never correctly initialized.
> 
> ...
>
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -342,6 +342,7 @@ int intel_panel_setup_backlight(struct drm_device *dev)
>  	else
>  		return -ENODEV;
>  
> +	memset(&props, 0, sizeof(props));

This code is all still quite fragile.  What happens if we add a new
field to backlight_properties?  We need to go edit a zillion drivers?

There are two ways of fixing this:

a) write and use

void backlight_properties_init(struct backlight_properties *props,
				int type, int max_brightness, etc);

   or

b) edit all sites to do

	struct backlight_properties bl_props = {
		.type = BACKLIGHT_RAW,
		.max_brighness = intel_panel_get_max_backlight(dev),
		.power = FB_BLANK_UNBLANK,
	};

they're largely equivalent - the struct will be zeroed out and
then certain fields will be initialised.  a) is a bit better because
some future field may not want the all-zeroes pattern (eg, a spinlock).

But they're both better than what we have now!

      parent reply	other threads:[~2012-05-22 20:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21  7:24 [PATCH] backlight: initialize struct backlight_properties properly Corentin Chary
2012-05-22  0:07 ` Jingoo Han
2012-05-22  9:25 ` Dave Airlie
2012-05-22 20:59 ` Andrew Morton [this message]

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=20120522135902.90253d07.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Dave@freedesktop.org \
    --cc=Florian@freedesktop.org \
    --cc=FlorianSchandinat@gmx.de \
    --cc=Lars-Peter@freedesktop.org \
    --cc=airlied@redhat.com \
    --cc=arnd@arndb.de \
    --cc=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=corentin.chary@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mjg@redhat.com \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /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).