19
19
20
20
#define DRIVER_NAME "mathworks_generic_of"
21
21
22
- static void mwgen_of_unlink_i2c_device (struct mathworks_ip_info * thisIpcore ){
22
+ static inline void mwgen_of_node_put (void * data )
23
+ {
24
+ struct device_node * node = data ;
25
+
26
+ of_node_put (node );
27
+ }
28
+
29
+ static inline void mwgen_put_device (void * data )
30
+ {
31
+ struct device * dev = data ;
32
+
33
+ put_device (dev );
34
+ }
35
+
36
+ static inline void mwgen_of_unlink_i2c_device (void * data )
37
+ {
38
+ struct mathworks_ip_info * thisIpcore = data ;
39
+
23
40
sysfs_remove_link (& thisIpcore -> char_device -> kobj , "i2c_device" );
24
41
}
25
42
26
- static void mwgen_of_unlink_i2c_adapter (struct mathworks_ip_info * thisIpcore ){
43
+ static inline void mwgen_of_unlink_i2c_adapter (void * data )
44
+ {
45
+ struct mathworks_ip_info * thisIpcore = data ;
46
+
27
47
sysfs_remove_link (& thisIpcore -> char_device -> kobj , "i2c_adapter" );
28
48
}
29
49
@@ -34,7 +54,8 @@ static int mathworks_generic_of_i2c_init(struct mathworks_ip_info *thisIpcore){
34
54
35
55
slave_node = of_parse_phandle (nodePointer , "i2c-controller" , 0 );
36
56
if (slave_node ) {
37
- status = devm_add_action_helper (thisIpcore -> dev , (devm_action_fn )of_node_put , slave_node );
57
+ status = devm_add_action_helper (thisIpcore -> dev ,
58
+ mwgen_of_node_put , slave_node );
38
59
if (status )
39
60
return status ;
40
61
@@ -45,7 +66,9 @@ static int mathworks_generic_of_i2c_init(struct mathworks_ip_info *thisIpcore){
45
66
dev_err (thisIpcore -> dev , "could not find i2c device\n" );
46
67
return - ENODEV ;
47
68
}
48
- status = devm_add_action_helper (thisIpcore -> dev , (devm_action_fn )put_device , & thisIpcore -> i2c -> dev );
69
+ status = devm_add_action_helper (thisIpcore -> dev ,
70
+ mwgen_put_device ,
71
+ & thisIpcore -> i2c -> dev );
49
72
if (status )
50
73
return status ;
51
74
@@ -55,15 +78,19 @@ static int mathworks_generic_of_i2c_init(struct mathworks_ip_info *thisIpcore){
55
78
status = sysfs_create_link (& thisIpcore -> char_device -> kobj , & thisIpcore -> i2c -> dev .kobj , "i2c_device" );
56
79
if (status )
57
80
return status ;
58
- status = devm_add_action_helper (thisIpcore -> dev , (devm_action_fn )mwgen_of_unlink_i2c_device , thisIpcore );
81
+ status = devm_add_action_helper (thisIpcore -> dev ,
82
+ mwgen_of_unlink_i2c_device ,
83
+ thisIpcore );
59
84
if (status )
60
85
return status ;
61
86
62
87
/* add a link to the i2c bus */
63
88
status = sysfs_create_link (& thisIpcore -> char_device -> kobj , & thisIpcore -> i2c -> adapter -> dev .kobj , "i2c_adapter" );
64
89
if (status )
65
90
return status ;
66
- status = devm_add_action_helper (thisIpcore -> dev , (devm_action_fn )mwgen_of_unlink_i2c_adapter , thisIpcore );
91
+ status = devm_add_action_helper (thisIpcore -> dev ,
92
+ mwgen_of_unlink_i2c_adapter ,
93
+ thisIpcore );
67
94
if (status )
68
95
return status ;
69
96
0 commit comments