From: Jingoo Han <jg1.han@samsung.com>
To: "'Andrew Morton'" <akpm@linux-foundation.org>,
"'LKML'" <linux-kernel@vger.kernel.org>
Cc: "'Richard Purdie'" <rpurdie@rpsys.net>,
"'Jingoo Han'" <jg1.han@samsung.com>
Subject: [PATCH 3/6] backlight: s6e63m0: remove unnecessary NULL deference check
Date: Thu, 20 Dec 2012 15:34:41 +0900 [thread overview]
Message-ID: <000b01cdde7c$175f3980$461dac80$%han@samsung.com> (raw)
In-Reply-To: <000901cdde7b$db4f6690$91ee33b0$%han@samsung.com>
This patch removes unnecessary NULL deference check, because it
was already checked in s6e63m0_probe(). Also, POWER_IS_ON is
replaced with s6e63m0_power_is_on().
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/backlight/s6e63m0.c | 41 ++++++++++++------------------------
1 files changed, 14 insertions(+), 27 deletions(-)
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index cff4515..633f0d3 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -43,8 +43,6 @@
#define MIN_BRIGHTNESS 0
#define MAX_BRIGHTNESS 10
-#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
-
struct s6e63m0 {
struct device *dev;
struct spi_device *spi;
@@ -501,23 +499,19 @@ static int s6e63m0_ldi_disable(struct s6e63m0 *lcd)
return ret;
}
+static int s6e63m0_power_is_on(int power)
+{
+ return power <= FB_BLANK_NORMAL;
+}
+
static int s6e63m0_power_on(struct s6e63m0 *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");
@@ -559,14 +553,10 @@ static int s6e63m0_power_on(struct s6e63m0 *lcd)
static int s6e63m0_power_off(struct s6e63m0 *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 = s6e63m0_ldi_disable(lcd);
if (ret) {
@@ -576,11 +566,7 @@ static int s6e63m0_power_off(struct s6e63m0 *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;
}
@@ -589,9 +575,9 @@ static int s6e63m0_power(struct s6e63m0 *lcd, int power)
{
int ret = 0;
- if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power))
+ if (s6e63m0_power_is_on(power) && !s6e63m0_power_is_on(lcd->power))
ret = s6e63m0_power_on(lcd);
- else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power))
+ else if (!s6e63m0_power_is_on(power) && s6e63m0_power_is_on(lcd->power))
ret = s6e63m0_power_off(lcd);
if (!ret)
@@ -812,8 +798,9 @@ static int s6e63m0_probe(struct spi_device *spi)
lcd->power = FB_BLANK_POWERDOWN;
s6e63m0_power(lcd, FB_BLANK_UNBLANK);
- } else
+ } else {
lcd->power = FB_BLANK_UNBLANK;
+ }
dev_set_drvdata(&spi->dev, lcd);
--
1.7.2.5
next prev parent reply other threads:[~2012-12-20 6:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-20 6:33 [PATCH 1/6] backlight: s6e63m0: use lowercase names of structs Jingoo Han
2012-12-20 6:33 ` [PATCH 2/6] backlight: s6e63m0: use sleep instead of delay Jingoo Han
2012-12-20 6:34 ` Jingoo Han [this message]
2012-12-20 6:35 ` [PATCH 4/6] backlight: s6e63m0: replace EFAULT with EINVAL Jingoo Han
2012-12-20 6:35 ` [PATCH 5/6] backlight: s6e63m0: remove redundant variable 'before_power' Jingoo Han
2012-12-20 6:36 ` [PATCH 6/6] backlight: s6e63m0: reorder inclusions of <linux/xxx.h> Jingoo Han
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='000b01cdde7c$175f3980$461dac80$%han@samsung.com' \
--to=jg1.han@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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®