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

Merge tag 'backlight-for-linus-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
- Stop using LP855X Platform Data to control regulators
- Move PWM8941 WLED driver into Backlight
- Remove invalid use of IS_ERR_VALUE() macro
- Remove duplicate check for NULL data before unregistering
- Export I2C Device ID structure

* tag 'backlight-for-linus-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
backlight: tosa: Export I2C module alias information
backlight: lp8788_bl: Delete a check before backlight_device_unregister()
backlight: sky81452: Remove unneeded use of IS_ERR_VALUE() macro
backlight: pm8941-wled: Move PM8941 WLED driver to backlight
backlight: lp855x: Use private data for regulator control

+62 -75
+1 -4
Documentation/devicetree/bindings/leds/leds-pm8941-wled.txt Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt
··· 5 5 - reg: slave address 6 6 7 7 Optional properties: 8 - - label: The label for this led 9 - See Documentation/devicetree/bindings/leds/common.txt 10 - - linux,default-trigger: Default trigger assigned to the LED 11 - See Documentation/devicetree/bindings/leds/common.txt 8 + - label: The name of the backlight device 12 9 - qcom,cs-out: bool; enable current sink output 13 10 - qcom,cabc: bool; enable content adaptive backlight control 14 11 - qcom,ext-gen: bool; use externally generated modulator signal to dim
-8
drivers/leds/Kconfig
··· 594 594 This option enabled support for the LEDs on the ARM Versatile 595 595 and RealView boards. Say Y to enabled these. 596 596 597 - config LEDS_PM8941_WLED 598 - tristate "LED support for the Qualcomm PM8941 WLED block" 599 - depends on LEDS_CLASS 600 - select REGMAP 601 - help 602 - This option enables support for the 'White' LED block 603 - on Qualcomm PM8941 PMICs. 604 - 605 597 comment "LED Triggers" 606 598 source "drivers/leds/trigger/Kconfig" 607 599
-1
drivers/leds/Makefile
··· 63 63 obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o 64 64 obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o 65 65 obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o 66 - obj-$(CONFIG_LEDS_PM8941_WLED) += leds-pm8941-wled.o 67 66 obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o 68 67 obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o 69 68
+26 -34
drivers/leds/leds-pm8941-wled.c drivers/video/backlight/pm8941-wled.c
··· 11 11 */ 12 12 13 13 #include <linux/kernel.h> 14 - #include <linux/leds.h> 14 + #include <linux/backlight.h> 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 17 #include <linux/of_device.h> ··· 76 76 }; 77 77 78 78 struct pm8941_wled { 79 + const char *name; 79 80 struct regmap *regmap; 80 81 u16 addr; 81 - 82 - struct led_classdev cdev; 83 82 84 83 struct pm8941_wled_config cfg; 85 84 }; 86 85 87 - static int pm8941_wled_set(struct led_classdev *cdev, 88 - enum led_brightness value) 86 + static int pm8941_wled_update_status(struct backlight_device *bl) 89 87 { 90 - struct pm8941_wled *wled; 88 + struct pm8941_wled *wled = bl_get_data(bl); 89 + u16 val = bl->props.brightness; 91 90 u8 ctrl = 0; 92 - u16 val; 93 91 int rc; 94 92 int i; 95 93 96 - wled = container_of(cdev, struct pm8941_wled, cdev); 94 + if (bl->props.power != FB_BLANK_UNBLANK || 95 + bl->props.fb_blank != FB_BLANK_UNBLANK || 96 + bl->props.state & BL_CORE_FBBLANK) 97 + val = 0; 97 98 98 - if (value != 0) 99 + if (val != 0) 99 100 ctrl = PM8941_WLED_REG_MOD_EN_BIT; 100 - 101 - val = value * PM8941_WLED_REG_VAL_MAX / LED_FULL; 102 101 103 102 rc = regmap_update_bits(wled->regmap, 104 103 wled->addr + PM8941_WLED_REG_MOD_EN, ··· 125 126 wled->addr + PM8941_WLED_REG_SYNC, 126 127 PM8941_WLED_REG_SYNC_MASK, PM8941_WLED_REG_SYNC_CLEAR); 127 128 return rc; 128 - } 129 - 130 - static void pm8941_wled_set_brightness(struct led_classdev *cdev, 131 - enum led_brightness value) 132 - { 133 - if (pm8941_wled_set(cdev, value)) { 134 - dev_err(cdev->dev, "Unable to set brightness\n"); 135 - return; 136 - } 137 - cdev->brightness = value; 138 129 } 139 130 140 131 static int pm8941_wled_setup(struct pm8941_wled *wled) ··· 325 336 } 326 337 wled->addr = val; 327 338 328 - rc = of_property_read_string(dev->of_node, "label", &wled->cdev.name); 339 + rc = of_property_read_string(dev->of_node, "label", &wled->name); 329 340 if (rc) 330 - wled->cdev.name = dev->of_node->name; 331 - 332 - wled->cdev.default_trigger = of_get_property(dev->of_node, 333 - "linux,default-trigger", NULL); 341 + wled->name = dev->of_node->name; 334 342 335 343 *cfg = pm8941_wled_config_defaults; 336 344 for (i = 0; i < ARRAY_SIZE(u32_opts); ++i) { ··· 363 377 return 0; 364 378 } 365 379 380 + static const struct backlight_ops pm8941_wled_ops = { 381 + .update_status = pm8941_wled_update_status, 382 + }; 383 + 366 384 static int pm8941_wled_probe(struct platform_device *pdev) 367 385 { 386 + struct backlight_properties props; 387 + struct backlight_device *bl; 368 388 struct pm8941_wled *wled; 369 389 struct regmap *regmap; 370 390 int rc; ··· 395 403 if (rc) 396 404 return rc; 397 405 398 - wled->cdev.brightness_set = pm8941_wled_set_brightness; 399 - 400 - rc = devm_led_classdev_register(&pdev->dev, &wled->cdev); 401 - if (rc) 402 - return rc; 403 - 404 - platform_set_drvdata(pdev, wled); 406 + memset(&props, 0, sizeof(struct backlight_properties)); 407 + props.type = BACKLIGHT_RAW; 408 + props.max_brightness = PM8941_WLED_REG_VAL_MAX; 409 + bl = devm_backlight_device_register(&pdev->dev, wled->name, 410 + &pdev->dev, wled, 411 + &pm8941_wled_ops, &props); 412 + if (IS_ERR(bl)) 413 + return PTR_ERR(bl); 405 414 406 415 return 0; 407 416 }; ··· 425 432 426 433 MODULE_DESCRIPTION("pm8941 wled driver"); 427 434 MODULE_LICENSE("GPL v2"); 428 - MODULE_ALIAS("platform:pm8941-wled");
+7
drivers/video/backlight/Kconfig
··· 299 299 If you have an Sharp SL-6000 Zaurus say Y to enable a driver 300 300 for its backlight 301 301 302 + config BACKLIGHT_PM8941_WLED 303 + tristate "Qualcomm PM8941 WLED Driver" 304 + select REGMAP 305 + help 306 + If you have the Qualcomm PM8941, say Y to enable a driver for the 307 + WLED block. 308 + 302 309 config BACKLIGHT_SAHARA 303 310 tristate "Tabletkiosk Sahara Touch-iT Backlight Driver" 304 311 depends on X86
+1
drivers/video/backlight/Makefile
··· 48 48 obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o 49 49 obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o 50 50 obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o 51 + obj-$(CONFIG_BACKLIGHT_PM8941_WLED) += pm8941-wled.o 51 52 obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 52 53 obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o 53 54 obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o
+12 -11
drivers/video/backlight/lp855x_bl.c
··· 73 73 struct device *dev; 74 74 struct lp855x_platform_data *pdata; 75 75 struct pwm_device *pwm; 76 + struct regulator *supply; /* regulator for VDD input */ 76 77 }; 77 78 78 79 static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data) ··· 379 378 pdata->rom_data = &rom[0]; 380 379 } 381 380 382 - pdata->supply = devm_regulator_get(dev, "power"); 383 - if (IS_ERR(pdata->supply)) { 384 - if (PTR_ERR(pdata->supply) == -EPROBE_DEFER) 385 - return -EPROBE_DEFER; 386 - pdata->supply = NULL; 387 - } 388 - 389 381 lp->pdata = pdata; 390 382 391 383 return 0; ··· 419 425 else 420 426 lp->mode = REGISTER_BASED; 421 427 422 - if (lp->pdata->supply) { 423 - ret = regulator_enable(lp->pdata->supply); 428 + lp->supply = devm_regulator_get(lp->dev, "power"); 429 + if (IS_ERR(lp->supply)) { 430 + if (PTR_ERR(lp->supply) == -EPROBE_DEFER) 431 + return -EPROBE_DEFER; 432 + lp->supply = NULL; 433 + } 434 + 435 + if (lp->supply) { 436 + ret = regulator_enable(lp->supply); 424 437 if (ret < 0) { 425 438 dev_err(&cl->dev, "failed to enable supply: %d\n", ret); 426 439 return ret; ··· 465 464 466 465 lp->bl->props.brightness = 0; 467 466 backlight_update_status(lp->bl); 468 - if (lp->pdata->supply) 469 - regulator_disable(lp->pdata->supply); 467 + if (lp->supply) 468 + regulator_disable(lp->supply); 470 469 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); 471 470 472 471 return 0;
+1 -2
drivers/video/backlight/lp8788_bl.c
··· 221 221 { 222 222 struct backlight_device *bl_dev = bl->bl_dev; 223 223 224 - if (bl_dev) 225 - backlight_device_unregister(bl_dev); 224 + backlight_device_unregister(bl_dev); 226 225 } 227 226 228 227 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
+13 -13
drivers/video/backlight/sky81452-backlight.c
··· 65 65 66 66 if (brightness > 0) { 67 67 ret = regmap_write(regmap, SKY81452_REG0, brightness - 1); 68 - if (IS_ERR_VALUE(ret)) 68 + if (ret < 0) 69 69 return ret; 70 70 71 71 return regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN, ··· 87 87 int ret; 88 88 89 89 ret = kstrtoul(buf, 16, &value); 90 - if (IS_ERR_VALUE(ret)) 90 + if (ret < 0) 91 91 return ret; 92 92 93 93 ret = regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN, 94 94 value << CTZ(SKY81452_EN)); 95 - if (IS_ERR_VALUE(ret)) 95 + if (ret < 0) 96 96 return ret; 97 97 98 98 return count; ··· 108 108 109 109 reg = !strcmp(attr->attr.name, "open") ? SKY81452_REG5 : SKY81452_REG4; 110 110 ret = regmap_read(regmap, reg, &value); 111 - if (IS_ERR_VALUE(ret)) 111 + if (ret < 0) 112 112 return ret; 113 113 114 114 if (value & SKY81452_SHRT) { ··· 136 136 int ret; 137 137 138 138 ret = regmap_read(regmap, SKY81452_REG4, &value); 139 - if (IS_ERR_VALUE(ret)) 139 + if (ret < 0) 140 140 return ret; 141 141 142 142 *buf = 0; ··· 196 196 pdata->gpio_enable = of_get_gpio(np, 0); 197 197 198 198 ret = of_property_count_u32_elems(np, "led-sources"); 199 - if (IS_ERR_VALUE(ret)) { 199 + if (ret < 0) { 200 200 pdata->enable = SKY81452_EN >> CTZ(SKY81452_EN); 201 201 } else { 202 202 num_entry = ret; ··· 205 205 206 206 ret = of_property_read_u32_array(np, "led-sources", sources, 207 207 num_entry); 208 - if (IS_ERR_VALUE(ret)) { 208 + if (ret < 0) { 209 209 dev_err(dev, "led-sources node is invalid.\n"); 210 210 return ERR_PTR(-EINVAL); 211 211 } ··· 218 218 ret = of_property_read_u32(np, 219 219 "skyworks,short-detection-threshold-volt", 220 220 &pdata->short_detection_threshold); 221 - if (IS_ERR_VALUE(ret)) 221 + if (ret < 0) 222 222 pdata->short_detection_threshold = 7; 223 223 224 224 ret = of_property_read_u32(np, "skyworks,current-limit-mA", 225 225 &pdata->boost_current_limit); 226 - if (IS_ERR_VALUE(ret)) 226 + if (ret < 0) 227 227 pdata->boost_current_limit = 2750; 228 228 229 229 of_node_put(np); ··· 278 278 if (gpio_is_valid(pdata->gpio_enable)) { 279 279 ret = devm_gpio_request_one(dev, pdata->gpio_enable, 280 280 GPIOF_OUT_INIT_HIGH, "sky81452-en"); 281 - if (IS_ERR_VALUE(ret)) { 281 + if (ret < 0) { 282 282 dev_err(dev, "failed to request GPIO. err=%d\n", ret); 283 283 return ret; 284 284 } 285 285 } 286 286 287 287 ret = sky81452_bl_init_device(regmap, pdata); 288 - if (IS_ERR_VALUE(ret)) { 288 + if (ret < 0) { 289 289 dev_err(dev, "failed to initialize. err=%d\n", ret); 290 290 return ret; 291 291 } ··· 302 302 303 303 platform_set_drvdata(pdev, bd); 304 304 305 - ret = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group); 306 - if (IS_ERR_VALUE(ret)) { 305 + ret = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group); 306 + if (ret < 0) { 307 307 dev_err(dev, "failed to create attribute. err=%d\n", ret); 308 308 return ret; 309 309 }
+1
drivers/video/backlight/tosa_bl.c
··· 158 158 { "tosa-bl", 0 }, 159 159 { }, 160 160 }; 161 + MODULE_DEVICE_TABLE(i2c, tosa_bl_id); 161 162 162 163 static struct i2c_driver tosa_bl_driver = { 163 164 .driver = {
-2
include/linux/platform_data/lp855x.h
··· 136 136 Only valid when mode is PWM_BASED. 137 137 * @size_program : total size of lp855x_rom_data 138 138 * @rom_data : list of new eeprom/eprom registers 139 - * @supply : regulator that supplies 3V input 140 139 */ 141 140 struct lp855x_platform_data { 142 141 const char *name; ··· 144 145 unsigned int period_ns; 145 146 int size_program; 146 147 struct lp855x_rom_data *rom_data; 147 - struct regulator *supply; 148 148 }; 149 149 150 150 #endif