All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard backlight on
@ 2009-08-22 21:33 ` Henrik Rydberg
  0 siblings, 0 replies; 8+ messages in thread
From: Henrik Rydberg @ 2009-08-22 21:33 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nicolas, lm-sensors, linux-kernel, Henrik Rydberg

On resume from suspend, the driver currently resets the logical
state as if it was brought up from halt. This patch uses the
dev_pm_ops.resume method to synchronize the hardware with the
memorized logical state, bringing back the backlight to the level
prior to suspend.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
 drivers/hwmon/applesmc.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 678e34b..0b781c8 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -178,6 +178,8 @@ static const int debug;
 static struct platform_device *pdev;
 static s16 rest_x;
 static s16 rest_y;
+static u8 backlight_state[2];
+
 static struct device *hwmon_dev;
 static struct input_polled_dev *applesmc_idev;
 
@@ -497,17 +499,25 @@ static int applesmc_probe(struct platform_device *dev)
 	return 0;
 }
 
-static int applesmc_resume(struct platform_device *dev)
+/* Synchronize device with memorized backlight state */
+static int applesmc_pm_resume(struct device *dev)
 {
-	return applesmc_device_init();
+	mutex_lock(&applesmc_lock);
+	applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2);
+	mutex_unlock(&applesmc_lock);
+	return 0;
 }
 
+static struct dev_pm_ops applesmc_pm_ops = {
+	.resume = applesmc_pm_resume,
+};
+
 static struct platform_driver applesmc_driver = {
 	.probe = applesmc_probe,
-	.resume = applesmc_resume,
 	.driver	= {
 		.name = "applesmc",
 		.owner = THIS_MODULE,
+		.pm = &applesmc_pm_ops,
 	},
 };
 
@@ -804,17 +814,10 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
 	return count;
 }
 
-/* Store the next backlight value to be written by the work */
-static unsigned int backlight_value;
-
 static void applesmc_backlight_set(struct work_struct *work)
 {
-	u8 buffer[2];
-
 	mutex_lock(&applesmc_lock);
-	buffer[0] = backlight_value;
-	buffer[1] = 0x00;
-	applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
+	applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2);
 	mutex_unlock(&applesmc_lock);
 }
 static DECLARE_WORK(backlight_work, &applesmc_backlight_set);
@@ -824,7 +827,7 @@ static void applesmc_brightness_set(struct led_classdev *led_cdev,
 {
 	int ret;
 
-	backlight_value = value;
+	backlight_state[0] = value;
 	ret = queue_work(applesmc_led_wq, &backlight_work);
 
 	if (debug && (!ret))
-- 
1.6.3.3


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] hwmon: applesmc: restore keyboard backlight on resume
@ 2009-08-22 21:33 ` Henrik Rydberg
  0 siblings, 0 replies; 8+ messages in thread
From: Henrik Rydberg @ 2009-08-22 21:33 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nicolas, lm-sensors, linux-kernel, Henrik Rydberg

On resume from suspend, the driver currently resets the logical
state as if it was brought up from halt. This patch uses the
dev_pm_ops.resume method to synchronize the hardware with the
memorized logical state, bringing back the backlight to the level
prior to suspend.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
 drivers/hwmon/applesmc.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 678e34b..0b781c8 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -178,6 +178,8 @@ static const int debug;
 static struct platform_device *pdev;
 static s16 rest_x;
 static s16 rest_y;
+static u8 backlight_state[2];
+
 static struct device *hwmon_dev;
 static struct input_polled_dev *applesmc_idev;
 
@@ -497,17 +499,25 @@ static int applesmc_probe(struct platform_device *dev)
 	return 0;
 }
 
-static int applesmc_resume(struct platform_device *dev)
+/* Synchronize device with memorized backlight state */
+static int applesmc_pm_resume(struct device *dev)
 {
-	return applesmc_device_init();
+	mutex_lock(&applesmc_lock);
+	applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2);
+	mutex_unlock(&applesmc_lock);
+	return 0;
 }
 
