From patchwork Mon Jul 1 07:39:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13717624 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14E9D69959 for ; Mon, 1 Jul 2024 07:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819592; cv=none; b=DId00iWsTFT2mGs6FKJIiuKlG0lxOrlcwDYi15k/zxiCBzgRMR/ZnqEBhi51Q6S8xTTehlZ8cTDYiGXmqlqOYLtDTIMizzD4d8MzyKw2LOogtJHxu6yJXRLVcm51zx0dG4ZHgUniNU2XDjKJJC+3KImvLYaxxOEIg+23dPMJCSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819592; c=relaxed/simple; bh=aNXS5oDU9Iznltvue5eW7LGccDPE1uOvOu0B8DutizM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tWy8YLd6HPviX9cBGNWtWqxphMJj08jEdhYO6jng/60K51sAk8SMV5pZ2zokTkyXZKfRxRCjFSRSqvteMhzQkOq8VreV9mio+lXMmzozpO93M/LX9CsLK94bjFCoXGJWvlHTbNlJjgNaRdpEvEENJln9vggZipyGbY6KgjCYL5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pCLaSNe9; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pCLaSNe9" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-425814992aeso4511285e9.1 for ; Mon, 01 Jul 2024 00:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719819587; x=1720424387; darn=vger.kernel.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=JV+cRI0obrw7Gr1AmKeclFNXK4wRSUvRfIa7nX0CC5w=; b=pCLaSNe9M6hk754DsSMD7lfRpCk2cTPFix+h7jCORa1Dik0tb06nF43XJRGoQc3mB9 3GgRwFdXQy/B126+lLFdSEi0ckyNQX8TQ5tCt8VmFbySIqMuiH9tkeev9QagagmoAkb6 MztzVXAMjIiGTqEbSPYyvZAtu1+Iv8e378QPzvFeuut/Z0UkRMqACOoaR3rXlvOH0G/5 dgQC9+xBC43cYgBXb1FuBjdDcaS/kffMHH+1aTKwHZiM6ZVI51eJB17VRUs4jlTnhJPO xuxGQSilSyWlD46tqU0Av9ZJq/306GSMrV9b4ORmHtt7VcB64szJv+Vm0MZpP5VsldW4 dSIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719819587; x=1720424387; 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=JV+cRI0obrw7Gr1AmKeclFNXK4wRSUvRfIa7nX0CC5w=; b=mHNJ6uer9tuJGSgTQ7eETJvKoH/iAtoBD/CUh4kwdG+w4niO+yAnsYgXlTasKRMO06 IvXKqbKcv32am06Jw8Oz5wsl1Xvv7mI2KLoEH2GRUybn8dwBSiP+zcJb5BAONLiwl6NK WRd0rgMrviZL4745HyQ6y/J9QStlntPaeQd8XGJ/jkCmj67dqNT1uxU8wfWK0kcxSj1t b1+tl6UUHrpJxqZQ9mvTwqdorK9aXni3jT1dYtjozaGeH7+sVkqTnbhWfImRFZTie7Y+ VxlsvX9WqqluQtntX0nJ5162trzd4UOp7F+34aXfkWanQbcodH+S/JEsdBLsZNNdbD10 3ksw== X-Forwarded-Encrypted: i=1; AJvYcCXYp01KkZ7ZH2lxzWykfmG7hkoizq26ffr3pC4qcaqye4Iz+8DFd0lDePG0a9hOq26utNnLoomY/G4/7HnCPKj+8ewO2C3MKl+1NRE= X-Gm-Message-State: AOJu0YxXILwdjb+qORFL2SYaFL+HySRvE7yJWu8n8SquYXpC8nq+4Lzi /vVVT57oy2m+9cvXFvQTkz2XYAiyoAg3fzGICYFBJRHSpEmD3ejgovjWqFWypfg= X-Google-Smtp-Source: AGHT+IG2h/MuEwnoTZQebFv4r/85gHz9u6yettb/wJx89L0LKVLKCmHMSB/zmGvvRwXSMwxJCfcw+A== X-Received: by 2002:a5d:5702:0:b0:35f:1c34:adfc with SMTP id ffacd0b85a97d-36775729a52mr2645023f8f.67.1719819587542; Mon, 01 Jul 2024 00:39:47 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm9279936f8f.80.2024.07.01.00.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:39:47 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 01 Jul 2024 09:39:33 +0200 Subject: [PATCH v3 1/6] ASoC: codecs: lpass-rx-macro: Simplify PDS cleanup with devm Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-1-6d98d4dd1ef5@linaro.org> References: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@linaro.org> In-Reply-To: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@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=3634; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=aNXS5oDU9Iznltvue5eW7LGccDPE1uOvOu0B8DutizM=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmgl07ZZ/P0X2KbPfUiKc26QrbS8ijbeuElhemc 0YPAc1aqKWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoJdOwAKCRDBN2bmhouD 15HHD/0ZHIWDX7+vSu+VVLfTCkXyU0PPIYh+vbTkyulS/CJ/ece8SI3bkYXj+QUATQJRxQjQGMY uboQLbCcXh2A7dhSgLPIJ85W7YyIl5GbUw934lXELcxrcs0RZVhQfDFND4+aRi3oNwOqXUqW2UM HvAdb8RhF2kEn0PW4TiE2IFbGcrs0k58KTPVwcaLrTNzIFt4aHr9UAXctUUZ9lONL8+BYwl8Z/2 /hKdpuccDFw2np7hokPiG5SOG2I7b1uXB3rsIFciah9lq0pdgbnSpsu4sKCuOt2au3ZK1ORGpXl U1WlcEh9YP9PJhFCxkahWCL2LqSKqtf9be7/rFxARIM5PkMd/XtifW0d/Px5bMqgsXvyt3/8nLk Uc8z/ZP6BjfzypcJTTLcYWR8iYBkPFrdTlPYjEHTJlvX9RHixmueA1z24C0DjexE4VPBXY79Kfn HZVALa21R9PaaQZXXXcZNoNZku5ge/00pd/NXU/soo7OFGXqRAOLLLJQdaxPeiy756LJcoVHedF xQ5MwiEanqOu7o9NUXddzma2xU+t1DXHp5ccnWotr5J2z9UaAVczlSL+P2v7PKPi8r4BYPvlEAG MAaj9JeH6hU7XurMb+QfLtLQ+C3Q7vPTUdnr2e6NQG2U3FRerE7cq+gf2wHVuaV7D7veizXo5Oy r3PXljUj/+SxO/w== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Eliminate PDS cleanup by using devm_add_action_or_reset() which results in one less error path and smaller cleanup in remove(). Signed-off-by: Krzysztof Kozlowski --- Changes in v3: 1. New patch --- sound/soc/codecs/lpass-macro-common.h | 5 +++++ sound/soc/codecs/lpass-rx-macro.c | 30 ++++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/lpass-macro-common.h b/sound/soc/codecs/lpass-macro-common.h index 3aa9737f2737..21cb30ab706d 100644 --- a/sound/soc/codecs/lpass-macro-common.h +++ b/sound/soc/codecs/lpass-macro-common.h @@ -41,6 +41,11 @@ void lpass_macro_pds_exit(struct lpass_macro *pds); void lpass_macro_set_codec_version(enum lpass_codec_version version); enum lpass_codec_version lpass_macro_get_codec_version(void); +static inline void lpass_macro_pds_exit_action(void *pds) +{ + lpass_macro_pds_exit(pds); +} + static inline const char *lpass_macro_get_codec_version_string(int version) { switch (version) { diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index d47c49c90de3..77e734ad1885 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -3803,11 +3803,14 @@ static int rx_macro_probe(struct platform_device *pdev) if (IS_ERR(rx->pds)) return PTR_ERR(rx->pds); + ret = devm_add_action_or_reset(dev, lpass_macro_pds_exit_action, rx->pds); + if (ret) + return ret; + base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(base)) { - ret = PTR_ERR(base); - goto err; - } + if (IS_ERR(base)) + return PTR_ERR(base); + rx->codec_version = lpass_macro_get_codec_version(); switch (rx->codec_version) { case LPASS_CODEC_VERSION_1_0: @@ -3818,10 +3821,8 @@ static int rx_macro_probe(struct platform_device *pdev) rx->rxn_reg_stride = 0x80; def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults); reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL); - if (!reg_defaults) { - ret = -ENOMEM; - goto err; - } + if (!reg_defaults) + return -ENOMEM; memcpy(®_defaults[0], rx_defaults, sizeof(rx_defaults)); memcpy(®_defaults[ARRAY_SIZE(rx_defaults)], rx_pre_2_5_defaults, sizeof(rx_pre_2_5_defaults)); @@ -3833,18 +3834,15 @@ static int rx_macro_probe(struct platform_device *pdev) rx->rxn_reg_stride = 0xc0; def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults); reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL); - if (!reg_defaults) { - ret = -ENOMEM; - goto err; - } + if (!reg_defaults) + return -ENOMEM; memcpy(®_defaults[0], rx_defaults, sizeof(rx_defaults)); memcpy(®_defaults[ARRAY_SIZE(rx_defaults)], rx_2_5_defaults, sizeof(rx_2_5_defaults)); break; default: dev_err(dev, "Unsupported Codec version (%d)\n", rx->codec_version); - ret = -EINVAL; - goto err; + return -EINVAL; } rx_regmap_config.reg_defaults = reg_defaults; @@ -3927,8 +3925,6 @@ static int rx_macro_probe(struct platform_device *pdev) clk_disable_unprepare(rx->macro); err_ver: kfree(reg_defaults); -err: - lpass_macro_pds_exit(rx->pds); return ret; } @@ -3942,8 +3938,6 @@ static void rx_macro_remove(struct platform_device *pdev) clk_disable_unprepare(rx->fsgen); clk_disable_unprepare(rx->macro); clk_disable_unprepare(rx->dcodec); - - lpass_macro_pds_exit(rx->pds); } static const struct of_device_id rx_macro_dt_match[] = { From patchwork Mon Jul 1 07:39:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13717625 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C424E7D412 for ; Mon, 1 Jul 2024 07:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819592; cv=none; b=hh5cIMOYTrhHU1ZzjjqcOvy7EC/3P5vsmuFbCe7RGvll43KXirQcrIZlOaRUeBQtIcsF+RAS5X68DhnMnJ4STMBzIvTdyuWFLfGyOAE+NMXW+tfcLGWOMe/OZACwrB1vwsKoF/knMzO9hW7PMMBmMmXgUgDzqWM27x3+WoUFZVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819592; c=relaxed/simple; bh=2LXhDj+OjHwm9PSo2QZCbe9HMxUgBLthEvA3G7WWahk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pdR7B57RfWJvROvZZxX+uaTE5SV1AUG9kLHVSxGxetFOf6Mnvr02KD4h6czRz4+C20fIslwiJvpeQ4i/8ZVA6t7WlVijSGr8HCx4yvvIOvLFSldPbwRFp6bM7HgAF7nkIFLunJobsXgY5M9DLJE90WP8WsUnhm5HGDomO6SUaJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QCgNK904; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QCgNK904" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2ec52fbb50cso26030781fa.2 for ; Mon, 01 Jul 2024 00:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719819589; x=1720424389; darn=vger.kernel.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=S8ExwtvC8Rv0PryTWXbkCNqG0vwkQRpwqxJGJECfGVk=; b=QCgNK904GydpNZqfondsGDGIvlyafCkwElD1a6LkfdZKYua9uNjlplerVImHHKIowG 34MHuPwhicBKlqyzZRXJsSDILdDksVbcoSTsVCX2X95MtTJNpkJGfFbQc/X3jIPeGEoF r1ShINGInYEO0JpQw1Qh+EWEahwE5rhCSjABHkQgBjBRJZt/Ap3FRb61aEUpiOP5g8tB Tl/pqicqT+NGZHu76XuqHzuSbsfWTz8oDWds1PVnzqpUZ5ZPymWgG3HK5e87ZIBkLhPU h9uigdZ0lk5FyZDetPA21uHhX0/ZJnOPZlodzFP7JV4btjUi4HaGtqNmyse1GPBSLGJE eKQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719819589; x=1720424389; 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=S8ExwtvC8Rv0PryTWXbkCNqG0vwkQRpwqxJGJECfGVk=; b=IP/8ymcUU8UIKBa/GO+bELOev+OjE/bnlpPQSEmDvrTI3yufXJMPL5k4RFY5m+WaYY wOOu5JseqpK5VHa43R/ojVJtccmq3u0rEiIfzIrt9RNyYE0bKrukCL+w1GxxWkfovm+l haD+u6BLuz646MH7QBmGdmhCVB2HPuBZDpXjSYvIY1U8YHjIUAPPH0wEAQyEaWqWwhzR ES2HlpCcmR8d3lRkJbZ2kt2JKaLsxrxYALV8b/bB2fZeqHybZ4KqMYKe2+ZD6nsFse1B 28GyAbjwWAYSJEpF810aZzUOpECZrKBOgrWH30xxPWAVWo5IHEhi/x8RUpcEJZouOgFV sEKQ== X-Forwarded-Encrypted: i=1; AJvYcCXHZQlAXLc31PAnkUZVk43hEUvnZpG/ujgkFTqDiDx2tzzi2h4tMvepar3/mttlYlUbn23MM4cY78gonUM7kpaSEc0eideX70eX7bA= X-Gm-Message-State: AOJu0YzgasKIDVidxGbUl6hvGbUTI37Vsn9o8PCG3oDq7gA12+0k/66v dmJWmdsMmnkK6pObkY82ogWbsFBq5G3sKK3pbUnXPkG/heYTE6MjvAZSd7bOylrP+GprCiZ4i3o W X-Google-Smtp-Source: AGHT+IHhZFMA0XT6XBDgJiHh2nMdh9If6ijL1sfRHPnrXsiQhUhG2w0sX4XVs3IUQY3q0KizhIYGUw== X-Received: by 2002:a2e:99c2:0:b0:2ec:50fa:1e47 with SMTP id 38308e7fff4ca-2ee5e392b79mr29326251fa.21.1719819588889; Mon, 01 Jul 2024 00:39:48 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm9279936f8f.80.2024.07.01.00.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:39:48 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 01 Jul 2024 09:39:34 +0200 Subject: [PATCH v3 2/6] ASoC: codecs: lpass-rx-macro: Simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-2-6d98d4dd1ef5@linaro.org> References: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@linaro.org> In-Reply-To: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@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=2459; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=2LXhDj+OjHwm9PSo2QZCbe9HMxUgBLthEvA3G7WWahk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmgl08N1puNYLwMumh8OH49VAat5Ny9jHNO2iyY 57k6THtXieJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoJdPAAKCRDBN2bmhouD 1//JD/9zt7hVaxdfvsXkn2F2F19ihi9vDCarT30YkxGA3IVJvvjXPnaZT5C1Xt6V2F3XAMi2V+L yg8KOfBaAgQ10sskIqnXUwJIw5oRsIO60s7mBNjpwHE1O9zykThNWZNRY9zaGQWeJtb/wE53L3T ctOQ9SyRUdKF4zKtquDYRJF7mUht2nNuCmOMWFUbK8xRAYFm0hmgNFjmCULr8X1os/Yyytk282N 81l5OF9q1Cx3KbeWKLrlsJawjiqh3xXxvg5bzBQYGhpfYYyTKkdcK1LyUVVF74NkdxlDepZWXd9 6LDZkFPgtoFW7+F+SeedcrKjpZk8aj+6jhWuNRfKipqK5756AZb4zdeFHTdtcbkc26EzKdh7DSr NOfP2fhazYtTEc0d3Bn8JEDX6zfAGWV4C7YnNKoGHK4TB2tlcLBR5i4pBDEIliiDN+zALH0ChTn inZfFV39xUrYmiSauHUelqX/gVuFOA+/8fiOPfhnsmYmHjWUeENk0k5skw2hjNJoUtqJ3YRKmUl kCYtIaDPlxxgI6oy2VJkKgF9dFvGymPDM1NuuNLme0oGoGljeR9i11DDVTLv0+11xJpGRi74Kjs icJ8U5RNKmVh8h8LO13LDpkpXewQK9gBX4twCTvk+rq/2gI12JUX9mXFvXBjPIWZtiCUbmhfxR0 ADa/jYSfZoHnAjw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B 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 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 77e734ad1885..638f3995a364 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; @@ -3812,6 +3812,8 @@ static int rx_macro_probe(struct platform_device *pdev) return PTR_ERR(base); 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: @@ -3849,10 +3851,8 @@ static int rx_macro_probe(struct platform_device *pdev) rx_regmap_config.num_reg_defaults = def_count; rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config); - if (IS_ERR(rx->regmap)) { - ret = PTR_ERR(rx->regmap); - goto err_ver; - } + if (IS_ERR(rx->regmap)) + return PTR_ERR(rx->regmap); dev_set_drvdata(dev, rx); @@ -3864,7 +3864,7 @@ static int rx_macro_probe(struct platform_device *pdev) ret = clk_prepare_enable(rx->macro); if (ret) - goto err_ver; + return ret; ret = clk_prepare_enable(rx->dcodec); if (ret) @@ -3910,7 +3910,6 @@ static int rx_macro_probe(struct platform_device *pdev) if (ret) goto err_clkout; - kfree(reg_defaults); return 0; err_clkout: @@ -3923,8 +3922,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); return ret; } From patchwork Mon Jul 1 07:39:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13717626 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4F2581AB4 for ; Mon, 1 Jul 2024 07:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819593; cv=none; b=ikf4cXwy5vme5cprw3n1zVaSLaDFsSJwwb1jbBLlaWf61fvxyOfpEyrAdSsylEbgNVnTLvMe1IeqTYQ4QYrGex7LmnifpnURU+igbt1So5NmFH3FznhzV9Z8qEhadGSOOZlOXFIOQrccljgEwt8ytO4TDtPXETu3yfPLEMAxnGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819593; c=relaxed/simple; bh=czPn/CM/13NiJAbbrT7HCu/fRfwdImlVtdxXFtiZJ1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UKdP+ag3XHGkto7st5J3hEgTKsJQHyzfneC0MNKWvh8U/kS19AF7pH6cPcHFjU/XSBukfPRqtV5SOrD3FpfQz1PD7lYuZRMx2eq4Yzh+TeJSfnK5gWV5Jtw1XXmLdWOgHFIStX0XKg4Eo2cPJtIgEOYj0JWmDKskgDpv/dLKAKQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Hch9Z4qC; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Hch9Z4qC" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3629c517da9so2261235f8f.2 for ; Mon, 01 Jul 2024 00:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719819590; x=1720424390; darn=vger.kernel.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=QGvHzxmQKKMhIxfo+E0orJJbLqAKfrzT9/+PYfiLJl4=; b=Hch9Z4qCxuvSg7HGBm99ADPhGlMfet9v9OcZ+h98fwhVCAs0yRbtcpLzT2nDGUh+8O VHA9LnuclfnnYKoO0uBq1I43FWsTRVQwuAo++Qx4/OebX/kgBtHYKUiE8k1dxzDVhzNn svWI0dZAKVfT58q3mRkVFqER3zrsQyP1RJsQ1qlyRG4Bf/hi0XovmOlH/QJDGzFTQozI LWJDs88x3n9b+rF8Hxy7uUByoWZulOKy7SvhNL/EuYEHx6Nd0AFXDSYwwDV3Jn1YjMZy HsF9rH1GfCyvQOd0Jh3GPKIFx9sgEa7idzd2kcj+p4/z/SeFXK9wl4AR1gefO+yGSODj Gv0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719819590; x=1720424390; 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=QGvHzxmQKKMhIxfo+E0orJJbLqAKfrzT9/+PYfiLJl4=; b=LMsL/MqEuO0RtB4LNr/Bc64VMCR92lkYtnzvmTpLrmrk3BaSjmdniBODyuXjNVTuEX F2xWDdbcpEmvUWGsYTISFwI1T0d7wacUl3B9ZyKFwQfNDrCWMEDsZJToSqkLPbjirKyX zePV6RPaO5qnXQoR0aIEDWM2yf9ZrYKyz2t9hrQwS8oeIxaUhjCAF7uyiLWd1VUFJ1Vp EZbBPRYZjuCUIGJwT64hBc9anRyrb8bbJen6oBpvPcLZN13lr0dnybkLWPDDJ54D/36h gz2s4ObGJiMJtZ63ftq5GkNQg5Xy30sE/nQQN++AbkffwD2Xjn0IZ1N3IisDcq1B4WgS XYRg== X-Forwarded-Encrypted: i=1; AJvYcCVx//XU/c5eN1LTjDlQBpxHRGSexsLZ9A4mkIVjohpVqI5L/Do23+IgJbO5kT69njMhoL5wZutmx+/citBZMM6kROAUXaArP2QF6K4= X-Gm-Message-State: AOJu0Yzd+XLFyy4uIJm0xWC+rNY8WYfQCZtj411j2QKD2G4XjNY8+jOb 3IVmb10ShtTwXA4gDXUMU9k8B5MfJFiZRk0aZkKvIkUdNWF9IUNNNwgXJ5Zy4qIDxizQjLaZuAR p X-Google-Smtp-Source: AGHT+IEFUHmMK/zO4EhXYonANzhb1VC398eAUKhzg9PoG26Tmg8Yf/8gaFSAOmXzJqc3on/yu1St1w== X-Received: by 2002:a5d:4d48:0:b0:35f:1d5e:e2ca with SMTP id ffacd0b85a97d-367756bc8c8mr3497048f8f.39.1719819590156; Mon, 01 Jul 2024 00:39:50 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm9279936f8f.80.2024.07.01.00.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:39:49 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 01 Jul 2024 09:39:35 +0200 Subject: [PATCH v3 3/6] ASoC: codecs: lpass-rx-macro: Keep static regmap_config as const Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-3-6d98d4dd1ef5@linaro.org> References: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@linaro.org> In-Reply-To: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@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=2050; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=czPn/CM/13NiJAbbrT7HCu/fRfwdImlVtdxXFtiZJ1I=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmgl0911QVEpEmn3e4yxo9c43S/NXMWVmdZzHgw lt+1KTUZOiJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoJdPQAKCRDBN2bmhouD 1314D/9pLEdlN9cv+0mx85JAB9c8ARYBd9ncY+xyUMR4nDwAUg8uSIfnylTdfdRAGD87pVN0XYl tcp0+uQ9I23yWSoyjsdM1Bs8UIV8L6EKCAt38pvfyVJFdeaTHj8AndJXDl7Ki1O+7gWNpP/zVXC u2Wq+LHhgfgcZHbV/nD671ndzIiENpNGp6slZAWkqhqNAEC4brOpHkVEjpb13U/1ZwQilSPFIaw 3t0HtgVQjpysrCQMNKeLRN59D1NBVwFsC43Cq7AUbobNF4t9FOTEdJx/kHymxASTdfDTydIJdjP +a8vq6KgBXcGN9LAqALmZsYapi6I4bTWzOM6oKmLjnOWqFNMwTuFcTeXI2Yd3eEORH4UbgLbnH9 cIZRfYAVfpClqLXZaoYnPhNv5r5Qt1FhIIuPdI//MmfXBqzuEJyxc5NgRI+pDQReRO+/mViDe8p ffO1bz+KJyWHesgrS/vPT9zyOEFzSYOdSqYJjz8LQ3NJrnl164MLsbmM2owu6LzvL9Izbt8dgrs yciOwnj9Jsg6bYoSOn4FrYloVNh6NomNlB8Rr3PhE984sxSPkFu48TAf8/BqUi6z6pctBWC+E7L ZouoM3qZCjG1CkL3aBYn6RxoDun3XM0wycmP7USHs+slfdHRRNmTN6Jk1wrodDv0PR8qwkj1616 Jdl+13eWO4IMv0Q== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B 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 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 638f3995a364..d4d7e02db83f 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 */ @@ -3847,10 +3847,16 @@ static int rx_macro_probe(struct platform_device *pdev) return -EINVAL; } - 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) + return -ENOMEM; - 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)) return PTR_ERR(rx->regmap); From patchwork Mon Jul 1 07:39:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13717627 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E877F82877 for ; Mon, 1 Jul 2024 07:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819595; cv=none; b=RVY2M9x1kG7lEbX9H6DIIiy2+ZdfuWxwHriwRnPvAPQImcHhZzaG5lwmCvqOzQCNvH+aWNzlChVMa1ZaZ+sCrYGxjyof1f31grCOQj1zojaWJh7VCtw00Q3p8ykaMiWC5t/PpoVnaqF0IuwDtkFugo9UqDtuqFI4QPzimJXjOfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819595; c=relaxed/simple; bh=Ad+uKCGSDe8rakMGGeF23SfGPaAfcaquc5R5IIxLKwU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ldiA+SCmkwXo5m2dH/Gj5fmbwZI5xFHPqyYZxd5fDMY3bECjLScDVx4JJeNd1eiMAv486rWWn9/1VNUx3ZeHdAsFdsTh1/Z7nPK7nHCkBQ6No0EElWb8jEKkI8BjUTn88lQK8THK0pgXeR5rATYfSF25fIdDE++ZIyKeB02CHL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qJuSJFzT; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qJuSJFzT" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3651ee582cfso1523099f8f.2 for ; Mon, 01 Jul 2024 00:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719819591; x=1720424391; darn=vger.kernel.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=qJuSJFzTuSfXuQIm0kUXjQPkUiGSo5ftpaBxXO/YKOCEBum1awxnhvYkGBgzRRRj5c lvezGssTBzOu0GULxM9dyEx1e8aHeDE2Pshm2mc72Bdjea6F/xdyUang68DguUAjTP0r Z7d2qTCXHoc5Ex09SDAzJJIhDV1WaKhHyHQXPixfK3yzTcvDxS8vriB10QUNTnim5cBf yGs6tO0OM52+PIDRc9dX5cCc5LQmc3qq7SrkjC9kuyKDY/WHcWdZbsTEXDIEZXILLKhW d72n0ZipgQgucwqPduoP4FrhPgTXvnG5zGjLyRp7Dhz4y+fKGc3viUQV6POyGXZTYfJ/ 9oTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719819591; x=1720424391; 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=J5XfUfZ1XexRi7cL7MK4/mPu+NBghPGLe+Ef98Ks9xIsXWgmNIQGpTiYJjUeEjm6FM X44D9Q5p25eDJR39zTHoS5qUU8iOZiFCumBqD/FB0dhYI1xILMsRqF+YaE3R55WO9w/N 5ew7Soy+7luyQZnnkusoSrU0TPG4gqTxBlGiA0Su4WkFmF00TNmbpx3lVKbMmEz8IBlT EntXIb7rTOW1XFt1O/zO6FfHpndfiaF64Spy9qmJlh6DrgImimbP2p6QnGkJyRBht6Ni JaacBaITBuDpLyBi9qEyLpVSMiFZs2ALLeysWMzx0ok9WBZhOStF0i1udvFv2k1WT81P G9Iw== X-Forwarded-Encrypted: i=1; AJvYcCVtP+DkYj4mWgkRuwmzkD4YIB3wtr0AySsG9K/belzTQTaINLTEqCDadHMHfaeVqMN+2zeCGiJNlODiekZ2Nry1BUJZRN6fw2ry4zY= X-Gm-Message-State: AOJu0YwkbzNObdBB9st910JrJpvajYUu+Bwgj676s2V2ZVeiBQy565J7 dYBm/Smk3+ll+LWAW9ZGUFYvfuA0cLoZ9jo7sWazGvlG1nZ45OQLmCMiCWdBCJY= X-Google-Smtp-Source: AGHT+IEbIUXccj8XAr3Pi+HR8BNf+tQNrJrtODvTWFS72V0zOXk9wxPAEE6XniRcWyYY2+RnDUWHiA== X-Received: by 2002:a05:6000:400c:b0:364:d2b6:4520 with SMTP id ffacd0b85a97d-367756233bbmr4242423f8f.0.1719819591373; Mon, 01 Jul 2024 00:39:51 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm9279936f8f.80.2024.07.01.00.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:39:50 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 01 Jul 2024 09:39:36 +0200 Subject: [PATCH v3 4/6] ASoC: dapm: Use unsigned for number of widgets in snd_soc_dapm_new_controls() Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-4-6d98d4dd1ef5@linaro.org> References: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@linaro.org> In-Reply-To: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@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=kA0DAAoBwTdm5oaLg9cByyZiAGaCXT6gS/qmIwhhz3JQvaEtkfOrO61QWr5ln39pMYOi8vd+e 4kCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJmgl0+AAoJEME3ZuaGi4PX1c0QAJl5 DR2okgESZi49MoN1Ws63ZWEeEn6VoZVEJIgmLYJqu4xMAtfgzvHKeFe7GnlgFOmu2GKIualxJc1 tzvu+9iOUyYkxvUojTVjT4obSTdZSPt9VJ3rIpzjVb4rdHhl7KWJZH4wYjBdAeydnGVn6KfDrpd enKKdUpVAQqwA43A5iZjoYYAq8E2UXS7swMDEEEAhRrAgJMoGDQOAijNlXhllzpVg8g0LfmVIMe UG8mSyzUSvUSyTe6dXhqjxsyxmnIPfJbPoqJF2+O2gE4Gktz/mQgcoCApFJ1GWdcGX1vxyO1edS Lamz3HAGA4xqNxzZdM3ByU02sOh6C/d8vCy8VZlmkVvfjOiZrIVmSFHmWsEUEUtDsb9HOnOytIQ edwPxJ5xtvHfCiTVib0RmgWEaOmvpouSSS7LTBNG5swGHpKbXB3VugNyxCTLR7LQavVrFf8IKC7 Vbyd5YTkrXrBjGYk8rC0DLlYxwepXDkOqsa0POpgjUVQsXAUIjZqPzs7xUx5pQh1CMAuPLq2u7W iA0WvmVzvWJ6YvUY89jXfYfSJ2dEnzPZ8hNqYO4cEX6+5oABVfL2FLtz099Y0cIc7m27rTy1+Zt EJoAegi1dzQhXviE9pWxufxXV3Ryb98d8lEtauqgWVgJ4uvCm7EmT/onJU24R7dUcIcFyAhBikV YpnPf X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B 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 Mon Jul 1 07:39:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13717628 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29D82839F1 for ; Mon, 1 Jul 2024 07:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819595; cv=none; b=UcStjpVAO/b85kbQyxcfAz8bCH63XPeshNGaUxBv3ro0+ZFGbOaEZxN70YZ1lfZVyJjUVA35650dPmTGhQvJNBiXNRnL2KFPagLOhXIoWV/c0MZdr84AzdgUYMQBd5ZAB0NDJwFkyXsP+U3HHPCwXpiwZVMzea6n7o1kqiA+lOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819595; c=relaxed/simple; bh=x29wiXWpg6jxb2D1xLhsOVHl1vLxmaL7w/bv/sExbXA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KM1IIoeWYpb0LwH9fPr+atJ8bZ/FpXNp1HX7D2ToD8CunM4VnFEbkpqQrI6KqaNga8QCnK+jaA/7Pv5dtJ5IDHmhUntrt+QCzLXOqKBJwFdiHV2apekhL489SoTIbLmT1MlKX096sMDe52Y7+IwRJmK7HIiCS8FBgYZa96V8IUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=wNj5/uXr; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wNj5/uXr" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3636c572257so2047668f8f.0 for ; Mon, 01 Jul 2024 00:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719819592; x=1720424392; darn=vger.kernel.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=JlFPWXG6JCmSDQcnpPbHIJV1hXvd50IYEdMdlRm8NpE=; b=wNj5/uXr4Symqe79zf+Tw1xUY5rayAtkc1NCLs6OiYE/y3nmiNOFZ79Q040cozoRz0 x9utJdKhDfuPuWV8KToHh+CE2K5TtkDUtgOIcnLK0y0EKwpxqP2umiZASdTGS8dw7mjO syiiDfLjd3DNusumHesQnqM4lZeW4uEVcSQsJSw/PxPZp2PKlQA0l7vFu2+X6GgQHvyN OXZM1HiD9o+JnkfWp2UCmiI87nQBvvgf0I3d4/2856s1JaGmxW4KkLkDnBPXNoJVzCYD HnYF2JJSRWJ5W0zl/JEEc/XEHzJY/TkiLkkDwn/42+/4ZfhHIMlMNWO8BDacEK6taJQ4 j8OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719819592; x=1720424392; 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=JlFPWXG6JCmSDQcnpPbHIJV1hXvd50IYEdMdlRm8NpE=; b=jPfX/coyH5GRja9iM8bEkxQlgocKGXXGTdtOkQBL6RHwqsiXJnc4+JsA325ZQA6Zw7 beif5iU2OGrXuNXl8SxIlqJmElYN8gHYFc0NsAZ/59fzfWBuFFpDshJv6zZtK7t3a4R1 J0Zb+Lr3lIG3v9x+zwuUnlnnp4znWWZkRRZ6sAbHhOwmW6k2xaOtolcKeJSsRE4Wv4Af 80Kv7xcgwRdytlYYP55sQsTxtlXzD1qyTbk4a/o7knLB/Gf2zWVRcTz6aRIP4C2SIGlW mNargNGgFk08JE+wPKM4mwFPSLpSxYaTy6U8MktFPA178+9lXHLcYX827NbhrlxMO80V EwnQ== X-Forwarded-Encrypted: i=1; AJvYcCU8kLzllOTrNG4feHr2tNWjkuLHLRCDBjbUHxBqvhkTKPtS0THwsva1E8lRUigU2NAEyHpgvs/utGaPkqn8Qw9MNYewPfQfgmmTz/M= X-Gm-Message-State: AOJu0YyLysK4mZRE9AfT5+3z46tMwIH0J7wQeX9Ky6hngRCCUUNDcTrt pQDtZTWc1XmKi3qGol3FP63WtNT5KDAMxzcLLyMv3KOfgnKxM6z8SLo5d0wiGHM= X-Google-Smtp-Source: AGHT+IHHtHxDqWdH128hQmSA0cf68mmpNc9DRTecEH9In5YhAxmj+nZy5eqG4zRev1smLhlwMVcEcg== X-Received: by 2002:adf:ce0a:0:b0:364:29ce:b14e with SMTP id ffacd0b85a97d-367757307aemr4223694f8f.69.1719819592610; Mon, 01 Jul 2024 00:39:52 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm9279936f8f.80.2024.07.01.00.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:39:52 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 01 Jul 2024 09:39:37 +0200 Subject: [PATCH v3 5/6] ASoC: codecs: lpass-rx-macro: Use unsigned for number of widgets Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-5-6d98d4dd1ef5@linaro.org> References: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@linaro.org> In-Reply-To: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@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=x29wiXWpg6jxb2D1xLhsOVHl1vLxmaL7w/bv/sExbXA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmgl0/b6W/jgS8oAl3i/WUq1uwI+lyOS8exPUTa 7WelHm2nIOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoJdPwAKCRDBN2bmhouD 17wJD/4nCEib+5DqPEHKrWFzzhh4Pm8WGZESnEx+zYlUmkRVYwHgyrsI4Mx532DRm3x1JpagKWI NNv5xvIOQARUI82dK92tuAaNW1qkThmKV6PIVa+Du38dXD0izYl7MYjaX+uJhODQwLiHXDioanX KpTfALvKiVIxq0CV19/BTcBNozPiWxCsCDd2TpnhKcCxes6uHEuU+5+5duoAh9YSqvOc+aOvl2J k+JTKgo7R4nN21KhbN+1I9KcV4CsLI/ctn5ck0fMzA0u8qs3dvDI2WbunOPZ5HDm8mPEO6K4Pyt CHe+AMqDcnb7v2LAwoD1HcXcGkKPFkBkKQ3JNZtBUB1Eqgrs889RAjPURnmPg56a0Frp261pnKb lx05CvmKdZ/BlXGt5Uig+hIaIB7HR45/DLoweL8UVXsZlUlDwhTneAwC9T34dCksGINAGffk3OP Q40wmTWZ4CS5nMZQoogd9DKazRdeQ165EUe4eBh+FUJOpJ1NQLPoJE5fkxvCYxrehrZCuAwB0ny 0GBdeBEWnA9t76TFcHt1c9HajeZ/57VAj6tprxMXq+It1J5C4UPp1zLaqss1o6ifvwVn1JELSJy fu38XyflpmvvHQra2o8VTeRd3BIHJ1bWKIQJXt4Em0MHDhTlXrnKEIasb5IYpDW7pwRQ0Xs9j9U CnbTb6iGmhl1w4g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B 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 d4d7e02db83f..ce42749660c8 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 Mon Jul 1 07:39:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13717629 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FEB284A32 for ; Mon, 1 Jul 2024 07:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819597; cv=none; b=aw8+QOUqV/Sj6mJQxuKTLFNHZ4Sbk49aqs30+r+1DxT3Ppzzn9o7e04KKc572hPZukKOu/aiAG4URomEbR7VCsqxjX4RGOs8gHjhkfQfKYOJo1gi2k0H5j5SsEObL8q3HqL5JxTzSTlVtMGtQSsBsZ1eE7OTwjjPoPkAJsO4jpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719819597; c=relaxed/simple; bh=mHTTaZNpcGoV/mUxNlKDTFQQYgAom9YHnI/rebyFS7Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fjDmOsz80wz6b5r2nKTxbHrwDIwEFGwhNXs5jmMEk0lc9DtLGYT3SK3CwjJ1wa/FATuExB8Qnqi7Kyve8efz4q5Oj8vPwJtEiG212stQh32bR9ObtBRm2QfvSino4AiS3EAss49ibay2rdkOKCwwEqzi9UJ2lVKQAZWMJyh/g9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PhXcidIB; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PhXcidIB" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-367339bd00aso2047646f8f.3 for ; Mon, 01 Jul 2024 00:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719819594; x=1720424394; darn=vger.kernel.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=PhXcidIBQYT9Kbag+uEEEp6fuwRteJgOY7oV5HZanr1XlMaKWwUiimxNAgrSlpAbuE 8eW3QiIUKxjvTMAqioVvUgy9O+6xYspxRqyHVrWbZkBLpESMlm8/9LLz3JLYHPBLfcOJ TGb25JVfhbJKqT/kcccg1A0MGdqxRLzzZPjQnNUbr1l8lNhudrQnEZCo9N9+7zTWiYCL plEoNXL6KJUA2r7gp+J4tz22bNMoHaDV1OY7/gmbhCFFDSYkkrrAhMZZq9p6bJiiZRko +kacKje6kazcefR0XXVhgVzQqBxFgTdQUHffQfWeaB+QjkqUUUGOnoAlWxQBXgM14ONh MtNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719819594; x=1720424394; 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=kiywezNze+z+1KHDBFu8T1I4O+Ds0rT77rKDSkmuIhcJx+nzanzVaQGfvO2YgDjXh1 jzOvYWOALDsR7e4Y8rtm+CUEkN4QqfifYDyuciKM32PuCMq8hzUiCyqnt/oXdH2jSnYv xWd7riaPjTUQNHclFGKUM9R43J9yIdym5P/PnvP4GGrJqfxteCK3voOORi+LCaKvESQO ytZrsjNKMgETdyAxz4qAmqhVeY9LWaqYWUVb9wfRypw5nDKseB8ISi2f18E5J71chyhk hPU6iyXkPGaeFXIxplAf+8MDenJNfD+G3PqlzoenKmlkBd/7aQm4/TaqwIysuBbOtyx8 5Bqw== X-Forwarded-Encrypted: i=1; AJvYcCUEw3V00UsQ7ipL2uN7mhjrfalijL2aM4wX/YIPcbLNLys1JaLbjXojZujyqaaN/QkxWI8SM24+6IiDLYSMHAlfHd3L5Iu8ZQ0fOtA= X-Gm-Message-State: AOJu0YwROyVCgzMWum0S/WqdeG5kPw33EToHvpWnerTHicqY/Wnf6/Zt rtV/OzmyfSn0uVe08338qnQSmc2gowRwdFRAroFT6b9hrgdc7Ff35rlpU0T9Hao= X-Google-Smtp-Source: AGHT+IELAP7OOkaVhC6selMuvtx3yRVOwXrHRpbUfCYh3qaNYGybZnve/dhn7uV2G1WhEKJKJ5oHWw== X-Received: by 2002:adf:f48e:0:b0:360:8537:ce27 with SMTP id ffacd0b85a97d-367756e5165mr3354107f8f.42.1719819594023; Mon, 01 Jul 2024 00:39:54 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm9279936f8f.80.2024.07.01.00.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:39:53 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 01 Jul 2024 09:39:38 +0200 Subject: [PATCH v3 6/6] ASoC: codecs: lpass-wsa-macro: Simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-6-6d98d4dd1ef5@linaro.org> References: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@linaro.org> In-Reply-To: <20240701-b4-qcom-audio-lpass-codec-cleanups-v3-0-6d98d4dd1ef5@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/ZANAwAKAcE3ZuaGi4PXAcsmYgBmgl1AQS92yL9416c8UVe+w7/0WkAuH7E1cdUAC ++EDTJccBuJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoJdQAAKCRDBN2bmhouD 1wEfD/wIHxe8tcpCX1EmCOcXJt2sUUnucJDFR+nNQ+DNVcA7ZufKmvMsEHQ1Mi7g7Ju0uhaRR9J DU9kt5wS350/08AZerCK99VA1Og8ddZwmAZ/gJoQXzKowQyjbwMw0gLheSEWkr1i1t3vJGpQNnS NbN/Gjg+IVHxrOCKgq68825mk5Q7v5WWM76u2201s4xIcSWajthZDoY6TM0C3x1rFsFckGBbvnc 5zaPV8b5+UENozlrb2tSuKcDpoCJ2WS5MmmfkDhRzya23JADD3/shIZOzt26mrGnItt5ZRS7az0 BQMFrrPRyYkc4GD1Po0YF72bdvPUTLyEt67WmKIlnnDUcOWe9kH4sE/Aey/+/JfURjkho0uEHpZ l6v9dHxXFMK2v9T5MMsh2IHA4sxRxyF0329W8cHUOFMMe/UM/KKXJPBkB1VbVacSukanSyyPt5D fVVisrQTdJbZWNdnCKCOXi0OEFBMr5m08sg0Oqn45wxTywy0E9yuuOHE5P9YXKnoQy5QhgDiS67 zJfBW//uMxxbHNeFS9UMCc2/7Jv6hWt70uKbtsAM0D3/faMH1AZrVwbv0CbRiIrn4PGdZsVMLPz zqXSAD0WJtPyD1Y3i1yIeqy09EzyrfW66qIKWYsncv5VcNTY3+3lv1axz1fX3DfXqPbMniYeF1y ydRmGBLBBIPO6Ng== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B 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;