@@ -65,13 +65,15 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
6565 unsigned int status ;
6666 unsigned int tmp ;
6767
68- spin_lock (& player -> irq_lock );
68+ guard ( spinlock ) (& player -> irq_lock );
6969 if (!player -> substream )
70- goto irq_spin_unlock ;
70+ return ret ;
7171
7272 snd_pcm_stream_lock (player -> substream );
73- if (player -> state == UNIPERIF_STATE_STOPPED )
74- goto stream_unlock ;
73+ if (player -> state == UNIPERIF_STATE_STOPPED ) {
74+ snd_pcm_stream_unlock (player -> substream );
75+ return ret ;
76+ }
7577
7678 /* Get interrupt status & clear them immediately */
7779 status = GET_UNIPERIF_ITS (player );
@@ -116,7 +118,8 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
116118 dev_err (player -> dev ,
117119 "unexpected Underflow recovering\n" );
118120 ret = - EPERM ;
119- goto stream_unlock ;
121+ snd_pcm_stream_unlock (player -> substream );
122+ return ret ;
120123 }
121124 /* Read the underflow recovery duration */
122125 tmp = GET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION (player );
@@ -143,10 +146,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
143146 ret = IRQ_HANDLED ;
144147 }
145148
146- stream_unlock :
147149 snd_pcm_stream_unlock (player -> substream );
148- irq_spin_unlock :
149- spin_unlock (& player -> irq_lock );
150150
151151 return ret ;
152152}
@@ -363,10 +363,10 @@ static int uni_player_prepare_iec958(struct uniperif *player,
363363
364364 SET_UNIPERIF_CTRL_ZERO_STUFF_HW (player );
365365
366- mutex_lock (& player -> ctrl_lock );
367366 /* Update the channel status */
368- uni_player_set_channel_status (player , runtime );
369- mutex_unlock (& player -> ctrl_lock );
367+ scoped_guard (mutex , & player -> ctrl_lock )
368+ uni_player_set_channel_status (player , runtime );
369+
370370
371371 /* Clear the user validity user bits */
372372 SET_UNIPERIF_USER_VALIDITY_VALIDITY_LR (player , 0 );
@@ -546,11 +546,11 @@ static int uni_player_prepare_tdm(struct uniperif *player,
546546
547547 /* set unip clk rate (not done vai set_sysclk ops) */
548548 freq = runtime -> rate * tdm_frame_size * 8 ;
549- mutex_lock ( & player -> ctrl_lock );
550- ret = uni_player_clk_set_rate (player , freq );
551- if (!ret )
552- player -> mclk = freq ;
553- mutex_unlock ( & player -> ctrl_lock );
549+ scoped_guard ( mutex , & player -> ctrl_lock ) {
550+ ret = uni_player_clk_set_rate (player , freq );
551+ if (!ret )
552+ player -> mclk = freq ;
553+ }
554554
555555 return 0 ;
556556}
@@ -575,12 +575,11 @@ static int uni_player_ctl_iec958_get(struct snd_kcontrol *kcontrol,
575575 struct uniperif * player = priv -> dai_data .uni ;
576576 struct snd_aes_iec958 * iec958 = & player -> stream_settings .iec958 ;
577577
578- mutex_lock (& player -> ctrl_lock );
578+ guard ( mutex ) (& player -> ctrl_lock );
579579 ucontrol -> value .iec958 .status [0 ] = iec958 -> status [0 ];
580580 ucontrol -> value .iec958 .status [1 ] = iec958 -> status [1 ];
581581 ucontrol -> value .iec958 .status [2 ] = iec958 -> status [2 ];
582582 ucontrol -> value .iec958 .status [3 ] = iec958 -> status [3 ];
583- mutex_unlock (& player -> ctrl_lock );
584583 return 0 ;
585584}
586585
@@ -591,23 +590,20 @@ static int uni_player_ctl_iec958_put(struct snd_kcontrol *kcontrol,
591590 struct sti_uniperiph_data * priv = snd_soc_dai_get_drvdata (dai );
592591 struct uniperif * player = priv -> dai_data .uni ;
593592 struct snd_aes_iec958 * iec958 = & player -> stream_settings .iec958 ;
594- unsigned long flags ;
595593
596- mutex_lock (& player -> ctrl_lock );
594+ guard ( mutex ) (& player -> ctrl_lock );
597595 iec958 -> status [0 ] = ucontrol -> value .iec958 .status [0 ];
598596 iec958 -> status [1 ] = ucontrol -> value .iec958 .status [1 ];
599597 iec958 -> status [2 ] = ucontrol -> value .iec958 .status [2 ];
600598 iec958 -> status [3 ] = ucontrol -> value .iec958 .status [3 ];
601599
602- spin_lock_irqsave (& player -> irq_lock , flags );
603- if (player -> substream && player -> substream -> runtime )
604- uni_player_set_channel_status (player ,
605- player -> substream -> runtime );
606- else
607- uni_player_set_channel_status (player , NULL );
608-
609- spin_unlock_irqrestore (& player -> irq_lock , flags );
610- mutex_unlock (& player -> ctrl_lock );
600+ scoped_guard (spinlock_irqsave , & player -> irq_lock ) {
601+ if (player -> substream && player -> substream -> runtime )
602+ uni_player_set_channel_status (player ,
603+ player -> substream -> runtime );
604+ else
605+ uni_player_set_channel_status (player , NULL );
606+ }
611607
612608 return 0 ;
613609}
@@ -642,9 +638,8 @@ static int snd_sti_clk_adjustment_get(struct snd_kcontrol *kcontrol,
642638 struct sti_uniperiph_data * priv = snd_soc_dai_get_drvdata (dai );
643639 struct uniperif * player = priv -> dai_data .uni ;
644640
645- mutex_lock (& player -> ctrl_lock );
641+ guard ( mutex ) (& player -> ctrl_lock );
646642 ucontrol -> value .integer .value [0 ] = player -> clk_adj ;
647- mutex_unlock (& player -> ctrl_lock );
648643
649644 return 0 ;
650645}
@@ -661,12 +656,11 @@ static int snd_sti_clk_adjustment_put(struct snd_kcontrol *kcontrol,
661656 (ucontrol -> value .integer .value [0 ] > UNIPERIF_PLAYER_CLK_ADJ_MAX ))
662657 return - EINVAL ;
663658
664- mutex_lock (& player -> ctrl_lock );
659+ guard ( mutex ) (& player -> ctrl_lock );
665660 player -> clk_adj = ucontrol -> value .integer .value [0 ];
666661
667662 if (player -> mclk )
668663 ret = uni_player_clk_set_rate (player , player -> mclk );
669- mutex_unlock (& player -> ctrl_lock );
670664
671665 return ret ;
672666}
@@ -693,12 +687,10 @@ static int uni_player_startup(struct snd_pcm_substream *substream,
693687{
694688 struct sti_uniperiph_data * priv = snd_soc_dai_get_drvdata (dai );
695689 struct uniperif * player = priv -> dai_data .uni ;
696- unsigned long flags ;
697690 int ret ;
698691
699- spin_lock_irqsave (& player -> irq_lock , flags );
700- player -> substream = substream ;
701- spin_unlock_irqrestore (& player -> irq_lock , flags );
692+ scoped_guard (spinlock_irqsave , & player -> irq_lock )
693+ player -> substream = substream ;
702694
703695 player -> clk_adj = 0 ;
704696
@@ -734,11 +726,10 @@ static int uni_player_set_sysclk(struct snd_soc_dai *dai, int clk_id,
734726 if (clk_id != 0 )
735727 return - EINVAL ;
736728
737- mutex_lock (& player -> ctrl_lock );
729+ guard ( mutex ) (& player -> ctrl_lock );
738730 ret = uni_player_clk_set_rate (player , freq );
739731 if (!ret )
740732 player -> mclk = freq ;
741- mutex_unlock (& player -> ctrl_lock );
742733
743734 return ret ;
744735}
@@ -996,15 +987,13 @@ static void uni_player_shutdown(struct snd_pcm_substream *substream,
996987{
997988 struct sti_uniperiph_data * priv = snd_soc_dai_get_drvdata (dai );
998989 struct uniperif * player = priv -> dai_data .uni ;
999- unsigned long flags ;
1000990
1001- spin_lock_irqsave ( & player -> irq_lock , flags );
991+ guard ( spinlock_irqsave )( & player -> irq_lock );
1002992 if (player -> state != UNIPERIF_STATE_STOPPED )
1003993 /* Stop the player */
1004994 uni_player_stop (player );
1005995
1006996 player -> substream = NULL ;
1007- spin_unlock_irqrestore (& player -> irq_lock , flags );
1008997}
1009998
1010999static int uni_player_parse_dt_audio_glue (struct platform_device * pdev ,
0 commit comments