From patchwork Fri Jun 28 10:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 808287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB040C3064D for ; Fri, 28 Jun 2024 10:12:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9F4782390; Fri, 28 Jun 2024 12:12:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9F4782390 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719569557; bh=t0oThzO9Q8Q8Ygu8zNE+tB4uDDaXPUAD51K7NJR7FOs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=F3JYveJPfCj6bvd5ddAXmMthjcUYfYMLoUUiLvzsZw03ULKRBDO+Y8va+PWDMMw94 434IB+3HO8RcCmSMxlu6OzOIV7Sw4zsK4n4wxsbqx3rbs2v5CpE0F1vzPeXOjz97jH KoBY4kLQhA256F97s7F+bj4r30H3EGb3aQdFSsBY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C29EBF805EA; Fri, 28 Jun 2024 12:11:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3EDDDF805E6; Fri, 28 Jun 2024 12:11:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D9EEBF804F2; Fri, 28 Jun 2024 12:11:42 +0200 (CEST) Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ADFAEF8013D for ; Fri, 28 Jun 2024 12:11:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ADFAEF8013D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=u5PmsYat Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2ebe0a81dc8so5459791fa.2 for ; Fri, 28 Jun 2024 03:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719569492; x=1720174292; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6rcUCvATOk6PUaPwOA0D72nSVujkGGCzYAuhpl2nZXU=; b=u5PmsYatkI3sThb2dPn2PM0NEX3dlB0nT/Frtf4vAVXiSX19OvwnH0UtyXxLCbAoWg NvUGto59nnd6cUYtkkAWYWXJ25GXqGN2MMUYkz0rtbaNac3fHG/XW2ocoeD2TNtaxKCw LHV6ZSCHymOhR42XOdhrH+Tp57Xb5AcDgH0bcnmad7WiXqTmz42M21NYb+Vx58hlKRKv xRzs5y6b4KdZMFiKKlZNd5SulVwz0XK/MdMd3syos9KSBxpkkdcKbgZQFybmVX52LAKL rlo/ok+IgJ5ng49epMVS1kjX9StdMVnBM46wiQlDvDHgeCWVsKjsxRCK6x5Zeypo7DvO le6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719569492; x=1720174292; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6rcUCvATOk6PUaPwOA0D72nSVujkGGCzYAuhpl2nZXU=; b=AFVEw47APuaSzUPLRO0hrxBGZQiVoC1wecOSzuMTWWfx+X0G5zaGRsDcXIVMHPIzJx hKRoo8crHKGxZSfNSDPQj8OMVzPUpPCpzKhGqeJM1YbRYxPlUh6zudCK4+4O6+jSfPoD R4QlaZDTva6EqdkoVKakZYcu6pa3jIl9kRMikt3CgiTB3Chb/wOL/zI3+C+KG5+ApLY9 4l50RqGWHyPxIAkHFr6zOpU/g/uTY/r3XfyQVyvkxh9B9jSjNryhabHXMId0MjXztJRf VXraoTlPpCT40oahxG6ksmssL4WiWctXxb3MULwwxXjDxu1hptew1P+yIvrXJ3LIjH7I yxiA== X-Gm-Message-State: AOJu0YxLKKccCrpK/K5Yg1tJNQidF1S308XfX0x2FoR/cq+VQeSo/lL5 AOydr7wO98OtugL66G/M4ywUA2NR+W7pH/AxLiNuYBahT53VYqopuGM0PHKAOT8= X-Google-Smtp-Source: AGHT+IGv+fN5oMBLkD52ryRZ8LfY0cXbKJU+4r6OFmL14KG93AcvWuOhqCYyA9visl1sjhxLli+LsA== X-Received: by 2002:a2e:3018:0:b0:2ec:588d:7eb4 with SMTP id 38308e7fff4ca-2ec5b30bd1fmr121706111fa.15.1719569492424; Fri, 28 Jun 2024 03:11:32 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c15f8sm27024605e9.47.2024.06.28.03.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 03:11:31 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 28 Jun 2024 12:10:55 +0200 Subject: [PATCH v2 1/5] ASoC: codecs: lpass-rx-macro: Simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-1-e9741143e485@linaro.org> References: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> In-Reply-To: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2363; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=t0oThzO9Q8Q8Ygu8zNE+tB4uDDaXPUAD51K7NJR7FOs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmfow9491/AvVpxy9ctPQeIOel+kU6a2WiOiqlU 6zfSOJQXdWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZn6MPQAKCRDBN2bmhouD 1y+dEACR1q3XmwV+WuYCly6WpPMyPcQz2N3xgpPi4saLYSobA8Gm/tUVbxMUqk/lL7Y/26lB8Un ffGLBUsDsO1Q/MY10YVArp/OE6gTvSRxBKElY03d1vTInfeu9gG8e9z/XQ2uSIUV1O6LN31pt3+ q4PpGqn4FBoH0vFc7i5AToHTHN8+/by4ppLJ3+gj2oWSiCLeoJhpL33hgZ0h1+DeUubgbeapgGY +TB0H/Tf20+Ghb1T5bssPfLYLLSiI2A6NANsDVkRRjTixkL8HTLxbeCII/hw+jEx6Lw/PUw4q1I DKREVV3B2rmI7OcAZY3RHJxjEATN1oAd2eCruzV1WrM1fnv4BaAp1Crb4oaFqhn4dOY0cTYJbWK T8PcUeLRUQMn0EQKsZ+huVovLod8Kxa2bKCC/YOrcyusPtfdZVS98rsv+iqu81BLuftRJ/FFNrb Xg5I3lc4pIGtDI1FILl+s4y0P2bKuwbEoGy74n6XGDyMXTbJCi8KFUQ4kszI+sJNpg+s4C23bG4 T77l4e+XF9d4YPs7d0kWa+Bcr2/qCFq6XnOUFdU7IvDzUqTRzTDyiJBT/vx5Noek4kaM//IBctS RRdjZm7RCqrOUahDN1rs+VV+V64eiw+bwy/A7jD7vH+9FlqPfyia8yNpRp2YrqQmB9DdODaxq/Y SMEiOpDlwyu9Y+g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: NPLI6C6FJ2XAOQGYGAA6JAHNSX7LZHOW X-Message-ID-Hash: NPLI6C6FJ2XAOQGYGAA6JAHNSX7LZHOW X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the default register values array with scoped/cleanup.h to reduce number of error paths and make code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- Not adding Dmitry's Rb tag, because of major change devm->cleanup.h. --- sound/soc/codecs/lpass-rx-macro.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index d47c49c90de3..4cf030760d74 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. +#include #include #include #include @@ -3764,7 +3765,6 @@ static const struct snd_soc_component_driver rx_macro_component_drv = { static int rx_macro_probe(struct platform_device *pdev) { - struct reg_default *reg_defaults; struct device *dev = &pdev->dev; kernel_ulong_t flags; struct rx_macro *rx; @@ -3809,6 +3809,8 @@ static int rx_macro_probe(struct platform_device *pdev) goto err; } rx->codec_version = lpass_macro_get_codec_version(); + struct reg_default *reg_defaults __free(kfree) = NULL; + switch (rx->codec_version) { case LPASS_CODEC_VERSION_1_0: case LPASS_CODEC_VERSION_1_1: @@ -3853,7 +3855,7 @@ static int rx_macro_probe(struct platform_device *pdev) rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config); if (IS_ERR(rx->regmap)) { ret = PTR_ERR(rx->regmap); - goto err_ver; + goto err; } dev_set_drvdata(dev, rx); @@ -3866,7 +3868,7 @@ static int rx_macro_probe(struct platform_device *pdev) ret = clk_prepare_enable(rx->macro); if (ret) - goto err_ver; + goto err; ret = clk_prepare_enable(rx->dcodec); if (ret) @@ -3912,7 +3914,6 @@ static int rx_macro_probe(struct platform_device *pdev) if (ret) goto err_clkout; - kfree(reg_defaults); return 0; err_clkout: @@ -3925,8 +3926,6 @@ static int rx_macro_probe(struct platform_device *pdev) clk_disable_unprepare(rx->dcodec); err_dcodec: clk_disable_unprepare(rx->macro); -err_ver: - kfree(reg_defaults); err: lpass_macro_pds_exit(rx->pds); From patchwork Fri Jun 28 10:10:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 808512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15E54C3064D for ; Fri, 28 Jun 2024 10:12:52 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 60FB42369; Fri, 28 Jun 2024 12:12:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 60FB42369 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719569570; bh=ycHPrSfshLbhaVlOmSrBNFLaE6akGY9mtxIkStrGvh4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NWyO5VfIy7SQboa6c9wAtK53a6VGDz77ebvEDU9w6KlUIauiolLTbFA4od0j5VSyp eFi7Cv+c8FiE8YOiWJKsvCXnTd7I0gcOQDxlV6YhnGpMVcnFUqOfV/yLqe/h2itcQM W4lvbE9MkCzgl5o2hzqGFXICTkiSLv7SaClLcVzU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 861F3F805FC; Fri, 28 Jun 2024 12:11:51 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D2A91F805ED; Fri, 28 Jun 2024 12:11:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 53838F8016E; Fri, 28 Jun 2024 12:11:46 +0200 (CEST) Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 175ADF8016E for ; Fri, 28 Jun 2024 12:11:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 175ADF8016E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=l5Q9l1EO Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ec61eeed8eso4732061fa.0 for ; Fri, 28 Jun 2024 03:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719569494; x=1720174294; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JrC0oanY/xXM5tNplzJFb5TLPsl7ab1mW6qPRTKsSC8=; b=l5Q9l1EOizYVbfVPcfKDasxdte7KP1mpRltGJoW0g4NEu5faZGyh1r5jo94POZwzxu i6vTYAylUrvTdoCIscVIn2WJKoFSW6GwIIFGhYT4ppzXdQOg+R4FQGk91yAtz2nqEDmh agL7u5wh3PHxhEZQPmsVqxrV7c/3aEv2i4whni8nvz8p+fHLejqhSmbJMNXPblA7LE8C PMVg9TRmZJYiYkhVGvzVY7zL8kOUMFB5BYeU5tVwMDXdMQIkE/TiHTn5p3yM9LSO//y6 QwtwCrxvc8Dae+ZJ8yyYamrlxI2AL/5r6p2E6RNrCNH6tdCyjDdplW2RUGZPTv5bHbhV AlOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719569494; x=1720174294; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JrC0oanY/xXM5tNplzJFb5TLPsl7ab1mW6qPRTKsSC8=; b=BacSk+gFyOpGKHl2OUE/zayWKoQRH6Tu6yboAc2VBu0k7IuoLBQv65Hw2uA/eiyEGa KA4emfLGUFFOF6rzlmJKBL0UmlPsoMugQB37JSAHWxbv50uc6FaHd5EhUuX38bxgF2lJ Dc/MpJH3wMVnTrb7FIFJwzG/n8xMdfwMN2X0oyqQXH7lRCEsEh5EZ8qbnleXBWwiaDsv wCU6nOISMCNm5OdcyW/OIi4lqT7PKWfPb15RZZGGQOyHdV3zPug2cimMu/yiUFREx+H9 YPpmszDGkkb9BUAL/s5/jWLorO7lIA/VqI/HhC4Fzip6165ixLhIpXdywhXVglcHdFv3 X4QQ== X-Gm-Message-State: AOJu0YyWtiFRA3Nt/06qLE0AO5SqVB/B5t2miW+3v0NXt9C9oHS1CYBp sYuq/harGob4V0YXsMsusO7Z7kN4xTxBhtNCDGdT5qb7+At26EG4LRAVLpfBuwFSz2JH6dMyYOL 0 X-Google-Smtp-Source: AGHT+IFKhIJpRNXOaeJJ2eW2v9e+5Ei4zrnP5FIL9QTBjvfsw4tDY8rG0xk7rsZ1cWCftr3DLKVXYg== X-Received: by 2002:a05:651c:10a2:b0:2ec:5cfe:2e99 with SMTP id 38308e7fff4ca-2ec5cfe2efcmr86889161fa.6.1719569493806; Fri, 28 Jun 2024 03:11:33 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c15f8sm27024605e9.47.2024.06.28.03.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 03:11:33 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 28 Jun 2024 12:10:56 +0200 Subject: [PATCH v2 2/5] ASoC: codecs: lpass-rx-macro: Keep static regmap_config as const MIME-Version: 1.0 Message-Id: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-2-e9741143e485@linaro.org> References: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> In-Reply-To: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2080; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ycHPrSfshLbhaVlOmSrBNFLaE6akGY9mtxIkStrGvh4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmfow+5/Q8/abTSGqS3WeeJmNN/eGY2CApICxtv 1RpQy+alaiJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZn6MPgAKCRDBN2bmhouD 1z1SD/977JGgYit9iIszAbc1+SmnkFG1Z8kCb/Hm66RsrpD3PCec7xncGbzpllIJD25/MWPHp3s KeYM25mJNwmtrsXQ2yAc1Mje5nEN6Oouc0m7Wt4UQUNvKGJ38kDZ7/zhj1H8bQ81swJyEFnDBT4 +0ibiITHjvLRXNi/1kQ1e2PxR9s9P20Uwxc0PD65gCXuIjDT9wsl0fpk3kH9t2C8w5TR+TwAkpw Mm2vgKQoLVlLyNE7h45yUka8PXhaDFqZ+7oOt1EYcYTv+h9nrk+YaAx9lkjxhZ3PgvuD7JccnKu ldQy3ghq9c0MgtN/S+JwHESNLt+OTx0IaKy9W/IohMVioYPFqVYXJVUyBBK8oXmbEjgv1bEI7do 3WQGEdEseFyaVbxm2uTD4gSEu7RER7FK9TtLTV/nxIZYxxy+QB7+DJaZRm5ib5Uv8ncmz07NMtF Jd+CWFUp3UZQKvCgc/Po6aTyAQajsF44iSbqV8XwLhC1m5WXe9loIEJqGkgI+iLWCL2Mqju8E5Q NK1VsC+W8KlfYce5yJoV7D7ohAJfGxoti96qi0H/FWbTGYZstQDvKbUICAVcRImPV7DXbKST2rI A4Ba+TyOP1XmyZrzMxoqKNasLw8KlgceFqahbL7BiX+7IdW/yn2LiMW5gkA3XC4nh0wg4LM5Ohn 1cPt/M88ksZ2LIA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: C2Q3VGWRQ6Z34C6LWONGV4BYDK3KYVFD X-Message-ID-Hash: C2Q3VGWRQ6Z34C6LWONGV4BYDK3KYVFD X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The driver has static 'struct regmap_config', which is then customized depending on device version. This works fine, because there should not be two devices in a system simultaneously and even less likely that such two devices would have different versions, thus different regmap config. However code is cleaner and more obvious when static data in the driver is also const - it serves as a template. Mark the 'struct regmap_config' as const and duplicate it in the probe() with kmemdup to allow customizing per detected device variant. Signed-off-by: Krzysztof Kozlowski --- Not adding Dmitry's Rb tag, because of major change devm->cleanup.h. --- sound/soc/codecs/lpass-rx-macro.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 4cf030760d74..1d2dce1f600c 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -1663,7 +1663,7 @@ static bool rx_is_readable_register(struct device *dev, unsigned int reg) return rx_is_rw_register(dev, reg); } -static struct regmap_config rx_regmap_config = { +static const struct regmap_config rx_regmap_config = { .name = "rx_macro", .reg_bits = 16, .val_bits = 32, /* 8 but with 32 bit read/write */ @@ -3849,10 +3849,18 @@ static int rx_macro_probe(struct platform_device *pdev) goto err; } - rx_regmap_config.reg_defaults = reg_defaults; - rx_regmap_config.num_reg_defaults = def_count; + struct regmap_config *reg_config __free(kfree) = kmemdup(&rx_regmap_config, + sizeof(*reg_config), + GFP_KERNEL); + if (!reg_config) { + ret = -ENOMEM; + goto err; + } - rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config); + reg_config->reg_defaults = reg_defaults; + reg_config->num_reg_defaults = def_count; + + rx->regmap = devm_regmap_init_mmio(dev, base, reg_config); if (IS_ERR(rx->regmap)) { ret = PTR_ERR(rx->regmap); goto err; From patchwork Fri Jun 28 10:10:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 808285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08FE2C2BBCA for ; Fri, 28 Jun 2024 10:14:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F2EF7238B; Fri, 28 Jun 2024 12:14:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F2EF7238B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719569685; bh=Ad+uKCGSDe8rakMGGeF23SfGPaAfcaquc5R5IIxLKwU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KSyxKx76ZyYsaFL7Utaeti5zXsk4h5YyJBU7el5nGXrfnEKLvmo70RIZXVWYSDv+y 9eku+AKhGnqmLynlzpwgTMzl0cE7XoYUUF3OvznlubCaJX6vCWWE5dpUfkwa79dqQR HySY8WipjIng1ZJR5s3ARinpMpr7OAMmmxKtzSF0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1DFA8F80601; Fri, 28 Jun 2024 12:13:48 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id ABB1EF805F8; Fri, 28 Jun 2024 12:13:45 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 81A6BF805C4; Fri, 28 Jun 2024 12:13:38 +0200 (CEST) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4A089F80495 for ; Fri, 28 Jun 2024 12:11:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4A089F80495 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=KOXdc/XO Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42562fde108so4105815e9.0 for ; Fri, 28 Jun 2024 03:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719569495; x=1720174295; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=PicI/VwwrTj8z258jc72WwlXuJ32jmr5AxPeFVRGEyg=; b=KOXdc/XOhRP0Ey4m0aUWPJEV+ArTvpkyekuC+5lH8UR/5Brt1MoQ76+ar/p2tKoj2y P/bMKi3S4BbXRYEZ39zWJ22x6f0W5z6lJamU15K2HiaEfWrJK68PIHaEog7FfbNVsJzY UfF07AaNWio7xzEgKdhXnj6fTzxCzqCHgmYpd3mC1cyO65hyok5rlGUM3zPiWrof7PRM W0K2wHjNX6CCfO1LG3sj1g5KXXLTCF1hRvn64NijWsNkXVkB8NZnoECfjlTA+hPGRw92 bgZB12EIoShAD8wxtg7lCgJGqZpsHTkl0jtjJ6XMkRX8X3TdiTEGYxzdpMYuew4Wrs1P q+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719569495; x=1720174295; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PicI/VwwrTj8z258jc72WwlXuJ32jmr5AxPeFVRGEyg=; b=ke2yhkHSR1r2TKAYDkEIQgbS29ysPv4zwACVAw37w707P/obJxv1s7cWG4k639Ao4c vPEm6Uz52ZAj6Eu+eAMnkDGdR1fa5jTNgswIwPH0kZCj2r/nY9+wE2kYFKNvoqTHhhD5 XKPBSLvO33kEnWysgOa/87NzwCjSfVhY4ZNM8ABWFJzexiIfeTnWJoyzM0nErTq1f6QG 1EEr+70rOrv7RshbwlJUCfjxEFyFcAinCH7pVemI0MXpwukDn3SYUghXsbl/fzGtKRwJ kMsQNJvGDUKdEPSJj8BmWbI6o/CObweBHwEeoo2ZRspQHcDYNglhtMqPc7Dx37zS/tGB K6SA== X-Gm-Message-State: AOJu0YyyKUfCs1VBVAgMl7y4tfhn+j18zhkfZUucgDHJNX0x1CG5ZK0H cMBC4oD0qcYGZGteSig5X5EG2epG/X8rBcAW7TVsrwrgtBFZwRUPVhPsJCMR6VM= X-Google-Smtp-Source: AGHT+IF+pgGQZfU5lPr4i1g9vWtUS2+TH+xCGlGbz2/0V8EIqgNIpPGUYP3hYpebbJgktsPW2jhF5Q== X-Received: by 2002:a05:600c:4f09:b0:425:680b:a6a8 with SMTP id 5b1f17b1804b1-425680ba7camr30266455e9.15.1719569495149; Fri, 28 Jun 2024 03:11:35 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c15f8sm27024605e9.47.2024.06.28.03.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 03:11:34 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 28 Jun 2024 12:10:57 +0200 Subject: [PATCH v2 3/5] ASoC: dapm: Use unsigned for number of widgets in snd_soc_dapm_new_controls() MIME-Version: 1.0 Message-Id: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-3-e9741143e485@linaro.org> References: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> In-Reply-To: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1647; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Ad+uKCGSDe8rakMGGeF23SfGPaAfcaquc5R5IIxLKwU=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmfow/CHxJHKXSrU35rkMdrR/G9PK+UceqkN2/f TIzT+/6MeyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZn6MPwAKCRDBN2bmhouD 1+KNEACA0txoe8z7xQCp/1czBOAR3nyYD2oUsKtrvoP8vdBhLubYOsiEFloCmFR/ZLXhAUeBpSZ Ij3B8o+u+G1bfFTjd0Byp3WN0BPFQCisLH49FSEGr1fBcMNgMJSF25LqOCQwPzBXjG9CDfEmqRU bhu6w6HssqzUJOT+ajHvj6zxaAuHvxBeML73axj07tSLsMrs35Ci8hmvs3+F4rqTpV9ByxALm3O ci30+PYDQPCCzi+DdYh57C96mDXD3znkqoefIBLTkMy+ALLXZcYN49ZPUxVOh5WBGh1h1uTwrcR 26MLyFv+4DMlHOCPw0LU4jR9uiEt6YdefoNDSz899AYAN8DPjTzS2lXTl7obdAuc6W+gVg1+TaN c+syZ9sPsBTfKI/vQx4aUz3UIe3LTuMwNaNePuPRo56a+/SeuSSMH09UYPQpu6S44mQBIWC+MBs 6uf8jtC0pkustFnarOJazUm4YZzE2gL0egzCOO6hwcmmcWu+jtHvo0F24nwQ3dthFXaCPTpuT6L BZo8SvhUoyLqeoH32Asa57EbAIfGUSDxBtAGRXtplJOKyac/OzY0CLvhnatbSt1dVk25sf0ohxO 2HrYjJ6ic4Qv9TQrr0iQiESClW1cW9bIGQWUc4/duxR7wZVwweMeWwOX/yPRxretk+Y4oSj96bH KK+Fxrl+6oGyE3g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: QKSU5BZTU3AOPTSN7JURWCCKSLWXXSJV X-Message-ID-Hash: QKSU5BZTU3AOPTSN7JURWCCKSLWXXSJV X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Number of widgets in array passed to snd_soc_dapm_new_controls() cannot be negative, so make it explicit by using 'unsigned int', just like snd_soc_add_component_controls() is doing. Reviewed-by: Dmitry Baryshkov Signed-off-by: Krzysztof Kozlowski --- include/sound/soc-dapm.h | 2 +- sound/soc/soc-dapm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 667ecd4daa68..12cd7b5a2202 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -457,7 +457,7 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uncontrol); int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, - const struct snd_soc_dapm_widget *widget, int num); + const struct snd_soc_dapm_widget *widget, unsigned int num); struct snd_soc_dapm_widget *snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget); struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 16dad4a45443..32cc90d09bc2 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3857,7 +3857,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control); */ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget, - int num) + unsigned int num) { int i; int ret = 0; From patchwork Fri Jun 28 10:10:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 808511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B05FFC2BBCA for ; Fri, 28 Jun 2024 10:14:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 55758238E; Fri, 28 Jun 2024 12:14:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 55758238E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719569672; bh=fhQZZ4QjPKXRqv6gWUJ77jDFeIWxAGyZqof8ycl13AE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YPtSIT5xdTmX2rpWyxfdy2mCqaddWXMV/7/bpO3lJ2CSHX4Hd5hS6pdb/0uGwfrwg kmxdwgrzJZpEIZxfdBNjGZTRdysXDNhiDQRPv9I9WVGkGbrOlQZOogfsj9gbBfC4Xg QTIZsyLCOZRBhcGephkwJgO8ZxChyYJs+P1WVb6k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E4A17F805EF; Fri, 28 Jun 2024 12:13:42 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 290F1F805E9; Fri, 28 Jun 2024 12:13:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 91D9EF805A8; Fri, 28 Jun 2024 12:13:37 +0200 (CEST) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2C36BF8049C for ; Fri, 28 Jun 2024 12:11:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2C36BF8049C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cEg+FKpq Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-425680b1d3aso2921845e9.2 for ; Fri, 28 Jun 2024 03:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719569496; x=1720174296; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=w+rpmUsm4rhHiHlN8KJCEkTWbouDx20N7nNq4S2dVmc=; b=cEg+FKpqChoM4Z7uxtAk6CvhwcGtXo+e9nTj6hOgetLaTy9dUZABS6maycyMWDs41u aneLHdUzdBfpBj+a2r756dKJ9gmTuo+vh9wTRvOjpjjLx15IijI4w7ko5D+XZ8aeedjA YKBJCMGTJfE9Jlh80gQDpju16ZnmOWkKdIDc9hHHGb4O+1jtYWq+jJN21cH7kJlEIixd KIrabb55bDOvkkg53W0mxLcoDhpfhPB25FgoP0AXf/DbXnn2VxTOyHErm4tZSS/Ta9MC rUAVHW8xwBUVgSyBS98Np0pfZChOnXj92+NtvibTVRtky8XQTAbrQ8mw6skCMj2En8Dx FysQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719569496; x=1720174296; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w+rpmUsm4rhHiHlN8KJCEkTWbouDx20N7nNq4S2dVmc=; b=NNU0FzMujeushyII73YorCJvMDmfkua/sWpSrtNAUeEIAXqvel+E674O1RGqzNKRzf QjDdLYDKUsUooi+49RIAfcHv0x/VhHR8nLL9re7Qgt5pkpA0u1C3M6u0+23TrwFWLA/7 3q4VYEdf9m/TqChVD/5zcf9wDXavPyeZ1wOskgD/9KCUDAD3MNZfourHQ34CxHhGgcGA Z0LnoGv9PPRmBbJ0P4oNVFFLfGmXUFa6KOm8VsjwgLaEOEVZHWeaGguzClcenJPavjN3 21+vmvgX1HYsf1134J7VCY6dNu2+SoEMbTUWIPpTsV7JeUqwL4iPtj5NqfXIQ4FbmJM7 R+lg== X-Gm-Message-State: AOJu0YwWa6eqJ2QJsy6Y3TkjKv4FxMrPIFyebYwGXaGqE9Y8oyDhwUQN pT3c8crZputoPcOGb29aNUGf9RLVrARucW/KZPEQrlJf2zihj2lIGRlwVFtko/Y= X-Google-Smtp-Source: AGHT+IHonegirDh7c82kEa3PisDCySFJqp+wAI8RX/TRs3710R34yTI3kBy+elemSn3wKoSxmIZJLg== X-Received: by 2002:a05:600c:1c1f:b0:424:8e3a:d02e with SMTP id 5b1f17b1804b1-4248e3ad244mr124740405e9.3.1719569496469; Fri, 28 Jun 2024 03:11:36 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c15f8sm27024605e9.47.2024.06.28.03.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 03:11:35 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 28 Jun 2024 12:10:58 +0200 Subject: [PATCH v2 4/5] ASoC: codecs: lpass-rx-macro: Use unsigned for number of widgets MIME-Version: 1.0 Message-Id: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-4-e9741143e485@linaro.org> References: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> In-Reply-To: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1007; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=fhQZZ4QjPKXRqv6gWUJ77jDFeIWxAGyZqof8ycl13AE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmfoxAtvV6h0PC01XQmUzFGtHvD3AQF3zcnGj8C taRAiVUTmqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZn6MQAAKCRDBN2bmhouD 1yTzD/45YqEc5uhFbMbSBNNU9dkOk2qQUblj+TJdVS1CIW3tMXjwpvGfZ2EgMouWgTcz2afrM4m ojDfVCYKekEAXfsmxJmXxB8j/7tSP3/X8N0w8t00Li1mZvz7owRSVfzuBNwOVL2q84aUHsuiRMo rS2OokjwAkyBMisqCTsIL+zeHodH8fP89yW8pO5qs4tE6cHuQKLAevWWlUNo/IhYECP11wt91AB oTgWswftId8J9ODsqHdEexwnEbdAxMazerRzqnG+D7ysICFPoYgaKxJh0UTCdGnL9H88K/cVP0b aK0B5Nb5UyzPkt8u6vkzT/i4HHggRVcrf/k+TRMZo4r2Kz1omfz3DdRDHWzXJT2WRlqg+aBKG1o 2uDRekyO+GCnC1YSedO1NvDjlT0aakVvWscVK/nxtiNXNixDD6ASS8YANb/LqIqQE1fSca8OSvE rZGcD/+vE7efrAG/TClGGgax/qKYyOLgD6OkzYMDHi2mY2gNu7bEQ8XQYBVO7B7kM4fBA1j/sU8 orjdW8G858pBkCMdi7gOCUBvCrbOAQTXKdw0raRamLxk7IWq0FWjdyU35ceP4cWslU+eKUkPXKA kfv3h9M3DyeKRw2YWYZbRkV83sCteLle+5kRMh6IsHmnBV9PZIfgsxuXtFlMSieb2JyV9rmJSCq MBGNjmdoo4g2Xmg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: M6JQZ3QEOPI36OSHR4J6OVHWYQJKO7SM X-Message-ID-Hash: M6JQZ3QEOPI36OSHR4J6OVHWYQJKO7SM X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Driver uses ARRAY_SIZE() to get number of widgets later passed to snd_soc_dapm_new_controls(), which is an 'unsigned int'. Reviewed-by: Dmitry Baryshkov Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/lpass-rx-macro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 1d2dce1f600c..c101d0b8995a 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -3612,8 +3612,8 @@ static int rx_macro_component_probe(struct snd_soc_component *component) struct rx_macro *rx = snd_soc_component_get_drvdata(component); const struct snd_soc_dapm_widget *widgets; const struct snd_kcontrol_new *controls; - unsigned int num_controls; - int ret, num_widgets; + unsigned int num_controls, num_widgets; + int ret; snd_soc_component_init_regmap(component, rx->regmap); From patchwork Fri Jun 28 10:10:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 808286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3A2CC2BBCA for ; Fri, 28 Jun 2024 10:14:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 03BCD2365; Fri, 28 Jun 2024 12:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 03BCD2365 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719569652; bh=mHTTaZNpcGoV/mUxNlKDTFQQYgAom9YHnI/rebyFS7Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=M02tyTKHPhLGlb2lQe2/o5KZbOQk+uUnerz470enW0t0NVIuL6flsnwMQjLarMU9G BseL+mRunhBSEX5C572AQH+NqEXYiRRINgSo2hO18pG5oxOohrbLH/UH0A3VQIA8f0 tsG6jDrZrMXlm4QX2Zfz5FftB2/PcE5Z4CSAVEP0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 47AA8F805BA; Fri, 28 Jun 2024 12:13:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 82477F805C1; Fri, 28 Jun 2024 12:13:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id ECBFCF800E4; Fri, 28 Jun 2024 12:13:33 +0200 (CEST) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6075DF800E4 for ; Fri, 28 Jun 2024 12:11:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6075DF800E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=jKGIVRcw Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42561c16ffeso3817505e9.3 for ; Fri, 28 Jun 2024 03:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719569497; x=1720174297; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LkhZEX+m4yRFERQhljwkeNudJNH97Tx+yLOdy4DNmag=; b=jKGIVRcwd39Twv0/S6Rflc4pAECxVpD2mYrTmUtH46mQlEND0DYzwQJKTB/6cLo46s wJSpVqf/NvmnXQslenv+elhNtrwvOy0mkyITyIb0KXfpenI9wZXnn3foUhmQCG41npr/ x3Hoqf9Z2YS4dXssQl25/7XJLYzm95C06C9kqpGgPspKSfCK5f2BQwUG9LSfo3ptxiNK 2lfsTRlOVG2pqfti7jTTPSzr7z/zqYsn3A+VU9R5XyTHokJhIACe/f4+gPBfj57RjsgK astVYLlyYIKWSMk6djJIH+GGOxLgVkODkgYX/LSka/KtTkLnabmLRxAHyCh04zhX1Od6 nNjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719569497; x=1720174297; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LkhZEX+m4yRFERQhljwkeNudJNH97Tx+yLOdy4DNmag=; b=ifwRyCrFx/tgaGw0eW3TP6zszDxFdEVo0BZiQkuqBW5Vhx0nLoo6B6RCOnJAjsjWYF NOAmRi9ofP94qaBTzvTg4wWlTqYkLpGAsNn3ZleJqKUteqFlNDz26xga6BpVf99wlGPL k/aXvn1qqv3wrZZNHyGb7S7Dmu7ii4lOFh56yxT2bArXFKZ7pYNU/9Tvm7xjZPsUDLUO bwa8p0u5fhtUIUEFYhuuvlY6Zviklje5S2+WDfIdQfRgBcnxudyi4wtZFH0ynuHETx6q Mph4PD+h+VsANvN1CDZF9PqENLT3vmHkCW9Kq1Hx5FGDQK9F1Z7aPcb4kMFMdaN0jVUb MLsg== X-Gm-Message-State: AOJu0YxxpexwPJ2rxDuw2e2+bhE3RX4NFwyfZ4XZrcovMjYNaausqWDu ublEf7YecN9YE9lazaQxYljgLjybwsYed8Cns/xJI9A0D/w6R0lU5xFygRF/acE= X-Google-Smtp-Source: AGHT+IFZAKYRP0ELHRLqVkzPXiFVn5Ahxi3UScj47Vi/DSByvBMN7t47V/esD9G6nGISyat/slInbA== X-Received: by 2002:a05:600c:5819:b0:421:5966:ca40 with SMTP id 5b1f17b1804b1-4248cc2a7c5mr108666635e9.10.1719569497596; Fri, 28 Jun 2024 03:11:37 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c15f8sm27024605e9.47.2024.06.28.03.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 03:11:37 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 28 Jun 2024 12:10:59 +0200 Subject: [PATCH v2 5/5] ASoC: codecs: lpass-wsa-macro: Simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-5-e9741143e485@linaro.org> References: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> In-Reply-To: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-0-e9741143e485@linaro.org> To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3389; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=mHTTaZNpcGoV/mUxNlKDTFQQYgAom9YHnI/rebyFS7Q=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmfoxByjErZrFpA2io6CZmKX5eVHl0S31rLIcwQ 2f2VwflwMOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZn6MQQAKCRDBN2bmhouD 18JEEACLa57k2Kdt04/TAWG2YVD7j2medFXWR35HQqZq7tCGbwlbGgmOIKAkK7gTKhV0C29W70s K4EUklMzCu1T1sfEXj6loRtyiBuF8ECRNzkDmUSRosn79fMoSb0O5AjiFEREM/x+kTZB8dhE5P8 eGSW7/ZSPR6xwngg/6MXkoYvAkoUhygozoe+s28L9kOdaHGyWL+P+dR1vt68dR4xieRaD4ODGE3 AACvLmKGSDKw9nnyo+d+2+KMPX9rmgZTPXFLA4WAS1X+C5i6ZK5MkDI2SyGs18M9Mhn/beLJ8+2 +RmSuGfpAiaeD3el/FM1sIQPLbPE96AcoxHB9SwtogsJF9HvO7+PkiRGhtDmOk+G84pgt9NGwgA 9/Tyo5wZffwXH3UmzTC5VylYGtZ30lcZDR/K4Ls/iLMZowfqF2UtAIbEKj6t3ds3SYLZ5TNxYT/ vxetsm0/b8K/2eKgcsmN4RRQYCFmSUYv42sy/Aa0KhPMltTdaPfJmcPZI8DcEo27ihzMdM8i8fG SbtIZf5DlMSMQMKqSkLMu/1PqlIOlHNMyhIpHJJ+5WbOfWiFdL9TZ8SAYwjR/5hwIs0U4PVE2JO BO4yzz6ETyhEimP5i9EWWrxI0n5JPxufOWDo2CKnk9XoLTyFXCUVAfQtUOFXBKrLDa3PAQMhqN9 fC8hCTxQmqvjJaA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: RGMJKPFPC6CQ2WU4RE3DAB7ZIC4NN72F X-Message-ID-Hash: RGMJKPFPC6CQ2WU4RE3DAB7ZIC4NN72F X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Driver's probe() has two allocations which are needed only within the probe() itself - for devm_regmap_init_mmio(). Usage of devm interface is a bit misleading here, because these can be freed right after each scope finishes. This makes the code a bit more obvious and self documenting. Signed-off-by: Krzysztof Kozlowski --- Changes in v2: 1. New patch --- sound/soc/codecs/lpass-wsa-macro.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index b4e7139bac61..73a588289408 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. +#include #include #include #include @@ -2725,8 +2726,6 @@ static const struct snd_soc_component_driver wsa_macro_component_drv = { static int wsa_macro_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct reg_default *reg_defaults; - struct regmap_config *reg_config; struct wsa_macro *wsa; kernel_ulong_t flags; void __iomem *base; @@ -2765,6 +2764,8 @@ static int wsa_macro_probe(struct platform_device *pdev) return PTR_ERR(base); wsa->codec_version = lpass_macro_get_codec_version(); + struct reg_default *reg_defaults __free(kfree) = NULL; + switch (wsa->codec_version) { case LPASS_CODEC_VERSION_1_0: case LPASS_CODEC_VERSION_1_1: @@ -2773,9 +2774,8 @@ static int wsa_macro_probe(struct platform_device *pdev) case LPASS_CODEC_VERSION_2_1: wsa->reg_layout = &wsa_codec_v2_1; def_count = ARRAY_SIZE(wsa_defaults) + ARRAY_SIZE(wsa_defaults_v2_1); - reg_defaults = devm_kmalloc_array(dev, def_count, - sizeof(*reg_defaults), - GFP_KERNEL); + reg_defaults = kmalloc_array(def_count, sizeof(*reg_defaults), + GFP_KERNEL); if (!reg_defaults) return -ENOMEM; memcpy(®_defaults[0], wsa_defaults, sizeof(wsa_defaults)); @@ -2789,9 +2789,8 @@ static int wsa_macro_probe(struct platform_device *pdev) case LPASS_CODEC_VERSION_2_8: wsa->reg_layout = &wsa_codec_v2_5; def_count = ARRAY_SIZE(wsa_defaults) + ARRAY_SIZE(wsa_defaults_v2_5); - reg_defaults = devm_kmalloc_array(dev, def_count, - sizeof(*reg_defaults), - GFP_KERNEL); + reg_defaults = kmalloc_array(def_count, sizeof(*reg_defaults), + GFP_KERNEL); if (!reg_defaults) return -ENOMEM; memcpy(®_defaults[0], wsa_defaults, sizeof(wsa_defaults)); @@ -2804,8 +2803,9 @@ static int wsa_macro_probe(struct platform_device *pdev) return -EINVAL; } - reg_config = devm_kmemdup(dev, &wsa_regmap_config, - sizeof(*reg_config), GFP_KERNEL); + struct regmap_config *reg_config __free(kfree) = kmemdup(&wsa_regmap_config, + sizeof(*reg_config), + GFP_KERNEL); if (!reg_config) return -ENOMEM; @@ -2816,8 +2816,6 @@ static int wsa_macro_probe(struct platform_device *pdev) if (IS_ERR(wsa->regmap)) return PTR_ERR(wsa->regmap); - devm_kfree(dev, reg_config); - devm_kfree(dev, reg_defaults); dev_set_drvdata(dev, wsa); wsa->dev = dev;