From patchwork Thu Jan 11 10:52:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187292 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1362436dyi; Thu, 11 Jan 2024 02:53:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDP6sIojB6kbVjd07mdaem8uKD2t4gcO+K6Z+W32G3mMFPz4pew5n1aHQbLr8HQptCWGze X-Received: by 2002:ac8:5b90:0:b0:429:a4fb:6472 with SMTP id a16-20020ac85b90000000b00429a4fb6472mr502076qta.67.1704970416805; Thu, 11 Jan 2024 02:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970416; cv=none; d=google.com; s=arc-20160816; b=eg1uFa85nDa674ex86GYorxxg+XpumGle0RXh6QhvagidKo1Lr/YOGqsYTZpkGSuni MzNSkNVufl/YNC9gSjksVD1E/Ij2DRR6x92wv74JoP3bzDHyhX/llLTJFhGTTSljZaEs 7/EmPJLEKNq0z3YgerFbcGuMENOC/bf4GkQVr7hHFr9xgyPNKEN86+y7bmveBd0ebJ0z DNBL8dPepZ/x8S8AUtLoHkqPJGKk4ilQj3eNsLinfFwWFAslX+A8tMy4v6bcu6QlUCqi eS6X4ICcxG6icJDlY+5D+AMSmDqc3EnmpVu2gFw/DaboZZwofp/xs9Q7cPA5rlTFlqOL QowQ== 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=9IYyC4d/hNrMlC2tVu1GIwMwt/EpR1E5m0XFiTNzcRE=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=JbGMKWs3dl16xJXCoaZasKkwq1MRLTC0AJs+Qr2xtcMWTqTAXwv0dpQgPJkc36P7wV GBiT37UlqZZ9cSnFT1JD44BF5f5zxMQ5AFQf2oZS6HL3ps7jztgFNJDeF3JhhLSUhex/ WTlpR3YRVaEp5Jf2oF5YUWEMh5jjsXJ4giiqjejACEB9jlL0RUG5fAdEceR6qDpX9Kbe W1e4S46LpjmXdH41fLi3xekgUMjHpURBCGe1gnf/AOSsrxC/1YiYfUNdqiGAPbKRaG4e bOi6ta98lpfhX6tXfddNrp/hDAGrFnLQV6IXfOW1AzWDYqlRFPM+E+P3wV/1JbJhV2Ki M5lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=qk+I+0Dx; spf=pass (google.com: domain of linux-kernel+bounces-23416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:53:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23416-ouuuleilei=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=qk+I+0Dx; spf=pass (google.com: domain of linux-kernel+bounces-23416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23416-ouuuleilei=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 975DB1C211A0 for ; Thu, 11 Jan 2024 10:53:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12401154AF; Thu, 11 Jan 2024 10:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="qk+I+0Dx" 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 07E3B14F62; Thu, 11 Jan 2024 10:52:53 +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=1704970372; bh=AMVfzvbVKztx/7y6kdCGWvpZXOG+ZdfCsQ9HsmGMSIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qk+I+0DxAYUMmqa4SXs2yQNDEr8U9KFs2met++sPRrAGr9Sv8ukwt5HOmrMslZ1b/ C8gok5VsWBPtXV+T38iN7/ogRpLsVSWbXRN7Lb7Ut714tTRoLCRRlpfMw9GtJvcqTj fwUvnljf4hrlDGINcL0v6lLnfJ22gP2G1iYV94ya+8jhgU5a0UzBweWPJ+QGF+R7TN XJkTvLgVkz+XLA6MV/Bb5fHToJfW0gNcJysA9P0lCXXFl2enyOS3rrUltQ5JFXEXX0 s4N1UbVY+stgZdg4nG7rRkiyFH/TO78m1+9AWXJOXqsb4164xAbxlZBQ/3c0JFsvDH LidQhyG5J8XVQ== 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 21F8E3781F8E; Thu, 11 Jan 2024 10:52:51 +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 1/7] ASoC: mediatek: mt8173-afe-pcm: Convert to devm_pm_runtime_enable() Date: Thu, 11 Jan 2024 11:52:41 +0100 Message-ID: <20240111105247.117766-2-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791060133849521 X-GMAIL-MSGID: 1787791060133849521 Switch from pm_runtime_enable() to devm_pm_runtime_enable() to simplify the probe function. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index b6291b7c811e..ea611730de9c 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -1117,11 +1117,11 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) platform_set_drvdata(pdev, afe); - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret) { ret = mt8173_afe_runtime_resume(&pdev->dev); if (ret) - goto err_pm_disable; + return ret; } afe->reg_back_up_list = mt8173_afe_backup_list; @@ -1133,19 +1133,17 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) &mtk_afe_pcm_platform, NULL, 0); if (ret) - goto err_pm_disable; + return ret; comp_pcm = devm_kzalloc(&pdev->dev, sizeof(*comp_pcm), GFP_KERNEL); - if (!comp_pcm) { - ret = -ENOMEM; - goto err_pm_disable; - } + if (!comp_pcm) + return -ENOMEM; ret = snd_soc_component_initialize(comp_pcm, &mt8173_afe_pcm_dai_component, &pdev->dev); if (ret) - goto err_pm_disable; + return ret; #ifdef CONFIG_DEBUG_FS comp_pcm->debugfs_prefix = "pcm"; @@ -1155,7 +1153,7 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) mt8173_afe_pcm_dais, ARRAY_SIZE(mt8173_afe_pcm_dais)); if (ret) - goto err_pm_disable; + return ret; comp_hdmi = devm_kzalloc(&pdev->dev, sizeof(*comp_hdmi), GFP_KERNEL); if (!comp_hdmi) { @@ -1191,18 +1189,12 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) err_cleanup_components: snd_soc_unregister_component(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); return ret; } static void mt8173_afe_pcm_dev_remove(struct platform_device *pdev) { snd_soc_unregister_component(&pdev->dev); - - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - mt8173_afe_runtime_suspend(&pdev->dev); } static const struct of_device_id mt8173_afe_pcm_dt_match[] = { From patchwork Thu Jan 11 10:52:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187293 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1362511dyi; Thu, 11 Jan 2024 02:53:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFx9O4zp6MfCve7zz57iVnd1n7SjoHEQT90+j7i11OutzYgb2xvUPEt9CYFqIYPtpMar0Z X-Received: by 2002:a05:6214:21cb:b0:681:21f5:7b4f with SMTP id d11-20020a05621421cb00b0068121f57b4fmr990687qvh.1.1704970429374; Thu, 11 Jan 2024 02:53:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970429; cv=none; d=google.com; s=arc-20160816; b=UpXez9i0++94khCCiUpGrb3is2bJw5dCtWccOobPE5xouDLCrtNb7/W2Pa60diguS2 IO6Alpwsw8yxJWXps3q/SB3iW9JzalKuZsGGwjqjsOacJOq16gStIao/HUkjaVxfLsSM kOCdWThHkYGr3SPaOHJaE/dLfpt2QPHjjAVxJpUVQmDqDJs+48q5P/1WaUcGyaXRDsVn 1TDOmj6C22Le/+VJ068vQTFDk3jYh3QzGyIBoFIE3Mk6WskiozNMjVFKK3DUzGok+kBV DzXhxqDB+anyKpVJeR3ngw6hxe6p2REQ2hdOkkHTxGxdJmLz6OGR/AFQapLAXQep/Mfw ANig== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23417-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b26-20020a05620a04fa00b007830d5da0d0si643103qkh.608.2024.01.11.02.53.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23417-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23417-ouuuleilei=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 200491C21398 for ; Thu, 11 Jan 2024 10:53:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BAB9156D2; Thu, 11 Jan 2024 10:52:59 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791073018873131 X-GMAIL-MSGID: 1787791073018873131 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); From patchwork Thu Jan 11 10:52:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1363172dyi; Thu, 11 Jan 2024 02:55:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPWttzp1G6QA6pHsjpfVSy9SgezdpKu5rbSot4jtuV1HxlsAayxeuFjk+zPUhbsW3W4Fs8 X-Received: by 2002:a9d:6b8b:0:b0:6dd:f04e:fa9c with SMTP id b11-20020a9d6b8b000000b006ddf04efa9cmr1020301otq.19.1704970534742; Thu, 11 Jan 2024 02:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970534; cv=none; d=google.com; s=arc-20160816; b=Lpzu1tFTzUhjHra9VTbnvCQwNvijk+KaJg2SWvivVqE1Xe/wtnX3XM08SgPh4LaxxV xYDLGwkbNHJGo8ftUa+TqHuJPTZeSxPFCYPHlOKxJFOQ8205vex4lK6NzHEDBO6502S4 NffTmOdIFNW1UrAxNUGBZfTPLCX6l8phwL0Z51hKKESuZ62fZ/tP/ASS+NVYq89qiHat NfnnqT4pTFpJmxaAKpaMDBTbl/xFH9AsSwWzMccViSbR2MjUyljoIUchbVUw5taQ/8Gp pP6MeYhNipFS3UAWAUJ8181IsgCi8Pba5jwf5v7mtKxZw6uB383Wqt0+QrA3qKnBwegJ yWuQ== 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=7O8ZrcaR95aEVQuJKgVgDSb7Jh2dZAmhdZPIKOujSEo=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=yAyOwO78J1V4uNJpWAmEHm6OmzH3yUvFL5O35MlOP4Unz/1yo405f38QONvt5/S/Hl QvjPOt4+7dyhFzg2J+SzLRy4PJeK0le4rsUyXHlzU6FFWEIg44vWWX6B95vHA7G4foWy 5b64ibeJWVqATtG/9bP9q26SNKRZxpQudB3k48jRk/WJx3EZatz1APkWkA0RvrTWyUyW sfNGvBl3cUjah+UE/LKFkfrudXnLCh49sa8ks7d53Z3Fk2d7DZEHSdfbysvy4nk62nQ7 gd1YhtxUW/djvE6bTsLppuz06ZOzeOjjI0GYsijrx7OcZYVq+OT1HmsDwpRZwkG1k7WU oAEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CNUrzbk4; spf=pass (google.com: domain of linux-kernel+bounces-23418-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23418-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q24-20020a656858000000b005ce2b993254si840353pgt.204.2024.01.11.02.55.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:55:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23418-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CNUrzbk4; spf=pass (google.com: domain of linux-kernel+bounces-23418-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23418-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F0A68B25E5F for ; Thu, 11 Jan 2024 10:54:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AB87156FC; Thu, 11 Jan 2024 10:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="CNUrzbk4" 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 8D21214F9E; Thu, 11 Jan 2024 10:52:56 +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=1704970374; bh=XtTNhQjNYRIFbYwAaKzO87OecuRQA3f4cAGt5GDFOck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CNUrzbk4r7fbiviJuXD8oxOtb3iKe5EZ6yqmDkIH8kPltzXtNMpmI4NOGq83MEVI1 4Oo7NquB7Nzi2dhpP6zLKHsiIAv4YfyQ94P04Tt7KnQHn1+6cs/B/4ujmR4GY2/chb ezNdk7jrKmWEYZYWLG6bfgIHa0EXuDHw+Quxj8Ab0WNdz0Vc6e1MUPPXwMtNqrI0+7 j99NGjV5OZp8xAq8LmRDhmiMLj2AONbdaj6D10To8MFPFOegcE7eEouWNyge8/QAJt u5G+4gBJ0vGkhi/GVWq8O4Fyk+rBpNVNLUj10ulNJgIRmVx5HdI90peUi77GUlQZPL IByK4lwVHvKtg== 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 AB3883781FCD; Thu, 11 Jan 2024 10:52:53 +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 3/7] ASoC: mediatek: mt8183-afe-pcm: Convert to devm_pm_runtime_enable() Date: Thu, 11 Jan 2024 11:52:43 +0100 Message-ID: <20240111105247.117766-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791183159424147 X-GMAIL-MSGID: 1787791183159424147 Switch from pm_runtime_enable() to devm_pm_runtime_enable() to simplify the probe function and remove the now useless .remove_new() callback. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 57 ++++++++-------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c index 9e432ed9124b..d10aabf65a78 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -1113,32 +1113,33 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) return ret; } - pm_runtime_enable(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; /* regmap init */ afe->regmap = syscon_node_to_regmap(dev->parent->of_node); if (IS_ERR(afe->regmap)) { dev_err(dev, "could not get regmap from parent\n"); - ret = PTR_ERR(afe->regmap); - goto err_pm_disable; + return PTR_ERR(afe->regmap); } ret = regmap_attach_dev(dev, afe->regmap, &mt8183_afe_regmap_config); if (ret) { dev_warn(dev, "regmap_attach_dev fail, ret %d\n", ret); - goto err_pm_disable; + return ret; } rstc = devm_reset_control_get(dev, "audiosys"); if (IS_ERR(rstc)) { ret = PTR_ERR(rstc); dev_err(dev, "could not get audiosys reset:%d\n", ret); - goto err_pm_disable; + return ret; } ret = reset_control_reset(rstc); if (ret) { dev_err(dev, "failed to trigger audio reset:%d\n", ret); - goto err_pm_disable; + return ret; } /* enable clock for regcache get default value from hw */ @@ -1148,7 +1149,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) ret = regmap_reinit_cache(afe->regmap, &mt8183_afe_regmap_config); if (ret) { dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret); - goto err_pm_disable; + return ret; } pm_runtime_put_sync(&pdev->dev); @@ -1161,10 +1162,8 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) afe->memif_size = MT8183_MEMIF_NUM; afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), GFP_KERNEL); - if (!afe->memif) { - ret = -ENOMEM; - goto err_pm_disable; - } + if (!afe->memif) + return -ENOMEM; for (i = 0; i < afe->memif_size; i++) { afe->memif[i].data = &memif_data[i]; @@ -1181,26 +1180,22 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) afe->irqs_size = MT8183_IRQ_NUM; afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), GFP_KERNEL); - if (!afe->irqs) { - ret = -ENOMEM; - goto err_pm_disable; - } + if (!afe->irqs) + return -ENOMEM; for (i = 0; i < afe->irqs_size; i++) afe->irqs[i].irq_data = &irq_data[i]; /* request irq */ irq_id = platform_get_irq(pdev, 0); - if (irq_id < 0) { - ret = irq_id; - goto err_pm_disable; - } + if (irq_id < 0) + return irq_id; ret = devm_request_irq(dev, irq_id, mt8183_afe_irq_handler, IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); if (ret) { dev_err(dev, "could not request_irq for asys-isr\n"); - goto err_pm_disable; + return ret; } /* init sub_dais */ @@ -1211,7 +1206,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) if (ret) { dev_warn(afe->dev, "dai register i %d fail, ret %d\n", i, ret); - goto err_pm_disable; + return ret; } } @@ -1220,7 +1215,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) if (ret) { dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", ret); - goto err_pm_disable; + return ret; } afe->mtk_afe_hardware = &mt8183_afe_hardware; @@ -1236,7 +1231,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); - goto err_pm_disable; + return ret; } ret = devm_snd_soc_register_component(afe->dev, @@ -1245,21 +1240,10 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) afe->num_dai_drivers); if (ret) { dev_warn(dev, "err_dai_component\n"); - goto err_pm_disable; + return ret; } - return ret; - -err_pm_disable: - pm_runtime_disable(&pdev->dev); - return ret; -} - -static void mt8183_afe_pcm_dev_remove(struct platform_device *pdev) -{ - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - mt8183_afe_runtime_suspend(&pdev->dev); + return 0; } static const struct of_device_id mt8183_afe_pcm_dt_match[] = { @@ -1280,7 +1264,6 @@ static struct platform_driver mt8183_afe_pcm_driver = { .pm = &mt8183_afe_pm_ops, }, .probe = mt8183_afe_pcm_dev_probe, - .remove_new = mt8183_afe_pcm_dev_remove, }; module_platform_driver(mt8183_afe_pcm_driver); From patchwork Thu Jan 11 10:52:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1362859dyi; Thu, 11 Jan 2024 02:54:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEc19SBEzKP4bqXXIME6pbKXmKLKV+5CNa2czVHPob81Y3epUBeU/E0ECYDKtl7Cn+KpH+5 X-Received: by 2002:a05:6402:1c8c:b0:557:5162:a9ea with SMTP id cy12-20020a0564021c8c00b005575162a9eamr238812edb.117.1704970477464; Thu, 11 Jan 2024 02:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970477; cv=none; d=google.com; s=arc-20160816; b=Qrc4sMh9Th/Qm5Tq6uXKWz210wgRoFG3FYXJvz2IqRvCegVPemdF1UsbOAL2IB2Iju w0eNcBADxq5gFmvmNpBbs8EpkfV0m9vBpdf42gpOiu6OA6q0KtEMtDanF+4kEy5Yu+wJ pTZhzXxo9u4km7kMOvDnAFlGE1CRCpQqsFoJy4JhiK6Akvs+k0BNfrvtpLH4yanZWwgL j0atiUM1EO10D23HP8XhImMYMg/TESMeGePPWp69L10Rx8M6upQ1CvxAJf5GIbmIicgO BuKKi+4B5Sjn9RJzk4aixasV5YW1AaPKjOX6yHage51qvUSjbxoFQVIhnRhXipBd0rOq aiKw== 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=lOl7fWc4WUggYE3srb3p8VMJWtSWR88hUf7Ithr1xR0=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=jPND7LVCtxlTr3MFwUI22zMYcOYr5FKcUeXkKrhinrnDelDZ6oilAmR19LfL5Y/GAs EuGglfYWWmmIJct7cHRmA+xIQZ/BzTYgc84yFgmzVe4dC9+nKiTMagT5vfgKLj0+6QQq 9Y6lO2lSUxMhLbQWEGNPpKGMZic6n0jmekSxtqLkKmJHKU1Bc21Ejo5wpotBQBUhwVsv WdSjSKXPC/cvmHiVXFqT9Wnwr5f4r1jQq2yG1fVag4slUJDadGBbDfeXD08W8mpQFoX5 qOGQcXcQsRXjeW3sKaKVZaEV30T8hwpNz82hwKAuzunuGmiGrkgSKZMgfgEhKCk1TGMu f5RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=z8F7gdjY; spf=pass (google.com: domain of linux-kernel+bounces-23420-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23420-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l6-20020aa7c306000000b00553fca4a42dsi418812edq.669.2024.01.11.02.54.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:54:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23420-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=z8F7gdjY; spf=pass (google.com: domain of linux-kernel+bounces-23420-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23420-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id E8E911F2440B for ; Thu, 11 Jan 2024 10:54:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D00E15AEB; Thu, 11 Jan 2024 10:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="z8F7gdjY" 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 B8FC1156C9; Thu, 11 Jan 2024 10:52:57 +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=1704970376; bh=g3CqTRg/KAT4Jr2vA+YY1oEjG0Ahta0bW0lXZtbFTC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z8F7gdjYXeUOMOswq9HWpzVX4f2vYR1n8DL/qeLIYB4WwkXvwzYF+O8ELMEstLl5f UW89SzvT3mrBdfaqAaF5vV4iO0v2kIjqwmSeLhpE65E4U7M75tYw8BddF2pETgpGTM wD+J4UWLTh1uDEKWoTIcKT/FcnWKRrBWx4LEZnN2niNAOJhxf/HKjNdZB+WIzy2HG8 /xz2T4YOeDeHHq+bCoqq4wUlROFNwBDbiAnCjQtVP9M0T/Ek+CZ1hTqH0LC5GHONa4 y6lZK6B2k1hgZPzGnyDKwNoIugpT4qIloud/FL7SOdtQPeUksm9o0RpWxv3MUFBvZp 8svFWuNxNfJJg== 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 F2D893781FCF; Thu, 11 Jan 2024 10:52:54 +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 4/7] ASoC: mediatek: mt8183-afe-pcm: Simplify with dev_err_probe() Date: Thu, 11 Jan 2024 11:52:44 +0100 Message-ID: <20240111105247.117766-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791123145875172 X-GMAIL-MSGID: 1787791123145875172 Simplify the probe function by switching error prints to return dev_err_probe(), lowering the lines count; while at it, also change some messages level from warn to error. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 71 ++++++++-------------- 1 file changed, 24 insertions(+), 47 deletions(-) diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c index d10aabf65a78..bca7cb782163 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -1108,10 +1108,8 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) /* initial audio related clock */ ret = mt8183_init_clock(afe); - if (ret) { - dev_err(dev, "init clock error\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "init clock error\n"); ret = devm_pm_runtime_enable(dev); if (ret) @@ -1119,38 +1117,29 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) /* regmap init */ afe->regmap = syscon_node_to_regmap(dev->parent->of_node); - if (IS_ERR(afe->regmap)) { - dev_err(dev, "could not get regmap from parent\n"); - return PTR_ERR(afe->regmap); - } + if (IS_ERR(afe->regmap)) + return dev_err_probe(dev, PTR_ERR(afe->regmap), + "could not get regmap from parent\n"); + ret = regmap_attach_dev(dev, afe->regmap, &mt8183_afe_regmap_config); - if (ret) { - dev_warn(dev, "regmap_attach_dev fail, ret %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "regmap_attach_dev fail\n"); rstc = devm_reset_control_get(dev, "audiosys"); - if (IS_ERR(rstc)) { - ret = PTR_ERR(rstc); - dev_err(dev, "could not get audiosys reset:%d\n", ret); - return ret; - } + if (IS_ERR(rstc)) + return dev_err_probe(dev, PTR_ERR(rstc), "could not get audiosys reset\n"); ret = reset_control_reset(rstc); - if (ret) { - dev_err(dev, "failed to trigger audio reset:%d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to trigger audio reset\n"); /* enable clock for regcache get default value from hw */ afe_priv->pm_runtime_bypass_reg_ctl = true; pm_runtime_get_sync(&pdev->dev); ret = regmap_reinit_cache(afe->regmap, &mt8183_afe_regmap_config); - if (ret) { - dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n"); pm_runtime_put_sync(&pdev->dev); afe_priv->pm_runtime_bypass_reg_ctl = false; @@ -1193,30 +1182,22 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) ret = devm_request_irq(dev, irq_id, mt8183_afe_irq_handler, IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); - if (ret) { - dev_err(dev, "could not request_irq for asys-isr\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "could not request_irq for asys-isr\n"); /* init sub_dais */ INIT_LIST_HEAD(&afe->sub_dais); for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { ret = dai_register_cbs[i](afe); - if (ret) { - dev_warn(afe->dev, "dai register i %d fail, ret %d\n", - i, ret); - return ret; - } + if (ret) + return dev_err_probe(afe->dev, ret, "dai register i %d fail\n", i); } /* init dai_driver and component_driver */ ret = mtk_afe_combine_sub_dai(afe); - if (ret) { - dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", - ret); - return ret; - } + if (ret) + return dev_err_probe(afe->dev, ret, "mtk_afe_combine_sub_dai fail\n"); afe->mtk_afe_hardware = &mt8183_afe_hardware; afe->memif_fs = mt8183_memif_fs; @@ -1229,19 +1210,15 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) ret = devm_snd_soc_register_component(&pdev->dev, &mt8183_afe_component, NULL, 0); - if (ret) { - dev_warn(dev, "err_platform\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "err_platform\n"); ret = devm_snd_soc_register_component(afe->dev, &mt8183_afe_pcm_dai_component, afe->dai_drivers, afe->num_dai_drivers); - if (ret) { - dev_warn(dev, "err_dai_component\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "err_dai_component\n"); return 0; } From patchwork Thu Jan 11 10:52:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1364212dyi; Thu, 11 Jan 2024 02:58:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEspu95hE8zeWc1hTQad0IQXQb9z8ZvpRiRfSsBuWICf1Q95Pq2O0hKMxFcLYhkdNYyl2Nv X-Received: by 2002:a05:6808:10d2:b0:3bd:54a3:2b5e with SMTP id s18-20020a05680810d200b003bd54a32b5emr634832ois.59.1704970706405; Thu, 11 Jan 2024 02:58:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970706; cv=none; d=google.com; s=arc-20160816; b=BpRFryKv6D4r74GLS5defh82RkdcRIXuC3iwQbqREEHA5wxfc+rxZK8CYepCR3v33r 9QlBN+SWYnHFbyPQVmv8hjLmT5EdSvc1jTAp2/nbg4m7SSvjALCoKlVIuylXNHDKk1uF 9Ew5h8mk3c1mH33WYb34kJYrTwMFbcWjBHlgZE9dGqdyOrGYY7jxCsJOg5/trC0S8vv0 aRxqB2xVC7ShV6xe3OZuc787297Iae8hoCDu+pzCirvpwCquJjcYqb0AC8UmS79U46Pm kctEymcNGFGl4WU2/tZknoYAV5Nyqz8cXS6AJbvxT6i01SVGQTwEDaQ4eDkKIk5TBMq7 CmvQ== 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=IB/GaW5+0qt7+R/o8Q9fVmekc0QqIMG+1aiL6AOHp3o=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=rWXPxmmqcMKdTnq2ZbEKSwrzkuHFsMbVwbNbGzsY/87KHkvxxqzJm0hdUG/PLFvFTJ oXUSB8lxY0vxHsGjku2CTk849LCOt+OncBtIZT2ntwxd8m7xQKwS7/9bB2i5IHKGggXg qH2H6T22eyW6FeEiR17tnHcii7ic5fxSXpHdKHbAee5tsJuzTxSdoWbLqJVrtXiViows cj9UiqQkmMKjcm0eGiEGU3ihLEOmfzSJuo3IyKPOMHjETVWhMBS3kqb+c7Jbf9gWIhuo 3qI1VgYWkCu5o8cD5Ws40mgdyMKY2W202S5/sf9yKmBSsVR7kby2qtTNE6qraMU8HohJ DQGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=3oiXd7rI; spf=pass (google.com: domain of linux-kernel+bounces-23419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23419-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f23-20020a635557000000b005cdf86014e2si814547pgm.674.2024.01.11.02.58.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:58:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=3oiXd7rI; spf=pass (google.com: domain of linux-kernel+bounces-23419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23419-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0B26DB215DD for ; Thu, 11 Jan 2024 10:54:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8BBE15AE8; Thu, 11 Jan 2024 10:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="3oiXd7rI" 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 AB21B156C7; Thu, 11 Jan 2024 10:52:58 +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=1704970377; bh=cS3iWx2ZcmgtyFlp+ugoE4KjZQAyQugEDmx4+ox8BZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=3oiXd7rILSK3f0uwWTdD2JU3mMEjow9Z/QtutW2OSVLF0k8m17MhaC4Vbsy7UX2Q2 VVZXfDfdDqfJrp1zWxI2+Cd2O9QzjRQ0qRxsOe/v4Fw8SY8iSGtoCz2BF0yk2gpS1z Mchc8PSNkAEG2ekPrBxbX43UkQ7Pbst2eRpgdMUNEFBGAZlsFA1+XgzleMIUy0OFKb rYctpBQ7WDbxGcgErJshofpl9h2ymUXfdeGWrEr06yDpJXYaLE5dnrWavk0n55llgB HcT+nsRvhVcDkotl24VgfpyG12U7XwOFXBjvz8MJuJlpX4ZU7TOP3Z/2RWXvwLkL77 wvRHXIh+oN2gg== 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 47EB337811D1; Thu, 11 Jan 2024 10:52:56 +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 5/7] ASoC: mediatek: mt8192-afe-pcm: Convert to devm_pm_runtime_enable() Date: Thu, 11 Jan 2024 11:52:45 +0100 Message-ID: <20240111105247.117766-6-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791363238271120 X-GMAIL-MSGID: 1787791363238271120 Switch from pm_runtime_enable() to devm_pm_runtime_enable(), allowing to remove all gotos from the probe function. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 46 ++++++++-------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c index bdd1e91824d9..794419d16b01 100644 --- a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +++ b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c @@ -2217,21 +2217,20 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) return ret; } - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) - goto err_pm_disable; + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret) + return ret; /* regmap init */ afe->regmap = syscon_node_to_regmap(dev->parent->of_node); if (IS_ERR(afe->regmap)) { dev_err(dev, "could not get regmap from parent\n"); - ret = PTR_ERR(afe->regmap); - goto err_pm_disable; + return PTR_ERR(afe->regmap); } ret = regmap_attach_dev(dev, afe->regmap, &mt8192_afe_regmap_config); if (ret) { dev_warn(dev, "regmap_attach_dev fail, ret %d\n", ret); - goto err_pm_disable; + return ret; } /* enable clock for regcache get default value from hw */ @@ -2241,7 +2240,7 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) ret = regmap_reinit_cache(afe->regmap, &mt8192_afe_regmap_config); if (ret) { dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret); - goto err_pm_disable; + return ret; } pm_runtime_put_sync(&pdev->dev); @@ -2254,10 +2253,8 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) afe->memif_size = MT8192_MEMIF_NUM; afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), GFP_KERNEL); - if (!afe->memif) { - ret = -ENOMEM; - goto err_pm_disable; - } + if (!afe->memif) + return -ENOMEM; for (i = 0; i < afe->memif_size; i++) { afe->memif[i].data = &memif_data[i]; @@ -2271,26 +2268,22 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) afe->irqs_size = MT8192_IRQ_NUM; afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), GFP_KERNEL); - if (!afe->irqs) { - ret = -ENOMEM; - goto err_pm_disable; - } + if (!afe->irqs) + return -ENOMEM; for (i = 0; i < afe->irqs_size; i++) afe->irqs[i].irq_data = &irq_data[i]; /* request irq */ irq_id = platform_get_irq(pdev, 0); - if (irq_id < 0) { - ret = irq_id; - goto err_pm_disable; - } + if (irq_id < 0) + return irq_id; ret = devm_request_irq(dev, irq_id, mt8192_afe_irq_handler, IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); if (ret) { dev_err(dev, "could not request_irq for Afe_ISR_Handle\n"); - goto err_pm_disable; + return ret; } /* init sub_dais */ @@ -2301,7 +2294,7 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) if (ret) { dev_warn(afe->dev, "dai register i %d fail, ret %d\n", i, ret); - goto err_pm_disable; + return ret; } } @@ -2310,7 +2303,7 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) if (ret) { dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", ret); - goto err_pm_disable; + return ret; } /* others */ @@ -2329,7 +2322,7 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) &mt8192_afe_component, NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); - goto err_pm_disable; + return ret; } ret = devm_snd_soc_register_component(&pdev->dev, @@ -2338,15 +2331,10 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) afe->num_dai_drivers); if (ret) { dev_warn(dev, "err_dai_component\n"); - goto err_pm_disable; + return ret; } return 0; - -err_pm_disable: - pm_runtime_disable(&pdev->dev); - - return ret; } static void mt8192_afe_pcm_dev_remove(struct platform_device *pdev) From patchwork Thu Jan 11 10:52:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1362927dyi; Thu, 11 Jan 2024 02:54:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiJbX7lBeMLdmCO+Z1F/bxJ2KFMd20O3DrCcudETjINwtA+sY1KEUfUILu4AOZVOPaKWp2 X-Received: by 2002:a17:90b:3754:b0:28b:d8c5:c8bb with SMTP id ne20-20020a17090b375400b0028bd8c5c8bbmr756354pjb.35.1704970493752; Thu, 11 Jan 2024 02:54:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970493; cv=none; d=google.com; s=arc-20160816; b=OEidVVc9xH+nTD9epalgdcpa6oeIYbZHoTtuQyVqVKavLZRV1lA9ons3UXALEGYNVH zDcPUE9udLqrEzObSB2vjaezWqEf5AJiLeRXRobiAR5lCbfyTma+0lIVSDqBfOfym2sH G2wNlbRQ+QExuPve2OgsUr6pGfJHNYKtSSjvfdt6FM5J0abamEZAIWjjRPb/hV35MvYs uP+4P6ckEluOpNdSjrcewjQoOqWsdmt1z+zBz+thFG+WYvxOWj4VOvSfn4Vf/thwgTN9 auagabk5kbgxjlCAFyL0a5bgsreOk2xzODySc/8NTev2YAYHVCffYnIxMZoEwCuTjYjc +wOw== 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=4ALrbd2JpX74rt3/OOa08roRjOzOcpqki0C3oZHINDg=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=IpuO94SMm5+PNeMavQ92ygyjBdQKaqsPLhV4PTXnSwCvI3z9iGTKDKuuo41A5jxhDw heE3Q5kFCDyDPWA0Vu5o3sSkZDWLJ/HCCdtcVkw9ZHXYgsUdr3Dz6DxxiInqVAVRML05 FaMlNACk4EpXx3Cn2Dj4TwOcA4k/gwUwdPIbaFujNefhNiIyDttR5XS+GYo9Nwb9RYVB ++fpQbaW01YYHoPLcMc/8NdQHmQIQ5WrGQ/hK5LiaTnTEu9+LN+MRU0mh5/uTUHDP2uQ 8y97NlMVo4jpWYEJ3b2I4rJiPRqngWJq/xK5C0GALmI9GEHurhKfLrGSai0F84nN3D1z l9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CLVk0hS9; spf=pass (google.com: domain of linux-kernel+bounces-23421-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23421-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z14-20020a17090a398e00b0028cb2fc7d4fsi827941pjb.172.2024.01.11.02.54.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:54:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23421-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CLVk0hS9; spf=pass (google.com: domain of linux-kernel+bounces-23421-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23421-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 85335284A80 for ; Thu, 11 Jan 2024 10:54:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9028B15E9D; Thu, 11 Jan 2024 10:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="CLVk0hS9" 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 443F114F81; Thu, 11 Jan 2024 10:53:00 +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=1704970378; bh=3cQvnwcXHoi10LGhXXkqD+S50rLO3Wezsg1rzILzUxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLVk0hS9qP1S0SfjosuThhHcG23RNZwo7E3I5N+W/tIuoxBDnsIj+HaMXf69ntc4i WNK7/lNLCd/XFvkNMyM/+Y7z/UEIFzf45S7zaWASQFMA88ATcBJCB+O3RSIVm23plI K/KPoRpBKcat+wzk0kK3DpfkHl4EtN3Ie+DRu0dz6W7M7TGBFOa7DlKL+PQDS9yx+7 QJSODtPQv5ASzB1zbVYuzxXnF/J1BrT78DYGqTVPr/E8mC6uEcY38yz+qCMbZyjiGw G6c78RnowRrlD36tFeMHibVHe5cJJWpeYGDXJBVTKgAxM2s+Mpa/6a8v4hMkuqMsG9 1cdHYvyEgmPcw== 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 8FB5F3781F8E; Thu, 11 Jan 2024 10:52:57 +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 6/7] ASoC: mediatek: mt8192-afe-pcm: Simplify with dev_err_probe() Date: Thu, 11 Jan 2024 11:52:46 +0100 Message-ID: <20240111105247.117766-7-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791140326440439 X-GMAIL-MSGID: 1787791140326440439 Simplify the probe function by switching error prints to return dev_err_probe(), lowering the lines count; while at it, also beautify some messages and change some others' level from warn to error. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 65 ++++++++-------------- 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c index 794419d16b01..7242e6a4625c 100644 --- a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +++ b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c @@ -2205,17 +2205,12 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) /* reset controller to reset audio regs before regmap cache */ rstc = devm_reset_control_get_exclusive(dev, "audiosys"); - if (IS_ERR(rstc)) { - ret = PTR_ERR(rstc); - dev_err(dev, "could not get audiosys reset:%d\n", ret); - return ret; - } + if (IS_ERR(rstc)) + return dev_err_probe(dev, PTR_ERR(rstc), "could not get audiosys reset\n"); ret = reset_control_reset(rstc); - if (ret) { - dev_err(dev, "failed to trigger audio reset:%d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to trigger audio reset\n"); ret = devm_pm_runtime_enable(&pdev->dev); if (ret) @@ -2223,25 +2218,21 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) /* regmap init */ afe->regmap = syscon_node_to_regmap(dev->parent->of_node); - if (IS_ERR(afe->regmap)) { - dev_err(dev, "could not get regmap from parent\n"); - return PTR_ERR(afe->regmap); - } + if (IS_ERR(afe->regmap)) + return dev_err_probe(dev, PTR_ERR(afe->regmap), + "could not get regmap from parent"); + ret = regmap_attach_dev(dev, afe->regmap, &mt8192_afe_regmap_config); - if (ret) { - dev_warn(dev, "regmap_attach_dev fail, ret %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "regmap_attach_dev fail\n"); /* enable clock for regcache get default value from hw */ afe_priv->pm_runtime_bypass_reg_ctl = true; pm_runtime_get_sync(&pdev->dev); ret = regmap_reinit_cache(afe->regmap, &mt8192_afe_regmap_config); - if (ret) { - dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n"); pm_runtime_put_sync(&pdev->dev); afe_priv->pm_runtime_bypass_reg_ctl = false; @@ -2281,30 +2272,22 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) ret = devm_request_irq(dev, irq_id, mt8192_afe_irq_handler, IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); - if (ret) { - dev_err(dev, "could not request_irq for Afe_ISR_Handle\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "could not request_irq for Afe_ISR_Handle\n"); /* init sub_dais */ INIT_LIST_HEAD(&afe->sub_dais); for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { ret = dai_register_cbs[i](afe); - if (ret) { - dev_warn(afe->dev, "dai register i %d fail, ret %d\n", - i, ret); - return ret; - } + if (ret) + return dev_err_probe(afe->dev, ret, "dai %d register fail"); } /* init dai_driver and component_driver */ ret = mtk_afe_combine_sub_dai(afe); - if (ret) { - dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", - ret); - return ret; - } + if (ret) + return dev_err_probe(afe->dev, ret, "mtk_afe_combine_sub_dai fail\n"); /* others */ afe->mtk_afe_hardware = &mt8192_afe_hardware; @@ -2320,19 +2303,15 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) /* register platform */ ret = devm_snd_soc_register_component(&pdev->dev, &mt8192_afe_component, NULL, 0); - if (ret) { - dev_warn(dev, "err_platform\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Couldn't register AFE component\n"); ret = devm_snd_soc_register_component(&pdev->dev, &mt8192_afe_pcm_component, afe->dai_drivers, afe->num_dai_drivers); - if (ret) { - dev_warn(dev, "err_dai_component\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Couldn't register AFE-PCM component\n"); return 0; } From patchwork Thu Jan 11 10:52:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 187296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1363057dyi; Thu, 11 Jan 2024 02:55:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGv5237wfFoJpHiu5Dx3WR7km1XQwSRprjKF+ooxIaCkBSvB8awLEUZme222CKhR9UWhCxz X-Received: by 2002:a05:6808:448b:b0:3bb:8cf5:92df with SMTP id eq11-20020a056808448b00b003bb8cf592dfmr1251410oib.112.1704970516608; Thu, 11 Jan 2024 02:55:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970516; cv=none; d=google.com; s=arc-20160816; b=WFy/OgUiVF4k2v2RHQ+n9nwjwGXOkjka/fJhujfZbRLU6ZIRGSI2LmxHI2xeVIef8e 2gNpa9lfovsOhz0rC2usPSfwUX7NyS2ERQ34XxQelkfDol5bDmNnlCNJNEtp7C+ZV5/4 m0b0BJXmR1EMy3qTYGo9Hun7V/gE5D8gUAXHbqi3mdeWksxA7J/8WkHa3uoT7FxON9QW BnME6SZ0iNom+/hsz0cKvjbfO5Kq8QJX6mnRgmkYVzwZijV4tDqTxqrKQ60a/+oC/8wM w3tqtRSB3CziDg7tgqd1oia0iHkzuX3PagqHTFSOrBvQN2b1iKJq/18Ab0ooAvf+OrTt vL2A== 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=wSziIE/ybAwAPJBQ3qsR9gVJSk9ocThVzINUn/igBl0=; fh=CUSLW4jgLN56Ew8AjCIrFKTaoeZ27cJOZmkfMWo61nk=; b=xCQmK8pnus9KgweVOcMATEQIr+MWSint2HsCQKEIdfBYDtcw6kxIlf5OEUZHPbCu6r pFRReXog0hEoKRWgVmjGiL1bTfjVf4ouLJXpt1C7lPXTvqsqHrKDMEjklZAuvYbgFHJM 5Qe/ZgWqpELHCGNh3fsQyU2ppZjrJcmEvN2k0DIM6PaIdhLedR8uOE7Cb6ZkqbwxlScY 4QeIrrJw4sh8Qp1IG2ujFpbf4WHwTvu3wc6twCcQHhVliNZCWgqnEJGpVBinKyWFJzY1 NNaZChixq82QgHqF1J68erR7fWXMc+g0KHgeoSjJ6eayVT/wBqEIOsLPaRfKDUnIEkW/ SpAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OumW6osQ; spf=pass (google.com: domain of linux-kernel+bounces-23422-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23422-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jw18-20020a056a00929200b006cb852928ffsi832903pfb.66.2024.01.11.02.55.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:55:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23422-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OumW6osQ; spf=pass (google.com: domain of linux-kernel+bounces-23422-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23422-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 84FA5281E95 for ; Thu, 11 Jan 2024 10:55:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77AE115EBE; Thu, 11 Jan 2024 10:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="OumW6osQ" 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 8073D15AC5; Thu, 11 Jan 2024 10:53:01 +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=1704970379; bh=INSFLjKGWUsq8D7Gv8F3E/m7g3Zw056cbg7I8BkqRIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OumW6osQ54b6FN4QQ5pFj7u91fs0CI6pFd0zZ+wlCvnEn8f3OWOs8vW2JcClOCh2j poZAzt8E2OIhTSxn+C3TyiMlBjvTzOVJv4pUepYve7s1dvMaCxJd9BdSc10mIi+B6B cxCnVYBMpwTcPwxodsHKcKrBOICZ6SevL8dySA5jiZlwu08PnLVq7O8Lqm6s6hlfin S5WP+d/I/rwkRxQSiLcYgbTHqC14ncBil6IkuuSozoNsPG41F6tp2GaolSXnNTKiFd Xrg785MqlGJ5kEfFv/QfcNdcZuA+Wv46lp3kSj50YaTukvS0ffctf7xYZ+kEFHUMIo 8fTIVjiX9lVXw== 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 D541F3781FCB; Thu, 11 Jan 2024 10:52:58 +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 7/7] ASoC: mediatek: mt8195-afe-pcm: Drop .remove_new() callback Date: Thu, 11 Jan 2024 11:52:47 +0100 Message-ID: <20240111105247.117766-8-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787791164364616615 X-GMAIL-MSGID: 1787791164364616615 As we're calling devm_pm_runtime_enable() in the probe function of this driver we don't need to disable it on remove as that's devm managed: drop the .remove_new() callback entirely. While at it, also add the sentinel comment to the last of_device_id entry. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Trevor Wu --- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c index 620d7ade1992..de848d872ce6 100644 --- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c +++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c @@ -3193,16 +3193,9 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) return ret; } -static void mt8195_afe_pcm_dev_remove(struct platform_device *pdev) -{ - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - mt8195_afe_runtime_suspend(&pdev->dev); -} - static const struct of_device_id mt8195_afe_pcm_dt_match[] = { - {.compatible = "mediatek,mt8195-audio", }, - {}, + { .compatible = "mediatek,mt8195-audio" }, + { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, mt8195_afe_pcm_dt_match); @@ -3218,7 +3211,6 @@ static struct platform_driver mt8195_afe_pcm_driver = { .pm = &mt8195_afe_pm_ops, }, .probe = mt8195_afe_pcm_dev_probe, - .remove_new = mt8195_afe_pcm_dev_remove, }; module_platform_driver(mt8195_afe_pcm_driver);