Skip to content

Commit 06c5206

Browse files
andy-shevlag-linaro
authored andcommitted
leds: sun50i-a100: Convert to be agnostic to property provider
Convert the driver to be agnostic to the property provider. LEDS subsytem is not dependent on OF, so no need to make drivers be a such. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://lore.kernel.org/r/20231214192131.1309912-1-andriy.shevchenko@linux.intel.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 808c788 commit 06c5206

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

drivers/leds/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ config LEDS_COBALT_RAQ
305305

306306
config LEDS_SUN50I_A100
307307
tristate "LED support for Allwinner A100 RGB LED controller"
308-
depends on LEDS_CLASS_MULTICOLOR && OF
308+
depends on LEDS_CLASS_MULTICOLOR
309309
depends on ARCH_SUNXI || COMPILE_TEST
310310
help
311311
This option enables support for the RGB LED controller found

drivers/leds/leds-sun50i-a100.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
#include <linux/io.h>
1616
#include <linux/led-class-multicolor.h>
1717
#include <linux/leds.h>
18+
#include <linux/mod_devicetable.h>
1819
#include <linux/module.h>
19-
#include <linux/of.h>
2020
#include <linux/platform_device.h>
2121
#include <linux/pm.h>
22+
#include <linux/property.h>
2223
#include <linux/reset.h>
2324
#include <linux/spinlock.h>
2425

@@ -247,13 +248,13 @@ static const char *const sun50i_a100_ledc_formats[] = {
247248
"rgb", "rbg", "grb", "gbr", "brg", "bgr",
248249
};
249250

