backlight: ld9040: use sleep instead of delay
Subsystems (2)
PATCH 1/5 backlight: ld9040: use sleep instead of delay
This patch replaces mdelay with msleep to remove the busy loop waiting.
--- drivers/video/backlight/ld9040.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/video/backlight/ld9040.c +7 -6
@@ -78,7 +78,7 @@ static void ld9040_regulator_enable(struct ld9040 *lcd) lcd->enabled = true; } -mdelay (pd->power_on_delay); +msleep (pd->power_on_delay); out:mutex_unlock (&lcd->lock); }
@@ -474,8 +474,9 @@ static int ld9040_panel_send_sequence(struct ld9040 *lcd, ret =ld9040_spi_write (lcd, wbuf[i], wbuf[i+1 ]);if (ret)break ; - }else -udelay (wbuf[i+1 ]*1000 ); + }else { +msleep (wbuf[i+1 ]); + } i +=2 ; }
@@ -539,7 +540,7 @@ static int ld9040_ldi_init(struct ld9040 *lcd)for (i =0 ; i <ARRAY_SIZE (init_seq); i++) { ret =ld9040_panel_send_sequence (lcd, init_seq[i]);/* workaround: minimum delay time for transferring CMD */ -udelay (300 ); +usleep_range (300 ,310 );if (ret)break ; }
@@ -584,7 +585,7 @@ static int ld9040_power_on(struct ld9040 *lcd)return -EFAULT ; }else { pd->reset (lcd->ld); -mdelay (pd->reset_delay); +msleep (pd->reset_delay); } ret =ld9040_ldi_init (lcd);
@@ -619,7 +620,7 @@ static int ld9040_power_off(struct ld9040 *lcd)return -EIO ; } -mdelay (pd->power_off_delay); +msleep (pd->power_off_delay);/* lcd power off */ ld9040_regulator_disable (lcd);
Signature · 1 line
1.7.2.5
PATCH 2/5 backlight: ld9040: remove unnecessary NULL deference check
This patch removes unnecessary NULL deference check, because it was already checked in ld9040_probe(). Also, power_is_on is replaced with ld9040_power_is_on().
--- drivers/video/backlight/ld9040.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-)
drivers/video/backlight/ld9040.c +13 -15
@@ -43,7 +43,6 @@#define MIN_BRIGHTNESS 0#define MAX_BRIGHTNESS 24 -#define power_is_on (pwr) ((pwr) <= FB_BLANK_NORMAL)struct ld9040 {struct device *dev;
@@ -567,15 +566,17 @@ static int ld9040_ldi_disable(struct ld9040 *lcd)return ret; } +static int ld9040_power_is_on (int power) +{ +return power <=FB_BLANK_NORMAL ; +} +static int ld9040_power_on (struct ld9040 *lcd) {int ret =0 ; -struct lcd_platform_data *pd =NULL ; +struct lcd_platform_data *pd; + pd = lcd->lcd_pd; -if (!pd) { -dev_err (lcd->dev,"platform data is NULL.\n" ); -return -EFAULT ; - }/* lcd power on */ ld9040_regulator_enable (lcd);
@@ -605,14 +606,10 @@ static int ld9040_power_on(struct ld9040 *lcd)static int ld9040_power_off (struct ld9040 *lcd) { -int ret =0 ; -struct lcd_platform_data *pd =NULL ; +int ret; +struct lcd_platform_data *pd; pd = lcd->lcd_pd; -if (!pd) { -dev_err (lcd->dev,"platform data is NULL.\n" ); -return -EFAULT ; - } ret =ld9040_ldi_disable (lcd);if (ret) {
@@ -632,9 +629,9 @@ static int ld9040_power(struct ld9040 *lcd, int power) {int ret =0 ; -if (power_is_on (power) && !power_is_on (lcd->power)) +if (ld9040_power_is_on (power) && !ld9040_power_is_on (lcd->power)) ret =ld9040_power_on (lcd); -else if (!power_is_on (power) &&power_is_on (lcd->power)) +else if (!ld9040_power_is_on (power) &&ld9040_power_is_on (lcd->power)) ret =ld9040_power_off (lcd);if (!ret)
@@ -773,8 +770,9 @@ static int ld9040_probe(struct spi_device *spi) lcd->power =FB_BLANK_POWERDOWN ;ld9040_power (lcd,FB_BLANK_UNBLANK ); - }else + }else { lcd->power =FB_BLANK_UNBLANK ; + }dev_set_drvdata (&spi->dev, lcd);
Signature · 1 line
1.7.2.5
PATCH 3/5 backlight: ld9040: replace EFAULT with EINVAL
In reply to Jingoo HanThis patch replaces EFAULT with EINVAL, because EFAULT tends to be for the invalid memory addresses.
--- drivers/video/backlight/ld9040.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/video/backlight/ld9040.c +2 -2
@@ -583,7 +583,7 @@ static int ld9040_power_on(struct ld9040 *lcd)if (!pd->reset) {dev_err (lcd->dev,"reset is NULL.\n" ); -return -EFAULT ; +return -EINVAL ; }else { pd->reset (lcd->ld);msleep (pd->reset_delay);
@@ -724,7 +724,7 @@ static int ld9040_probe(struct spi_device *spi) lcd->lcd_pd = spi->dev.platform_data;if (!lcd->lcd_pd) {dev_err (&spi->dev,"platform data is NULL.\n" ); -return -EFAULT ; +return -EINVAL ; }mutex_init (&lcd->lock);
Signature · 1 line
1.7.2.5
PATCH 4/5 backlight: ld9040: remove redundant return variables
In reply to Jingoo HanRedundant return variables are removed to reduce the code.
--- drivers/video/backlight/ld9040.c | 24 ++++-------------------- 1 files changed, 4 insertions(+), 20 deletions(-)
drivers/video/backlight/ld9040.c +4 -20
@@ -513,14 +513,9 @@ gamma_err:static int ld9040_gamma_ctl (struct ld9040 *lcd,int gamma) { -int ret =0 ; - - ret =_ld9040_gamma_ctl (lcd, gamma_table.gamma_22_table[gamma]); - -return ret; +return _ld9040_gamma_ctl (lcd, gamma_table.gamma_22_table[gamma]); } -static int ld9040_ldi_init (struct ld9040 *lcd) {int ret, i;
@@ -549,11 +544,7 @@ static int ld9040_ldi_init(struct ld9040 *lcd)static int ld9040_ldi_enable (struct ld9040 *lcd) { -int ret =0 ; - - ret =ld9040_panel_send_sequence (lcd, seq_display_on); - -return ret; +return ld9040_panel_send_sequence (lcd, seq_display_on); }static int ld9040_ldi_disable (struct ld9040 *lcd)
@@ -696,7 +687,6 @@ static const struct backlight_ops ld9040_backlight_ops = { .update_status = ld9040_set_brightness, }; -static int ld9040_probe (struct spi_device *spi) {int ret =0 ;
@@ -802,7 +792,6 @@ static int ld9040_remove(struct spi_device *spi)#if defined(CONFIG_PM )static int ld9040_suspend (struct spi_device *spi,pm_message_t mesg) { -int ret =0 ;struct ld9040 *lcd =dev_get_drvdata (&spi->dev);dev_dbg (&spi->dev,"lcd->power = %d\n" , lcd->power);
@@ -811,21 +800,16 @@ static int ld9040_suspend(struct spi_device *spi, pm_message_t mesg)* when lcd panel is suspend, lcd panel becomes off * regardless of status. */ - ret =ld9040_power (lcd,FB_BLANK_POWERDOWN ); - - return ret; + return ld9040_power(lcd, FB_BLANK_POWERDOWN); }static int ld9040_resume (struct spi_device *spi) { -int ret =0 ;struct ld9040 *lcd =dev_get_drvdata (&spi->dev); lcd->power =FB_BLANK_POWERDOWN ; - ret =ld9040_power (lcd,FB_BLANK_UNBLANK ); - -return ret; +return ld9040_power (lcd,FB_BLANK_UNBLANK ); }#else #define ld9040_suspend NULL
Signature · 1 line
1.7.2.5
PATCH 5/5 backlight: ld9040: reorder inclusions of <linux/xxx.h>
In reply to Jingoo HanThis patch reorders inclusions of <linux/xxx.h> for redability, according to alphabetical ordering. Also, unnecessary header comments are removed.
--- drivers/video/backlight/ld9040.c | 19 +++++-------------- 1 files changed, 5 insertions(+), 14 deletions(-)
drivers/video/backlight/ld9040.c +5 -14
@@ -9,29 +9,20 @@* under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, write to the Free Software Foundation, Inc., -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <linux/wait.h> -#include <linux/fb.h> +#include <linux/backlight.h> #include <linux/delay.h> +#include <linux/fb.h> #include <linux/gpio.h> -#include <linux/spi/spi.h> -#include <linux/irq.h> #include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/kernel.h> #include <linux/lcd.h> -#include <linux/backlight.h> #include <linux/module.h> #include <linux/regulator/consumer.h> +#include <linux/spi/spi.h> +#include <linux/wait.h> #include "ld9040_gamma.h"
Signature · 1 line
1.7.2.5