22
22
#include <linux/of.h>
23
23
#include "leds.h"
24
24
25
- static struct class * leds_class ;
26
25
static DEFINE_MUTEX (leds_lookup_lock );
27
26
static LIST_HEAD (leds_lookup_list );
28
27
@@ -248,6 +247,12 @@ static struct led_classdev *led_module_get(struct device *led_dev)
248
247
return led_cdev ;
249
248
}
250
249
250
+ static const struct class leds_class = {
251
+ .name = "leds" ,
252
+ .dev_groups = led_groups ,
253
+ .pm = & leds_class_dev_pm_ops ,
254
+ };
255
+
251
256
/**
252
257
* of_led_get() - request a LED device via the LED framework
253
258
* @np: device node to get the LED device from
@@ -265,7 +270,7 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
265
270
if (!led_node )
266
271
return ERR_PTR (- ENOENT );
267
272
268
- led_dev = class_find_device_by_of_node (leds_class , led_node );
273
+ led_dev = class_find_device_by_of_node (& leds_class , led_node );
269
274
of_node_put (led_node );
270
275
put_device (led_dev );
271
276
@@ -360,7 +365,7 @@ struct led_classdev *led_get(struct device *dev, char *con_id)
360
365
if (!provider )
361
366
return ERR_PTR (- ENOENT );
362
367
363
- led_dev = class_find_device_by_name (leds_class , provider );
368
+ led_dev = class_find_device_by_name (& leds_class , provider );
364
369
kfree_const (provider );
365
370
366
371
return led_module_get (led_dev );
@@ -451,7 +456,7 @@ static int led_classdev_next_name(const char *init_name, char *name,
451
456
strscpy (name , init_name , len );
452
457
453
458
while ((ret < len ) &&
454
- (dev = class_find_device_by_name (leds_class , name ))) {
459
+ (dev = class_find_device_by_name (& leds_class , name ))) {
455
460
put_device (dev );
456
461
ret = snprintf (name , len , "%s_%u" , init_name , ++ i );
457
462
}
@@ -518,8 +523,8 @@ int led_classdev_register_ext(struct device *parent,
518
523
519
524
mutex_init (& led_cdev -> led_access );
520
525
mutex_lock (& led_cdev -> led_access );
521
- led_cdev -> dev = device_create_with_groups (leds_class , parent , 0 ,
522
- led_cdev , led_cdev -> groups , "%s" , final_name );
526
+ led_cdev -> dev = device_create_with_groups (& leds_class , parent , 0 ,
527
+ led_cdev , led_cdev -> groups , "%s" , final_name );
523
528
if (IS_ERR (led_cdev -> dev )) {
524
529
mutex_unlock (& led_cdev -> led_access );
525
530
return PTR_ERR (led_cdev -> dev );
@@ -676,17 +681,12 @@ EXPORT_SYMBOL_GPL(devm_led_classdev_unregister);
676
681
677
682
static int __init leds_init (void )
678
683
{
679
- leds_class = class_create ("leds" );
680
- if (IS_ERR (leds_class ))
681
- return PTR_ERR (leds_class );
682
- leds_class -> pm = & leds_class_dev_pm_ops ;
683
- leds_class -> dev_groups = led_groups ;
684
- return 0 ;
684
+ return class_register (& leds_class );
685
685
}
686
686
687
687
static void __exit leds_exit (void )
688
688
{
689
- class_destroy ( leds_class );
689
+ class_unregister ( & leds_class );
690
690
}
691
691
692
692
subsys_initcall (leds_init );
0 commit comments