@@ -159,8 +159,6 @@ static ssize_t max_contrast_show(struct device *dev,
159
159
}
160
160
static DEVICE_ATTR_RO (max_contrast );
161
161
162
- static struct class * lcd_class ;
163
-
164
162
static void lcd_device_release (struct device * dev )
165
163
{
166
164
struct lcd_device * ld = to_lcd_device (dev );
@@ -175,6 +173,11 @@ static struct attribute *lcd_device_attrs[] = {
175
173
};
176
174
ATTRIBUTE_GROUPS (lcd_device );
177
175
176
+ static const struct class lcd_class = {
177
+ .name = "lcd" ,
178
+ .dev_groups = lcd_device_groups ,
179
+ };
180
+
178
181
/**
179
182
* lcd_device_register - register a new object of lcd_device class.
180
183
* @name: the name of the new object(must be the same as the name of the
@@ -202,7 +205,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
202
205
mutex_init (& new_ld -> ops_lock );
203
206
mutex_init (& new_ld -> update_lock );
204
207
205
- new_ld -> dev .class = lcd_class ;
208
+ new_ld -> dev .class = & lcd_class ;
206
209
new_ld -> dev .parent = parent ;
207
210
new_ld -> dev .release = lcd_device_release ;
208
211
dev_set_name (& new_ld -> dev , "%s" , name );
@@ -318,19 +321,19 @@ EXPORT_SYMBOL(devm_lcd_device_unregister);
318
321
319
322
static void __exit lcd_class_exit (void )
320
323
{
321
- class_destroy ( lcd_class );
324
+ class_unregister ( & lcd_class );
322
325
}
323
326
324
327
static int __init lcd_class_init (void )
325
328
{
326
- lcd_class = class_create ("lcd" );
327
- if (IS_ERR (lcd_class )) {
328
- pr_warn ("Unable to create backlight class; errno = %ld\n" ,
329
- PTR_ERR (lcd_class ));
330
- return PTR_ERR (lcd_class );
329
+ int ret ;
330
+
331
+ ret = class_register (& lcd_class );
332
+ if (ret ) {
333
+ pr_warn ("Unable to create backlight class; errno = %d\n" , ret );
334
+ return ret ;
331
335
}
332
336
333
- lcd_class -> dev_groups = lcd_device_groups ;
334
337
return 0 ;
335
338
}
336
339
0 commit comments