| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for BCM6358 memory-mapped LEDs, based on leds-syscon.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2015 Álvaro Fernández Rojas <noltari@gmail.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 8 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 9 | | - * option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | #include <linux/delay.h> |
|---|
| 12 | 8 | #include <linux/io.h> |
|---|
| .. | .. |
|---|
| 98 | 94 | static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, |
|---|
| 99 | 95 | void __iomem *mem, spinlock_t *lock) |
|---|
| 100 | 96 | { |
|---|
| 97 | + struct led_init_data init_data = {}; |
|---|
| 101 | 98 | struct bcm6358_led *led; |
|---|
| 102 | 99 | const char *state; |
|---|
| 103 | 100 | int rc; |
|---|
| .. | .. |
|---|
| 112 | 109 | |
|---|
| 113 | 110 | if (of_property_read_bool(nc, "active-low")) |
|---|
| 114 | 111 | led->active_low = true; |
|---|
| 115 | | - |
|---|
| 116 | | - led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name; |
|---|
| 117 | | - led->cdev.default_trigger = of_get_property(nc, |
|---|
| 118 | | - "linux,default-trigger", |
|---|
| 119 | | - NULL); |
|---|
| 120 | 112 | |
|---|
| 121 | 113 | if (!of_property_read_string(nc, "default-state", &state)) { |
|---|
| 122 | 114 | if (!strcmp(state, "on")) { |
|---|
| .. | .. |
|---|
| 140 | 132 | bcm6358_led_set(&led->cdev, led->cdev.brightness); |
|---|
| 141 | 133 | |
|---|
| 142 | 134 | led->cdev.brightness_set = bcm6358_led_set; |
|---|
| 135 | + init_data.fwnode = of_fwnode_handle(nc); |
|---|
| 143 | 136 | |
|---|
| 144 | | - rc = devm_led_classdev_register(dev, &led->cdev); |
|---|
| 137 | + rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); |
|---|
| 145 | 138 | if (rc < 0) |
|---|
| 146 | 139 | return rc; |
|---|
| 147 | 140 | |
|---|
| .. | .. |
|---|
| 153 | 146 | static int bcm6358_leds_probe(struct platform_device *pdev) |
|---|
| 154 | 147 | { |
|---|
| 155 | 148 | struct device *dev = &pdev->dev; |
|---|
| 156 | | - struct device_node *np = pdev->dev.of_node; |
|---|
| 149 | + struct device_node *np = dev_of_node(&pdev->dev); |
|---|
| 157 | 150 | struct device_node *child; |
|---|
| 158 | | - struct resource *mem_r; |
|---|
| 159 | 151 | void __iomem *mem; |
|---|
| 160 | 152 | spinlock_t *lock; /* memory lock */ |
|---|
| 161 | 153 | unsigned long val; |
|---|
| 162 | 154 | u32 clk_div; |
|---|
| 163 | 155 | |
|---|
| 164 | | - mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 165 | | - if (!mem_r) |
|---|
| 166 | | - return -EINVAL; |
|---|
| 167 | | - |
|---|
| 168 | | - mem = devm_ioremap_resource(dev, mem_r); |
|---|
| 156 | + mem = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 169 | 157 | if (IS_ERR(mem)) |
|---|
| 170 | 158 | return PTR_ERR(mem); |
|---|
| 171 | 159 | |
|---|