| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * TI LP8860 4-Channel LED Driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2014 Texas Instruments |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Author: Dan Murphy <dmurphy@ti.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License |
|---|
| 10 | | - * version 2 as published by the Free Software Foundation. |
|---|
| 11 | | - * |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | |
|---|
| 14 | 10 | #include <linux/i2c.h> |
|---|
| .. | .. |
|---|
| 22 | 18 | #include <linux/of_gpio.h> |
|---|
| 23 | 19 | #include <linux/gpio/consumer.h> |
|---|
| 24 | 20 | #include <linux/slab.h> |
|---|
| 25 | | -#include <uapi/linux/uleds.h> |
|---|
| 26 | 21 | |
|---|
| 27 | 22 | #define LP8860_DISP_CL1_BRT_MSB 0x00 |
|---|
| 28 | 23 | #define LP8860_DISP_CL1_BRT_LSB 0x01 |
|---|
| .. | .. |
|---|
| 87 | 82 | |
|---|
| 88 | 83 | #define LP8860_CLEAR_FAULTS 0x01 |
|---|
| 89 | 84 | |
|---|
| 85 | +#define LP8860_NAME "lp8860" |
|---|
| 86 | + |
|---|
| 90 | 87 | /** |
|---|
| 91 | 88 | * struct lp8860_led - |
|---|
| 92 | 89 | * @lock - Lock for reading/writing the device |
|---|
| .. | .. |
|---|
| 96 | 93 | * @eeprom_regmap - EEPROM register map |
|---|
| 97 | 94 | * @enable_gpio - VDDIO/EN gpio to enable communication interface |
|---|
| 98 | 95 | * @regulator - LED supply regulator pointer |
|---|
| 99 | | - * @label - LED label |
|---|
| 100 | 96 | */ |
|---|
| 101 | 97 | struct lp8860_led { |
|---|
| 102 | 98 | struct mutex lock; |
|---|
| .. | .. |
|---|
| 106 | 102 | struct regmap *eeprom_regmap; |
|---|
| 107 | 103 | struct gpio_desc *enable_gpio; |
|---|
| 108 | 104 | struct regulator *regulator; |
|---|
| 109 | | - char label[LED_MAX_NAME_SIZE]; |
|---|
| 110 | 105 | }; |
|---|
| 111 | 106 | |
|---|
| 112 | 107 | struct lp8860_eeprom_reg { |
|---|
| .. | .. |
|---|
| 385 | 380 | { |
|---|
| 386 | 381 | int ret; |
|---|
| 387 | 382 | struct lp8860_led *led; |
|---|
| 388 | | - struct device_node *np = client->dev.of_node; |
|---|
| 383 | + struct device_node *np = dev_of_node(&client->dev); |
|---|
| 389 | 384 | struct device_node *child_node; |
|---|
| 390 | | - const char *name; |
|---|
| 385 | + struct led_init_data init_data = {}; |
|---|
| 391 | 386 | |
|---|
| 392 | 387 | led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); |
|---|
| 393 | 388 | if (!led) |
|---|
| 394 | 389 | return -ENOMEM; |
|---|
| 395 | 390 | |
|---|
| 396 | | - for_each_available_child_of_node(np, child_node) { |
|---|
| 397 | | - led->led_dev.default_trigger = of_get_property(child_node, |
|---|
| 398 | | - "linux,default-trigger", |
|---|
| 399 | | - NULL); |
|---|
| 400 | | - |
|---|
| 401 | | - ret = of_property_read_string(child_node, "label", &name); |
|---|
| 402 | | - if (!ret) |
|---|
| 403 | | - snprintf(led->label, sizeof(led->label), "%s:%s", |
|---|
| 404 | | - id->name, name); |
|---|
| 405 | | - else |
|---|
| 406 | | - snprintf(led->label, sizeof(led->label), |
|---|
| 407 | | - "%s::display_cluster", id->name); |
|---|
| 408 | | - } |
|---|
| 391 | + child_node = of_get_next_available_child(np, NULL); |
|---|
| 392 | + if (!child_node) |
|---|
| 393 | + return -EINVAL; |
|---|
| 409 | 394 | |
|---|
| 410 | 395 | led->enable_gpio = devm_gpiod_get_optional(&client->dev, |
|---|
| 411 | 396 | "enable", GPIOD_OUT_LOW); |
|---|
| .. | .. |
|---|
| 420 | 405 | led->regulator = NULL; |
|---|
| 421 | 406 | |
|---|
| 422 | 407 | led->client = client; |
|---|
| 423 | | - led->led_dev.name = led->label; |
|---|
| 424 | 408 | led->led_dev.brightness_set_blocking = lp8860_brightness_set; |
|---|
| 425 | 409 | |
|---|
| 426 | 410 | mutex_init(&led->lock); |
|---|
| .. | .. |
|---|
| 447 | 431 | if (ret) |
|---|
| 448 | 432 | return ret; |
|---|
| 449 | 433 | |
|---|
| 450 | | - ret = devm_led_classdev_register(&client->dev, &led->led_dev); |
|---|
| 434 | + init_data.fwnode = of_fwnode_handle(child_node); |
|---|
| 435 | + init_data.devicename = LP8860_NAME; |
|---|
| 436 | + init_data.default_label = ":display_cluster"; |
|---|
| 437 | + |
|---|
| 438 | + ret = devm_led_classdev_register_ext(&client->dev, &led->led_dev, |
|---|
| 439 | + &init_data); |
|---|
| 451 | 440 | if (ret) { |
|---|
| 452 | 441 | dev_err(&client->dev, "led register err: %d\n", ret); |
|---|
| 453 | 442 | return ret; |
|---|