Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1558063rdd; Thu, 11 Jan 2024 02:53:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdjL/UIl8GYfjNxr6xd6gje+58Je96VL7LD8viXMJ6mZqfbdLYC4dHRt+Fa9GG2psI1pMc X-Received: by 2002:a25:bf84:0:b0:dbd:afaf:2e2f with SMTP id l4-20020a25bf84000000b00dbdafaf2e2fmr757198ybk.41.1704970409685; Thu, 11 Jan 2024 02:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970409; cv=none; d=google.com; s=arc-20160816; b=W4BQaoVm+Eu6u75Vw2Tu8FgH6yR9ukh53jybZWL6B3fdKPKmUw9uPv9TuwljJbprr8 ooAJzkGCs1E60eQucJjr7B8xtCleObdiDAlPJXnG3MxtCtWfX+48iFtM4R7qjdgx3nJR AKjn3NoMCNNx0FgEbNF22ft5n7T5UwnEYmtLGfgJrAN+2xAwJf41Ps2zRVElUdZH8A2h 8YeAjqJfHUZcPEh8Q6U9hXdFXjiVo88FjL70V8QX4X3kOJDyyxy4SGdGBxXPTQYg5OyI 7C4zpqIVYwc6/8agteu8Wg4siIq+JpZKosfuSD1EEYZVZz80yvsL5aQr6RYjeKPwdQTF Y9Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xCkOlbpufV21T73lKyqSSfv/lw+c6vBMckvXJPt/9ic=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=nwOE26VTpTu5EEgDgvEugb2rj+Z1edBUtF9x8xjFRplIvtntuDxezV7SUbHxyXQ8wQ QuZeqwBn9uEgrsNsdYf16UDxEpmDFMAtStYhncwZwhnMmeqbvdBciKXE4WTYP8WxXbdG 6Vb887Z7mbYMFEYYlNC+eMQEnQIYUTrHUqO5AJ7zONcy0oh44mLE2JogEFl4oCjkFobd GyfjAPkSuY4OBW3yw2d/8HzAi7SuSzYL5rjOJ3FQEAA91TNyWIuQytgSGxILMHcN/hHd 15fZnYT7erGesBxLEA5GfLdx4HBpnzQshASko9q6IqY6h/lmZmVtan9B+eVWWkh7MF5N JbQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=q4kLQ0pR; spf=pass (google.com: domain of linux-kernel+bounces-23417-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k1-20020ac85fc1000000b00429c7bfc4b2si274122qta.392.2024.01.11.02.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23417-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=q4kLQ0pR; spf=pass (google.com: domain of linux-kernel+bounces-23417-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6FC651C21BA5 for ; Thu, 11 Jan 2024 10:53:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D8701549C; Thu, 11 Jan 2024 10:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="q4kLQ0pR" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 211CB14F68; Thu, 11 Jan 2024 10:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704970373; bh=t5/M/FDJlEol50qHM5SqsEKoXsNv1Vb4Pkp42aLqIa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q4kLQ0pRzFTsf7+QSE8HGBiTkkbxto3GLyZ/YvnTZ3mYaGX8FfpVDoW/lCHeVEnrp KDquhySZRSotQRrNpFz7IxcBhS8HRZql2vryLjMWnFXGTsPv1mm83U4LWKVWBbFh1n kNp5Q0TsZ4yta0eBv1yrC3tqnJJTrn5uMX1BLsO1an4Om8eIsjITCVEyP2Ge9CLhXz AVRGSiVkjnfVb9kpbBfTX9kERC6Xsl8c4gwQuOo2AF/PHqrXvKSWgPTtGbCs1Hs2qQ Igi4DuQN7WY0gWzRwOnUKN+jHP27eSWNFbWSYz6lwKV+xDJIKIwqjyrKQ5zUgG2YPn TBQ7/nNSxctcA== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 65DF93781FCB; Thu, 11 Jan 2024 10:52:52 +0000 (UTC) From: AngeloGioacchino Del Regno To: lgirdwood@gmail.com Cc: broonie@kernel.org, perex@perex.cz, tiwai@suse.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, ribalda@chromium.org, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, kuninori.morimoto.gx@renesas.com, nfraprado@collabora.com, alsa-devel@alsa-project.org, trevor.wu@mediatek.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 2/7] ASoC: mediatek: mt8173-afe-pcm: Use devm_snd_soc_register_component() Date: Thu, 11 Jan 2024 11:52:42 +0100 Message-ID: <20240111105247.117766-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111105247.117766-1-angelogioacchino.delregno@collabora.com> References: <20240111105247.117766-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Function devm_snd_soc_register_component() allocates a new struct snd_soc_component, adds components and initializes them; since this is also devm, it automatically unregisters components and frees memory upon destruction. That's exactly what we're doing in the probe function of this driver: switch to that function instead, allowing to remove the last goto and to discard the .remove_new() callback for this driver. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 58 +++------------------- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index ea611730de9c..b887e10635fe 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -1129,72 +1129,31 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) afe->runtime_resume = mt8173_afe_runtime_resume; afe->runtime_suspend = mt8173_afe_runtime_suspend; - ret = devm_snd_soc_register_component(&pdev->dev, - &mtk_afe_pcm_platform, - NULL, 0); + ret = devm_snd_soc_register_component(&pdev->dev, &mtk_afe_pcm_platform, NULL, 0); if (ret) return ret; - comp_pcm = devm_kzalloc(&pdev->dev, sizeof(*comp_pcm), GFP_KERNEL); - if (!comp_pcm) - return -ENOMEM; - - ret = snd_soc_component_initialize(comp_pcm, - &mt8173_afe_pcm_dai_component, - &pdev->dev); + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_pcm_dai_component, + mt8173_afe_pcm_dais, + ARRAY_SIZE(mt8173_afe_pcm_dais)); if (ret) return ret; -#ifdef CONFIG_DEBUG_FS - comp_pcm->debugfs_prefix = "pcm"; -#endif - - ret = snd_soc_add_component(comp_pcm, - mt8173_afe_pcm_dais, - ARRAY_SIZE(mt8173_afe_pcm_dais)); + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_hdmi_dai_component, + mt8173_afe_hdmi_dais, + ARRAY_SIZE(mt8173_afe_hdmi_dais)); if (ret) return ret; - comp_hdmi = devm_kzalloc(&pdev->dev, sizeof(*comp_hdmi), GFP_KERNEL); - if (!comp_hdmi) { - ret = -ENOMEM; - goto err_cleanup_components; - } - - ret = snd_soc_component_initialize(comp_hdmi, - &mt8173_afe_hdmi_dai_component, - &pdev->dev); - if (ret) - goto err_cleanup_components; - -#ifdef CONFIG_DEBUG_FS - comp_hdmi->debugfs_prefix = "hdmi"; -#endif - - ret = snd_soc_add_component(comp_hdmi, - mt8173_afe_hdmi_dais, - ARRAY_SIZE(mt8173_afe_hdmi_dais)); - if (ret) - goto err_cleanup_components; - ret = devm_request_irq(afe->dev, irq_id, mt8173_afe_irq_handler, 0, "Afe_ISR_Handle", (void *)afe); if (ret) { dev_err(afe->dev, "could not request_irq\n"); - goto err_cleanup_components; + return ret; } dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n"); return 0; - -err_cleanup_components: - snd_soc_unregister_component(&pdev->dev); - return ret; -} - -static void mt8173_afe_pcm_dev_remove(struct platform_device *pdev) -{ - snd_soc_unregister_component(&pdev->dev); } static const struct of_device_id mt8173_afe_pcm_dt_match[] = { @@ -1215,7 +1174,6 @@ static struct platform_driver mt8173_afe_pcm_driver = { .pm = &mt8173_afe_pm_ops, }, .probe = mt8173_afe_pcm_dev_probe, - .remove_new = mt8173_afe_pcm_dev_remove, }; module_platform_driver(mt8173_afe_pcm_driver); -- 2.43.0