mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] backlight: ams369fg06: use sleep instead of delay
@ 2012-12-20  6:28 Jingoo Han
  2012-12-20  6:29 ` [PATCH 2/5] backlight: ams369fg06: remove unnecessary NULL deference check Jingoo Han
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jingoo Han @ 2012-12-20  6:28 UTC (permalink / raw)
  To: 'Andrew Morton', 'LKML'
  Cc: 'Richard Purdie', 'Jingoo Han'

This patch replaces mdelay with msleep to remove the busy loop
waiting.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/backlight/ams369fg06.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index f57e190..55b2792 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -210,8 +210,9 @@ static int ams369fg06_panel_send_sequence(struct ams369fg06 *lcd,
 			ret = ams369fg06_spi_write(lcd, wbuf[i], wbuf[i+1]);
 			if (ret)
 				break;
-		} else
-			mdelay(wbuf[i+1]);
+		} else {
+			msleep(wbuf[i+1]);
+		}
 		i += 2;
 	}
 
@@ -339,7 +340,7 @@ static int ams369fg06_power_on(struct ams369fg06 *lcd)
 		return -EFAULT;
 	} else {
 		pd->power_on(lcd->ld, 1);
-		mdelay(pd->power_on_delay);
+		msleep(pd->power_on_delay);
 	}
 
 	if (!pd->reset) {
@@ -347,7 +348,7 @@ static int ams369fg06_power_on(struct ams369fg06 *lcd)
 		return -EFAULT;
 	} else {
 		pd->reset(lcd->ld);
-		mdelay(pd->reset_delay);
+		msleep(pd->reset_delay);
 	}
 
 	ret = ams369fg06_ldi_init(lcd);
@@ -389,7 +390,7 @@ static int ams369fg06_power_off(struct ams369fg06 *lcd)
 		return -EIO;
 	}
 
-	mdelay(pd->power_off_delay);
+	msleep(pd->power_off_delay);
 
 	if (!pd->power_on) {
 		dev_err(lcd->dev, "power_on is NULL.\n");
-- 
1.7.2.5



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

* [PATCH 2/5] backlight: ams369fg06: remove unnecessary NULL deference check
  2012-12-20  6:28 [PATCH 1/5] backlight: ams369fg06: use sleep instead of delay Jingoo Han
@ 2012-12-20  6:29 ` Jingoo Han
  2012-12-20  6:29 ` [PATCH 3/5] backlight: ams369fg06: replace EFAULT with EINVAL Jingoo Han
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jingoo Han @ 2012-12-20  6:29 UTC (permalink / raw)
  To: 'Andrew Morton', 'LKML'
  Cc: 'Richard Purdie', 'Jingoo Han'

This patch removes unnecessary NULL deference check, because
it was already checked in ams369fg06_probe(). Also, unnecessary
parentheses are removed in ams369fg06_power_is_on().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/backlight/ams369fg06.c |   32 ++++++++------------------------
 1 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index 55b2792..b4bf130 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -314,26 +314,17 @@ static int ams369fg06_ldi_disable(struct ams369fg06 *lcd)
 
 static int ams369fg06_power_is_on(int power)
 {
-	return ((power) <= FB_BLANK_NORMAL);
+	return power <= FB_BLANK_NORMAL;
 }
 
 static int ams369fg06_power_on(struct ams369fg06 *lcd)
 {
 	int ret = 0;
-	struct lcd_platform_data *pd = NULL;
-	struct backlight_device *bd = NULL;
+	struct lcd_platform_data *pd;
+	struct backlight_device *bd;
 
 	pd = lcd->lcd_pd;
-	if (!pd) {
-		dev_err(lcd->dev, "platform data is NULL.\n");
-		return -EFAULT;
-	}
-
 	bd = lcd->bd;
-	if (!bd) {
-		dev_err(lcd->dev, "backlight device is NULL.\n");
-		return -EFAULT;
-	}
 
 	if (!pd->power_on) {
 		dev_err(lcd->dev, "power_on is NULL.\n");
@@ -375,14 +366,10 @@ static int ams369fg06_power_on(struct ams369fg06 *lcd)
 
 static int ams369fg06_power_off(struct ams369fg06 *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 = ams369fg06_ldi_disable(lcd);
 	if (ret) {
@@ -392,11 +379,7 @@ static int ams369fg06_power_off(struct ams369fg06 *lcd)
 
 	msleep(pd->power_off_delay);
 
-	if (!pd->power_on) {
-		dev_err(lcd->dev, "power_on is NULL.\n");
-		return -EFAULT;
-	} else
-		pd->power_on(lcd->ld, 0);
+	pd->power_on(lcd->ld, 0);
 
 	return 0;
 }
@@ -535,8 +518,9 @@ static int ams369fg06_probe(struct spi_device *spi)
 		lcd->power = FB_BLANK_POWERDOWN;
 
 		ams369fg06_power(lcd, FB_BLANK_UNBLANK);
-	} else
+	} else {
 		lcd->power = FB_BLANK_UNBLANK;
+	}
 
 	dev_set_drvdata(&spi->dev, lcd);
 
-- 
1.7.2.5



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

* [PATCH 3/5] backlight: ams369fg06: replace EFAULT with EINVAL
  2012-12-20  6:28 [PATCH 1/5] backlight: ams369fg06: use sleep instead of delay Jingoo Han
  2012-12-20  6:29 ` [PATCH 2/5] backlight: ams369fg06: remove unnecessary NULL deference check Jingoo Han
