mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: Matthew Garrett <mjg@redhat.com>, Greg KH <greg@kroah.com>
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Jason Stubbs <jasonbstubbs@gmail.com>, stable <stable@kernel.org>
Subject: [patch 4/8] platform: samsung_laptop: fix samsung brightness min/max calculations
Date: Tue, 20 Sep 2011 09:16:11 -0700	[thread overview]
Message-ID: <20110920161735.789648948@clark.kroah.org> (raw)
In-Reply-To: <20110920161743.GA32737@kroah.com>

From: Jason Stubbs <jasonbstubbs@gmail.com>

The min_brightness value of the sabi_config is incorrectly used in brightness
calculations. For the config where min_brightness = 1 and max_brightness = 8,
the user visible range should be 0 to 7 with hardware being set in the range
of 1 to 8. What is actually happening is that the user visible range is 0 to
8 with hardware being set in the range of -1 to 7.

This patch fixes the above issue as well as a miscalculation that would occur
in the case of min_brightness > 1.

Signed-off-by: Jason Stubbs <jasonbstubbs@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/platform/x86/samsung-laptop.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -370,15 +370,17 @@ static u8 read_brightness(void)
 				  &sretval);
 	if (!retval) {
 		user_brightness = sretval.retval[0];
-		if (user_brightness != 0)
+		if (user_brightness > sabi_config->min_brightness)
 			user_brightness -= sabi_config->min_brightness;
+		else
+			user_brightness = 0;
 	}
 	return user_brightness;
 }
 
 static void set_brightness(u8 user_brightness)
 {
-	u8 user_level = user_brightness - sabi_config->min_brightness;
+	u8 user_level = user_brightness + sabi_config->min_brightness;
 
 	sabi_set_command(sabi_config->commands.set_brightness, user_level);
 }
@@ -829,7 +831,8 @@ static int __init samsung_init(void)
 	/* create a backlight device to talk to this one */
 	memset(&props, 0, sizeof(struct backlight_properties));
 	props.type = BACKLIGHT_PLATFORM;
-	props.max_brightness = sabi_config->max_brightness;
+	props.max_brightness = sabi_config->max_brightness -
+				sabi_config->min_brightness;
 	backlight_device = backlight_device_register("samsung", &sdev->dev,
 						     NULL, &backlight_ops,
 						     &props);



  parent reply	other threads:[~2011-09-20 16:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20 16:17 [patch 0/8] Samsung Laptop driver patches - resend Greg KH
2011-09-20 16:16 ` [patch 1/8] platform: samsung_laptop: add dmi information for Samsung R700 laptops Greg KH
2011-09-20 16:16 ` [patch 2/8] Platform: samsung_laptop: add support for X520 machines Greg KH
2011-09-20 16:16 ` [patch 3/8] Platform: samsung_laptop: samsung backlight for R528/R728 Greg KH
2011-09-20 16:16 ` Greg KH [this message]
2011-09-20 16:16 ` [patch 5/8] Platform: Fix error path in samsung-laptop init Greg KH
2011-09-20 16:16 ` [patch 6/8] Platform: Brightness quirk for samsung laptop driver Greg KH
2011-09-20 16:16 ` [patch 7/8] Platform: Samsung laptop DMI info for NC210/NC110 Greg KH
2011-09-20 16:16 ` [patch 8/8] Platform: fix samsung-laptop DMI identification for N220 model Greg KH
2011-11-06 22:54 ` [patch 0/8] Samsung Laptop driver patches - resend Corentin Chary
2011-11-07 18:12   ` Greg KH
2011-11-07 22:57     ` Corentin Chary
2011-11-13  9:52       ` Corentin Chary
2011-11-13 15:58         ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2011-09-01 22:54 [patch 0/8] Samsung Laptop driver patches gregkh
2011-09-01 22:50 ` [patch 4/8] platform: samsung_laptop: fix samsung brightness min/max calculations gregkh

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=20110920161735.789648948@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=greg@kroah.com \
    --cc=jasonbstubbs@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stable@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®