From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2680C433FE for ; Wed, 20 Oct 2021 09:17:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 909A960F9E for ; Wed, 20 Oct 2021 09:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbhJTJTk (ORCPT ); Wed, 20 Oct 2021 05:19:40 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:53068 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbhJTJTj (ORCPT ); Wed, 20 Oct 2021 05:19:39 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2412821A95; Wed, 20 Oct 2021 09:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1634721444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mDhieyIXeE4V5jHwQZTe7ZXZZbr+qjBnbmqOemXSzlk=; b=fc1si36eMekGSQDqcS/Hn3Eorlm6YyDIm/s2QHHgKQUzjS46rECZKO3+n1oE9Nbk4ifixX lHutHNI6ClB8dkbZYqDyWqO4MSVM5OdXNwSw0pd/TeeNDcLAcLbQu7Al7YRxspvGYABhm/ kEFqql32f4JdNRImBy/VF3c03nUsD6Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1634721444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mDhieyIXeE4V5jHwQZTe7ZXZZbr+qjBnbmqOemXSzlk=; b=pEnnCCdRCZrs86YOnpoamSueJv/AfbpZdfLMiHOcWnBqMS+tMPKzKMwcS74ex8rJLtlK+x yUV8QW7y9zvj8BBQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 04F4FA3B83; Wed, 20 Oct 2021 09:17:24 +0000 (UTC) Date: Wed, 20 Oct 2021 11:17:24 +0200 Message-ID: From: Takashi Iwai To: Lucas Tanure Cc: Mark Brown , Takashi Iwai , "Jaroslav Kysela" , Len Brown , David Rhodes , Liam Girdwood , "Rafael J . Wysocki" , , , , Subject: Re: [RFC PATCH v2 2/3] ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop Speakers In-Reply-To: <20211020085944.17577-3-tanureal@opensource.cirrus.com> References: <20211020085944.17577-1-tanureal@opensource.cirrus.com> <20211020085944.17577-3-tanureal@opensource.cirrus.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 20 Oct 2021 10:59:43 +0200, Lucas Tanure wrote: > > Find the associated Amps by dai name, and use dai ops to configure it. > Disable support for Amps if ASoC not built. Hrm, it's the question whether such a sneaking into DAI access in open code is a good idea. If any, it could be done by some helper function instead. And some more details: > +static int alc_add_soc_dai_list(struct alc_spec *spec, const char *dai_name) > +{ > +#if IS_ENABLED(CONFIG_SND_SOC) > + struct snd_soc_dai_link_component dlc; > + struct alc_soc_dai_node *dai_node; > + //struct snd_soc_component *comp; > + struct snd_soc_dai *dai; > + > + dlc.dai_name = dai_name; > + dlc.of_node = NULL; > + dlc.name = NULL; > + > + dai = snd_soc_find_dai(&dlc); > + if (!dai) > + return -EPROBE_DEFER; The deferred probe won't work at this stage for HD-audio codecs unlike many ASoC codec drivers. And moreover, the fixup action doesn't handle the error at all... Second, this way may lead to use-after-free if the ASoC stuff is unbound while the usage from HD-audio codec side. Also, the dependency mess is still there. Even if we allow the hard binding to ASoC core here, IS_ENABLED() wouldn't work properly. It must be IS_REACHABLE(). thanks, Takashi