15
15
#include <linux/io.h>
16
16
#include <linux/led-class-multicolor.h>
17
17
#include <linux/leds.h>
18
+ #include <linux/mod_devicetable.h>
18
19
#include <linux/module.h>
19
- #include <linux/of.h>
20
20
#include <linux/platform_device.h>
21
21
#include <linux/pm.h>
22
+ #include <linux/property.h>
22
23
#include <linux/reset.h>
23
24
#include <linux/spinlock.h>
24
25
@@ -247,13 +248,13 @@ static const char *const sun50i_a100_ledc_formats[] = {
247
248
"rgb" , "rbg" , "grb" , "gbr" , "brg" , "bgr" ,
248
249
};
249
250
250
- static int sun50i_a100_ledc_parse_format (const struct device_node * np ,
251
+ static int sun50i_a100_ledc_parse_format (struct device * dev ,
251
252
struct sun50i_a100_ledc * priv )
252
253
{
253
254
const char * format = "grb" ;
254
255
u32 i ;
255
256
256
- of_property_read_string ( np , "allwinner,pixel-format" , & format );
257
+ device_property_read_string ( dev , "allwinner,pixel-format" , & format );
257
258
258
259
for (i = 0 ; i < ARRAY_SIZE (sun50i_a100_ledc_formats ); i ++ ) {
259
260
if (!strcmp (format , sun50i_a100_ledc_formats [i ])) {
@@ -262,7 +263,7 @@ static int sun50i_a100_ledc_parse_format(const struct device_node *np,
262
263
}
263
264
}
264
265
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 );
266
267
}
267
268
268
269
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 = {
283
284
.treset_ns = 300000 ,
284
285
};
285
286
286
- static int sun50i_a100_ledc_parse_timing (const struct device_node * np ,
287
+ static int sun50i_a100_ledc_parse_timing (struct device * dev ,
287
288
struct sun50i_a100_ledc * priv )
288
289
{
289
290
struct sun50i_a100_ledc_timing * timing = & priv -> timing ;
290
291
291
292
* timing = sun50i_a100_ledc_default_timing ;
292
293
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 );
298
299
299
300
return 0 ;
300
301
}
@@ -388,13 +389,12 @@ static void sun50i_a100_ledc_dma_cleanup(void *data)
388
389
389
390
static int sun50i_a100_ledc_probe (struct platform_device * pdev )
390
391
{
391
- const struct device_node * np = pdev -> dev .of_node ;
392
392
struct dma_slave_config dma_cfg = {};
393
393
struct led_init_data init_data = {};
394
394
struct sun50i_a100_ledc_led * led ;
395
395
struct device * dev = & pdev -> dev ;
396
396
struct sun50i_a100_ledc * priv ;
397
- struct device_node * child ;
397
+ struct fwnode_handle * child ;
398
398
struct resource * mem ;
399
399
u32 max_addr = 0 ;
400
400
u32 num_leds = 0 ;
@@ -404,19 +404,19 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
404
404
* The maximum LED address must be known in sun50i_a100_ledc_resume() before
405
405
* class device registration, so parse and validate the subnodes up front.
406
406
*/
407
- for_each_available_child_of_node ( np , child ) {
407
+ device_for_each_child_node ( dev , child ) {
408
408
u32 addr , color ;
409
409
410
- ret = of_property_read_u32 (child , "reg" , & addr );
410
+ ret = fwnode_property_read_u32 (child , "reg" , & addr );
411
411
if (ret || addr >= LEDC_MAX_LEDS ) {
412
- of_node_put (child );
412
+ fwnode_handle_put (child );
413
413
return dev_err_probe (dev , - EINVAL , "'reg' must be between 0 and %d\n" ,
414
414
LEDC_MAX_LEDS - 1 );
415
415
}
416
416
417
- ret = of_property_read_u32 (child , "color" , & color );
417
+ ret = fwnode_property_read_u32 (child , "color" , & color );
418
418
if (ret || color != LED_COLOR_ID_RGB ) {
419
- of_node_put (child );
419
+ fwnode_handle_put (child );
420
420
return dev_err_probe (dev , - EINVAL , "'color' must be LED_COLOR_ID_RGB\n" );
421
421
}
422
422
@@ -437,11 +437,11 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
437
437
spin_lock_init (& priv -> lock );
438
438
dev_set_drvdata (dev , priv );
439
439
440
- ret = sun50i_a100_ledc_parse_format (np , priv );
440
+ ret = sun50i_a100_ledc_parse_format (dev , priv );
441
441
if (ret )
442
442
return ret ;
443
443
444
- ret = sun50i_a100_ledc_parse_timing (np , priv );
444
+ ret = sun50i_a100_ledc_parse_timing (dev , priv );
445
445
if (ret )
446
446
return ret ;
447
447
@@ -504,11 +504,11 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
504
504
return ret ;
505
505
506
506
led = priv -> leds ;
507
- for_each_available_child_of_node ( np , child ) {
507
+ device_for_each_child_node ( dev , child ) {
508
508
struct led_classdev * cdev ;
509
509
510
510
/* The node was already validated above. */
511
- of_property_read_u32 (child , "reg" , & led -> addr );
511
+ fwnode_property_read_u32 (child , "reg" , & led -> addr );
512
512
513
513
led -> subled_info [0 ].color_index = LED_COLOR_ID_RED ;
514
514
led -> subled_info [0 ].channel = 0 ;
@@ -524,7 +524,7 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
524
524
cdev -> max_brightness = U8_MAX ;
525
525
cdev -> brightness_set = sun50i_a100_ledc_brightness_set ;
526
526
527
- init_data .fwnode = of_fwnode_handle ( child ) ;
527
+ init_data .fwnode = child ;
528
528
529
529
ret = led_classdev_multicolor_register_ext (dev , & led -> mc_cdev , & init_data );
530
530
if (ret ) {
@@ -540,7 +540,7 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev)
540
540
return 0 ;
541
541
542
542
err_put_child :
543
- of_node_put (child );
543
+ fwnode_handle_put (child );
544
544
while (led -- > priv -> leds )
545
545
led_classdev_multicolor_unregister (& led -> mc_cdev );
546
546
sun50i_a100_ledc_suspend (& pdev -> dev );
0 commit comments