From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 2/2] ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC Date: Mon, 29 Apr 2019 09:12:37 +0200 Message-ID: References: <20190427205340.8830-1-yung-chuan.liao@linux.intel.com> <20190427205340.8830-2-yung-chuan.liao@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A7F6EF89693 for ; Mon, 29 Apr 2019 09:12:37 +0200 (CEST) In-Reply-To: <20190427205340.8830-2-yung-chuan.liao@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Bard liao Cc: liam.r.girdwood@linux.intel.com, alsa-devel@alsa-project.org, broonie@kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com List-Id: alsa-devel@alsa-project.org On Sat, 27 Apr 2019 22:53:40 +0200, Bard liao wrote: > > In ASoC driver, snd_hdac_device_register() will be called by > snd_hdac_ext_bus_device_init() and snd_hdac_device_unregister() > will called by snd_hdac_ext_bus_device_remove(). However when > ASoC codec driver call snd_hda_codec_device_new() to create a > new hda codec, it will assign snd_hda_codec_dev_free() to the > dev_free ops and snd_hda_codec_dev_free() will call > snd_hdac_device_unregister(). As a result, snd_hdac_device_unregister() > will be called twice in ASoC driver. To prevent it, we use hdev > type to determine if the hda codec is registered by legacy HDA > driver or ASoC driver and unregister device in snd_hda_codec_dev_free() > only if it is a legacy HDA device. > This patch will overwrite the hdev type so that we can know it is > a ASoC device. > > Signed-off-by: Bard liao Applied, thanks. Takashi > --- > sound/soc/codecs/hdac_hda.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c > index f889d94c8e3c..7d4940256914 100644 > --- a/sound/soc/codecs/hdac_hda.c > +++ b/sound/soc/codecs/hdac_hda.c > @@ -328,6 +328,12 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) > dev_err(&hdev->dev, "failed to create hda codec %d\n", ret); > goto error_no_pm; > } > + /* > + * Overwrite type to HDA_DEV_ASOC since it is a ASoC driver > + * hda_codec.c will check this flag to determine if unregister > + * device is needed. > + */ > + hdev->type = HDA_DEV_ASOC; > > /* > * snd_hda_codec_device_new decrements the usage count so call get pm > -- > 2.17.1 >