Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Subject: Re: [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing
Date: Mon, 20 May 2019 08:29:50 -0500	[thread overview]
Message-ID: <deb932a6-32cf-d455-e609-ea4657ecb229@linux.intel.com> (raw)
In-Reply-To: <87imu5zzh7.wl-kuninori.morimoto.gx@renesas.com>



On 5/19/19 8:42 PM, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> soc_pcm_components_open/close() try to call
> try_module_get()/module_put() based on
> component->driver->module_get_upon_open.
> 
> Here, the purpose why we need to call these functions are to
> checking module reference.
> Thus, we need to call try_module_open() even though it doesn't
> have .open callback.
> 
> The same reason, we need to call module_put() even though it
> doesn't have .close
> 
> This patch calls try_module_get()/module_put() regardless of
> .open/.close
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>


LGTM, this removes the assumptions on the implementation of .open and 
.close.

FWIW
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Thanks!

> ---
> v1 -> v2
> 
>   - merge both try_module_get()/module_put() patch into 1
> 
>   sound/soc/soc-pcm.c | 16 +++++++---------
>   1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 7737e00..e24eab3 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -440,10 +440,6 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
>   		component = rtdcom->component;
>   		*last = component;
>   
> -		if (!component->driver->ops ||
> -		    !component->driver->ops->open)
> -			continue;
> -
>   		if (component->driver->module_get_upon_open &&
>   		    !try_module_get(component->dev->driver->owner)) {
>   			dev_err(component->dev,
> @@ -452,6 +448,10 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
>   			return -ENODEV;
>   		}
>   
> +		if (!component->driver->ops ||
> +		    !component->driver->ops->open)
> +			continue;
> +
>   		ret = component->driver->ops->open(substream);
>   		if (ret < 0) {
>   			dev_err(component->dev,
> @@ -477,11 +477,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
>   		if (component == last)
>   			break;
>   
> -		if (!component->driver->ops ||
> -		    !component->driver->ops->close)
> -			continue;
> -
> -		component->driver->ops->close(substream);
> +		if (component->driver->ops &&
> +		    component->driver->ops->close)
> +			component->driver->ops->close(substream);
>   
>   		if (component->driver->module_get_upon_open)
>   			module_put(component->dev->driver->owner);
> 

  reply	other threads:[~2019-05-20 13:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20  1:42 [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing Kuninori Morimoto
2019-05-20 13:29 ` Pierre-Louis Bossart [this message]
2019-05-21 21:04 ` Applied "ASoC: soc-pcm: fixup try_module_get()/module_put() timing" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=deb932a6-32cf-d455-e609-ea4657ecb229@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=ranjani.sridharan@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox