diff mbox series

[v5,6/9] media: adv748x: prepare/enable mclk when the audio is used

Message ID d9b7a7290e3d95b484a7a760484f827c3ed7651e.1585852001.git.alexander.riesen@cetitec.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series media: adv748x: add support for HDMI audio | expand

Commit Message

Alex Riesen April 2, 2020, 6:34 p.m. UTC
As there is nothing else (the consumers are supposed to do that) which
enables the clock, do it in the driver.

Signed-off-by: Alexander Riesen <alexander.riesen@cetitec.com>
--

v3: added
---
 drivers/media/i2c/adv748x/adv748x-dai.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Kieran Bingham June 18, 2020, 4:23 p.m. UTC | #1
Hi Alex,

On 02/04/2020 19:34, Alex Riesen wrote:
> As there is nothing else (the consumers are supposed to do that) which
> enables the clock, do it in the driver.
> 
> Signed-off-by: Alexander Riesen <alexander.riesen@cetitec.com>
> --
> 
> v3: added
> ---
>  drivers/media/i2c/adv748x/adv748x-dai.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-dai.c b/drivers/media/i2c/adv748x/adv748x-dai.c
> index c9191f8f1ca8..185f78023e91 100644
> --- a/drivers/media/i2c/adv748x/adv748x-dai.c
> +++ b/drivers/media/i2c/adv748x/adv748x-dai.c
> @@ -117,11 +117,22 @@ static int adv748x_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
>  
>  static int adv748x_dai_startup(struct snd_pcm_substream *sub, struct snd_soc_dai *dai)
>  {
> +	int ret;
>  	struct adv748x_state *state = state_of(dai);
>  
>  	if (sub->stream != SNDRV_PCM_STREAM_CAPTURE)
>  		return -EINVAL;
this looks quite bunched up so :

Newline...

> -	return set_audio_pads_state(state, 1);
> +	ret = set_audio_pads_state(state, 1);
> +	if (ret)
> +		goto fail;

With no action required to cleanup here, I would just
		return ret;
and remove the fail: label.


Newline...

> +	ret = clk_prepare_enable(mclk_of(state));
> +	if (ret)
> +		goto fail_pwdn;

newline...

> +	return 0;

newline...

Other than that:

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> +fail_pwdn:
> +	set_audio_pads_state(state, 0);
> +fail:
> +	return ret;
>  }
>  
>  static int adv748x_dai_hw_params(struct snd_pcm_substream *sub,
> @@ -174,6 +185,7 @@ static void adv748x_dai_shutdown(struct snd_pcm_substream *sub, struct snd_soc_d
>  {
>  	struct adv748x_state *state = state_of(dai);
>  
> +	clk_disable_unprepare(mclk_of(state));
>  	set_audio_pads_state(state, 0);
>  }
>  
>
Alex Riesen June 19, 2020, 8:51 a.m. UTC | #2
Kieran Bingham, Thu, Jun 18, 2020 18:23:14 +0200:
> On 02/04/2020 19:34, Alex Riesen wrote:
> > --- a/drivers/media/i2c/adv748x/adv748x-dai.c
> > +++ b/drivers/media/i2c/adv748x/adv748x-dai.c
> > @@ -117,11 +117,22 @@ static int adv748x_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
> >  
> >  static int adv748x_dai_startup(struct snd_pcm_substream *sub, struct snd_soc_dai *dai)
> >  {
> > +	int ret;
> >  	struct adv748x_state *state = state_of(dai);
> >  
> >  	if (sub->stream != SNDRV_PCM_STREAM_CAPTURE)
> >  		return -EINVAL;
> this looks quite bunched up so :
> 
> Newline...

Will do.

> > -	return set_audio_pads_state(state, 1);
> > +	ret = set_audio_pads_state(state, 1);
> > +	if (ret)
> > +		goto fail;
> 
> With no action required to cleanup here, I would just
> 		return ret;
> and remove the fail: label.

Of course.

> > +	ret = clk_prepare_enable(mclk_of(state));
> > +	if (ret)
> > +		goto fail_pwdn;
> 
> newline...
> 
> > +	return 0;
> 
> newline...
> 
> Other than that:
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Thanks!
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv748x/adv748x-dai.c b/drivers/media/i2c/adv748x/adv748x-dai.c
index c9191f8f1ca8..185f78023e91 100644
--- a/drivers/media/i2c/adv748x/adv748x-dai.c
+++ b/drivers/media/i2c/adv748x/adv748x-dai.c
@@ -117,11 +117,22 @@  static int adv748x_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 
 static int adv748x_dai_startup(struct snd_pcm_substream *sub, struct snd_soc_dai *dai)
 {
+	int ret;
 	struct adv748x_state *state = state_of(dai);
 
 	if (sub->stream != SNDRV_PCM_STREAM_CAPTURE)
 		return -EINVAL;
-	return set_audio_pads_state(state, 1);
+	ret = set_audio_pads_state(state, 1);
+	if (ret)
+		goto fail;
+	ret = clk_prepare_enable(mclk_of(state));
+	if (ret)
+		goto fail_pwdn;
+	return 0;
+fail_pwdn:
+	set_audio_pads_state(state, 0);
+fail:
+	return ret;
 }
 
 static int adv748x_dai_hw_params(struct snd_pcm_substream *sub,
@@ -174,6 +185,7 @@  static void adv748x_dai_shutdown(struct snd_pcm_substream *sub, struct snd_soc_d
 {
 	struct adv748x_state *state = state_of(dai);
 
+	clk_disable_unprepare(mclk_of(state));
 	set_audio_pads_state(state, 0);
 }