From: Corentin Chary <corentincj@iksaif.net>
To: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Corentin Chary <corentincj@iksaif.net>,
acpi4asus-user@lists.sourceforge.net (open list:ASUS NOTEBOOKS
AN...),
platform-driver-x86@vger.kernel.org (open list:ASUS NOTEBOOKS
AN...), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 08/14] asus-wmi: fix and clean backlight code
Date: Sat, 26 Feb 2011 10:20:37 +0100 [thread overview]
Message-ID: <1298712045-17671-9-git-send-email-corentincj@iksaif.net> (raw)
In-Reply-To: <1298712045-17671-1-git-send-email-corentincj@iksaif.net>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/asus-wmi.c | 44 +++++++++++++++++++++++++-------------
1 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index fd5b08ee..adf7b05 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -765,9 +765,8 @@ static int read_backlight_power(struct asus_wmi *asus)
return ret ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
}
-static int read_brightness(struct backlight_device *bd)
+static int read_brightness_max(struct asus_wmi *asus)
{
- struct asus_wmi *asus = bl_get_data(bd);
u32 retval;
int err;
@@ -776,6 +775,25 @@ static int read_brightness(struct backlight_device *bd)
if (err < 0)
return err;
+ retval = retval & ASUS_WMI_DSTS_MAX_BRIGTH_MASK;
+ retval >>= 8;
+
+ if (!retval)
+ return -ENODEV;
+
+ return retval;
+}
+
+static int read_brightness(struct backlight_device *bd)
+{
+ struct asus_wmi *asus = bl_get_data(bd);
+ u32 retval, err;
+
+ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_BRIGHTNESS, &retval);
+
+ if (err < 0)
+ return err;
+
return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK;
}
@@ -799,7 +817,7 @@ static int update_bl_status(struct backlight_device *bd)
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT,
ctrl_param, NULL);
}
- return 0;
+ return err;
}
static const struct backlight_ops asus_wmi_bl_ops = {
@@ -832,23 +850,19 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus)
int max;
int power;
- max = asus_wmi_get_devstate_bits(asus, ASUS_WMI_DEVID_BRIGHTNESS,
- ASUS_WMI_DSTS_MAX_BRIGTH_MASK);
- power = read_backlight_power(asus);
+ max = read_brightness_max(asus);
- if (max < 0 && power < 0) {
- /* Try to keep the original error */
- if (max == -ENODEV && power == -ENODEV)
- return -ENODEV;
- if (max != -ENODEV)
- return max;
- else
- return power;
- }
if (max == -ENODEV)
max = 0;
+ else if (max < 0)
+ return max;
+
+ power = read_backlight_power(asus);
+
if (power == -ENODEV)
power = FB_BLANK_UNBLANK;
+ else if (power < 0)
+ return power;
memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = max;
--
1.7.4
next prev parent reply other threads:[~2011-02-26 9:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-26 9:20 [PATCH 00/14] Support Asus WMI capable Notebooks (asus-wmi, asus-nb-wmi and eeepc-wmi) Corentin Chary
2011-02-26 9:20 ` [PATCH 01/14] asus-wmi: move generic code to asus-wmi Corentin Chary
2011-02-26 9:20 ` [PATCH 02/14] eeepc-wmi: asus generic asus-wmi.ko module Corentin Chary
2011-02-26 9:20 ` [PATCH 03/14] asus-wmi: minor cleanups Corentin Chary
2011-02-26 9:20 ` [PATCH 04/14] asus-wmi: introduce struct asus_rfkill Corentin Chary
2011-02-26 9:20 ` [PATCH 05/14] asus-wmi: handle "unknown status" bit Corentin Chary
2011-02-26 9:20 ` [PATCH 06/14] asus-wmi: factorise wmi_evaluate_method call Corentin Chary
2011-02-26 9:20 ` [PATCH 07/14] asus-wmi: try to guess the right DSTS methods Corentin Chary
2011-02-26 9:20 ` Corentin Chary [this message]
2011-02-26 9:20 ` [PATCH 09/14] asus-wmi: add calls to INIT, SPEC and SFUN on init Corentin Chary
2011-02-26 9:20 ` [PATCH 10/14] asus-wmi: allow debugfs interface to call arbitrary method Corentin Chary
2011-02-26 9:20 ` [PATCH 11/14] asus-nb-wmi: Asus Notebooks WMI Driver Corentin Chary
2011-02-26 9:20 ` [PATCH 12/14] asus-wmi: add some common device ids and method ids Corentin Chary
2011-02-26 9:20 ` [PATCH 13/14] asus-wmi: add hwmon interface and pwm1 Corentin Chary
2011-02-26 9:20 ` [PATCH 14/14] eeepc-wmi: restore KEY_CAMERA_* keys lost in 190ca27 Corentin Chary
2011-03-11 17:29 ` [PATCH 00/14] Support Asus WMI capable Notebooks (asus-wmi, asus-nb-wmi and eeepc-wmi) Matthew Garrett
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=1298712045-17671-9-git-send-email-corentincj@iksaif.net \
--to=corentincj@iksaif.net \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
/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
all inboxes | Powered by JetHome®