@@ -166,19 +166,21 @@ static int is_iso_resource(const struct client_resource *resource)
166166 return resource -> release == release_iso_resource ;
167167}
168168
169+ static void release_transaction (struct client * client ,
170+ struct client_resource * resource );
171+
172+ static int is_outbound_transaction_resource (const struct client_resource * resource )
173+ {
174+ return resource -> release == release_transaction ;
175+ }
176+
169177static void schedule_iso_resource (struct iso_resource * r , unsigned long delay )
170178{
171179 client_get (r -> client );
172180 if (!queue_delayed_work (fw_workqueue , & r -> work , delay ))
173181 client_put (r -> client );
174182}
175183
176- static void schedule_if_iso_resource (struct client_resource * resource )
177- {
178- if (is_iso_resource (resource ))
179- schedule_iso_resource (to_iso_resource (resource ), 0 );
180- }
181-
182184/*
183185 * dequeue_event() just kfree()'s the event, so the event has to be
184186 * the first field in a struct XYZ_event.
@@ -401,16 +403,11 @@ static void for_each_client(struct fw_device *device,
401403 callback (c );
402404}
403405
404- static int schedule_reallocations (int id , void * p , void * data )
405- {
406- schedule_if_iso_resource (p );
407-
408- return 0 ;
409- }
410-
411406static void queue_bus_reset_event (struct client * client )
412407{
413408 struct bus_reset_event * e ;
409+ struct client_resource * resource ;
410+ int id ;
414411
415412 e = kzalloc (sizeof (* e ), GFP_KERNEL );
416413 if (e == NULL )
@@ -423,7 +420,10 @@ static void queue_bus_reset_event(struct client *client)
423420
424421 guard (spinlock_irq )(& client -> lock );
425422
426- idr_for_each (& client -> resource_idr , schedule_reallocations , client );
423+ idr_for_each_entry (& client -> resource_idr , resource , id ) {
424+ if (is_iso_resource (resource ))
425+ schedule_iso_resource (to_iso_resource (resource ), 0 );
426+ }
427427}
428428
429429void fw_device_cdev_update (struct fw_device * device )
@@ -518,7 +518,8 @@ static int add_client_resource(struct client *client,
518518 if (ret >= 0 ) {
519519 resource -> handle = ret ;
520520 client_get (client );
521- schedule_if_iso_resource (resource );
521+ if (is_iso_resource (resource ))
522+ schedule_iso_resource (to_iso_resource (resource ), 0 );
522523 }
523524 }
524525
@@ -1835,35 +1836,27 @@ static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma)
18351836 return ret ;
18361837}
18371838
1838- static int is_outbound_transaction_resource ( int id , void * p , void * data )
1839+ static bool has_outbound_transactions ( struct client * client )
18391840{
1840- struct client_resource * resource = p ;
1841-
1842- return resource -> release == release_transaction ;
1843- }
1841+ struct client_resource * resource ;
1842+ int id ;
18441843
1845- static int has_outbound_transactions (struct client * client )
1846- {
18471844 guard (spinlock_irq )(& client -> lock );
18481845
1849- return idr_for_each (& client -> resource_idr , is_outbound_transaction_resource , NULL );
1850- }
1851-
1852- static int shutdown_resource (int id , void * p , void * data )
1853- {
1854- struct client_resource * resource = p ;
1855- struct client * client = data ;
1856-
1857- resource -> release (client , resource );
1858- client_put (client );
1846+ idr_for_each_entry (& client -> resource_idr , resource , id ) {
1847+ if (is_outbound_transaction_resource (resource ))
1848+ return true;
1849+ }
18591850
1860- return 0 ;
1851+ return false ;
18611852}
18621853
18631854static int fw_device_op_release (struct inode * inode , struct file * file )
18641855{
18651856 struct client * client = file -> private_data ;
18661857 struct event * event , * next_event ;
1858+ struct client_resource * resource ;
1859+ int id ;
18671860
18681861 scoped_guard (spinlock_irq , & client -> device -> card -> lock )
18691862 list_del (& client -> phy_receiver_link );
@@ -1883,7 +1876,10 @@ static int fw_device_op_release(struct inode *inode, struct file *file)
18831876
18841877 wait_event (client -> tx_flush_wait , !has_outbound_transactions (client ));
18851878
1886- idr_for_each (& client -> resource_idr , shutdown_resource , client );
1879+ idr_for_each_entry (& client -> resource_idr , resource , id ) {
1880+ resource -> release (client , resource );
1881+ client_put (client );
1882+ }
18871883 idr_destroy (& client -> resource_idr );
18881884
18891885 list_for_each_entry_safe (event , next_event , & client -> event_list , link )
0 commit comments