+static struct dev_pm_ops applesmc_pm_ops = {
+	.resume = applesmc_pm_resume,
+};
+
 static struct platform_driver applesmc_driver = {
 	.probe = applesmc_probe,
-	.resume = applesmc_resume,
 	.driver	= {
 		.name = "applesmc",
 		.owner = THIS_MODULE,
+		.pm = &applesmc_pm_ops,
 	},
 };
 
@@ -804,17 +814,10 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
 	return count;
 }
 
-/* Store the next backlight value to be written by the work */
-static unsigned int backlight_value;
-
 static void applesmc_backlight_set(struct work_struct *work)
 {
-	u8 buffer[2];
-
 	mutex_lock(&applesmc_lock);
-	buffer[0] = backlight_value;
-	buffer[1] = 0x00;
-	applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
+	applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2);
 	mutex_unlock(&applesmc_lock);
 }
 static DECLARE_WORK(backlight_work, &applesmc_backlight_set);
@@ -824,7 +827,7 @@ static void applesmc_brightness_set(struct led_classdev *led_cdev,
 {
 	int ret;
 
-	backlight_value = value;
+	backlight_state[0] = value;
 	ret = queue_work(applesmc_led_wq, &backlight_work);
 
 	if (debug && (!ret))
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard
  2009-08-22 21:33 ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Henrik Rydberg
@ 2009-08-24 21:07   ` Andrew Morton
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2009-08-24 21:07 UTC (permalink / raw)
  To: Henrik Rydberg; +Cc: nicolas, lm-sensors, linux-kernel, rydberg

On Sat, 22 Aug 2009 23:33:52 +0200
"Henrik Rydberg" <rydberg@euromail.se> wrote:

> On resume from suspend, the driver currently resets the logical
> state as if it was brought up from halt. This patch uses the
> dev_pm_ops.resume method to synchronize the hardware with the
> memorized logical state, bringing back the backlight to the level
> prior to suspend.

What are the runtime effects of this change?

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hwmon: applesmc: restore keyboard backlight on resume
@ 2009-08-24 21:07   ` Andrew Morton
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2009-08-24 21:07 UTC (permalink / raw)
  To: Henrik Rydberg; +Cc: nicolas, lm-sensors, linux-kernel, rydberg

On Sat, 22 Aug 2009 23:33:52 +0200
"Henrik Rydberg" <rydberg@euromail.se> wrote:

> On resume from suspend, the driver currently resets the logical
> state as if it was brought up from halt. This patch uses the
> dev_pm_ops.resume method to synchronize the hardware with the
> memorized logical state, bringing back the backlight to the level
> prior to suspend.

What are the runtime effects of this change?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard
  2009-08-24 21:07   ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Andrew Morton
@ 2009-08-24 21:49     ` Henrik Rydberg
  -1 siblings, 0 replies; 8+ messages in thread
From: Henrik Rydberg @ 2009-08-24 21:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nicolas, lm-sensors, linux-kernel

Andrew Morton wrote:
> On Sat, 22 Aug 2009 23:33:52 +0200
> "Henrik Rydberg" <rydberg@euromail.se> wrote:
> 
>> On resume from suspend, the driver currently resets the logical
>> state as if it was brought up from halt. This patch uses the
>> dev_pm_ops.resume method to synchronize the hardware with the
>> memorized logical state, bringing back the backlight to the level
>> prior to suspend.
> 
> What are the runtime effects of this change?

The patch has zero impact on a running system, only suspend/resume
behavior is affected.

Precondition: Suspend computer with keyboard backlight brightness
greater than zero.

Before patch: On resume, the backlight stays off.

After patch: On resume, the backlight is set to the brightness prior to
suspend.

There is one side-effect of the patch: the accelerometer no longer
re-calibrates on resume, but keeps the calibration from before suspend.
I consider this a good change, but it is after all a change.

Henrik


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hwmon: applesmc: restore keyboard backlight on resume
@ 2009-08-24 21:49     ` Henrik Rydberg
  0 siblings, 0 replies; 8+ messages in thread
From: Henrik Rydberg @ 2009-08-24 21:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nicolas, lm-sensors, linux-kernel

Andrew Morton wrote:
> On Sat, 22 Aug 2009 23:33:52 +0200
> "Henrik Rydberg" <rydberg@euromail.se> wrote:
> 
>> On resume from suspend, the driver currently resets the logical
>> state as if it was brought up from halt. This patch uses the
>> dev_pm_ops.resume method to synchronize the hardware with the
>> memorized logical state, bringing back the backlight to the level
>> prior to suspend.
> 
> What are the runtime effects of this change?

The patch has zero impact on a running system, only suspend/resume
behavior is affected.

Precondition: Suspend computer with keyboard backlight brightness
greater than zero.

Before patch: On resume, the backlight stays off.

After patch: On resume, the backlight is set to the brightness prior to
suspend.

There is one side-effect of the patch: the accelerometer no longer
re-calibrates on resume, but keeps the calibration from before suspend.
I consider this a good change, but it is after all a change.

Henrik


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard
  2009-08-24 21:07   ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Andrew Morton
@ 2009-08-24 23:37     ` Henrik Rydberg
  -1 siblings, 0 replies; 8+ messages in thread
From: Henrik Rydberg @ 2009-08-24 23:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Henrik Rydberg, nicolas, lm-sensors, linux-kernel

Andrew Morton wrote:
> On Sat, 22 Aug 2009 23:33:52 +0200
> "Henrik Rydberg" <rydberg@euromail.se> wrote:
> 
>> On resume from suspend, the driver currently resets the logical
>> state as if it was brought up from halt. This patch uses the
>> dev_pm_ops.resume method to synchronize the hardware with the
>> memorized logical state, bringing back the backlight to the level
>> prior to suspend.
> 
> What are the runtime effects of this change?
> 

My apologies, the patch has two flaws.

1) For macbook models without keyboard backlight, the resume function
will fail internally, presumably resulting in a small unnecessary delay.

2) The accelerometer does not reset properly after hibernation.

Please drop this patch from -mm, I am sending a corrected patch
with a slightly different title. Sorry about this.

Henrik

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hwmon: applesmc: restore keyboard backlight on resume
@ 2009-08-24 23:37     ` Henrik Rydberg
  0 siblings, 0 replies; 8+ messages in thread
From: Henrik Rydberg @ 2009-08-24 23:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Henrik Rydberg, nicolas, lm-sensors, linux-kernel

Andrew Morton wrote:
> On Sat, 22 Aug 2009 23:33:52 +0200
> "Henrik Rydberg" <rydberg@euromail.se> wrote:
> 
>> On resume from suspend, the driver currently resets the logical
>> state as if it was brought up from halt. This patch uses the
>> dev_pm_ops.resume method to synchronize the hardware with the
>> memorized logical state, bringing back the backlight to the level
>> prior to suspend.
> 
> What are the runtime effects of this change?
> 

My apologies, the patch has two flaws.

1) For macbook models without keyboard backlight, the resume function
will fail internally, presumably resulting in a small unnecessary delay.

2) The accelerometer does not reset properly after hibernation.

Please drop this patch from -mm, I am sending a corrected patch
with a slightly different title. Sorry about this.

Henrik

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-08-24 23:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-22 21:33 [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard backlight on Henrik Rydberg
2009-08-22 21:33 ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Henrik Rydberg
2009-08-24 21:07 ` [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard Andrew Morton
2009-08-24 21:07   ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Andrew Morton
2009-08-24 21:49   ` [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard Henrik Rydberg
2009-08-24 21:49     ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Henrik Rydberg
2009-08-24 23:37   ` [lm-sensors] [PATCH] hwmon: applesmc: restore keyboard Henrik Rydberg
2009-08-24 23:37     ` [PATCH] hwmon: applesmc: restore keyboard backlight on resume Henrik Rydberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.