@@ -2419,10 +2419,20 @@ static irqreturn_t rt5640_jd_gpio_irq(int irq, void *data)
2419
2419
return IRQ_HANDLED ;
2420
2420
}
2421
2421
2422
- static void rt5640_cancel_work (void * data )
2422
+ static void rt5640_disable_irq_and_cancel_work (void * data )
2423
2423
{
2424
2424
struct rt5640_priv * rt5640 = data ;
2425
2425
2426
+ if (rt5640 -> jd_gpio_irq_requested ) {
2427
+ free_irq (rt5640 -> jd_gpio_irq , rt5640 );
2428
+ rt5640 -> jd_gpio_irq_requested = false;
2429
+ }
2430
+
2431
+ if (rt5640 -> irq_requested ) {
2432
+ free_irq (rt5640 -> irq , rt5640 );
2433
+ rt5640 -> irq_requested = false;
2434
+ }
2435
+
2426
2436
cancel_delayed_work_sync (& rt5640 -> jack_work );
2427
2437
cancel_delayed_work_sync (& rt5640 -> bp_work );
2428
2438
}
@@ -2463,22 +2473,14 @@ static void rt5640_disable_jack_detect(struct snd_soc_component *component)
2463
2473
if (!rt5640 -> jack )
2464
2474
return ;
2465
2475
2466
- if (rt5640 -> jd_gpio_irq_requested )
2467
- free_irq (rt5640 -> jd_gpio_irq , rt5640 );
2468
-
2469
- if (rt5640 -> irq_requested )
2470
- free_irq (rt5640 -> irq , rt5640 );
2471
-
2472
- rt5640_cancel_work (rt5640 );
2476
+ rt5640_disable_irq_and_cancel_work (rt5640 );
2473
2477
2474
2478
if (rt5640 -> jack -> status & SND_JACK_MICROPHONE ) {
2475
2479
rt5640_disable_micbias1_ovcd_irq (component );
2476
2480
rt5640_disable_micbias1_for_ovcd (component );
2477
2481
snd_soc_jack_report (rt5640 -> jack , 0 , SND_JACK_BTN_0 );
2478
2482
}
2479
2483
2480
- rt5640 -> jd_gpio_irq_requested = false;
2481
- rt5640 -> irq_requested = false;
2482
2484
rt5640 -> jd_gpio = NULL ;
2483
2485
rt5640 -> jack = NULL ;
2484
2486
}
@@ -2798,7 +2800,8 @@ static int rt5640_suspend(struct snd_soc_component *component)
2798
2800
if (rt5640 -> jack ) {
2799
2801
/* disable jack interrupts during system suspend */
2800
2802
disable_irq (rt5640 -> irq );
2801
- rt5640_cancel_work (rt5640 );
2803
+ cancel_delayed_work_sync (& rt5640 -> jack_work );
2804
+ cancel_delayed_work_sync (& rt5640 -> bp_work );
2802
2805
}
2803
2806
2804
2807
snd_soc_component_force_bias_level (component , SND_SOC_BIAS_OFF );
@@ -3032,7 +3035,7 @@ static int rt5640_i2c_probe(struct i2c_client *i2c)
3032
3035
INIT_DELAYED_WORK (& rt5640 -> jack_work , rt5640_jack_work );
3033
3036
3034
3037
/* Make sure work is stopped on probe-error / remove */
3035
- ret = devm_add_action_or_reset (& i2c -> dev , rt5640_cancel_work , rt5640 );
3038
+ ret = devm_add_action_or_reset (& i2c -> dev , rt5640_disable_irq_and_cancel_work , rt5640 );
3036
3039
if (ret )
3037
3040
return ret ;
3038
3041
0 commit comments