From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752601Ab1ITQTA (ORCPT ); Tue, 20 Sep 2011 12:19:00 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37210 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576Ab1ITQS5 (ORCPT ); Tue, 20 Sep 2011 12:18:57 -0400 X-Mailbox-Line: From gregkh@clark.kroah.org Tue Sep 20 09:17:35 2011 Message-Id: <20110920161735.789648948@clark.kroah.org> User-Agent: quilt/0.48-16.4 Date: Tue, 20 Sep 2011 09:16:11 -0700 From: Greg KH To: Matthew Garrett , Greg KH Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Stubbs , stable Subject: [patch 4/8] platform: samsung_laptop: fix samsung brightness min/max calculations In-Reply-To: <20110920161743.GA32737@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Stubbs 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 Cc: stable Signed-off-by: Greg Kroah-Hartman --- 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);