@ 2012-12-20  6:29 ` Jingoo Han
  2012-12-20  6:30 ` [PATCH 4/5] backlight: ams369fg06: remove redundant variable 'before_power' Jingoo Han
  2012-12-20  6:31 ` [PATCH 5/5] backlight: ams369fg06: reorder inclusions of <linux/xxx.h> Jingoo Han
  3 siblings, 0 replies; 5+ messages in thread
From: Jingoo Han @ 2012-12-20  6:29 UTC (permalink / raw)
  To: 'Andrew Morton', 'LKML'
  Cc: 'Richard Purdie', 'Jingoo Han'

This patch replaces EFAULT with EINVAL, because EFAULT tends to be
for the invalid memory addresses.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/backlight/ams369fg06.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index b4bf130..22756dd 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -328,7 +328,7 @@ static int ams369fg06_power_on(struct ams369fg06 *lcd)
 
 	if (!pd->power_on) {
 		dev_err(lcd->dev, "power_on is NULL.\n");
-		return -EFAULT;
+		return -EINVAL;
 	} else {
 		pd->power_on(lcd->ld, 1);
 		msleep(pd->power_on_delay);
@@ -336,7 +336,7 @@ static int ams369fg06_power_on(struct ams369fg06 *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);
@@ -485,7 +485,7 @@ static int ams369fg06_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;
 	}
 
 	ld = lcd_device_register("ams369fg06", &spi->dev, lcd,
-- 
1.7.2.5



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

* [PATCH 4/5] backlight: ams369fg06: remove redundant variable 'before_power'
  2012-12-20  6:28 [PATCH 1/5] backlight: ams369fg06: use sleep instead of delay Jingoo Han
  2012-12-20  6:29 ` [PATCH 2/5] backlight: ams369fg06: remove unnecessary NULL deference check Jingoo Han
  2012-12-20  6:29 ` [PATCH 3/5] backlight: ams369fg06: replace EFAULT with EINVAL Jingoo Han
@ 2012-12-20  6:30 ` Jingoo Han
  2012-12-20  6:31 ` [PATCH 5/5] backlight: ams369fg06: reorder inclusions of <linux/xxx.h> Jingoo Han
  3 siblings, 0 replies; 5+ messages in thread
From: Jingoo Han @ 2012-12-20  6:30 UTC (permalink / raw)
  To: 'Andrew Morton', 'LKML'
  Cc: 'Richard Purdie', 'Jingoo Han'

'before_power' was used to check the previous status when resume()
is called. However, FB_BLANK_POWERDOWN was used in suspend() all
the time, so there is no need to check the previous status.
Also, redundant return variables are removed to reduce the code.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/backlight/ams369fg06.c |   24 +++---------------------
 1 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index 22756dd..4794a9a 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -545,44 +545,26 @@ static int ams369fg06_remove(struct spi_device *spi)
 }
 
 #if defined(CONFIG_PM)
-static unsigned int before_power;
-
 static int ams369fg06_suspend(struct spi_device *spi, pm_message_t mesg)
 {
-	int ret = 0;
 	struct ams369fg06 *lcd = dev_get_drvdata(&spi->dev);
 
 	dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power);
 
-	before_power = lcd->power;
-
 	/*
 	 * when lcd panel is suspend, lcd panel becomes off
 	 * regardless of status.
 	 */
-	ret = ams369fg06_power(lcd, FB_BLANK_POWERDOWN);
-
-	return ret;
+	return ams369fg06_power(lcd, FB_BLANK_POWERDOWN);
 }
 
 static int ams369fg06_resume(struct spi_device *spi)
 {
-	int ret = 0;
 	struct ams369fg06 *lcd = dev_get_drvdata(&spi->dev);
 
-	/*
-	 * after suspended, if lcd panel status is FB_BLANK_UNBLANK
-	 * (at that time, before_power is FB_BLANK_UNBLANK) then
-	 * it changes that status to FB_BLANK_POWERDOWN to get lcd on.
-	 */
-	if (before_power == FB_BLANK_UNBLANK)
-		lcd->power = FB_BLANK_POWERDOWN;
+	lcd->power = FB_BLANK_POWERDOWN;
 
-	dev_dbg(&spi->dev, "before_power = %d\n", before_power);
-
-	ret = ams369fg06_power(lcd, before_power);
-
-	return ret;
+	return ams369fg06_power(lcd, FB_BLANK_UNBLANK);
 }
 #else
 #define ams369fg06_suspend	NULL
-- 
1.7.2.5



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

* [PATCH 5/5] backlight: ams369fg06: reorder inclusions of <linux/xxx.h>
  2012-12-20  6:28 [PATCH 1/5] backlight: ams369fg06: use sleep instead of delay Jingoo Han
                   ` (2 preceding siblings ...)
  2012-12-20  6:30 ` [PATCH 4/5] backlight: ams369fg06: remove redundant variable 'before_power' Jingoo Han
@ 2012-12-20  6:31 ` Jingoo Han
  3 siblings, 0 replies; 5+ messages in thread
