From patchwork Wed May 3 11:34:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 89716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1256336vqo; Wed, 3 May 2023 04:36:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WxkdYiSnDvhqOipHhqIc/JERZ3ay7wfONN37jiOgsjqpel1xqV+EqOmFDLpsAtHeJ+Yo9 X-Received: by 2002:a05:6a20:4289:b0:ef:f558:b7d with SMTP id o9-20020a056a20428900b000eff5580b7dmr27169917pzj.59.1683113775800; Wed, 03 May 2023 04:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683113775; cv=none; d=google.com; s=arc-20160816; b=NHktchTzzXDv6UdaYuArc7fVxTjRZlOJfqynZZtTKErSgj+mleVBDdye7vyUVWSXqL GBm8hmCEByoCVRQ0NgylbY4UbnqeIR22SdLeGj6iIyBzbFTDEFbboqeJR+4nr5V1IHa1 92nOqke6racGYBvwZ2MhAiE5+seOQTUGeJFY8jg9fHyNNyExDsUsXax0gJR0Ygz9xyGh +CNmO4BXKQ+lgZICotPvFz32bWslJdIgikcCHiLdtUs4LXrD+qJWe7d/U49BhjT7LeZo Du0iKbuKgDyeCyu0Nmtnj68CkkeZL0Vh6Jt3Yr1l3dCMLNEO4OaZdlTlyUN4SwFqO63y GSdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OlfPqWT97z1YROQRQvh6WsNP+KyqyN3e7xtJb7b7v5E=; b=klpN7+ji/jDOqNq7tHcdMmTBQUyCANZwuWIXbLuqaXPjvEaFcSbPlMOQ2pN2umno5d YI9jhQjyh70ibDo/FU0i9xKmC0hVSSIoH1JY777xfVjpMSKdo5a/On4luNb0sCo1qVh+ 5+VdC7ghX2pDvJJVv6my9QXqY9YG78a6f+OQXQtPGqbPXUEvACtrN3w6d1hvno6sqqyI WqSs7qyjpUfVB2y2OthvftzMI5m62VxEyiv83GP5Eh+HqYEwTekjn5sDqdNxABGydVzS O18Ou/+StJ9+P5gL8pNXU6dpOPX0BC898ZlX9iEgK5BhZKzNG90TH27mR1mHesP1ilr4 4gPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RbCuGRvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a63f755000000b00517a4a75528si31207313pgk.162.2023.05.03.04.36.03; Wed, 03 May 2023 04:36:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RbCuGRvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbjECLea (ORCPT + 99 others); Wed, 3 May 2023 07:34:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbjECLeY (ORCPT ); Wed, 3 May 2023 07:34:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E111268B for ; Wed, 3 May 2023 04:34:23 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id CBFE56603137; Wed, 3 May 2023 12:34:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683113662; bh=Gj6A+un8r1QWElAagp5zDVAgfl0pGla/oA/vRjwfzxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbCuGRvcGZM3gl/VcwXhnEvM3JsvydoH6TP/0t+ncFEZqbKdHKjJf73zqAPPzFGW2 nJb6xnVZhrj48PS+tPMX0M9/acadRZOg8lcrb/+KJ2KBclN+dDP175/MdxII2Ymkjs 9RdpRCYeJbB18jj6RE6+ylyJca9UCZaqh/PL7y4ELbMScGnjrVE+BR/z+Zk7aWMAfY rkzuXMboJZHL1Aza50FpNuMspCTVN8wPuNnh1At2iYvpH6Wm2tDlxuh1c1gd78rC66 EvwCXq3sOiwfLU6HZ0utyT8V6/ntdsT6ZlsszEzNPo5KEf1zfUrm73nvvu0EPlRGPq qmjKZjSeVITmg== 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, pierre-louis.bossart@linux.intel.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, daniel.baluta@nxp.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, chunxu.li@mediatek.com, tinghan.shen@mediatek.com, error27@gmail.com, ribalda@chromium.org, yc.hung@mediatek.com, Allen-KH.Cheng@mediatek.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, sound-open-firmware@alsa-project.org, kernel@collabora.com Subject: [PATCH 1/5] ASoC: SOF: mediatek: mt8195: Use snd_sof_ipc_process_reply() helper Date: Wed, 3 May 2023 13:34:09 +0200 Message-Id: <20230503113413.149235-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> References: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764872710799010071?= X-GMAIL-MSGID: =?utf-8?q?1764872710799010071?= Function mt8195_get_reply() performs practically the same operation as the common snd_sof_ipc_get_reply() helper: removing the custom function allows us to simply perform a call to the sof-priv helper snd_sof_ipc_process_reply(), simplifying and shortening this driver and getting all the benefits of using a common API. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/sof/mediatek/mt8195/mt8195.c | 36 +------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 42bae574c87a..7d6a568556ea 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -49,47 +49,13 @@ static int mt8195_send_msg(struct snd_sof_dev *sdev, return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ); } -static void mt8195_get_reply(struct snd_sof_dev *sdev) -{ - struct snd_sof_ipc_msg *msg = sdev->msg; - struct sof_ipc_reply reply; - int ret = 0; - - if (!msg) { - dev_warn(sdev->dev, "unexpected ipc interrupt\n"); - return; - } - - /* get reply */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; - } else { - /* reply has correct size? */ - if (reply.hdr.size != msg->reply_size) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); - } - - msg->reply_error = ret; -} - static void mt8195_dsp_handle_reply(struct mtk_adsp_ipc *ipc) { struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc); unsigned long flags; spin_lock_irqsave(&priv->sdev->ipc_lock, flags); - mt8195_get_reply(priv->sdev); - snd_sof_ipc_reply(priv->sdev, 0); + snd_sof_ipc_process_reply(priv->sdev, 0); spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); } From patchwork Wed May 3 11:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 89721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1263476vqo; Wed, 3 May 2023 04:50:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KMsArUwwy1OePuV2tSj+ywOOz5aVmKpxTb3UKI4/o+HtfpEm3PG1i0DFiPXCCEPuFcOHA X-Received: by 2002:a17:903:41c4:b0:1a6:e58f:8aee with SMTP id u4-20020a17090341c400b001a6e58f8aeemr1778476ple.65.1683114619142; Wed, 03 May 2023 04:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683114619; cv=none; d=google.com; s=arc-20160816; b=eVr98gRiZJXgpJUsX/okmjICYfK5Or1CuRmBhIStnega+NRHvshGHARD3Tmhz6HfDE 6vbwsBP5nOj5NT45E7U+U4tu14fFtZYfujoUyhxK78z11uz2ZBJtWXs3WiLw2CJREXI2 poIFuFRn32M4pEz5yn+5K+dNPYm1uHK3VNUrh/8i1h8jervLmOf9JqHWr2o4XRryX/9C oS3Q7G1oiCSX66LAQpfzF4aU9LB52PALh3amLkdacAK5LXGzA3Qj4NENxKf169pgW4xz nCK4MI2UdICVDY3R2yQXlSo6F27vTLdz6pXdsB5TicmcSZP/eId53Byw8NWlzRwftVRp GYmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DHPLzKmBsUm9HQgDoTgBtcEUS4EMTLqMPq94LXx/M/c=; b=RcdcopfRG4DlQdsHiwy1XqZwU4hBcjQBt2Dil7AxNeeOTJcgvx3H8xETAW3IkUZ6uy ErbfieRNqp3q1unsYVf8Kh4JxuVM+YJqC2nKNXtwOUlgzXub88hrd90UQNDsK/vmvSVR bTY2+iVtrlNCGojWd9l4iI/xDW428QWsja/51hkbanpKsLHnvR6CGmHOiXFxTjQXvi9S yCcQufUtytcfiC/LheqxCYyRmn7rZJANfWhGUk7/mgggJpyToRgzPd6kuwmlSijP7tUH A87n65w+8Oshyn/SFpQThwfLf0GCAxiBAfgt1UkS6eDILo9TIGDVTI0xlbNLDX55puTY xnvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="LJB0T/0i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k16-20020a170902c41000b001a9b4bda723si3103149plk.421.2023.05.03.04.50.04; Wed, 03 May 2023 04:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="LJB0T/0i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjECLed (ORCPT + 99 others); Wed, 3 May 2023 07:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjECLe0 (ORCPT ); Wed, 3 May 2023 07:34:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A97449EC for ; Wed, 3 May 2023 04:34:25 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id 797F266056CE; Wed, 3 May 2023 12:34:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683113663; bh=L39f0aIGeOnQPRMtTubkebioIWUYydMxDfJeYgCV4k0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJB0T/0iHKJUrGdMcxKrOMKcwBeIRmFsrMfUR+fGgA+VlJT4FAhaa8QDVQSsfZzH1 HmD6uIVi4pUAE9Crl0yTwgVPK7eFAqnf4f4RZcZ9tGQp6Ol3CprXYGZxOjSydK1amL unew7PpOHyq082BVucjyF89Ukx5JEiCDyQelNqF9GHhrLO/CXbbNOm28rWQvC924JM VvBBK2VAXHlek50LaoirqagFS+McddJfCHVgZH1/NBGiF979ZdIQv3rxRNfsjWAcl1 46/w1s0Kx7odsvmZr8dlWqdCrBQHNnhOL8k0DhoWryOIRoH4kQHk4Ct4GZAZrH4iip pKOjoz3LpptjA== 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, pierre-louis.bossart@linux.intel.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, daniel.baluta@nxp.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, chunxu.li@mediatek.com, tinghan.shen@mediatek.com, error27@gmail.com, ribalda@chromium.org, yc.hung@mediatek.com, Allen-KH.Cheng@mediatek.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, sound-open-firmware@alsa-project.org, kernel@collabora.com Subject: [PATCH 2/5] ASoC: SOF: mediatek: mt8186: Use snd_sof_ipc_process_reply() helper Date: Wed, 3 May 2023 13:34:10 +0200 Message-Id: <20230503113413.149235-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> References: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764873594694350313?= X-GMAIL-MSGID: =?utf-8?q?1764873594694350313?= Function mt8186_get_reply() performs practically the same operation as the common snd_sof_ipc_get_reply() helper: removing the custom function allows us to simply perform a call to the sof-priv helper snd_sof_ipc_process_reply(), simplifying and shortening this driver and getting all the benefits of using a common API. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/sof/mediatek/mt8186/mt8186.c | 36 +------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 597cb4476acb..419913c8474d 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -48,47 +48,13 @@ static int mt8186_send_msg(struct snd_sof_dev *sdev, return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ); } -static void mt8186_get_reply(struct snd_sof_dev *sdev) -{ - struct snd_sof_ipc_msg *msg = sdev->msg; - struct sof_ipc_reply reply; - int ret = 0; - - if (!msg) { - dev_warn(sdev->dev, "unexpected ipc interrupt\n"); - return; - } - - /* get reply */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; - } else { - /* reply has correct size? */ - if (reply.hdr.size != msg->reply_size) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); - } - - msg->reply_error = ret; -} - static void mt8186_dsp_handle_reply(struct mtk_adsp_ipc *ipc) { struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc); unsigned long flags; spin_lock_irqsave(&priv->sdev->ipc_lock, flags); - mt8186_get_reply(priv->sdev); - snd_sof_ipc_reply(priv->sdev, 0); + snd_sof_ipc_process_reply(priv->sdev, 0); spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); } From patchwork Wed May 3 11:34:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 89717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1256485vqo; Wed, 3 May 2023 04:36:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cM02DlH7lReV2YRB3J87QD0PiXhJoQDPXyAZqque8KnGDqTSichoiKz9qsUcmNLXpVI2Y X-Received: by 2002:a05:6a00:2d1b:b0:63a:8533:d6a7 with SMTP id fa27-20020a056a002d1b00b0063a8533d6a7mr28510409pfb.9.1683113791549; Wed, 03 May 2023 04:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683113791; cv=none; d=google.com; s=arc-20160816; b=zOnnCcfbLIxnQ9350pWbkYMEFgyiEbZrW0b8mBvgp/Zro9RS7v/+dOM/aA/iZl9t6i nht379k5lHvERxUolpH+il2/g+8UzGxDkuw/nOIAEZW7ZjSiWPhhdVnMHMP2sq1hkoEY 0NOyiDoo2m6rhJLKMBSv7QRWuws879qpDDRtKxoHN8O0uFd9+VfPPEaaRLjw4Dk5pa06 Kryrhq2qK6Zaq/3lf7M52SYFL3qbFlqtX8I81cq0xUEoN7Ga1O00WB/iIt6C46eFxj9b IdlAQSQMzfABswPciFX51NJy6ROFek6M48X9lUMShCyIlVAnvbWwDuiYj4DQa3KDvPJJ K9JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PK4+EPXcGtyHsPnNI1DUEoESxsYoNonqxfNie/0quto=; b=onMYrItUOmUw5TY4EjcDLVMM9kFVoTGMXlel7gBJMwqh65tD/xeYfzZafubo6Ar08N uJPbNa7aIt6/k1csjJDW+e0Iv3b8hVWdOFu1lG9PWjdmaJ32kDJpBpRI2tC9c0TC2tfr yyEayJ+vUTWlVubr1TtSEviR+7BrmxU4H998DlVjwVVeiVYmmdj2MPa8S1wSmXi+1Ne+ od908ti36Tcu3e28JTdrzgwDrpOiQDWSoEtfX2sdSsEHEdMnm1hVGJ/5ShRhsW/mcMrC LreG9c9IIzakwBzbkVkogxucTFi9vf7zk11CX0EaS3SfEr+7x7MeaPoosQSRIex26Na5 6IXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HSzFx8Gb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t14-20020aa7946e000000b0063b895e9781si33365476pfq.138.2023.05.03.04.36.18; Wed, 03 May 2023 04:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HSzFx8Gb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbjECLeh (ORCPT + 99 others); Wed, 3 May 2023 07:34:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjECLe1 (ORCPT ); Wed, 3 May 2023 07:34:27 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75A25273 for ; Wed, 3 May 2023 04:34:26 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id 2552766056D2; Wed, 3 May 2023 12:34:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683113665; bh=lJinXQ8uqP7CnqlUjGVARURr70ufEO+/YnYRE0JoVQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HSzFx8GbrJ8qs8mBrbeP+h7EcY1pogSEhyzSPpiZVHTaiFRSXaGbp5P86Vt16B/07 c7V+Xj5slpef3GSmiz/Pf9bnkDA025Mw3wy8GD8HVuedzDpHs1REkrHXWHXaQs8nYw /J5brCacAgQ3HeDaNVMLMDpgZ4lkPe+LCU+SB0SksECniQJvf0vdahY0Yx7//fAURU +GvoQmfEw4XOQawfFSXrCABO/+LpP1qxWI3y1jQiPDuCe0ey0iPu9Y/FJmCXAqzLTy oh2aaralDRQaWp++iEIUJHa+6Lm4w+kgiByyia77GGEm8NnOE4N083/yLbzxO3FkNI 2+9iNKO5hHbrA== 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, pierre-louis.bossart@linux.intel.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, daniel.baluta@nxp.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, chunxu.li@mediatek.com, tinghan.shen@mediatek.com, error27@gmail.com, ribalda@chromium.org, yc.hung@mediatek.com, Allen-KH.Cheng@mediatek.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, sound-open-firmware@alsa-project.org, kernel@collabora.com Subject: [PATCH 3/5] ASoC: mediatek: mt8195-afe-pcm: Simplify runtime PM during probe Date: Wed, 3 May 2023 13:34:11 +0200 Message-Id: <20230503113413.149235-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> References: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764872727025491522?= X-GMAIL-MSGID: =?utf-8?q?1764872727025491522?= Use devm_pm_runtime_enable() and pm_runtime_resume_and_get() to to simplify the probe function. Signed-off-by: AngeloGioacchino Del Regno Acked-by: Trevor Wu --- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c index 9e45efeada55..a54c16e0aa05 100644 --- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c +++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c @@ -3179,16 +3179,16 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) mt8195_afe_parse_of(afe, pdev->dev.of_node); - pm_runtime_enable(dev); - if (!pm_runtime_enabled(dev)) { - ret = mt8195_afe_runtime_resume(dev); - if (ret) - return ret; - } - /* enable clock for regcache get default value from hw */ afe_priv->pm_runtime_bypass_reg_ctl = true; - pm_runtime_get_sync(dev); + + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; + + ret = pm_runtime_resume_and_get(dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to resume device\n"); afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, &mt8195_afe_regmap_config); @@ -3238,7 +3238,10 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) mt8195_afe_init_registers(afe); - pm_runtime_put_sync(dev); + ret = pm_runtime_put_sync(dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to suspend device\n"); + afe_priv->pm_runtime_bypass_reg_ctl = false; regcache_cache_only(afe->regmap, true); @@ -3248,7 +3251,6 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) err_pm_put: pm_runtime_put_sync(dev); - pm_runtime_disable(dev); return ret; } From patchwork Wed May 3 11:34:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 89718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1256507vqo; Wed, 3 May 2023 04:36:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xNb16rFOWjV0b066mHV2ldpk524ZBzrG0WYiwUeprtFvwVo3p1/7Ol4UEsXhmU32GON/Z X-Received: by 2002:a05:6a21:1690:b0:f5:4d31:6193 with SMTP id np16-20020a056a21169000b000f54d316193mr22548209pzb.37.1683113793222; Wed, 03 May 2023 04:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683113793; cv=none; d=google.com; s=arc-20160816; b=gheX6LBGJVXiDNlwxnxf5KwBOiCYvdWipfU9i+HGn7k5E2iLmG2Mjn3uWG37pY8JL8 NmoLZshKXMr5kF8dmI4op/AC7zputOunyq6ukhPwhPql+sFoEZSEaDX8fSfhlg1uuH6b /+eT6DvtE4WRSW/qxWJtEQ8+pG53mafO9niOfUPOUjxKvY9KeYb0kW0Ytb4ngGtovwk4 08UPftIsWrHFaPmQfbr7XM6WqrsDsuGsMMduKpydwV5axINXmSZGZ2S9GtR5OOLyqW4N pwU3VlDbWG4xgyqsRQH7xP7X6h83E7XJksIZktdFdiJB6HJp3aFOdmmSh6vd221682iS 9Znw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=n1ogUVz+sCu5XyWCUPhpxN+sQujx6zZOhqs0xWjGeOQ=; b=CzaobvAZMxbIKApHK2mDZuAbx+KtupJOjHMOzUWAryX5BLuc0yZjvRit+ZdohbCfkL 0ZNfDVuxg+l0FWZgRitS4N888jOQUQtVoDFKFvQ1r+vLwG2d31Ds6HVexafjyO8+6e0U aCiu49r59Y4WDJoPWHi8wJN81BstUu50bLWYB0lMf6VQ8n0iXtAPgramXD6gobb4Q1Us qh1HuJdGmScGviJGQQt4568DBnhkK2IljplGdkNX8R/WEXAXw2BCKSsXbBMjuaJm3O+P abWlktrIowaBtqfR/d++ci2JYtZtfHL5Gx9N4PUWmODurtZ9iYqKyWZhAJUwJYgoOBcp yDsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bSzjfc7E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf11-20020a17090b1d8b00b0024e0254d807si1364612pjb.143.2023.05.03.04.36.20; Wed, 03 May 2023 04:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bSzjfc7E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjECLeq (ORCPT + 99 others); Wed, 3 May 2023 07:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjECLea (ORCPT ); Wed, 3 May 2023 07:34:30 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C3159DA for ; Wed, 3 May 2023 04:34:28 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id C896D66056D3; Wed, 3 May 2023 12:34:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683113667; bh=S4CgoCQHjSzDV+ANF2xZcYt7UKYACrFS841NHZgYjfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSzjfc7ECNNyEtLKzke72Nb5BjqW2QRpVPcqoSbpFvF2xwjJF/b3svXSVsbbdU4uZ bMqzFyVFxfom3DZbQXCoUehXnTHeLY0zPw5sFMYuMmRBHmq94rQNIvTvx/VG8I9lXs ms1IL3A7BR6+xmjT0tUQa8e8/RLAvzRS7q8dDlwTSzAZ7BPpKsQiKDtKxRigCQIpge Ul1dP+WZxhnSfh0wF9j07b13taAGJvaVTKPTVarIpZ8oaIPiIKT5bhtIXuY+A06Ggz Yb63e99gTZD3e5yyndqPBAF00RCApXbRhoSDI+brPP1T34lSJAkcSTZ5ZiWA2AUl3M OOWgt+6u7ci6A== 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, pierre-louis.bossart@linux.intel.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, daniel.baluta@nxp.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, chunxu.li@mediatek.com, tinghan.shen@mediatek.com, error27@gmail.com, ribalda@chromium.org, yc.hung@mediatek.com, Allen-KH.Cheng@mediatek.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, sound-open-firmware@alsa-project.org, kernel@collabora.com Subject: [PATCH 4/5] ASoC: mediatek: mt8195-afe-pcm: Simplify with dev_err_probe() Date: Wed, 3 May 2023 13:34:12 +0200 Message-Id: <20230503113413.149235-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> References: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764872729025994124?= X-GMAIL-MSGID: =?utf-8?q?1764872729025994124?= Shorten the probe function by switching to dev_err_probe() where possible. Signed-off-by: AngeloGioacchino Del Regno Acked-by: Trevor Wu --- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 45 +++++++--------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c index a54c16e0aa05..105db11eecec 100644 --- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c +++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c @@ -3062,10 +3062,8 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) struct snd_soc_component *component; ret = of_reserved_mem_device_init(dev); - if (ret) { - dev_err(dev, "failed to assign memory region: %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to assign memory region\n"); ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33)); if (ret) @@ -3089,24 +3087,17 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) /* initial audio related clock */ ret = mt8195_afe_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"); /* 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"); spin_lock_init(&afe_priv->afe_ctrl_lock); @@ -3143,30 +3134,22 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) ret = devm_request_irq(dev, irq_id, mt8195_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(dev, "dai register i %d fail, ret %d\n", - i, ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "dai cb%i register fail\n", i); } /* init dai_driver and component_driver */ ret = mtk_afe_combine_sub_dai(afe); - if (ret) { - dev_warn(dev, "mtk_afe_combine_sub_dai fail, ret %d\n", - ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "mtk_afe_combine_sub_dai fail\n"); afe->mtk_afe_hardware = &mt8195_afe_hardware; afe->memif_fs = mt8195_memif_fs; From patchwork Wed May 3 11:34:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 89719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1256574vqo; Wed, 3 May 2023 04:36:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6nRuqbMSThPzb1POqtFAHxkNSzhPYHOgz7c7i9jeZuYMFqwcjOJc5zkzHqP7OtD5JNBRkx X-Received: by 2002:a17:90b:1e4f:b0:247:9d19:311f with SMTP id pi15-20020a17090b1e4f00b002479d19311fmr22194819pjb.30.1683113800260; Wed, 03 May 2023 04:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683113800; cv=none; d=google.com; s=arc-20160816; b=u87ygRTSjdpqowmOhLk/y1wXuoGDZ0nWCCTSPrO7BZ2jGEBX909OAsyCu8+OGAh1g/ 5LZH6GJEe+uB8gPCi524JanCbcuVphGmMuAGxirbVDp5fep3nYzInoUyECyF4rMcLrvm dW1MAAtpr94rVAx33C9ddphsMV2Z8iGGtY6QswtABS0NSvDacRTb6EGY5UDh/TdXsV61 SF3X85ljmDQCZNU9p2h7sb2pTq8bsZQ+X2hemcbeRFYePyK+ZNpP07F6H30BliuW7w4b 9lPYBEVmpFPNPOEzrCWQbz1QLLwwbMW5RtPI3tV1JEtroEqvRZmqtmu56lgNsqwbJbPj j6Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J4vZNRJbRSvAHuMgBj8rZFvL4Lt1CBAzXdTVl14UkhM=; b=yKRvqBzKJ5tZHkMUIgr4X0wbnDNOu/HMcXFomvaOcMhNvp3OwLukJmI1x7tMEYh2Sc ZXg6oYAxsCJEOU8A/iuwzp31tn39rtX2QuUWPL0BUAXHDWjwahrVN3A00X5EIIbsG8oV 6PGzxsGJGrmXspLCcRuKlz/XEn6AMsb3Zlbc/0z8AgX64EAMy5rVLHKEOOOY1sluK/xz /aVB/VU4F7LtQkbyUwJL705R8r5zmyjkNX0mzxAhmsIIcQPkp98/DEOjkLrwcJnTDi5x NVIOx1tVoYPqBlTE96VPOMJyoaBrsl5JDt60ZulVev6duG4pPDnbfzhHNsEJr3on8uNi 6GjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nnSLnjd9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mg20-20020a17090b371400b002467a036c62si13028936pjb.45.2023.05.03.04.36.27; Wed, 03 May 2023 04:36:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nnSLnjd9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbjECLev (ORCPT + 99 others); Wed, 3 May 2023 07:34:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbjECLei (ORCPT ); Wed, 3 May 2023 07:34:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55F4D46B8 for ; Wed, 3 May 2023 04:34:30 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id 743AE66056D4; Wed, 3 May 2023 12:34:27 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683113668; bh=oygimjOCk8FTKzESWYFnGtWGKI3xuJTfmDm18J1tugE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnSLnjd9bpSYeCY/2/NZVqduUmxCHwexohgvPshz2JTllUkmyRo/njwEw9d4MwMJT 7WEzj0+RlugeL+084Qu1byhLz321QBuV8Sp92WcW9OzgyfZhtdh9RnF9AP4e5g/EHW wZvTDMxTRy+WptLhVtHFLPGx8Ifv3Vg6GQiytY7PaF4r5l1Qti/S0P4uF6QHP4VZ0S uYa3FmhoPtjBPdT4YwwzCHzPe8XQAyhTpqzOo4CW4+mImzfQm5qUEWB1WEordvvWqk Onn4CAvpadjEBcP9u3b3WgmRzKWsJ3zxVdgaTHuF3A+t+/U+XHxKLbGXCt2O6Cov0N i+M3I5tgi8W/A== 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, pierre-louis.bossart@linux.intel.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, daniel.baluta@nxp.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, chunxu.li@mediatek.com, tinghan.shen@mediatek.com, error27@gmail.com, ribalda@chromium.org, yc.hung@mediatek.com, Allen-KH.Cheng@mediatek.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, sound-open-firmware@alsa-project.org, kernel@collabora.com Subject: [PATCH 5/5] ASoC: mediatek: mt8195-afe-pcm: Clean up unnecessary functions Date: Wed, 3 May 2023 13:34:13 +0200 Message-Id: <20230503113413.149235-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> References: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764872736443733676?= X-GMAIL-MSGID: =?utf-8?q?1764872736443733676?= Function mt8195_afe_init_registers() performs just a single call to regmap_multi_reg_write(), it returns int and it's not error checked; move that call to the probe function and also add some error check. While at it, also move the contents of mt8195_afe_parse_of() to the probe function as well: since this is getting a handle to topckgen and since that's optional, the ifdef for CONFIG_SND_SOC_MT6359 can also be removed. Signed-off-by: AngeloGioacchino Del Regno Acked-by: Trevor Wu --- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 32 ++++++---------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c index 105db11eecec..d22cf1664d8a 100644 --- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c +++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c @@ -3030,28 +3030,6 @@ static const struct reg_sequence mt8195_cg_patch[] = { { AUDIO_TOP_CON1, 0xfffffff8 }, }; -static int mt8195_afe_init_registers(struct mtk_base_afe *afe) -{ - return regmap_multi_reg_write(afe->regmap, - mt8195_afe_reg_defaults, - ARRAY_SIZE(mt8195_afe_reg_defaults)); -} - -static void mt8195_afe_parse_of(struct mtk_base_afe *afe, - struct device_node *np) -{ -#if IS_ENABLED(CONFIG_SND_SOC_MT6359) - struct mt8195_afe_private *afe_priv = afe->platform_priv; - - afe_priv->topckgen = syscon_regmap_lookup_by_phandle(afe->dev->of_node, - "mediatek,topckgen"); - if (IS_ERR(afe_priv->topckgen)) { - dev_info(afe->dev, "%s() Cannot find topckgen controller: %ld\n", - __func__, PTR_ERR(afe_priv->topckgen)); - } -#endif -} - static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) { struct mtk_base_afe *afe; @@ -3160,7 +3138,10 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) platform_set_drvdata(pdev, afe); - mt8195_afe_parse_of(afe, pdev->dev.of_node); + afe_priv->topckgen = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,topckgen"); + if (IS_ERR(afe_priv->topckgen)) + dev_dbg(afe->dev, "Cannot find topckgen controller: %ld\n", + PTR_ERR(afe_priv->topckgen)); /* enable clock for regcache get default value from hw */ afe_priv->pm_runtime_bypass_reg_ctl = true; @@ -3219,7 +3200,10 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) goto err_pm_put; } - mt8195_afe_init_registers(afe); + ret = regmap_multi_reg_write(afe->regmap, mt8195_afe_reg_defaults, + ARRAY_SIZE(mt8195_afe_reg_defaults)); + if (ret) + goto err_pm_put; ret = pm_runtime_put_sync(dev); if (ret)