@@ -30,18 +30,17 @@ static DEFINE_RAW_SPINLOCK(irq_resend_lock);
3030 */
3131static void resend_irqs (struct tasklet_struct * unused )
3232{
33- struct irq_desc * desc ;
34-
35- raw_spin_lock_irq (& irq_resend_lock );
33+ guard (raw_spinlock_irq )(& irq_resend_lock );
3634 while (!hlist_empty (& irq_resend_list )) {
37- desc = hlist_entry (irq_resend_list .first , struct irq_desc ,
38- resend_node );
35+ struct irq_desc * desc ;
36+
37+ desc = hlist_entry (irq_resend_list .first , struct irq_desc , resend_node );
3938 hlist_del_init (& desc -> resend_node );
39+
4040 raw_spin_unlock (& irq_resend_lock );
4141 desc -> handle_irq (desc );
4242 raw_spin_lock (& irq_resend_lock );
4343 }
44- raw_spin_unlock_irq (& irq_resend_lock );
4544}
4645
4746/* Tasklet to handle resend: */
@@ -75,19 +74,18 @@ static int irq_sw_resend(struct irq_desc *desc)
7574 }
7675
7776 /* Add to resend_list and activate the softirq: */
78- raw_spin_lock ( & irq_resend_lock );
79- if (hlist_unhashed (& desc -> resend_node ))
80- hlist_add_head (& desc -> resend_node , & irq_resend_list );
81- raw_spin_unlock ( & irq_resend_lock );
77+ scoped_guard ( raw_spinlock , & irq_resend_lock ) {
78+ if (hlist_unhashed (& desc -> resend_node ))
79+ hlist_add_head (& desc -> resend_node , & irq_resend_list );
80+ }
8281 tasklet_schedule (& resend_tasklet );
8382 return 0 ;
8483}
8584
8685void clear_irq_resend (struct irq_desc * desc )
8786{
88- raw_spin_lock (& irq_resend_lock );
87+ guard ( raw_spinlock ) (& irq_resend_lock );
8988 hlist_del_init (& desc -> resend_node );
90- raw_spin_unlock (& irq_resend_lock );
9189}
9290
9391void irq_resend_init (struct irq_desc * desc )
@@ -172,30 +170,24 @@ int check_irq_resend(struct irq_desc *desc, bool inject)
172170 */
173171int irq_inject_interrupt (unsigned int irq )
174172{
175- struct irq_desc * desc ;
176- unsigned long flags ;
177- int err ;
173+ int err = - EINVAL ;
178174
179175 /* Try the state injection hardware interface first */
180176 if (!irq_set_irqchip_state (irq , IRQCHIP_STATE_PENDING , true))
181177 return 0 ;
182178
183179 /* That failed, try via the resend mechanism */
184- desc = irq_get_desc_buslock (irq , & flags , 0 );
185- if (!desc )
186- return - EINVAL ;
180+ scoped_irqdesc_get_and_buslock (irq , 0 ) {
181+ struct irq_desc * desc = scoped_irqdesc ;
187182
188- /*
189- * Only try to inject when the interrupt is:
190- * - not NMI type
191- * - activated
192- */
193- if (irq_is_nmi (desc ) || !irqd_is_activated (& desc -> irq_data ))
194- err = - EINVAL ;
195- else
196- err = check_irq_resend (desc , true);
197-
198- irq_put_desc_busunlock (desc , flags );
183+ /*
184+ * Only try to inject when the interrupt is:
185+ * - not NMI type
186+ * - activated
187+ */
188+ if (!irq_is_nmi (desc ) && irqd_is_activated (& desc -> irq_data ))
189+ err = check_irq_resend (desc , true);
190+ }
199191 return err ;
200192}
201193EXPORT_SYMBOL_GPL (irq_inject_interrupt );
0 commit comments