mirror of https://gitee.com/openkylin/linux.git
- Call put_device() instead of kfree() - core
- Add DT support - gpio-backlight - Use managed resources - lm3639_bl -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAABAgAGBQJTRTU4AAoJEFGvii+H/HdhAe8QAK9E9DwDMItv0HNCtbEe/FUd SU4cXvZXaBe+Zr0xc7qA4Z71PCdrf7R9UfGay7DikuO47BzQ5idwGSjcSyyg7IJL QHjkjGIRea1JuYMCXcFjBUsnsXBcb4E5masYijcOwuKMewnlwwTteDN8czEkAKN7 aKTEHcTWcJkVl7HcFiKn+QoqXvnPb7EXGCB//dug3jbo/F9xQ3Zn6zpNbc1fm9Ge rgsy0mg4idxqWj0hcnmIvKBFbmzpwwSJHGZfQcpwCB/T4fCf+bHm07DUhub54biA n8/EwFaGkFZ58QjwRcnkcKw2zzTd2OnyB9CtuZY3ByEysknQMEvazZcqaRyoXZIa 09qiFanYD4WblUJtK9ArCc8iiYTstYYzVf42G7Hb4Zb313vJgeisYTPh5PBB5Y1x 9LdF4YCFnGyqbtAHG7P600l++2ogjqpbU/NugqYaSPgugPEjit5zePxepHVehDvY CNkEgfkq0WlkmcTI1CgKqsJphslGkY3KsWgcSadCpf21tLOhtu7r1bNzartVrbR9 THr+I60c4++z0/r/BYEvdnviLUX+nBd1zeH4KQ6aFTJYQ9S/tv/OTGTU2cirDSL6 mq37nd1Ky4tjXGJBZOjJLJAGB5S645YCOlgCQ7lBvMnN2jCawgCrY16FN3JadpOm dizYOK7hDq0WDpmMioKY =qva8 -----END PGP SIGNATURE----- Merge tag 'backlight-for-linus-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight Pull backlight changes from Lee Jones: - core: call put_device() instead of kfree() - gpio-backlight: add DT support - lm3639_bl driver: use managed resources * tag 'backlight-for-linus-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: backlight: lm3639: Use devm_backlight_device_register() backlight: gpio-backlight: Add DT support backlight: core: Replace kfree with put_device
This commit is contained in:
commit
edf2377c47
|
@ -0,0 +1,16 @@
|
|||
gpio-backlight bindings
|
||||
|
||||
Required properties:
|
||||
- compatible: "gpio-backlight"
|
||||
- gpios: describes the gpio that is used for enabling/disabling the backlight.
|
||||
refer to bindings/gpio/gpio.txt for more details.
|
||||
|
||||
Optional properties:
|
||||
- default-on: enable the backlight at boot.
|
||||
|
||||
Example:
|
||||
backlight {
|
||||
compatible = "gpio-backlight";
|
||||
gpios = <&gpio3 4 GPIO_ACTIVE_HIGH>;
|
||||
default-on;
|
||||
};
|
|
@ -347,7 +347,7 @@ struct backlight_device *backlight_device_register(const char *name,
|
|||
|
||||
rc = device_register(&new_bd->dev);
|
||||
if (rc) {
|
||||
kfree(new_bd);
|
||||
put_device(&new_bd->dev);
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/platform_data/gpio_backlight.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
@ -23,6 +25,7 @@ struct gpio_backlight {
|
|||
|
||||
int gpio;
|
||||
int active;
|
||||
int def_value;
|
||||
};
|
||||
|
||||
static int gpio_backlight_update_status(struct backlight_device *bl)
|
||||
|
@ -60,6 +63,29 @@ static const struct backlight_ops gpio_backlight_ops = {
|
|||
.check_fb = gpio_backlight_check_fb,
|
||||
};
|
||||
|
||||
static int gpio_backlight_probe_dt(struct platform_device *pdev,
|
||||
struct gpio_backlight *gbl)
|
||||
{
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
enum of_gpio_flags gpio_flags;
|
||||
|
||||
gbl->gpio = of_get_gpio_flags(np, 0, &gpio_flags);
|
||||
|
||||
if (!gpio_is_valid(gbl->gpio)) {
|
||||
if (gbl->gpio != -EPROBE_DEFER) {
|
||||
dev_err(&pdev->dev,
|
||||
"Error: The gpios parameter is missing or invalid.\n");
|
||||
}
|
||||
return gbl->gpio;
|
||||
}
|
||||
|
||||
gbl->active = (gpio_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
|
||||
|
||||
gbl->def_value = of_property_read_bool(np, "default-on");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_backlight_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct gpio_backlight_platform_data *pdata =
|
||||
|
@ -67,10 +93,12 @@ static int gpio_backlight_probe(struct platform_device *pdev)
|
|||
struct backlight_properties props;
|
||||
struct backlight_device *bl;
|
||||
struct gpio_backlight *gbl;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
int ret;
|
||||
|
||||
if (!pdata) {
|
||||
dev_err(&pdev->dev, "failed to find platform data\n");
|
||||
if (!pdata && !np) {
|
||||
dev_err(&pdev->dev,
|
||||
"failed to find platform data or device tree node.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -79,14 +107,22 @@ static int gpio_backlight_probe(struct platform_device *pdev)
|
|||
return -ENOMEM;
|
||||
|
||||
gbl->dev = &pdev->dev;
|
||||
gbl->fbdev = pdata->fbdev;
|
||||
gbl->gpio = pdata->gpio;
|
||||
gbl->active = pdata->active_low ? 0 : 1;
|
||||
|
||||
if (np) {
|
||||
ret = gpio_backlight_probe_dt(pdev, gbl);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
gbl->fbdev = pdata->fbdev;
|
||||
gbl->gpio = pdata->gpio;
|
||||
gbl->active = pdata->active_low ? 0 : 1;
|
||||
gbl->def_value = pdata->def_value;
|
||||
}
|
||||
|
||||
ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT |
|
||||
(gbl->active ? GPIOF_INIT_LOW
|
||||
: GPIOF_INIT_HIGH),
|
||||
pdata->name);
|
||||
pdata ? pdata->name : "backlight");
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "unable to request GPIO\n");
|
||||
return ret;
|
||||
|
@ -103,17 +139,25 @@ static int gpio_backlight_probe(struct platform_device *pdev)
|
|||
return PTR_ERR(bl);
|
||||
}
|
||||
|
||||
bl->props.brightness = pdata->def_value;
|
||||
bl->props.brightness = gbl->def_value;
|
||||
backlight_update_status(bl);
|
||||
|
||||
platform_set_drvdata(pdev, bl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static struct of_device_id gpio_backlight_of_match[] = {
|
||||
{ .compatible = "gpio-backlight" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct platform_driver gpio_backlight_driver = {
|
||||
.driver = {
|
||||
.name = "gpio-backlight",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(gpio_backlight_of_match),
|
||||
},
|
||||
.probe = gpio_backlight_probe,
|
||||
};
|
||||
|
|
|
@ -349,8 +349,9 @@ static int lm3639_probe(struct i2c_client *client,
|
|||
props.brightness = pdata->init_brt_led;
|
||||
props.max_brightness = pdata->max_brt_led;
|
||||
pchip->bled =
|
||||
backlight_device_register("lm3639_bled", pchip->dev, pchip,
|
||||
&lm3639_bled_ops, &props);
|
||||
devm_backlight_device_register(pchip->dev, "lm3639_bled",
|
||||
pchip->dev, pchip, &lm3639_bled_ops,
|
||||
&props);
|
||||
if (IS_ERR(pchip->bled)) {
|
||||
dev_err(&client->dev, "fail : backlight register\n");
|
||||
ret = PTR_ERR(pchip->bled);
|
||||
|
@ -360,7 +361,7 @@ static int lm3639_probe(struct i2c_client *client,
|
|||
ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "failed : add sysfs entries\n");
|
||||
goto err_bled_mode;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
/* flash */
|
||||
|
@ -391,8 +392,6 @@ static int lm3639_probe(struct i2c_client *client,
|
|||
led_classdev_unregister(&pchip->cdev_flash);
|
||||
err_flash:
|
||||
device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode);
|
||||
err_bled_mode:
|
||||
backlight_device_unregister(pchip->bled);
|
||||
err_out:
|
||||
return ret;
|
||||
}
|
||||
|
@ -407,10 +406,8 @@ static int lm3639_remove(struct i2c_client *client)
|
|||
led_classdev_unregister(&pchip->cdev_torch);
|
||||
if (&pchip->cdev_flash)
|
||||
led_classdev_unregister(&pchip->cdev_flash);
|
||||
if (pchip->bled) {
|
||||
if (pchip->bled)
|
||||
device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode);
|
||||
backlight_device_unregister(pchip->bled);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -432,6 +429,6 @@ static struct i2c_driver lm3639_i2c_driver = {
|
|||
module_i2c_driver(lm3639_i2c_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Texas Instruments Backlight+Flash LED driver for LM3639");
|
||||
MODULE_AUTHOR("Daniel Jeong <daniel.jeong@ti.com>");
|
||||
MODULE_AUTHOR("G.Shark Jeong <gshark.jeong@gmail.com>");
|
||||
MODULE_AUTHOR("Daniel Jeong <gshark.jeong@gmail.com>");
|
||||
MODULE_AUTHOR("Ldd Mlp <ldd-mlp@list.ti.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
Loading…
Reference in New Issue