From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Richard Purdie <rpurdie@rpsys.net>,
"Milo(Woogyom) Kim" <milo.kim@ti.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 2/2] backlight: lp855x_bl: Small cleanups
Date: Thu, 02 Feb 2012 16:14:24 +0800 [thread overview]
Message-ID: <1328170464.11502.3.camel@phoenix> (raw)
In-Reply-To: <1328170333.11502.1.camel@phoenix>
This patch includes below cleanups:
- Make lp855x_bl_update_status() return 0 instead of bl->props.brightness.
It looks pointless to return bl->props.brightness for lp855x_bl_update_status.
Make it return 0 on success.
- Use devm_kzalloc to save a few error handling code.
- Use module_i2c_driver
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/video/backlight/lp855x_bl.c | 25 +++++--------------------
1 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 5ab9ec8..c337b7a 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -131,7 +131,7 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
lp855x_write_byte(lp, BRIGHTNESS_CTRL, val);
}
- return bl->props.brightness;
+ return 0;
}
static int lp855x_bl_get_brightness(struct backlight_device *bl)
@@ -241,7 +241,7 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
return -EIO;
- lp = kzalloc(sizeof(struct lp855x), GFP_KERNEL);
+ lp = devm_kzalloc(&cl->dev, sizeof(struct lp855x), GFP_KERNEL);
if (!lp)
return -ENOMEM;
@@ -275,14 +275,11 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
}
backlight_update_status(lp->bl);
- return ret;
+ return 0;
-err_dev:
- kfree(lp);
- return ret;
err_sysfs:
lp855x_backlight_unregister(lp);
- kfree(lp);
+err_dev:
return ret;
}
@@ -294,7 +291,6 @@ static int __devexit lp855x_remove(struct i2c_client *cl)
backlight_update_status(lp->bl);
sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
lp855x_backlight_unregister(lp);
- kfree(lp);
return 0;
}
@@ -318,18 +314,7 @@ static struct i2c_driver lp855x_driver = {
.id_table = lp855x_ids,
};
-static int __init lp855x_init(void)
-{
- return i2c_add_driver(&lp855x_driver);
-}
-
-static void __exit lp855x_exit(void)
-{
- i2c_del_driver(&lp855x_driver);
-}
-
-module_init(lp855x_init);
-module_exit(lp855x_exit);
+module_i2c_driver(lp855x_driver);
MODULE_DESCRIPTION("Texas Instruments LP855x Backlight driver");
MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>");
--
1.7.5.4
prev parent reply other threads:[~2012-02-02 8:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 8:12 [PATCH 1/2] backlight: lp855x_bl: Checking platform data in lp855x_probe Axel Lin
2012-02-02 8:14 ` Axel Lin [this message]
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=1328170464.11502.3.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=milo.kim@ti.com \
--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;
as well as URLs for NNTP newsgroup(s).