7070 */
7171static LIST_HEAD (rv_reactors_list );
7272
73- static struct rv_reactor_def * get_reactor_rdef_by_name (char * name )
73+ static struct rv_reactor * get_reactor_rdef_by_name (char * name )
7474{
75- struct rv_reactor_def * r ;
75+ struct rv_reactor * r ;
7676
7777 list_for_each_entry (r , & rv_reactors_list , list ) {
78- if (strcmp (name , r -> reactor -> name ) == 0 )
78+ if (strcmp (name , r -> name ) == 0 )
7979 return r ;
8080 }
8181 return NULL ;
@@ -86,9 +86,9 @@ static struct rv_reactor_def *get_reactor_rdef_by_name(char *name)
8686 */
8787static int reactors_show (struct seq_file * m , void * p )
8888{
89- struct rv_reactor_def * rea_def = p ;
89+ struct rv_reactor * reactor = p ;
9090
91- seq_printf (m , "%s\n" , rea_def -> reactor -> name );
91+ seq_printf (m , "%s\n" , reactor -> name );
9292 return 0 ;
9393}
9494
@@ -139,12 +139,12 @@ static const struct file_operations available_reactors_ops = {
139139static int monitor_reactor_show (struct seq_file * m , void * p )
140140{
141141 struct rv_monitor * mon = m -> private ;
142- struct rv_reactor_def * rdef = p ;
142+ struct rv_reactor * reactor = p ;
143143
144- if (mon -> rdef == rdef )
145- seq_printf (m , "[%s]\n" , rdef -> reactor -> name );
144+ if (mon -> reactor == reactor )
145+ seq_printf (m , "[%s]\n" , reactor -> name );
146146 else
147- seq_printf (m , "%s\n" , rdef -> reactor -> name );
147+ seq_printf (m , "%s\n" , reactor -> name );
148148 return 0 ;
149149}
150150
@@ -159,50 +159,50 @@ static const struct seq_operations monitor_reactors_seq_ops = {
159159};
160160
161161static void monitor_swap_reactors_single (struct rv_monitor * mon ,
162- struct rv_reactor_def * rdef ,
162+ struct rv_reactor * reactor ,
163163 bool reacting , bool nested )
164164{
165165 bool monitor_enabled ;
166166
167167 /* nothing to do */
168- if (mon -> rdef == rdef )
168+ if (mon -> reactor == reactor )
169169 return ;
170170
171171 monitor_enabled = mon -> enabled ;
172172 if (monitor_enabled )
173173 rv_disable_monitor (mon );
174174
175175 /* swap reactor's usage */
176- mon -> rdef -> counter -- ;
177- rdef -> counter ++ ;
176+ mon -> reactor -> counter -- ;
177+ reactor -> counter ++ ;
178178
179- mon -> rdef = rdef ;
179+ mon -> reactor = reactor ;
180180 mon -> reacting = reacting ;
181- mon -> react = rdef -> reactor -> react ;
181+ mon -> react = reactor -> react ;
182182
183183 /* enable only once if iterating through a container */
184184 if (monitor_enabled && !nested )
185185 rv_enable_monitor (mon );
186186}
187187
188188static void monitor_swap_reactors (struct rv_monitor * mon ,
189- struct rv_reactor_def * rdef , bool reacting )
189+ struct rv_reactor * reactor , bool reacting )
190190{
191191 struct rv_monitor * p = mon ;
192192
193193 if (rv_is_container_monitor (mon ))
194194 list_for_each_entry_continue (p , & rv_monitors_list , list ) {
195195 if (p -> parent != mon )
196196 break ;
197- monitor_swap_reactors_single (p , rdef , reacting , true);
197+ monitor_swap_reactors_single (p , reactor , reacting , true);
198198 }
199199 /*
200200 * This call enables and disables the monitor if they were active.
201201 * In case of a container, we already disabled all and will enable all.
202202 * All nested monitors are enabled also if they were off, we may refine
203203 * this logic in the future.
204204 */
205- monitor_swap_reactors_single (mon , rdef , reacting , false);
205+ monitor_swap_reactors_single (mon , reactor , reacting , false);
206206}
207207
208208static ssize_t
@@ -211,7 +211,7 @@ monitor_reactors_write(struct file *file, const char __user *user_buf,
211211{
212212 char buff [MAX_RV_REACTOR_NAME_SIZE + 2 ];
213213 struct rv_monitor * mon ;
214- struct rv_reactor_def * rdef ;
214+ struct rv_reactor * reactor ;
215215 struct seq_file * seq_f ;
216216 int retval = - EINVAL ;
217217 bool enable ;
@@ -243,16 +243,16 @@ monitor_reactors_write(struct file *file, const char __user *user_buf,
243243
244244 retval = - EINVAL ;
245245
246- list_for_each_entry (rdef , & rv_reactors_list , list ) {
247- if (strcmp (ptr , rdef -> reactor -> name ) != 0 )
246+ list_for_each_entry (reactor , & rv_reactors_list , list ) {
247+ if (strcmp (ptr , reactor -> name ) != 0 )
248248 continue ;
249249
250- if (rdef == get_reactor_rdef_by_name ( "nop" ))
250+ if (strcmp ( reactor -> name , "nop" ))
251251 enable = false;
252252 else
253253 enable = true;
254254
255- monitor_swap_reactors (mon , rdef , enable );
255+ monitor_swap_reactors (mon , reactor , enable );
256256
257257 retval = count ;
258258 break ;
@@ -299,23 +299,16 @@ static const struct file_operations monitor_reactors_ops = {
299299
300300static int __rv_register_reactor (struct rv_reactor * reactor )
301301{
302- struct rv_reactor_def * r ;
302+ struct rv_reactor * r ;
303303
304304 list_for_each_entry (r , & rv_reactors_list , list ) {
305- if (strcmp (reactor -> name , r -> reactor -> name ) == 0 ) {
305+ if (strcmp (reactor -> name , r -> name ) == 0 ) {
306306 pr_info ("Reactor %s is already registered\n" , reactor -> name );
307307 return - EINVAL ;
308308 }
309309 }
310310
311- r = kzalloc (sizeof (struct rv_reactor_def ), GFP_KERNEL );
312- if (!r )
313- return - ENOMEM ;
314-
315- r -> reactor = reactor ;
316- r -> counter = 0 ;
317-
318- list_add_tail (& r -> list , & rv_reactors_list );
311+ list_add_tail (& reactor -> list , & rv_reactors_list );
319312
320313 return 0 ;
321314}
@@ -350,26 +343,19 @@ int rv_register_reactor(struct rv_reactor *reactor)
350343 */
351344int rv_unregister_reactor (struct rv_reactor * reactor )
352345{
353- struct rv_reactor_def * ptr , * next ;
354346 int ret = 0 ;
355347
356348 mutex_lock (& rv_interface_lock );
357349
358- list_for_each_entry_safe (ptr , next , & rv_reactors_list , list ) {
359- if (strcmp (reactor -> name , ptr -> reactor -> name ) == 0 ) {
360-
361- if (!ptr -> counter ) {
362- list_del (& ptr -> list );
363- } else {
364- printk (KERN_WARNING
365- "rv: the rv_reactor %s is in use by %d monitor(s)\n" ,
366- ptr -> reactor -> name , ptr -> counter );
367- printk (KERN_WARNING "rv: the rv_reactor %s cannot be removed\n" ,
368- ptr -> reactor -> name );
369- ret = - EBUSY ;
370- break ;
371- }
372- }
350+ if (!reactor -> counter ) {
351+ list_del (& reactor -> list );
352+ } else {
353+ printk (KERN_WARNING
354+ "rv: the rv_reactor %s is in use by %d monitor(s)\n" ,
355+ reactor -> name , reactor -> counter );
356+ printk (KERN_WARNING "rv: the rv_reactor %s cannot be removed\n" ,
357+ reactor -> name );
358+ ret = - EBUSY ;
373359 }
374360
375361 mutex_unlock (& rv_interface_lock );
@@ -469,8 +455,8 @@ int reactor_populate_monitor(struct rv_monitor *mon)
469455 /*
470456 * Configure as the rv_nop reactor.
471457 */
472- mon -> rdef = get_reactor_rdef_by_name ("nop" );
473- mon -> rdef -> counter ++ ;
458+ mon -> reactor = get_reactor_rdef_by_name ("nop" );
459+ mon -> reactor -> counter ++ ;
474460 mon -> reacting = false;
475461
476462 return 0 ;
@@ -483,8 +469,8 @@ int reactor_populate_monitor(struct rv_monitor *mon)
483469void reactor_cleanup_monitor (struct rv_monitor * mon )
484470{
485471 lockdep_assert_held (& rv_interface_lock );
486- mon -> rdef -> counter -- ;
487- WARN_ON_ONCE (mon -> rdef -> counter < 0 );
472+ mon -> reactor -> counter -- ;
473+ WARN_ON_ONCE (mon -> reactor -> counter < 0 );
488474}
489475
490476/*
0 commit comments