linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seth Forshee <seth.forshee@canonical.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-kernel@vger.kernel.org, Richard Purdie <rpurdie@rpsys.net>,
	Matthew Garrett <mjg@redhat.com>
Subject: Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support
Date: Fri, 3 Feb 2012 16:51:23 -0600	[thread overview]
Message-ID: <20120203225123.GD22758@ubuntu-macmini> (raw)
In-Reply-To: <4F2C5EC8.8090203@metafoo.de>

On Fri, Feb 03, 2012 at 11:25:12PM +0100, Lars-Peter Clausen wrote:
> On 02/03/2012 09:28 PM, Seth Forshee wrote:
> > Make it easier to support backlights without a fixed I/O range, and
> > remove use of global variables to allow having multiple backlights
> > concurrently.
> > 
> > Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
> > ---
> >  drivers/video/backlight/apple_bl.c |  163 +++++++++++++++++++-----------------
> >  1 files changed, 85 insertions(+), 78 deletions(-)
> > 
> > diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
> > index 66d5bec..e65b459 100644
> > --- a/drivers/video/backlight/apple_bl.c
> > +++ b/drivers/video/backlight/apple_bl.c
> > @@ -27,39 +27,30 @@
> >  #include <linux/pci.h>
> >  #include <linux/acpi.h>
> > [...]
> > + */
> > +static int apple_bl_get_brightness(struct backlight_device *bd)
> > +{
> > +	struct apple_bl_data *bl_data = bl_get_data(bd);
> > +	return bl_data->get_brightness(bl_data);
> > +}
> > +
> > +static int apple_bl_update_status(struct backlight_device *bd)
> > +{
> > +	struct apple_bl_data *bl_data = bl_get_data(bd);
> > +
> > +	bl_data->set_brightness(bl_data, bd->props.brightness);
> > +	return 0;
> > +}
> > +
> > +static const struct backlight_ops apple_bl_ops = {
> > +	.get_brightness = apple_bl_get_brightness,
> > +	.update_status = apple_bl_update_status,
> >  };
> 
> Adding this extra indirection here isn't so nice and isn't necessary either.
> Just define one set of backlight ops for the intel case and one for the nvidia
> case and use it accordingly when registering the backlight device.

There's a reason for the extra level of indirection to be there. The
driver uses {get,set}_brightness before the backlight device has been
allocated to test whether or not the backlight interface actually works.
This worked okay previously because the functions didn't need any extra
data; they just access fixed port addresses (really it only half-worked,
the update_status actually already has this indirection to support the
test, duplicated for each interface). But for the gmux backlight we're
getting the I/O address range from ACPI, so it needs to get at the data.

Of course there are a couple of ways we could get around this. Not
calling the backlight ops in the gmux case would be an option; then you
don't get the check, but so far as I know right now the check doesn't
work for the gmux backlight anyway. Or allocating the backlight device
first before doing the check, but I don't see that as a good option.

I feel like what I've done is the cleanest way to accommodate the test,
and the extra level of indirection really isn't all that bad imho.

Seth

  reply	other threads:[~2012-02-03 22:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 20:28 [PATCH 0/3] apple_bl: Add support for gmux backlight control Seth Forshee
2012-02-03 20:28 ` [PATCH 1/3] apple_bl: Convert printks to pr_<level> Seth Forshee
2012-02-03 20:39   ` Joe Perches
2012-02-05 23:23   ` Ryan Mallon
2012-02-06 14:35     ` Seth Forshee
2012-02-06 21:47       ` Ryan Mallon
2012-02-03 20:28 ` [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support Seth Forshee
2012-02-03 22:25   ` Lars-Peter Clausen
2012-02-03 22:51     ` Seth Forshee [this message]
2012-02-04 17:25       ` Lars-Peter Clausen
2012-02-06 14:56         ` Seth Forshee
2012-02-09 17:20           ` Seth Forshee
2012-02-10  9:25             ` Lars-Peter Clausen
2012-02-10 14:50               ` Seth Forshee
2012-02-03 20:28 ` [PATCH 3/3] apple_bl: Add support for gmux backlight control Seth Forshee

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=20120203225123.GD22758@ubuntu-macmini \
    --to=seth.forshee@canonical.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --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).