public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: rpurdie@rpsys.net
Cc: linux-acpi <linux-acpi@vger.kernel.org>,
	Len Brown <lenb@kernel.org>, "Zhang, Rui" <rui.zhang@intel.com>
Subject: [PATCH 2/2] video: mark "actual_brightness" deprecated
Date: Wed, 24 Dec 2008 11:07:41 +0800	[thread overview]
Message-ID: <1230088061.562.220.camel@rzhang-dt> (raw)

/sys/class/backlight/.../brightness returns a cached value,
which confuses a lot of users.

Make the "brightness" reflect the actual backlight levels,
and mark /sys/class/backlight/.../brightness as depreacated
in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/video/backlight/Kconfig     |   17 +++++++++++++++++
 drivers/video/backlight/backlight.c |   11 ++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/video/backlight/Kconfig
===================================================================
--- linux-2.6.orig/drivers/video/backlight/Kconfig
+++ linux-2.6/drivers/video/backlight/Kconfig
@@ -98,6 +98,23 @@ config BACKLIGHT_CLASS_DEVICE
 	  To have support for your specific LCD panel you will have to
 	  select the proper drivers which depend on this option.
 
+config BACKLIGHT_CLASS_DEVICE_LEGACY_INTERFACE
+	bool "Deprecated lowlevel Backlight control legacy sysfs I/F"
+	depends on BACKLIGHT_CLASS_DEVICE
+	default y
+	help
+	  "brightness" file used to return a cached brightness level.
+	  And users need to poke the "actual_brightness" to get the
+	  correct current backlight level.
+	  Now the "brightness" file always reflects the actual
+	  brightness and "actual_brightness" is superfluous.
+
+	  Some applications including X still use this file to get the current
+	  backlight level, thus we can not remove it immediately.
+
+	  Say N here if you're sure no application depends on the
+	  "actual_brightness" file.
+
 config BACKLIGHT_ATMEL_LCDC
 	bool "Atmel LCDC Contrast-as-Backlight control"
 	depends on BACKLIGHT_CLASS_DEVICE && FB_ATMEL
Index: linux-2.6/drivers/video/backlight/backlight.c
===================================================================
--- linux-2.6.orig/drivers/video/backlight/backlight.c
+++ linux-2.6/drivers/video/backlight/backlight.c
@@ -108,9 +108,14 @@ static ssize_t backlight_store_power(str
 static ssize_t backlight_show_brightness(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
+	int rc = -ENXIO;
 	struct backlight_device *bd = to_backlight_device(dev);
 
-	return sprintf(buf, "%d\n", bd->props.brightness);
+	mutex_lock(&bd->ops_lock);
+	if (bd->ops && bd->ops->get_brightness)
+		rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd));
+	mutex_unlock(&bd->ops_lock);
+	return rc;
 }
 
 static ssize_t backlight_store_brightness(struct device *dev,
@@ -152,6 +157,7 @@ static ssize_t backlight_show_max_bright
 	return sprintf(buf, "%d\n", bd->props.max_brightness);
 }
 
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE_LEGACY_INTERFACE
 static ssize_t backlight_show_actual_brightness(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
@@ -165,6 +171,7 @@ static ssize_t backlight_show_actual_bri
 
 	return rc;
 }
+#endif
 
 static struct class *backlight_class;
 
@@ -178,8 +185,10 @@ static struct device_attribute bl_device
 	__ATTR(bl_power, 0644, backlight_show_power, backlight_store_power),
 	__ATTR(brightness, 0644, backlight_show_brightness,
 		     backlight_store_brightness),
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE_LEGACY_INTERFACE
 	__ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
 		     NULL),
+#endif
 	__ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
 	__ATTR_NULL,
 };



             reply	other threads:[~2008-12-24  3:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-24  3:07 Zhang Rui [this message]
2008-12-30 10:37 ` [PATCH 2/2] video: mark "actual_brightness" deprecated Richard Purdie
2008-12-31  2:12   ` Zhang Rui
2008-12-31 13:32     ` Richard Purdie

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=1230088061.562.220.camel@rzhang-dt \
    --to=rui.zhang@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@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