From: Jingoo Han @ 2012-12-20  6:31 UTC (permalink / raw)
  To: 'Andrew Morton', 'LKML'
  Cc: 'Richard Purdie', 'Jingoo Han'

This patch reorders inclusions of <linux/xxx.h> for redability,
according to alphabetical ordering. Also, unnecessary header
comments are removed.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/backlight/ams369fg06.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index 4794a9a..72d71e0 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -10,25 +10,16 @@
  * 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/module.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/lcd.h>
-#include <linux/backlight.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/wait.h>
 
 #define SLEEPMSEC		0x1000
 #define ENDDEF			0x2000
-- 
1.7.2.5



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

end of thread, other threads:[~2012-12-20  6:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-20  6:28 [PATCH 1/5] backlight: ams369fg06: use sleep instead of delay Jingoo Han
2012-12-20  6:29 ` [PATCH 2/5] backlight: ams369fg06: remove unnecessary NULL deference check Jingoo Han
2012-12-20  6:29 ` [PATCH 3/5] backlight: ams369fg06: replace EFAULT with EINVAL Jingoo Han
2012-12-20  6:30 ` [PATCH 4/5] backlight: ams369fg06: remove redundant variable 'before_power' Jingoo Han
2012-12-20  6:31 ` [PATCH 5/5] backlight: ams369fg06: reorder inclusions of <linux/xxx.h> Jingoo Han

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®