Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+75 -18
+16
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt
··· 1 + gpio-backlight bindings 2 + 3 + Required properties: 4 + - compatible: "gpio-backlight" 5 + - gpios: describes the gpio that is used for enabling/disabling the backlight. 6 + refer to bindings/gpio/gpio.txt for more details. 7 + 8 + Optional properties: 9 + - default-on: enable the backlight at boot. 10 + 11 + Example: 12 + backlight { 13 + compatible = "gpio-backlight"; 14 + gpios = <&gpio3 4 GPIO_ACTIVE_HIGH>; 15 + default-on; 16 + };
+1 -1
drivers/video/backlight/backlight.c
··· 347 347 348 348 rc = device_register(&new_bd->dev); 349 349 if (rc) { 350 - kfree(new_bd); 350 + put_device(&new_bd->dev); 351 351 return ERR_PTR(rc); 352 352 } 353 353
+51 -7
drivers/video/backlight/gpio_backlight.c
··· 13 13 #include <linux/init.h> 14 14 #include <linux/kernel.h> 15 15 #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/of_gpio.h> 16 18 #include <linux/platform_data/gpio_backlight.h> 17 19 #include <linux/platform_device.h> 18 20 #include <linux/slab.h> ··· 25 23 26 24 int gpio; 27 25 int active; 26 + int def_value; 28 27 }; 29 28 30 29 static int gpio_backlight_update_status(struct backlight_device *bl) ··· 63 60 .check_fb = gpio_backlight_check_fb, 64 61 }; 65 62 63 + static int gpio_backlight_probe_dt(struct platform_device *pdev, 64 + struct gpio_backlight *gbl) 65 + { 66 + struct device_node *np = pdev->dev.of_node; 67 + enum of_gpio_flags gpio_flags; 68 + 69 + gbl->gpio = of_get_gpio_flags(np, 0, &gpio_flags); 70 + 71 + if (!gpio_is_valid(gbl->gpio)) { 72 + if (gbl->gpio != -EPROBE_DEFER) { 73 + dev_err(&pdev->dev, 74 + "Error: The gpios parameter is missing or invalid.\n"); 75 + } 76 + return gbl->gpio; 77 + } 78 + 79 + gbl->active = (gpio_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1; 80 + 81 + gbl->def_value = of_property_read_bool(np, "default-on"); 82 + 83 + return 0; 84 + } 85 + 66 86 static int gpio_backlight_probe(struct platform_device *pdev) 67 87 { 68 88 struct gpio_backlight_platform_data *pdata = ··· 93 67 struct backlight_properties props; 94 68 struct backlight_device *bl; 95 69 struct gpio_backlight *gbl; 70 + struct device_node *np = pdev->dev.of_node; 96 71 int ret; 97 72 98 - if (!pdata) { 99 - dev_err(&pdev->dev, "failed to find platform data\n"); 73 + if (!pdata && !np) { 74 + dev_err(&pdev->dev, 75 + "failed to find platform data or device tree node.\n"); 100 76 return -ENODEV; 101 77 } 102 78 ··· 107 79 return -ENOMEM; 108 80 109 81 gbl->dev = &pdev->dev; 110 - gbl->fbdev = pdata->fbdev; 111 - gbl->gpio = pdata->gpio; 112 - gbl->active = pdata->active_low ? 0 : 1; 82 + 83 + if (np) { 84 + ret = gpio_backlight_probe_dt(pdev, gbl); 85 + if (ret) 86 + return ret; 87 + } else { 88 + gbl->fbdev = pdata->fbdev; 89 + gbl->gpio = pdata->gpio; 90 + gbl->active = pdata->active_low ? 0 : 1; 91 + gbl->def_value = pdata->def_value; 92 + } 113 93 114 94 ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT | 115 95 (gbl->active ? GPIOF_INIT_LOW 116 96 : GPIOF_INIT_HIGH), 117 - pdata->name); 97 + pdata ? pdata->name : "backlight"); 118 98 if (ret < 0) { 119 99 dev_err(&pdev->dev, "unable to request GPIO\n"); 120 100 return ret; ··· 139 103 return PTR_ERR(bl); 140 104 } 141 105 142 - bl->props.brightness = pdata->def_value; 106 + bl->props.brightness = gbl->def_value; 143 107 backlight_update_status(bl); 144 108 145 109 platform_set_drvdata(pdev, bl); 146 110 return 0; 147 111 } 148 112 113 + #ifdef CONFIG_OF 114 + static struct of_device_id gpio_backlight_of_match[] = { 115 + { .compatible = "gpio-backlight" }, 116 + { /* sentinel */ } 117 + }; 118 + #endif 119 + 149 120 static struct platform_driver gpio_backlight_driver = { 150 121 .driver = { 151 122 .name = "gpio-backlight", 152 123 .owner = THIS_MODULE, 124 + .of_match_table = of_match_ptr(gpio_backlight_of_match), 153 125 }, 154 126 .probe = gpio_backlight_probe, 155 127 };
+7 -10
drivers/video/backlight/lm3639_bl.c
··· 349 349 props.brightness = pdata->init_brt_led; 350 350 props.max_brightness = pdata->max_brt_led; 351 351 pchip->bled = 352 - backlight_device_register("lm3639_bled", pchip->dev, pchip, 353 - &lm3639_bled_ops, &props); 352 + devm_backlight_device_register(pchip->dev, "lm3639_bled", 353 + pchip->dev, pchip, &lm3639_bled_ops, 354 + &props); 354 355 if (IS_ERR(pchip->bled)) { 355 356 dev_err(&client->dev, "fail : backlight register\n"); 356 357 ret = PTR_ERR(pchip->bled); ··· 361 360 ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode); 362 361 if (ret < 0) { 363 362 dev_err(&client->dev, "failed : add sysfs entries\n"); 364 - goto err_bled_mode; 363 + goto err_out; 365 364 } 366 365 367 366 /* flash */ ··· 392 391 led_classdev_unregister(&pchip->cdev_flash); 393 392 err_flash: 394 393 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); 395 - err_bled_mode: 396 - backlight_device_unregister(pchip->bled); 397 394 err_out: 398 395 return ret; 399 396 } ··· 406 407 led_classdev_unregister(&pchip->cdev_torch); 407 408 if (&pchip->cdev_flash) 408 409 led_classdev_unregister(&pchip->cdev_flash); 409 - if (pchip->bled) { 410 + if (pchip->bled) 410 411 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); 411 - backlight_device_unregister(pchip->bled); 412 - } 413 412 return 0; 414 413 } 415 414 ··· 429 432 module_i2c_driver(lm3639_i2c_driver); 430 433 431 434 MODULE_DESCRIPTION("Texas Instruments Backlight+Flash LED driver for LM3639"); 432 - MODULE_AUTHOR("Daniel Jeong <daniel.jeong@ti.com>"); 433 - MODULE_AUTHOR("G.Shark Jeong <gshark.jeong@gmail.com>"); 435 + MODULE_AUTHOR("Daniel Jeong <gshark.jeong@gmail.com>"); 436 + MODULE_AUTHOR("Ldd Mlp <ldd-mlp@list.ti.com>"); 434 437 MODULE_LICENSE("GPL v2");