@@ -107,7 +107,11 @@ EXPORT_SYMBOL(zcrypt_msgtype);
107
107
108
108
struct zcdn_device ;
109
109
110
- static struct class * zcrypt_class ;
110
+ static void zcdn_device_release (struct device * dev );
111
+ static const struct class zcrypt_class = {
112
+ .name = ZCRYPT_NAME ,
113
+ .dev_release = zcdn_device_release ,
114
+ };
111
115
static dev_t zcrypt_devt ;
112
116
static struct cdev zcrypt_cdev ;
113
117
@@ -130,7 +134,7 @@ static int zcdn_destroy(const char *name);
130
134
*/
131
135
static inline struct zcdn_device * find_zcdndev_by_name (const char * name )
132
136
{
133
- struct device * dev = class_find_device_by_name (zcrypt_class , name );
137
+ struct device * dev = class_find_device_by_name (& zcrypt_class , name );
134
138
135
139
return dev ? to_zcdn_dev (dev ) : NULL ;
136
140
}
@@ -142,7 +146,7 @@ static inline struct zcdn_device *find_zcdndev_by_name(const char *name)
142
146
*/
143
147
static inline struct zcdn_device * find_zcdndev_by_devt (dev_t devt )
144
148
{
145
- struct device * dev = class_find_device_by_devt (zcrypt_class , devt );
149
+ struct device * dev = class_find_device_by_devt (& zcrypt_class , devt );
146
150
147
151
return dev ? to_zcdn_dev (dev ) : NULL ;
148
152
}
@@ -396,7 +400,7 @@ static int zcdn_create(const char *name)
396
400
goto unlockout ;
397
401
}
398
402
zcdndev -> device .release = zcdn_device_release ;
399
- zcdndev -> device .class = zcrypt_class ;
403
+ zcdndev -> device .class = & zcrypt_class ;
400
404
zcdndev -> device .devt = devt ;
401
405
zcdndev -> device .groups = zcdn_dev_attr_groups ;
402
406
if (name [0 ])
@@ -2077,12 +2081,9 @@ static int __init zcdn_init(void)
2077
2081
int rc ;
2078
2082
2079
2083
/* create a new class 'zcrypt' */
2080
- zcrypt_class = class_create (ZCRYPT_NAME );
2081
- if (IS_ERR (zcrypt_class )) {
2082
- rc = PTR_ERR (zcrypt_class );
2083
- goto out_class_create_failed ;
2084
- }
2085
- zcrypt_class -> dev_release = zcdn_device_release ;
2084
+ rc = class_register (& zcrypt_class );
2085
+ if (rc )
2086
+ goto out_class_register_failed ;
2086
2087
2087
2088
/* alloc device minor range */
2088
2089
rc = alloc_chrdev_region (& zcrypt_devt ,
@@ -2098,35 +2099,35 @@ static int __init zcdn_init(void)
2098
2099
goto out_cdev_add_failed ;
2099
2100
2100
2101
/* need some class specific sysfs attributes */
2101
- rc = class_create_file (zcrypt_class , & class_attr_zcdn_create );
2102
+ rc = class_create_file (& zcrypt_class , & class_attr_zcdn_create );
2102
2103
if (rc )
2103
2104
goto out_class_create_file_1_failed ;
2104
- rc = class_create_file (zcrypt_class , & class_attr_zcdn_destroy );
2105
+ rc = class_create_file (& zcrypt_class , & class_attr_zcdn_destroy );
2105
2106
if (rc )
2106
2107
goto out_class_create_file_2_failed ;
2107
2108
2108
2109
return 0 ;
2109
2110
2110
2111
out_class_create_file_2_failed :
2111
- class_remove_file (zcrypt_class , & class_attr_zcdn_create );
2112
+ class_remove_file (& zcrypt_class , & class_attr_zcdn_create );
2112
2113
out_class_create_file_1_failed :
2113
2114
cdev_del (& zcrypt_cdev );
2114
2115
out_cdev_add_failed :
2115
2116
unregister_chrdev_region (zcrypt_devt , ZCRYPT_MAX_MINOR_NODES );
2116
2117
out_alloc_chrdev_failed :
2117
- class_destroy ( zcrypt_class );
2118
- out_class_create_failed :
2118
+ class_unregister ( & zcrypt_class );
2119
+ out_class_register_failed :
2119
2120
return rc ;
2120
2121
}
2121
2122
2122
2123
static void zcdn_exit (void )
2123
2124
{
2124
- class_remove_file (zcrypt_class , & class_attr_zcdn_create );
2125
- class_remove_file (zcrypt_class , & class_attr_zcdn_destroy );
2125
+ class_remove_file (& zcrypt_class , & class_attr_zcdn_create );
2126
+ class_remove_file (& zcrypt_class , & class_attr_zcdn_destroy );
2126
2127
zcdn_destroy_all ();
2127
2128
cdev_del (& zcrypt_cdev );
2128
2129
unregister_chrdev_region (zcrypt_devt , ZCRYPT_MAX_MINOR_NODES );
2129
- class_destroy ( zcrypt_class );
2130
+ class_unregister ( & zcrypt_class );
2130
2131
}
2131
2132
2132
2133
/*
0 commit comments