250-
static int sun50i_a100_ledc_parse_format(const struct device_node *np,
251+
static int sun50i_a100_ledc_parse_format(struct device *dev,
251252
struct sun50i_a100_ledc *priv)
252253
{
253254
const char *format = "grb";
254255
u32 i;
255256

256-
of_property_read_string(np, "allwinner,pixel-format", &format);
257+
device_property_read_string(dev, "allwinner,pixel-format", &format);
257258

258259
for (i = 0; i < ARRAY_SIZE(sun50i_a100_ledc_formats); i++) {
259260
if (!strcmp(format, sun50i_a100_ledc_formats[i])) {
@@ -262,7 +263,7 @@ static int sun50i_a100_ledc_parse_format(const struct device_node *np,
262263
}
263264
}
264265

265-
return dev_err_probe(priv->dev, -EINVAL, "Bad pixel format '%s'\n", format);
266+
return dev_err_probe(dev, -EINVAL, "Bad pixel format '%s'\n", format);
266267
}
267268

268269
static void sun50i_a100_ledc_set_format(struct sun50i_a100_ledc *priv)
@@ -283,18 +284,18 @@ static const struct sun50i_a100_ledc_timing sun50i_a100_ledc_default_timing = {
283284
.treset_ns = 300000,
284285
};
285286

286-
static int sun50i_a100_ledc_parse_timing(const struct device_node *np,
287+
static int sun50i_a100_ledc_parse_timing(struct device *dev,
287288
struct sun50i_a100_ledc *priv)
288289
{
289290
struct sun50i_a100_ledc_timing *timing = &priv->timing;
290291

291292
*timing = sun50i_a100_ledc_default_timing;
292293

293-
of_property_read_u32(np, "allwinner,t0h-ns", &timing->t0h_ns);
294-
of_property_read_u32(np, "allwinner,t0l-ns", &timing->t0l_ns);
295-
of_property_read_u32(np, "allwinner,t1h-ns", &timing->t1h_ns);
296-
of_property_read_u32(np, "allwinner,t1l-ns", &timing->t1l_ns);
297-
of_property_read_u32(np, "allwinner,treset-ns", &timing->treset_ns);
294+
device_property_read_u32(dev, "allwinner,t0h-ns", &timing->t0h_ns);
295+
device_property_read_u32(dev, "allwinner,t0l-ns", &timing->t0l_ns);
296+
device_property_read_u32(dev, "allwinner,t1h-ns", &timing->t1h_ns);
297+
device_property_read_u32(dev, "allwinner,t1l-ns", &timing->t1l_ns);
298+
device_property_read_u32(dev, "allwinner,treset-ns", &timing->treset_ns);
298299

299300
return 0;
300301
}
@@ -388,13 +389,12 @@ static void sun50i_a100_ledc_dma_cleanup(void *data)
388389

389390
static int sun50i_a100_ledc_probe(struct platform_device *pdev)
390391
{
391-
const struct device_node *np = pdev->dev.of_node;
392392
struct dma_slave_config dma_cfg = {};
393393
struct led_init_data init_data = {};
394394
struct sun50i_a100_ledc_led *led;
395395
struct device *dev = &pdev->dev;
396396
struct sun50i_a100_ledc *priv;
397-
struct device_node *child;
397+
struct fwnode_handle *child;
398398
struct resource *mem;
399399
u32 max_addr = 0;
400400
u32 num_leds = 0;
@@ -404,19 +404,19 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
404404
* The maximum LED address must be known in sun50i_a100_ledc_resume() before
405405
* class device registration, so parse and validate the subnodes up front.
406406
*/
407-
for_each_available_child_of_node(np, child) {
407+
device_for_each_child_node(dev, child) {
408408
u32 addr, color;
409409

410-
ret = of_property_read_u32(child, "reg", &addr);
410+
ret = fwnode_property_read_u32(child, "reg", &addr);
411411
if (ret || addr >= LEDC_MAX_LEDS) {
412-
of_node_put(child);
412+
fwnode_handle_put(child);
413413
return dev_err_probe(dev, -EINVAL, "'reg' must be between 0 and %d\n",
414414
LEDC_MAX_LEDS - 1);
415415
}
416416

417-
ret = of_property_read_u32(child, "color", &color);
417+
ret = fwnode_property_read_u32(child, "color", &color);
418418
if (ret || color != LED_COLOR_ID_RGB) {
419-
of_node_put(child);
419+
fwnode_handle_put(child);
420420
return dev_err_probe(dev, -EINVAL, "'color' must be LED_COLOR_ID_RGB\n");
421421
}
422422

@@ -437,11 +437,11 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
437437
spin_lock_init(&priv->lock);
438438
dev_set_drvdata(dev, priv);
439439

440-
ret = sun50i_a100_ledc_parse_format(np, priv);
440+
ret = sun50i_a100_ledc_parse_format(dev, priv);
441441
if (ret)
442442
return ret;
443443

444-
ret = sun50i_a100_ledc_parse_timing(np, priv);
444+
ret = sun50i_a100_ledc_parse_timing(dev, priv);
445445
if (ret)
446446
return ret;
447447

@@ -504,11 +504,11 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
504504
return ret;
505505

506506
led = priv->leds;
507-
for_each_available_child_of_node(np, child) {
507+
device_for_each_child_node(dev, child) {
508508
struct led_classdev *cdev;
509509

510510
/* The node was already validated above. */
511-
of_property_read_u32(child, "reg", &led->addr);
511+
fwnode_property_read_u32(child, "reg", &led->addr);
512512

513513
led->subled_info[0].color_index = LED_COLOR_ID_RED;
514514
led->subled_info[0].channel = 0;
@@ -524,7 +524,7 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
524524
cdev->max_brightness = U8_MAX;
525525
cdev->brightness_set = sun50i_a100_ledc_brightness_set;
526526

527-
init_data.fwnode = of_fwnode_handle(child);
527+
init_data.fwnode = child;
528528

529529
ret = led_classdev_multicolor_register_ext(dev, &led->mc_cdev, &init_data);
530530
if (ret) {
@@ -540,7 +540,7 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
540540
return 0;
541541

542542
err_put_child:
543-
of_node_put(child);
543+
fwnode_handle_put(child);
544544
while (led-- > priv->leds)
545545
led_classdev_multicolor_unregister(&led->mc_cdev);
546546
sun50i_a100_ledc_suspend(&pdev->dev);

0 commit comments

Comments
 (0)