From: Takashi Iwai Subject: Re: [RFC 3/3] ALSA: hda - add soc hda bus wrapper Date: Sat, 04 Apr 2015 14:31:38 +0200 Message-ID: References: <1427968651-7821-1-git-send-email-vinod.koul@intel.com> <1427968651-7821-4-git-send-email-vinod.koul@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 mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id BE6112604EB for ; Sat, 4 Apr 2015 14:31:39 +0200 (CEST) In-Reply-To: <1427968651-7821-4-git-send-email-vinod.koul@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Vinod Koul Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com, pathes.audio@intel.com, Ramesh Babu List-Id: alsa-devel@alsa-project.org At Thu, 2 Apr 2015 15:27:31 +0530, Vinod Koul wrote: > > From: Ramesh Babu > > The SKL controller will be ASoC device but needs access to HDA code, so > create asoc wrppers on top of hdac. > > Signed-off-by: Ramesh Babu > Signed-off-by: Vinod Koul Just a few comment after a quicky glance. Will do more reviews once after processing my huge backlogs after vacation. > +/** > + * hda_device_unregister - unregister a hda device > + * @pdev: hda device we're unregistering > + * > + * Unregistration is done in 2 steps. First we release all resources > + * and remove it from the subsystem, then we drop reference count by > + * calling hda_device_put(). > + */ > +void snd_soc_hdac_device_unregister(struct snd_soc_hdac_device *pdev) > +{ > + snd_hdac_device_exit(&pdev->hdac); > + snd_hdac_device_unregister(&pdev->hdac); > + snd_soc_hdac_device_put(pdev); > +} > +EXPORT_SYMBOL_GPL(snd_soc_hdac_device_unregister); > + Doing this in a shot is basically wrong. Since ASoC doesn't care much about the hotplug/unplug, maybe it doesn't matter so much for now, though... In general, you should unregister from the subsystem at first. And calling snd_hdac_device_exit() should be done in the device object destructor. Unregister doesn't guarantee the immediate release of resources that was being used, thus it's pretty much racy. BTW, the function name in the comment must be same as the real name. > +/** > + * hda_match - bind hda device to hda driver. > + * @dev: device. > + * @drv: driver. > + * > + */ > +static int soc_hdac_match(struct device *dev, struct device_driver *drv) > +{ > + struct snd_soc_hdac_device *pdev = to_soc_hdac_device(dev); > + struct snd_soc_hdac_driver *pdrv = to_soc_hdac_driver(drv); > + > + /* Then try to match against the id table */ > + if (pdrv->id_table) > + return soc_hda_match_id(pdrv->id_table, pdev) != NULL; > + > + /* fall-back to driver name match */ > + return (strcmp(pdev->name, drv->name) == 0); > +} > +EXPORT_SYMBOL_GPL(soc_hdac_match); Any reason to drop snd_ prefix only for this function? > +MODULE_DESCRIPTION("ASOC HDA bus core"); ASoC. Takashi