From patchwork Wed Jul 3 12: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: 810871 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 BD4EC17279B for ; Wed, 3 Jul 2024 12:11:12 +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=1720008674; cv=none; b=cLQIzKGamxKdyJFpAZuI++Q79st6gQwVk8PM+iQO+/N5tduo1LTaZIaFf3LhuvJTvoxsDo0xmuqHStbZ8Veu47Axhcl6ME4oewvFPq8nrxsc3b/1+Bz0JhJo8TT4dN4dJx2IiSmspwjjezn4WP3sYrLvPknjr9lMocqOVghAOIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008674; c=relaxed/simple; bh=zkBYXA5XhH4F6q1m9UDysUTPImTnL2Gru3YtQza5a+s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i/6otY3ZkrxlGd0bjA1JL/TIudniNMqrhqS5fTty2bShQ4FOjgZa5xenKoUMEvfGnFBhx51jQ27Tni9Ccy21IMhVadLN/q8frU9a8KJbTyXOU9Vtp/Uh6ynNQHRsZn9sla3lVOHaweFufbE5tTOQXf9uktrfKX7S8/AFYFxt5CQ= 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=yinf8q62; 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="yinf8q62" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-36743a79dceso376068f8f.0 for ; Wed, 03 Jul 2024 05:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008671; x=1720613471; 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=7cLxowQxGXKyItHO9t5LQNge45csaHkg4VU8jx6Qm+I=; b=yinf8q62WNkfCKrJA8xgleqMQO7qSsl23P729JNkKfm3ERJdcoAKP8/eDe3qt/j98s Z7kqV9rqyGgAbEUxIG9338sx/rRtkS4THO1ffdHRN0wAyD/KAfLpGW9Y9y6Noui2BrLN U1vV/WDI+GnAkVdg9pJrFJQgARnMH3a4uvN97045rGM8WYaz3jbJX1S15l91bIauI817 mnelTHbYU8AcO/mEwBZSq6iI7xYHnoTZ00sQEdalq5W/dJPOVa7H0H5QpTv/hcPLDPnU ATWv6BG1I0AEG4NPX91V+zQbzdqsHUiJZuaxQNu2xJ3BGoXUF2s/3HLZSMJRuS3XltVB 7wuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008671; x=1720613471; 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=7cLxowQxGXKyItHO9t5LQNge45csaHkg4VU8jx6Qm+I=; b=YeZZnTLYj2djDhIc2CzbTXoIE543jpYWYp+9amGhLQY+f3wBYapzmTt4IB005ccC3L +LDqRpkx+0KfX1veRnp9S//p3b78+2XYsvj7vafH4b+pJkNn63lngdlaaqN9roMH9kDi ll0lobmPRkkFAgxtKLdK8Y/3m1BU8qm2+9YzKuMu/yJ+oby/mnrkt30I69Gim/5uJRw1 iY5hHwoCD+z93SRZ3PS4MZ+t63rSvge5GphHaiEOzlJx1j9mPFh/epWuNyB+uIHnhRU/ bV1RsPpWuIlCZFQtfzTwGC8suelGLISIO9XXi2XtE/f+SawOSEoHzjg8iWKYvbzikmjE YnaA== X-Forwarded-Encrypted: i=1; AJvYcCVqF85h0nzAwFdf4KJcEM8cRx51ASQ5WMHnKFKMeO7sFD+462Q+AmI4Hk4GF+BrUT8a+3X6VbXXWYY38heNKbJlHaQIJDIxGqheH6cWIg== X-Gm-Message-State: AOJu0YzIqiTlDsWmCBWK9ayIO18/CJqTlDkzkrJsjJEnEbpPq66Hxgrs i/TAykDiuvC8NEm+hcEcJ3ZV3HNjhHg18wKJXxELScHdk3Ly91dqW0xKbzqGF63cBhc2JE2eUI1 fhFA= X-Google-Smtp-Source: AGHT+IFy7XIwYIBv75NcGjjGCl0VS2oKdh8CqLT1sJCeuF/ePWgLta3XoHjrEoA8051q0A7kko4l1Q== X-Received: by 2002:adf:f652:0:b0:363:337a:3e0 with SMTP id ffacd0b85a97d-36794780b27mr1367398f8f.1.1720008670720; Wed, 03 Jul 2024 05:11:10 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:10 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:10:55 +0200 Subject: [PATCH 01/11] ASoC: codecs: audio-iio-aux: Simplify audio_iio_aux_add_dapms() with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-1-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2812; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=zkBYXA5XhH4F6q1m9UDysUTPImTnL2Gru3YtQza5a+s=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/SBRZL/pAdnmTHzMWcEt1sae0bOVf+MOlLi 9Iouwdrzt+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/0gAKCRDBN2bmhouD 1++xD/4smEI7/Q/xqQ8kHg3Br1em0PyUgtV32GF4yvl2OjiJmfHfqwc4MC8tYzguMEV3m9v143t 3is1DhFHdotHjyQMMJiMG+/b3egvgKx8MxxKLDTGJ3MbXRecLSlQAaMuSCGeuLk4bCEXAZtN2nZ 59l6mosBbXKPDZGIBe3M+soiCM03Ydl01cJl8dSK5suDjwRpkMhb0+JXQjOl4yk2ZO0u8RmvM0j uTtxKpGljxGv78qEXDf1jblZH1uShAGNoK1Ox0ZKWxrhVpaG14Ytg1DC66Mpd7oomSWnyWBt1wU EshhBKabPnUlVVJObbJ1XFzGZURbnFu/lUXJgmBgaxhNczlYsv9/5T60tarIxLoFEClMrdN5NF4 7an704jrG2hU0kQtKZznWsT3bxDivQfnUj/7hEgnVcadq4eChOBHgZKl886/hgKB4b7l25UUdxr 7Zw7a1u0wlt1n9SPZTdlqdQwGj/1eL8hAkZkxLW54Dn6o59EUy415ArhoHSaawTLZFbER5UtXSs JrKvhfVNnjlmMmOGlnXUwCWRTfLqf9HBuynCCUJsjfA4B6sMDo0lV+P5grGPlQlghYxPgiaUAzU H96CRf99qS+tBY6o3K4/0HEsWzv1FLK3oz/6DmIkUKweb/sR9xpbL8JxcMRwZsi762H3cuL7vTE RVySwVK/E7N7Ziw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h in audio_iio_aux_add_dapms() to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/audio-iio-aux.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/audio-iio-aux.c b/sound/soc/codecs/audio-iio-aux.c index 1e8e1effc2af..3969ee45f41e 100644 --- a/sound/soc/codecs/audio-iio-aux.c +++ b/sound/soc/codecs/audio-iio-aux.c @@ -6,6 +6,7 @@ // // Author: Herve Codina +#include #include #include #include @@ -131,33 +132,27 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component, struct audio_iio_aux_chan *chan) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - char *output_name; - char *input_name; - char *pga_name; int ret; - input_name = kasprintf(GFP_KERNEL, "%s IN", chan->name); + /* Allocated names are not needed afterwards (duplicated in ASoC internals) */ + char *input_name __free(kfree) = kasprintf(GFP_KERNEL, "%s IN", chan->name); if (!input_name) return -ENOMEM; - output_name = kasprintf(GFP_KERNEL, "%s OUT", chan->name); - if (!output_name) { - ret = -ENOMEM; - goto out_free_input_name; - } + char *output_name __free(kfree) = kasprintf(GFP_KERNEL, "%s OUT", chan->name); + if (!output_name) + return -ENOMEM; - pga_name = kasprintf(GFP_KERNEL, "%s PGA", chan->name); - if (!pga_name) { - ret = -ENOMEM; - goto out_free_output_name; - } + char *pga_name __free(kfree) = kasprintf(GFP_KERNEL, "%s PGA", chan->name); + if (!pga_name) + return -ENOMEM; widgets[0] = SND_SOC_DAPM_INPUT(input_name); widgets[1] = SND_SOC_DAPM_OUTPUT(output_name); widgets[2] = SND_SOC_DAPM_PGA(pga_name, SND_SOC_NOPM, 0, 0, NULL, 0); ret = snd_soc_dapm_new_controls(dapm, widgets, 3); if (ret) - goto out_free_pga_name; + return ret; routes[0].sink = pga_name; routes[0].control = NULL; @@ -165,17 +160,8 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component, routes[1].sink = output_name; routes[1].control = NULL; routes[1].source = pga_name; - ret = snd_soc_dapm_add_routes(dapm, routes, 2); - /* Allocated names are no more needed (duplicated in ASoC internals) */ - -out_free_pga_name: - kfree(pga_name); -out_free_output_name: - kfree(output_name); -out_free_input_name: - kfree(input_name); - return ret; + return snd_soc_dapm_add_routes(dapm, routes, 2); } static int audio_iio_aux_component_probe(struct snd_soc_component *component) From patchwork Wed Jul 3 12: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: 809393 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 206441741C9 for ; Wed, 3 Jul 2024 12:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008675; cv=none; b=Qp3/RpZW2ugmkSikKC5WQvu34UELky2mcVOyvpb5orPVS9wIc/o1ZKIxto3wai+3Mwbowwv0wvzg2jTEQnJsjbsw/PV1dQX+W/tDyb03QRPhivKFnVtTZ0DNcRBTFQdO5F0YXbZZeg/JfoNy44/X+qmHueLhURDkvZf54fQqra0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008675; c=relaxed/simple; bh=C2mr7bEsmKb5ROqOqNDH7IBKsoD0jmhYaojg0nmAdOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gLSsI6QKVfMkKiwoXhNTnTLylmu63DZQE4YtoZXBl2Dfeddrvrtb0HDI9TyciwCJX1xxASL9euUCsDxN+B0kVvxjxPKVwbYC+/U3++ysBbvqZB4n2UnF+0PnsRgeS12gpRlFaK1YBhSPbA+/9dc0LvgjvKyMsKB12bUr3ysroQk= 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=AS/uMFHq; arc=none smtp.client-ip=209.85.128.46 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="AS/uMFHq" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-425809eef0eso24406495e9.3 for ; Wed, 03 Jul 2024 05:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008672; x=1720613472; 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=q7ezAWLj7MMf6cupnuxIo+JndCzydckyqulVxplwpWA=; b=AS/uMFHqiFE5tc581B5apYRNtnR3h8asIeU1fs6ZS3XcZd7Iu/d4ajsbcZGi82/fVc GoNWM4WOsa1bpQ+kKjks+eowbTQSLXjHyVepTwnV5jhxL1WWghBMb2XoXNnnE9MIhnwT 6E9F6JtFMZCdL+jpAe0JgmLU9HGx5sdeNrEE196/p3jOLk1wJ68fkKGxFRmw9E+GEvVs eeASsX8p/81vAOXknF1PqvOfLwsRXag7F5BL57lQGRDy4NJgSpAu3Jv3klzIAS4jTNp8 XtdCAGhiIOK2zp4uzzCOJtQiYImzGXx4w9hNQ57Tod1JcYP0Ja/2WzhDPhoIUN6zG9YT TvZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008672; x=1720613472; 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=q7ezAWLj7MMf6cupnuxIo+JndCzydckyqulVxplwpWA=; b=kvAf9pwaVnWJXQTaJzWTPCEoQe5sK2aG1c/fxoTkFht4TYRralQm8eI+fgq0cWomhG VqSSTxDSOAPSuQPr5xi3diBOKcppIMnRUJP50l+BEQhQZbegvNfbv1zXUegBxIeB1FqI yCYewiRqwsB8fy/doEFcHCbwzpuR+SY7nqZe3AcQoEb02NwVTOty1Rv/pwWMoE34aERB Tvauue09TepDlS9bbl2astdrBc+dKgFQv3M3vCcBNGkeEyBZ2r1j4p5nw5kpB7mTMQ8g AfUjAIVpsfPNdjrGGvHxfoGdDzC0BbFhUB1kk/J16aDxFumEPjqxP24nBiKIgnJlykMS Ky/g== X-Forwarded-Encrypted: i=1; AJvYcCWr1cF382CofoWU3VN3mI6zkgtNZXsur3atOxgABFBrnjbO5jB75J71tGWMJyKgJ4ro7SgLP1SUXa9PBFJtg9wjfUcz8A/GazXZ1ElXSg== X-Gm-Message-State: AOJu0YwZuaWYNPV//haqj9vuR5bMFPEO2o8b0BWkgDmI0kgAXBVd0kx4 fcoxKjfjZixUzQNylvzoiSXF4aprdIKbYi0+6KyviVHMwU44yL6AAMBGFuyDBVZdin5CDOVY42a my14= X-Google-Smtp-Source: AGHT+IHjhpXQtXuOXL2sG7Nz/kypplntZTHCDuejtJNJgkYlN74FsUPBIXDr/hqUtpG9V0bzXDVXnA== X-Received: by 2002:a05:600c:181b:b0:421:7bed:5274 with SMTP id 5b1f17b1804b1-4257a02f7f0mr79850405e9.10.1720008672113; Wed, 03 Jul 2024 05:11:12 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:11 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:10:56 +0200 Subject: [PATCH 02/11] ASoC: codecs: audio-iio-aux: Simplify audio_iio_aux_probe() with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-2-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3506; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=C2mr7bEsmKb5ROqOqNDH7IBKsoD0jmhYaojg0nmAdOo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/S1XP/zEy17um3RkbB+7GXXnM0KA43l8+pw GB5H7vS1OCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/0gAKCRDBN2bmhouD 15/ED/4tY2cdMjmCzBV33UogE0kN1pHip/43JaL23ZH7qMeMHA3I3HXhF7aKMqK7J2sC0UIzYGz 3UF5+KEbKvi9RXaKQmvPhEEboYiZWEeayVfsviuXZz8nxxyJd+9az94jDrtbZTcz+A/y7RrQpIV 0RRIbNATso7rZk4UUuVrjIKKlRO2N78g4xrJRvaTmsEUB88uJGF3kZAQOniUdfxXOUpn8eCwLQM ED/8KZPkZCnzSghFw8NgYfG8qG7VzAVWfp+IDWZPwF875VBep7TgSR8l8oxFvSjhtzykewNxMXH 170X/msAVpt0RDwMRwNiSYjecVw4pCmF6nG1b7jzaUQ8bf9tJpqzHD+Xzilpx5y/CFIgz6Qvv2Y 2ykvK6o4boLyK+rgP+KAr+/jnfAfLT5yIGFu6ufyNL2JkaWnwvo9B6Rh5T3Ccts3uOvJyWNCXG2 Fm0n1cnNo3w4Y1sYeSqq1znPn7s5a25nX9fFp+9pCwLPFei70SRPfU5+jB3fbDlGcqm/vITVx2f raw0aCQ2q6xyCFwKg/H2Ib62EqpEAKnUuC99UxwTH+ud5nYPnxN+pqS55kZPvGDzyWZuEty8kK8 reZVthBBte8bn0XyuOOkBiJ7vd9IvPpbOFsJpx34YEEruH6wFTVCkUf3D3WRfx28Zg5ccZcC5nh 2dZFA30ZhxUEPwg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h in audio_iio_aux_probe() to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/audio-iio-aux.c | 47 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/sound/soc/codecs/audio-iio-aux.c b/sound/soc/codecs/audio-iio-aux.c index 3969ee45f41e..588e48044c13 100644 --- a/sound/soc/codecs/audio-iio-aux.c +++ b/sound/soc/codecs/audio-iio-aux.c @@ -230,8 +230,6 @@ static int audio_iio_aux_probe(struct platform_device *pdev) struct audio_iio_aux_chan *iio_aux_chan; struct device *dev = &pdev->dev; struct audio_iio_aux *iio_aux; - const char **names; - u32 *invert_ranges; int count; int ret; int i; @@ -248,22 +246,22 @@ static int audio_iio_aux_probe(struct platform_device *pdev) iio_aux->num_chans = count; - names = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL); + const char **names __free(kfree) = kcalloc(iio_aux->num_chans, + sizeof(*names), + GFP_KERNEL); if (!names) return -ENOMEM; - invert_ranges = kcalloc(iio_aux->num_chans, sizeof(*invert_ranges), GFP_KERNEL); - if (!invert_ranges) { - ret = -ENOMEM; - goto out_free_names; - } + u32 *invert_ranges __free(kfree) = kcalloc(iio_aux->num_chans, + sizeof(*invert_ranges), + GFP_KERNEL); + if (!invert_ranges) + return -ENOMEM; ret = device_property_read_string_array(dev, "io-channel-names", names, iio_aux->num_chans); - if (ret < 0) { - dev_err_probe(dev, ret, "failed to read io-channel-names\n"); - goto out_free_invert_ranges; - } + if (ret < 0) + return dev_err_probe(dev, ret, "failed to read io-channel-names\n"); /* * snd-control-invert-range is optional and can contain fewer items @@ -274,10 +272,8 @@ static int audio_iio_aux_probe(struct platform_device *pdev) count = min_t(unsigned int, count, iio_aux->num_chans); ret = device_property_read_u32_array(dev, "snd-control-invert-range", invert_ranges, count); - if (ret < 0) { - dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n"); - goto out_free_invert_ranges; - } + if (ret < 0) + return dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n"); } for (i = 0; i < iio_aux->num_chans; i++) { @@ -286,23 +282,16 @@ static int audio_iio_aux_probe(struct platform_device *pdev) iio_aux_chan->is_invert_range = invert_ranges[i]; iio_aux_chan->iio_chan = devm_iio_channel_get(dev, iio_aux_chan->name); - if (IS_ERR(iio_aux_chan->iio_chan)) { - ret = PTR_ERR(iio_aux_chan->iio_chan); - dev_err_probe(dev, ret, "get IIO channel '%s' failed\n", - iio_aux_chan->name); - goto out_free_invert_ranges; - } + if (IS_ERR(iio_aux_chan->iio_chan)) + return dev_err_probe(dev, PTR_ERR(iio_aux_chan->iio_chan), + "get IIO channel '%s' failed\n", + iio_aux_chan->name); } platform_set_drvdata(pdev, iio_aux); - ret = devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver, - NULL, 0); -out_free_invert_ranges: - kfree(invert_ranges); -out_free_names: - kfree(names); - return ret; + return devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver, + NULL, 0); } static const struct of_device_id audio_iio_aux_ids[] = { From patchwork Wed Jul 3 12: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: 810870 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 45B2D17557E for ; Wed, 3 Jul 2024 12:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008676; cv=none; b=OAFli7w00MKD+dtKk5V0+cWzm5PXgFd56pkEtKz0p3gPVaJ8FbvqkdoFEjbeZc8BG2f6p80eNouVDDfOxQs2mTOC9KVcrEU4zcVhBrrLM279gcu/QEIpOoOtc3XNpWag/ijXp14CkVI9OddXT3BvM1tz+dS+pKdoFThV+SFhSXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008676; c=relaxed/simple; bh=hcQM/u4gdKEirg5JUeG8TyWsInxszV0wEWN+duol+CY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dq0UKw9CnguBdatIgb6NKmROj/aK4NMtE7QVvf2pDGfI52uOsEpEiuGnFr5aWCUA7NwMI1UZ3OqzYtQD+4wI/mYxH1xMHaOHiKeLY/tQ75xJP7pdGkcr1i4f939v5G090kK8uf+yaz1AjmNodFxNcZ1T+FceHAbBKh151CLHQn8= 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=mi4q4QbP; arc=none smtp.client-ip=209.85.128.54 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="mi4q4QbP" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-424adaa6ceeso32595035e9.1 for ; Wed, 03 Jul 2024 05:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008673; x=1720613473; 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=TvfHWDLawXK7UTQtN1jPqjdOr/fZ9HhxS6j/T8wlgb0=; b=mi4q4QbPZgLrl8yfIBksIq5MO+QZwUrk+2v5qqn5LVO8nBQ0Pa6g670jnh5cTJH8w6 XUUJAUwL7vlkD9ZlPZUL6bJGemaViI40UuUVO88EBUcE4Fmu8ZVPR7BSbZGEWCI0Hm4N hzcTYntyCzveoUY7PXRESxmcZQQ3PlYe0KcIqAeaRLUJfLTJEsS3SXV+R1V2vjw3vYNr I9vcZ5FMxUgvftYRDSe1yX2/m05+0RdOr+ttBimaxb8U7xdD2xfgw2rC+Ck8TCUAbQeV 2Mxv6kcJFlMXrz9mmSTYXhMmQr/f7ffASivOVpeNwIpV+YEUBgmbNweeoyuqM8pyWaOr 3Xlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008673; x=1720613473; 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=TvfHWDLawXK7UTQtN1jPqjdOr/fZ9HhxS6j/T8wlgb0=; b=qbjfeTr5cvCh3XiWc0tcOSP0ymSvSope2siK6OU7N0vrrHt1t+XBCBj6yIPQSZo07E KLIUyo2qKrpry6zK4f8XEhvvH/RxBI2AYmpMUWDqz9akEu6dcKt4/HsFl5go4e6WJVAH c2Cp5Pb4y1fhRBXJ86cxXbpCs3i5q0LBOP1X+EIKtAgjZpxgVu3i7kxSrY/IG5CKDxcN 4rACFpxvFzNYLS02oTkWITsMgIjkH1qWafqewDg/kFUcx+jTnpNlmAA4lT25Ltj4V1lv 5I9nupG8Z1ZZal84JCdJbv0gqHAjnloKnoz4cwXEqR3hLDnGyMqaIqTKpjIK1IP0NFIY R2Qg== X-Forwarded-Encrypted: i=1; AJvYcCUJTot23Im8jdQklr4/n9jx2loTGpn1b8W9t/D1MSD6FsQItRcm8e87uZQWh+/SVoWeg9qG39prg3KYzuwVdnpdD65ntQCkcIlwRusX/Q== X-Gm-Message-State: AOJu0Yw7OiJbMm6nCkOREr7/cy6c+NRceG6pBjuimJJmMXMx+SYD19+P S1rqEYLV0M5yoorkuaLPhDzw3+bjw0crIpZiuKt8aYwrWM6ta/dcuV2OR+DXSekUvAISgdcS4SN kKhM= X-Google-Smtp-Source: AGHT+IH/sDmBGQHkKlo6P8bbLVjWf52TOStaaHtlhq8jk1kOVYcLwRGZwRzl7cnPOdgKGkCKo6+RoQ== X-Received: by 2002:adf:e24e:0:b0:366:ecc4:aa6e with SMTP id ffacd0b85a97d-3677569e9e7mr7912505f8f.4.1720008673463; Wed, 03 Jul 2024 05:11:13 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:13 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:10:57 +0200 Subject: [PATCH 03/11] ASoC: codecs: wcd9335: Simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-3-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2386; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=hcQM/u4gdKEirg5JUeG8TyWsInxszV0wEWN+duol+CY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/TOLcCIz6vRLHZuKKP8eFZ3aNZ0lSBNsBPR gPoj0LQArmJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/0wAKCRDBN2bmhouD 15lDD/90zgr9CUgmwUMkXnQnamYu6m4EoSre0Pt416O1Wakpe2GuaQQXnXtSAFvkzmCN10TFJZS 5mtDly3oBv29VLaL69b+0QdddwCyIaiHwr8ZHtoQyRQQbJ96V5mnVIzjvtdwcLji6ImP6o5nqw1 7wXJnm8S6bE9dTMtmAIVqk7VZsp3HYcC57MFq8tHaNaCIszhbI3ac3d06FT+mEUjh/DK1zHBXrp YlAvQWzutJrs63xmHSN5017bL6GJ8WTFqfjN/1zVIZu5LjANy1Q6Pjy14KFkr3BMiAlVOCsI7/v UixaWOhI2XyG3sVrfnsI9OC2Tn5/90qd+qsG6yW9ajxs1BQLdfmH/sbF3dt+yH8nzH1uMDrIEuK 9JaG3EaZj6+sMovJfP7FOkKSZQp2Nh4BGcw1OEuI1hzfOQAUdq4JQ/7aAGuWb5NZ5LK7Mel7Ixd FHdoYh5nEFncyG6eylOXFPv18YVRccUV0jLdRQR8qiTs/pdNlpdkMnER5LtZhphvqXfFOZJfiNW DxCSuGc/e7LCeRnXNj9bIxhaLPxD6IbRm+gny4Yvj6y3/yOVe21+yLfYFxGNvJlJ+4lQYThBc6g 0ul+8ij1wZ4eAoA6XHNKr3O3LN6k7/KbGdnaduYaVQyTS5PESikZXMDj/ZbKqwSmli2SPa9+JwI QXVLp6ds12r0Jfg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/wcd9335.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index 1a20131e2a60..373a31ddccb2 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -2714,25 +2715,23 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; - char *widget_name = NULL; - char *wname; + char *widget_name; int ret = 0, amic_n; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; char *dec; u8 hpf_coff_freq; - widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); - if (!widget_name) + char *wname __free(kfree) = kmemdup_nul(w->name, 15, GFP_KERNEL); + if (!wname) return -ENOMEM; - wname = widget_name; + widget_name = wname; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, w->name); - ret = -EINVAL; - goto out; + return -EINVAL; } dec_adc_mux_name = widget_name; @@ -2740,16 +2739,14 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, if (!dec) { dev_err(comp->dev, "%s: decimator index not found\n", __func__); - ret = -EINVAL; - goto out; + return -EINVAL; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, wname); - ret = -EINVAL; - goto out; + return -EINVAL; } tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator; @@ -2836,8 +2833,7 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, snd_soc_component_update_bits(comp, tx_vol_ctl_reg, 0x10, 0x00); break; } -out: - kfree(wname); + return ret; } From patchwork Wed Jul 3 12: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: 809392 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 97F801741C0 for ; Wed, 3 Jul 2024 12:11:16 +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=1720008678; cv=none; b=AU2jjSYZjf2cYgmijaDZDSoNGGWswzYjj+WvbkoxAP2KsOZdUQSw6WeAQAnNR7zEs+qXCd6ag8JufZ/u0NuL1ZF4XaR8hGxsTRpRjPQDSOd7yHJ9zw8jCZUdw+9x93O7uu+Wk2wMZO1JMKe087M/z+ExRWKRViHUiSxWFD3hIxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008678; c=relaxed/simple; bh=kohttqfCWrqbGc8ure/Vt69RKlLKq333AiDxnpMSqxs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hX8nOneVM/3qPHGcH+MeXjWHWG2nGmda+6/eRaRDVL90Tude58Bj4IGEzi91YWuFZFEPvsJWo+kkFtrIntSW0Db+OmOtMBMIyjaaFjhktIaHb0AUGCshrWyf+8LlE/vS94+OvijLGc0RC8A39VPIz0d2/mBoOlxi5qCpygahqzg= 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=ukGMD67J; 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="ukGMD67J" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42567ddf099so37061475e9.3 for ; Wed, 03 Jul 2024 05:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008675; x=1720613475; 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=rdbATdFaTptmFaDd3LBcoz91pHQr1cKSbt3yHXPYoFA=; b=ukGMD67J3/3y5Ok4gt/EhrLW4SWTqdM/gIHOt6VEkgBvgn8CrEzjyhZH4Mel9c2JIg 6KFU7Ng2dQ00+xVgEcUpGg62IzW2SFV/S8gs3elUQWo9x48Y4n+tmta3ZAzA6D49AzRS vSAolF4Up8FTfC2pAFPCLL8PVqgFM0ow81TGH0997ZwxjodEMresm67z01x2/vU5Krwh K3RmOClFvNrh4DtJN1RHi7nDj0Wj+zZQOaAN1if9OJT0JernSUCo1EC6cTJ76ePgFuFj lWcxM/t8EExQbeMBekQ/FT87kR6AjRPx72urvFo2vALQtjrFNHKQzHU7DfjF3RlNFjny s7HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008675; x=1720613475; 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=rdbATdFaTptmFaDd3LBcoz91pHQr1cKSbt3yHXPYoFA=; b=AzMxzujr1gZ0oBDlD96bP4/KHipEjYN0G4EZtBsoZRlG7WRoS/U+e6TN5ex9dxPF9P Liau2p1Xe8NYT6AguUrp4HXptwhso+Ri21B/9WYBmlag6r25KvI9SkUTtfnUgspDI6L3 4vJDEWZj235SQnWWWbMC5POMuaK0Fec+vYn7Ab+nv2r8yqUK6eE6Kz46+4gR8snGnW0s nMDRrAW6Zhw6Q+yLDGJHTq0MuNEzmJOTb+huwCRzDa6DrFjAZpYXjd5p2v8YlDb3rqaN zdWUrYWAhDVuK3jiJeGAU2KAhR/11Uxv8Po5vPuzFdPWCp0oKWTS+ArvPSJozpLjIkEV V8Eg== X-Forwarded-Encrypted: i=1; AJvYcCWwUdjlhgUWCIczgZ02JCwJbnh0sETli2kuw6C87bG070VwtvSZf818jByVAGr318pV/K3HKnsriltvvaCvKcPYnQMeHOQozWdeVqILCg== X-Gm-Message-State: AOJu0YztSuXwKbs4phQVQ5+XOUV49n7S+nyBtbGcmXgp5zHAj2oe/ZzC Pms5adfA166Xz9yFItyy4Bo/1yAuHGOZAgdvVnKEUTv0jKj9OPcwjEZr0dX0qcFQCd1Oijl0cLo rRds= X-Google-Smtp-Source: AGHT+IGrLsHp3VA6L8jTQ5ej6pjKRa1e82AI7Hd2/DqZYivIJ2FyYoGUJpc1Ou30fG1o2MruG9SS7g== X-Received: by 2002:a05:600c:4c14:b0:424:abd7:2321 with SMTP id 5b1f17b1804b1-4257a00dc53mr75429565e9.12.1720008674781; Wed, 03 Jul 2024 05:11:14 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:14 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:10:58 +0200 Subject: [PATCH 04/11] ASoC: codecs: wcd934x: Simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-4-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2346; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=kohttqfCWrqbGc8ure/Vt69RKlLKq333AiDxnpMSqxs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/Up3Lhqw1lG8hf6t79kWGG+4wCsdFcumtsc T9S3yaOibyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/1AAKCRDBN2bmhouD 18TVD/sFzG/Chwmi1OFCni8P6wToAEF0mWU3fsKO4cdcBdThHB5JG0otzPtaSKk/NngKHF8qFYx 7bXfnXw65p0AIzyIi+K/KT/HS2JqWziHSf8ztIiu/eMt3jxbSaC71V5k1gfSZxJEvLNMIcBUOhU s8IQoNsMSSatumy4nLovUfHNChCas82BtISCmoEpHftZIr4FJZ1G5mGgJWWdX2wbxBia3stm11X VYBQxG18BC7NsyLY0Y0KVdOOMNYbB4zOJYCA96xlTzOwiWz0etfgvArlb7y5nl1pq7HdGoJ7NTm hrX4nR5SaQudQg1PWP7HlVuOtyYH4DmGw4PNaV/7CImP+hPBSh5bHjp3PpDMOcHLcyVmX/xu5Mk nJ0kAi4Yyqo33sFw5jKjCDtMmy3C065QqrP4gpssMYt+yVluRTme+gD6VXEufkCLn1HXiWkET3Y 2tYePWhNHAWy2r1kLkVLmEJUnICPHQh3KV8gRdsE58tTNb2CUIKALHqTzKVMn5PvY/DD6rW5ze2 1ypvy76pvgSdXSz8O1ZlRw4m/LfpkUWp3PhaD7GyzsHE3gDnXakzA/PySna6wcTQl2a8jJKBIQr f6fwRFI8zzDPmUpI8d/ixZSZNGdMOtURZgzK5GYpzsyfgq0m6s2IP6rI7FXctnclehMYDltwEAR 8r+c07k6ETwUrSQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/wcd934x.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 6c65b46e2dc9..291d0c80a6fc 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019, Linaro Limited +#include #include #include #include @@ -4973,25 +4974,23 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; - char *widget_name = NULL; - char *wname; + char *widget_name; int ret = 0, amic_n; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; char *dec; u8 hpf_coff_freq; - widget_name = kstrndup(w->name, 15, GFP_KERNEL); - if (!widget_name) + char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL); + if (!wname) return -ENOMEM; - wname = widget_name; + widget_name = wname; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, w->name); - ret = -EINVAL; - goto out; + return -EINVAL; } dec_adc_mux_name = widget_name; @@ -4999,16 +4998,14 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, if (!dec) { dev_err(comp->dev, "%s: decimator index not found\n", __func__); - ret = -EINVAL; - goto out; + return -EINVAL; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, wname); - ret = -EINVAL; - goto out; + return -EINVAL; } tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; @@ -5101,8 +5098,7 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, WCD934X_DEC_PWR_LVL_DF); break; } -out: - kfree(wname); + return ret; } From patchwork Wed Jul 3 12: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: 810869 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 236BA178CFA for ; Wed, 3 Jul 2024 12:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008679; cv=none; b=KuWrJ7xuYQDcvM/r+bP/BYSt8mo21UWwo0ABNpmDcXb1pel9igCt38rl3V9krfSd3yJK7jAy8GMy1Brafi/3rfl5BHO7TTot5yxVT9VkvtN8InDiEbIdvuBUr1MopIV6jDVyC2BX1IrNxLN8OOLS21ZgWWbA5m1WUAWQB3Upp+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008679; c=relaxed/simple; bh=5n2U7Ii8u9qpjNSh5gTMMpFE3U1zzbLfE0z6dwMWgWY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e8yWXxuvcSh1zlz6zu7cW5LIEftm0Qr+RWZAci1RDD6gQQKwrmwAZJnKjV0KHWX37xHPofBqXCGjo6dda9jiirD45w8LuAiMeTD3Zj2402A+sFscvCmWEeK2DHT22AAN4HgS0JvsvjoYep/F6cUwHdt8ffHu5fHAMFNrMmT8exU= 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=YlUDUCNA; arc=none smtp.client-ip=209.85.221.54 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="YlUDUCNA" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-36796d2e5a9so172278f8f.3 for ; Wed, 03 Jul 2024 05:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008676; x=1720613476; 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=voPxYQD0gS+6s0oE8RPo9jZsqMZNTCeTe5vHHnILF0s=; b=YlUDUCNA5DW9JzmyxXROL5pYYoM5+FyfaJRxN+RdRaWzIzSI8O7UnyHgxcIkTwlvl0 4Dvo8THa0eovczK4bWodvyf6/EYD/betLmWTR/8q2tWv5efpsJHtmPoTy8EV3YrKg6qr +4+w731Y4TJEejUd9Vu26WTWAHitTljqve8gyfzcg/pL+xvOqYyFFery/9Bx8BnRYhB1 YwGJ99nVjq9Ca9go9BywHWlIu3iSz/rWrkf8CdZypsyFPrXglrtWtTSmRNnTCfNE9vQK vBlSwR5MLrC8/uAg5JPtfG9sltgTHK6aDQKJkNc2cTINS6JPQt8SUzUlp2K0M5d6O7ZS zdtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008676; x=1720613476; 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=voPxYQD0gS+6s0oE8RPo9jZsqMZNTCeTe5vHHnILF0s=; b=r0YXVZ7i0aU/VX3/W9otYcbb9Nb593JPLN+lnZJfWujr4SIrhlfG4C1YMQdkIeKYGy qExUASU4PSqIvr+fOmfJdlvdR6JvoTcgnfln2VqEo+kseyzgtrCW2RfEiMGPjko0f8hL MLahgBut3DFpXbhB8tX3Gzs3Zr1OGGRm9WCqDkmVg6cgeY2cQ0BabWX4xdpLRMQTv0zB cNl7rQP36Pf6ucQ9CcPgC87g3wRlD7i77l/411VkfeABT/E7uQMcZDBFXP5dlCkWn44d /jEyUrSSjdnm67Kr3pOyQVFj4AzLMQrFOL4/423b1l54GQ8S77VZGCUNyvzUv5UftFgp g9sw== X-Forwarded-Encrypted: i=1; AJvYcCXUbv77vKuCCNMwWbuTKmHG3vzQsUEvWpi925AmCXy9svl1SU+fbtY0Ge2XpqASi/mgvoKpjfkMJ6O65DGo4fAZYU7CPVH+pvIH+xP6ZA== X-Gm-Message-State: AOJu0YzUinLVMgPCC9Q2Z4F2beQRY1Nrx6RVoCOQraZNPefmailBmqJa rWKX0i7aqqKRWEsx8S5lOIH+hfS/6LltIYPOTEVHELmaXiJaTzGKiuIM8XDxY6xdjefw2n/TNPl p0is= X-Google-Smtp-Source: AGHT+IHUpJv09c/tX0BJoWGcywOs1/igC2JtMah//K7mGQHmsYLuuC/hM6I4L59TczjXLvEdh4+MWg== X-Received: by 2002:adf:fe88:0:b0:364:aafb:5fd7 with SMTP id ffacd0b85a97d-36775725e0bmr7848385f8f.45.1720008676185; Wed, 03 Jul 2024 05:11:16 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:15 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:10:59 +0200 Subject: [PATCH 05/11] ASoC: simple-card-utils: Simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-5-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1989; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=5n2U7Ii8u9qpjNSh5gTMMpFE3U1zzbLfE0z6dwMWgWY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/VpH4b1lQMWfJeGjQDjMJ4k7DARxOdBMzRK YzljfxO+aqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/1QAKCRDBN2bmhouD 172hEACWQQu3Q5imqmfhy2Da+4TNTvqC5znQ4ArWh4RI66hNVDgTQHmyb+N0fxWIL3qrevl8eSr 0AN3N1lmd6D7W5upGGqIks/nPJgFiEe7VqIhy13tVhA7ebEYCWp88sNtgOYg55zmOJh5E+Bsf5H DlSPHhaaDgKoFK6wwXe9XGHUMDnSuuortUIxpQeiKT7U1DKNHYHfeUsKuB1y1miIV0ZO2F+15Uw Ek5WblZNHEWX5C9PS9z6mW8epDNRqFh6wuCZNXx7UnVD7845z5wO6Kq6etIlVxVi2m3wzdPh2ED URWvk1er5OxmQgbjwYoZlZTHY5Na/xooBuKB9bywJATWbzltzlE1RHlcJJT4JsHMnd62Gf7/bGq Y1yeVYjgi2LV2ocil3//TPQItf1LRV/odPQ8BLUssFP3BLg1gfFLfZq+bZ/sb2wny8cLVE2Zm/T /xX4nd0/068uemcuJIOOrzOv6RFH5u71oP3Pw5WhhqPybcpXw/KhztBlBBNv79PtO5MOjH86s3E hVzSxSqHUtzRB0nvkkPw+Z/7uV0sovANZSF25ogEV8Yb92eQg+KNfeS5pbHryj2Lhzekufvp6wD 5uEgE8Og4+VCN28mAw2TKrmk1fGO+0o8ETKvaYlPlWTUghUVwV0O0pu8xEnjXMiNB3MSf0ZwV7w rA74nq0PkFkfJyA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/generic/simple-card-utils.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index a18de86b3c88..fedae7f6f70c 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -5,6 +5,7 @@ // Copyright (c) 2016 Kuninori Morimoto #include +#include #include #include #include @@ -135,8 +136,8 @@ EXPORT_SYMBOL_GPL(simple_util_parse_daifmt); int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, struct simple_util_dai *dai) { - u32 *array_values, *p; int n, i, ret; + u32 *p; if (!of_property_read_bool(np, "dai-tdm-slot-width-map")) return 0; @@ -151,14 +152,15 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, if (!dai->tdm_width_map) return -ENOMEM; - array_values = kcalloc(n, sizeof(*array_values), GFP_KERNEL); + u32 *array_values __free(kfree) = kcalloc(n, sizeof(*array_values), + GFP_KERNEL); if (!array_values) return -ENOMEM; ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n); if (ret < 0) { dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret); - goto out; + return ret; } p = array_values; @@ -169,11 +171,8 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, } dai->n_tdm_widths = i; - ret = 0; -out: - kfree(array_values); - return ret; + return 0; } EXPORT_SYMBOL_GPL(simple_util_parse_tdm_width_map); From patchwork Wed Jul 3 12:11:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 809391 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 A1F6717A5A8 for ; Wed, 3 Jul 2024 12:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008681; cv=none; b=ICZ9lBOZBr1d/yGIGrLo19t7L0PFqLFHsCxWeMwlkXRPtZGZ5SwmTZemz3/tNmtX3+YnpRWOycEzrYS8TlhjtYbqnO/tsJev5n+52dBSUG6+4tbdIgdezovbIavMh04KAt1OSS5iCNlqmLzUr20gU8TuwRRgEQ7Xj2uS2vvUSBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008681; c=relaxed/simple; bh=DS/IDp+LqdRHE3mvtnrgUtVAz5GNkmhuj8B4aFV9euQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G66nnZBu/04QQfjJlq82+5pcZPW0fKiHWbP02Z1HjUslVF1r8CU5ucTqBSsKJ/H9p6xuMaM5D9TBkF1hEuFddRbnGmupfwK2Hl0Vm3ncUvz94/mw2eYrKk73XIpOBrl/w4UV0EOpavAKqtUXMQ9t6z7Wdm9aqJWx7XLhA/4TGXQ= 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=NEWc08Jf; arc=none smtp.client-ip=209.85.221.48 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="NEWc08Jf" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-36796aee597so170026f8f.1 for ; Wed, 03 Jul 2024 05:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008678; x=1720613478; 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=V81m9R3WE5N86wntgnBniIBHNui3TaNJXIYWRSi4OAc=; b=NEWc08Jfo287bKYKUUiLpafzU0NJzbN/1pl6uojLyyuZqEmkw1yS+f21zDOWmYV5Bs ysEII2kxEdgw70FuT0uoovFsu0cqmeo8fLO1iRqlR21F7rHTsOJSnKHRP2QlOBcpCVt1 eli2b3LQb+hWTtky7Q5K0EPTqul09nv6NNu9XUTQJaUIs9M/rkeS5GJ3D4AXL9IqJXpB GoCmnhDjvC+ty6XK+zE5Hi5fXqKvjZY3P4G9kwBQqaq0j6FIi3JjKLG7g+v7MXj+Jjrr tydPu3bl6rfxhMYbl8M1bX/ki3oTyC/tvZA+zNiSqUgmBfdbkMRQ1XoEE4znF+ltIime xb7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008678; x=1720613478; 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=V81m9R3WE5N86wntgnBniIBHNui3TaNJXIYWRSi4OAc=; b=WfFZejEqdJxeg5p9ViU2BRnmULVxxwf8wyZFmvIZkGgLXs+EGndz5umgiU0jYUvi/8 oIXjAFolWaNxeL9s8wtbhqyOU1t5O0nBWarvErc5BP2Icd22LJYA9alYCIpl8wx0b4DQ LVOXjU9Oi/MkPqRFEEWlVRVviDZ3/Yv1WLxnFRU2e5BzMVnUdqV8i0Y6gzYFbiM5Jk96 5GydrWKQToSuKU0+gMWMThiEfb9VZCESEWydAl5l9Z8DRuc+qitNJsSMCK8x/HXy0LYq kmVh43B4cvMCWMPm0Muu5lguH9vW6ZlB3un2EOcAAQuylO6ichdoQHOk89DBMo4BztgF JLtg== X-Forwarded-Encrypted: i=1; AJvYcCVAeVYbYS+9cFnCCnOI8XeWCNwvgcEUXCXfH3+R/EeGWb+WjmwKEk9kG6n4Wns/ni9NtNXbKs3ACSnHH1miRshjJhngsw/+FhwORPKb2g== X-Gm-Message-State: AOJu0Yzg974rp/63rr7Z5+lTvmMosOknI922ese35ogQtYTkOjH98Qmr /nI7nfKkovsZdd6u97jCmhiNPVHqank3iPKOnJBRyhq0gDi+HAW7+K/G6liCimWZ+HwLOxfkXvF Zo88= X-Google-Smtp-Source: AGHT+IEy3cvbIPXgRehmrxbeY1VP2hPk71QJIpRF5k9fYxa9g3eh0P0YLDcrqZVRfqAtmQR/bgW1Eg== X-Received: by 2002:a5d:58c8:0:b0:367:4d9d:569e with SMTP id ffacd0b85a97d-3677573211fmr7148838f8f.71.1720008677736; Wed, 03 Jul 2024 05:11:17 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:17 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:11:00 +0200 Subject: [PATCH 06/11] ASoC: audio-graph-card: Use cleanup.h instead of devm_kfree() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-6-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1357; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=DS/IDp+LqdRHE3mvtnrgUtVAz5GNkmhuj8B4aFV9euQ=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/WXyjhdMmNo0GaMA/nQmQHmNLei7121GkMX 9CXdHbwkg2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/1gAKCRDBN2bmhouD 1zySD/9moQASzEdIyJNIMW/1XTuG74QTsA+WHBfP/SMJNsQ14mbjd5gXLpmMxWJ5nTj2Tn3HvqP FGGryHmFFr3jexVUU5Ueq8LvG8EfsLNZLrGhJQdeTGo5CPdCR00RvhkIWBBzvT8r3ix7fltedvS KD79KoVa6+ARsgBCqGNmzmfaiUjsOTIyfzG4BX3lHtBoJ01r6g2HhjStY2Tp6xvqQlHvG8S12md pBW8QUI1YM+gk6L0L/wSzBMIb6C5q7aTJpRjY4rAP5267YeLa/m994LCzRcjHz8DYihyO3AlxfX wvrHCLk89XyUuS+LavCeHanMxHB0/AlaEeF8eE9vtudNWKrTFhQU0w26qVqWHq9lVw3C+jqqs4x GgpgQgl6k3QzHJQziZ05kyolA/N0hPYuPGBUGxjgJZVn4/q8FuaB4VYlJfmocBRNJe4kYJnUqXI 5azhw7+mDi7iJSMQe1QazVFW0Q8M5JuEc6lRRggJ8ZH6+lTqnUn6UtPM4EQGzqytgduJXtaXm7z XWERZodnnF9NJ4B3YEaCO47KNoW/ZRxGgXAviKq7L8U4uaxuKV7Qgvk2rLNaqzOKAkPV1lzcmLO 0s5ffkOj2vDYNcjqLFht/W2+R8i97qRsLWTf7l9GWinkLTZSaTTJYXVoK0fhKqpjTs4eM3roqP3 SVE73xekq9kTZcA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h, instead of devm interface, to make the code more obvious that memory is not used outside this scope. Signed-off-by: Krzysztof Kozlowski Acked-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index acf7d92d21e6..3425fbbcbd7e 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -7,6 +7,7 @@ // // based on ${LINUX}/sound/soc/generic/simple-card.c +#include #include #include #include @@ -573,10 +574,9 @@ static int graph_get_dais_count(struct simple_util_priv *priv, int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) { struct snd_soc_card *card = simple_priv_to_card(priv); - struct link_info *li; int ret; - li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); + struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; @@ -628,7 +628,6 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) if (ret < 0) goto err; - devm_kfree(dev, li); return 0; err: From patchwork Wed Jul 3 12:11:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 810868 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 5538417B42D for ; Wed, 3 Jul 2024 12:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008683; cv=none; b=P0/FhTEtWPFmxZFXf+uzBO9jgbjRqUWAGtEOjPbOmRe3Lt0vGmf2gDCS7MA4Z07gThnOnYwgY9Q+1/nPLWqJOejj6ehG6XSPSrTQhymr7Lb5bZGeMwC4jfnd/Ts4oeOrGxifsNEzTHAN3itpdd8c1p/DPfGEX493kFkcTnU7PgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008683; c=relaxed/simple; bh=S5zvkzQpDxgR0YGwGmmFBfehEAbVxpQY2x0q3BNuI2o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uwfkikIxCLbn2BANkCkiusAzl4byGVC+4MUGMT2NQt+jD0LnHv34Y1YOAA+zKuN7/ZNFzj1cFCPg3CMKVgbgsFRSxO4MNcTfoPazVIOeu6/me9fB3mWIIqKiTu0E272cG7p78qCIVe6lVnneWvqAY7TdhE+mCiTwyw8cc+wLYu4= 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=UElA+R2b; arc=none smtp.client-ip=209.85.128.51 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="UElA+R2b" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-42565697036so3613555e9.1 for ; Wed, 03 Jul 2024 05:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008679; x=1720613479; 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=aJVuVtK10DRmUdGmaG4/PmO6Oec2LjszDDiQAZFkSrc=; b=UElA+R2beYATP/RTfSx9YbCDRbDaXISBOW/cpqE9zJCqaDHyOHGzGKy4PXigUQWKfi MFVovwQ4pFHIw+k4PZp3VSlRNbvUcL9IM30mviYLbCTWa/pm8M+ll4eDBXX4NPOtUj73 3a6343VTaazZ9TaCpX4MnDzvaDA9a+Z8/s9iy0zqEy9zjJedj5Mn5Jtu7ntwsz7FlDQR gQOlYlFSgIlB9bjDgPiiuwd5+9ZocIDMONjwDRUUhLst7xFNLghvl2qlSBzhooxLbLtT NHyLJ+u+f7ckPz5cnfvt94kx7pYn9WQ+Pt8GAb94ufvUJmIHTWUEnVmj3yZA6Td3GVkb mlxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008679; x=1720613479; 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=aJVuVtK10DRmUdGmaG4/PmO6Oec2LjszDDiQAZFkSrc=; b=KA27QkLLIDXiK3pjIaInyGq1P0EOAO8yOcTo96IcQDQcQ9stzGg7IzuDYdAEBPimFt XdFkpm5x+7ZRw1q3DVhnPtC9rT6hVMvySuEEG2bannqI4CFN/nRyab2xe1kbEqltkI4v 1vL3qFLg30q6uL7j4Uv6gq2SeCuFLN+wloC5bGHTFaI1BOecABOX4n80esU56JpIaKTW gnS8gr2iaEFRLstaQ1jbya3CHJuXpDbHXoNRLdyGvlDvim9chokzaigCTTcjeNggntH4 2twWtAw6C4fLtqShspsi2n/z5ZabZ62vI+UbkSqb8xSf1cfGufp+5h+P/A19s6giNrvr QCQg== X-Forwarded-Encrypted: i=1; AJvYcCUxDcHqcQAhoZeRXozq/Eq1D4pmqG9Vw6KbRa+hAiJMIEXoBpmBTJV3k5OhyojSvL63o9BYW7qRMAmxKaibw09++nPp5jBgT318csGkqw== X-Gm-Message-State: AOJu0YxL6boKqwHw9LzgBla2Cl2R6mh126qhpwk2drOn7h394e/X/0B1 y9Y/8GbxGqv0Ntw0GzDl7wNgdjvOlFo5hXRynkMEHmJWE11zP+/xoclwmF3EnxcNdhbR9UdOhjQ HpBU= X-Google-Smtp-Source: AGHT+IGxHphf5D82gF71UP89obxHtvR4jIfjhlOvTO3r6ArO5pT2ywt5RlxUaNm4CuKeT17LcvrrIA== X-Received: by 2002:a05:600c:4506:b0:425:7c42:d24b with SMTP id 5b1f17b1804b1-4264093f010mr12776955e9.18.1720008679207; Wed, 03 Jul 2024 05:11:19 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:18 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:11:01 +0200 Subject: [PATCH 07/11] ASoC: audio-graph-card2: Use cleanup.h instead of devm_kfree() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-7-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1217; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=S5zvkzQpDxgR0YGwGmmFBfehEAbVxpQY2x0q3BNuI2o=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/XW0SWctuZtJUcXCPlhsiWx2TNOffJ8CK/G W7SJVqOCxqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/1wAKCRDBN2bmhouD 1wwmD/9/pdf7GwTIbhrVdNSj8ifQJAxH/unze4Doo1292r/QQqP/NTi6JIM9k11NGv/KmT68EbP wNtd2gHNAOILhJhnS83opBMJfoZWYjEguTMZtaD5RevZ2UuufFqvZRID1ikULZVGwuayXjCUebq BahUAoPu1hzTYOwToTFdCJYnTQAl+dg/umhIGuC7Hhsf8n9votw1LG7D0XJUEiCYC88xcT1Z/IR fRuzt1+eHyDSkSEFF3AtQlns1pVsDFe6IAGb9HDG24oLwD2glp+UmzdaXtlpTXAYPqmwXkFhe7r tBE7PSWWyGH3HgldHG0CDe8lVhj2yl9Gf3eqXWDUv7NsxrsbwRpVuaumm6BBXG4YbGnfTiyjXPQ b3qJY1g7ko5/Q2b0I8EXPh/Ca6yJ/+XwWZg4tjnEld0PBCtT+AOXhYgdZuQ3jODb4qMC0H6yvEI buwQeuR5d/DgsJAIUSRGIyGYKrUOyb97fJrDuk3VYDTflh9kwMw8Kn2qQrhp7aBDOC1pndwf5xG 7RJduqVwRtVICBdGI0bP22ckUVhXToXgc6XnOlbQznn3Eakd+Qn2gsKlRw5jQdIfPnQrYVnVupW 8sZ5WMY69SEMC0YZsiAMkSP+HfRvZcK+xH2NasIDubd2B2TuMG+zKFQKNndW03d/Ur2KJuIvmE4 4mikRl8ItjzC1gQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h, instead of devm interface, to make the code more obvious that memory is not used outside this scope. Signed-off-by: Krzysztof Kozlowski --- sound/soc/generic/audio-graph-card2.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 93d9d045587b..56f7f946882e 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1350,10 +1350,9 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, struct graph2_custom_hooks *hooks) { struct snd_soc_card *card = simple_priv_to_card(priv); - struct link_info *li; int ret; - li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); + struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; @@ -1417,8 +1416,6 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, ret = devm_snd_soc_register_card(dev, card); err: - devm_kfree(dev, li); - if (ret < 0) dev_err_probe(dev, ret, "parse error\n"); From patchwork Wed Jul 3 12:11:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 809390 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 92EBC17B509 for ; Wed, 3 Jul 2024 12:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008684; cv=none; b=lv7qxMdWpnDSKskDnoMATA7k8ccqnw8UgGgKlrubSh5L4vschp9EpXkCSHDf0TY4VUQSyUCcNxHXzEdM3asmqajm/R12HsRNptOQBWXNgGp/2nPZ684a6LFw1beRK4S9kXlEfWIEkWZZrhvLPVr1c7pB07EAgKG06MG3//HKM4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008684; c=relaxed/simple; bh=X9RGNO5wB0C8KAI2bKN+Sff6tTbKWBwR8b9RYI6jmJE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wy4VkiFtVUdViuHmavY1bo5mcvwbVzRUTBB4/r3UjDhsdPave43fLM1TR2xyDLEvp/g+01nbzyqxwKZ7StHyJhViS1tsvd1HYrokA7WfIPcLO3u2q+C8bAw54VctNNrOTc73RBe1aC9MUlEJyc4+CVG6aip/Hyr+fJdTNAL+PG4= 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=Lqjeo5kW; arc=none smtp.client-ip=209.85.221.51 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="Lqjeo5kW" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-36794da7c96so272803f8f.0 for ; Wed, 03 Jul 2024 05:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008680; x=1720613480; 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=30H4wuVh6MTN8EFct4l0si8PnCcJgk04g6gE9lXf/C0=; b=Lqjeo5kWdS5KIKjk2O0hYJtYZ0JXhOiOhcntMD5j+5oxkatTpfwbM6SOpT+mkzuepq +dEEBwuxqBRu1AGQEgbGwDglox/XSc0T2eoK0dupi9sztwq/H+NaN5sa/EPgmgCd/L25 UYAnJIOnhLWPvL/HbhRVWC29j3ZRYKDX1ZPZFqeRv7B/1KnVtpk3zNevg7jPqk7S9QNY cduNkKUCl8JqU/ZFvaaLtCY66KlFEAFHctCflW2ZiBPlheztfBsBWwMHWCX1oFSbgjgS veJABVaa8W0UiPoGzScpJvajsJ+lFYTm5rzFew6JcrWrErW8LyNJTWGNh/QAJp4jZ0bo YT9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008680; x=1720613480; 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=30H4wuVh6MTN8EFct4l0si8PnCcJgk04g6gE9lXf/C0=; b=TbajeNwCBOiaGWwW6lVL5IYidCoK/yet/Tr5GmE8wlZjk7cqViab0qzXWxdgAqI/kk B7D5iXxAsHIggqdniFXI3rvCbXu6Cu0hZ5jdwB/A9FHSvHp4xpLp9UDoJmhG9FfvqFRE esFAd9VZeGoT2KR2yjeN6PR7mCzo8KXjO4RITt6vc8B2SrKF4sGa+XuZaLysNDUU9UtE 9RA+VyZxIVJD1vJeBsNcS6VvLiLTurlYAHRR1IBRmABKS7K6h68K19zUO7Ea+xIP0O29 SUohE+VvUgxZy+zZ5mebRgNGbSRBhX/d7SWqzhZKuzSVEDFvDFS1H/3OklLycbUAbH9c i4rg== X-Forwarded-Encrypted: i=1; AJvYcCWSadgV/vkpM8Gb7fH61ihH41XBTyTmSCzzxqzR7khwXd7VlSIxH4YqxEriCNSfgOWuB+ik9OqU30iqFLICcnihJKcSsNZYwLswFlxV1A== X-Gm-Message-State: AOJu0YzLtTcW7BreYOQU8RmSibUlxVNm5YVJ3vsKogLLpUzVXIuYNRZa bY5sC29TotTvVXS40K9+o+lHX1R1d3CbNOYowx/PJ2gramEoT8AgOdyFKvIR63oNVI6Rvp4ZeGd UcN8= X-Google-Smtp-Source: AGHT+IEDsnzvMssWW12W73oyc5NjjqnLZ9RF8bwCkjxaj+IHTX4GIR6Mw8E9wybObB/fyceJvM28mQ== X-Received: by 2002:a05:6000:156a:b0:366:e508:c7d7 with SMTP id ffacd0b85a97d-36775696c9emr9653713f8f.7.1720008680569; Wed, 03 Jul 2024 05:11:20 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:20 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:11:02 +0200 Subject: [PATCH 08/11] ASoC: simple-card: Use cleanup.h instead of devm_kfree() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-8-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1558; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=X9RGNO5wB0C8KAI2bKN+Sff6tTbKWBwR8b9RYI6jmJE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/YMEj7J9NvFTYv5P+4OQRpfot2iJsqj4iuF QE/7PDROlCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/2AAKCRDBN2bmhouD 1yMlD/9U1tGNEULLbx4K0Qb3ti9u79wPsPOGSVTGfeT4IvhdfTtElmd6RNSsJxBuhTXESGpgNLM BmhcGaYslhtTD5iwD6vr/ytTPHZHB6olK1Q7+BMin5qZfeFVIf+rFICGdJy6UZnvy5491siZ1qq NUSYVGoY0JPq8xa0CdB7vTiKEUFofiWfIr9DEqxJG1LsbA1goDvah5Iu2alGtaZmmDojm0CJwjL O1MmfJx/7mxQvCrYj1gdENaI3q7b4DPDa+QDqY5HG5MIfBAad0EaANQSaKQRABSpZs9aagn+oF+ ucjzTD3VGG4Bv7rzp8mDddiADe0ew/umdLAkcFACuAfDXntAsYA08R4Ers9+7B2RbreeFEU9yQw i/aMefqRpMeMYEjd/Gmb+KMUHt28mbk7P92iIOTTNB99yxn662j1EjY2tDC2bZWSeD2XAgMwDja hBd4XutXGRhK4PL3sRvKWiJnJByM0ybhTpTzKsE/AxF5YWiADGrXrPeGBOktP0/+J+gmwmBQHQL 9qDUp++viikr3mnx++adqlVaRCg1x4A3qp7c6O3GO8hfSWn2DUGjnJE1kVFGQql/5IlIUQy0mEm UbiTrZ86Sg9n836zL7qIJHai2oZrfWzs2Gd8wq57VVVUOZ8clFwJDeQfcznZ9kBlY0hE5UTqm0N R6WtkzOurrfY+yw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h, instead of devm interface, to make the code more obvious that memory is not used outside this scope. Signed-off-by: Krzysztof Kozlowski Acked-by: Kuninori Morimoto --- sound/soc/generic/simple-card.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index edbb6322e9be..d2588f1ea54e 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -5,6 +5,7 @@ // Copyright (C) 2012 Renesas Solutions Corp. // Kuninori Morimoto +#include #include #include #include @@ -727,7 +728,6 @@ static int simple_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct snd_soc_card *card; - struct link_info *li; int ret; /* Allocate the private data and the DAI link array */ @@ -741,7 +741,7 @@ static int simple_probe(struct platform_device *pdev) card->probe = simple_soc_probe; card->driver_name = "simple-card"; - li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); + struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; @@ -818,7 +818,6 @@ static int simple_probe(struct platform_device *pdev) if (ret < 0) goto err; - devm_kfree(dev, li); return 0; err: simple_util_clean_reference(card); From patchwork Wed Jul 3 12:11:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 810867 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 C61C517BB1C for ; Wed, 3 Jul 2024 12:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008685; cv=none; b=KHwGO5WWpa7YLDEa+49C/Xm2OzCti4sp3Teh3SewGvBi1tNt6Y6fW7iFvQAsG9udFFP967cctLihcj7R/z0dV/47kHtaIUJG4V7SlaGN6hvDODSgdErw4MFeK1VlH/zfUnwsdp4ZTd9YEIgtJHPK8VwO8MYK13gKErXBhfqIWNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008685; c=relaxed/simple; bh=RsWsmysnuoF6fY/OCoGbFZiI1xwwnVRPPOdxwdqc+3o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nknEkTmUu4sne5YLPfUHpkq1ThAW4z5AZhZT8jlkbs+4rHFmu9utBRLmfXH6AATTKw+1KWvX1fvoMh/zikwd3vL3g7WZ3KZZLdLNOzr8D/fTb6NVpx3g3bVcUfGGaFpRYy38aSTqyWGAPCyxR/3cTHka2lRuFcauuHB7cOaQ3rE= 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=NsVJR+2a; arc=none smtp.client-ip=209.85.221.47 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="NsVJR+2a" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3651ee582cfso2931426f8f.2 for ; Wed, 03 Jul 2024 05:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008682; x=1720613482; 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=WJA9Libl+Uqmyn52YGiFDQqu33nD4AolbxKyly1SWNY=; b=NsVJR+2aOdEdFV7GCS9yekFecKaF7Wh7OyQil/wcGp54C6ay20118w/WoxPtmcAda9 R6/z5kjJEs5ahynF7ZxY9NqshcWFvMlhESiOp6bbgYbNhIP6oUttt8sSrxI9AqqXxDTX O/YmGMCiIGATwR10iWaBUCzxdZmGdemm0lm2++s+T8eopG0ybq0oTLPTkTJl41oyegPL FG1urnBWLytfbsFm5ZBpeNx7ZAwPH2494xtDlYFVEMvUEG7MmM15Ejdp79V7h6JfMaTv NwqFtryOlDUC7+Jxoalpon0JNfUkJK4gsCKEknzYJ17JX0IS3Oi84rifiQqUFK9zMvCj Dmbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008682; x=1720613482; 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=WJA9Libl+Uqmyn52YGiFDQqu33nD4AolbxKyly1SWNY=; b=XlD2Nootb7sdtvT5CcvIno6aO3+t/E0j2Z2KVgO6xRh/JzgLaviC3MJ+ywjxa6Y9JQ YSgmTydlNMLwcHOOb+l1o8E8HiKS1N1LMEOgdsZVeG5ZOPvikV0R/DKCvLhYq6ff15OW YUzmuF4N+fAgIH/n+DciG8LVyJPxmO5FGjSF5AuII6Raeep9dHFb7yWKHV/r5PNd4bnP Da6jHoRNODyOrBN8UrciCMoLKng5arbohejk1mr8RfmdB908lyUfTmH/ouJAVW17KSxl AdazsZWjWZ48ShmqwhnKv0iS7F0U7YwsP1kje0Xu46YjZVjwrmkt93EGVCc9f+zeCId9 J5yw== X-Forwarded-Encrypted: i=1; AJvYcCXgsujLI2sz3BfNEXXhwiENI2YnneK71HYKflgRs6SVCRqM9FQ3xWB1D7Kq/ewV2LfNKAm/VbhqIYoSwnE8WnHnor9o8a4hdGC6VD8UnQ== X-Gm-Message-State: AOJu0YzHH57zJjU3fH4IzrU0+M9yIItH5zArlLoMom4Qu5auDLJ7ZakG NrUdy2ocFCChxmnWO9ahSlbJu7w1LSucKvcOMnXuc5gdiuKaS5qGG0sNBukAcfOKOTFyj7ch7eF dNEg= X-Google-Smtp-Source: AGHT+IF/dzKmxxIVuo0OfSIDGShstJ+GWG2IgoFCIidChX+Z7q4QU3VbhgmbdYsAVhPZV4fPfKOv3A== X-Received: by 2002:adf:fe88:0:b0:364:aafb:5fd7 with SMTP id ffacd0b85a97d-36775725e0bmr7848589f8f.45.1720008681897; Wed, 03 Jul 2024 05:11:21 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:21 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:11:03 +0200 Subject: [PATCH 09/11] ASoC: ops: Simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-9-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2630; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=RsWsmysnuoF6fY/OCoGbFZiI1xwwnVRPPOdxwdqc+3o=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/ZFFYqtapjqgR+qkmLxS6NgXzZ72SPoiC+n AVOrALK50WJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/2QAKCRDBN2bmhouD 1wVjD/9Kmx9Xn33PLX+O7XctVZDImIZXAIG3VS1fDB+WBE3Ein5aZrxm2K8EqHw8WshLKTu0N/+ NbmILfiW8aIUfLIDgS/w7Bjen5cqwb4YyiT1pfCszbkNiFv2Jyc+MmxD3IXLwvWTr7AuZTqIILI l9JAeRHCPjEB2ch/Z/+UfsP1irQnj0d6xIgssBDxo7KRqPT2v/0vr3tqNDKKBnO3tkCd8D53lJW BJ5hIYReOcJXnyXU3mQB/GL0qK9daJygRgsofiW7Y94QzLtH6EMZW9u3pkTxrddhFXbD7q8Nvea 1a6SCrP8t1xmXUNFEphcHVPVNtPsTcH0IAHFufd/Y94WNI+bnMv+/GC3llrBbqaRxVxgcpH1Bd1 A7zCih62eVxnL2sbHpj/H9ADke3xGuuJ9x5BBWbOQQJhOKSU/k5UEscxiLla2DzcZykz0VpIR7z ocdZNaZhCc6ndeIPyrTNdZIpAfMmeyOkcbXUC3PuVzpR1i0jL/2BkOblsoa9+f9G+eCkLnx18XO oyPEFhdWrSJgr46XD9ADdva2yLcNZ/mCH+SCw5fP6Ta2U4gb0GKg+bJKArwkV1TsuxbUQ4rcsJn qLzd5Is+F2ga+9kpn5L72q578OAib/R87VK+XhAl50di/RTJn47RmDuuPpc1PyIPTJh8k713IGD fHN13N60FiqYYSw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/soc-ops.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index b27e89ff6a16..19928f098d8d 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -11,6 +11,7 @@ // with code, comments and ideas from :- // Richard Purdie +#include #include #include #include @@ -727,14 +728,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, struct soc_bytes *params = (void *)kcontrol->private_value; int ret, len; unsigned int val, mask; - void *data; if (!component->regmap || !params->num_regs) return -EINVAL; len = params->num_regs * component->val_bytes; - data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA); + void *data __free(kfree) = kmemdup(ucontrol->value.bytes.data, len, + GFP_KERNEL | GFP_DMA); if (!data) return -ENOMEM; @@ -746,7 +747,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, if (params->mask) { ret = regmap_read(component->regmap, params->base, &val); if (ret != 0) - goto out; + return ret; val &= params->mask; @@ -760,14 +761,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ret = regmap_parse_val(component->regmap, &mask, &mask); if (ret != 0) - goto out; + return ret; ((u16 *)data)[0] &= mask; ret = regmap_parse_val(component->regmap, &val, &val); if (ret != 0) - goto out; + return ret; ((u16 *)data)[0] |= val; break; @@ -776,30 +777,23 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ret = regmap_parse_val(component->regmap, &mask, &mask); if (ret != 0) - goto out; + return ret; ((u32 *)data)[0] &= mask; ret = regmap_parse_val(component->regmap, &val, &val); if (ret != 0) - goto out; + return ret; ((u32 *)data)[0] |= val; break; default: - ret = -EINVAL; - goto out; + return -EINVAL; } } - ret = regmap_raw_write(component->regmap, params->base, - data, len); - -out: - kfree(data); - - return ret; + return regmap_raw_write(component->regmap, params->base, data, len); } EXPORT_SYMBOL_GPL(snd_soc_bytes_put); From patchwork Wed Jul 3 12:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 809389 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 1E65217C218 for ; Wed, 3 Jul 2024 12:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008686; cv=none; b=Qahww7GzuP4BnKnJYCLUgSZ1lA4loHHS8bg9Qo2FxnOzT4R4OnLXMJ//IKmcsgrN/VRf4FsUdN3Tw16BbMwHbM9kPyspYp/33HUTsmSovGIoarG2zTzOutVXuIfn1DAVM6QxTdEA7K0SAUwLp7nAcaeupP61eelrMq7WGo689aU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008686; c=relaxed/simple; bh=PRQQy74IKpWXY3QRzTxqKhhESPCzDa1EA9BIIyylgGQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=imwPpXfd2dXKSWytqyY0yaoMvZhZs6cLMCeH2GMAHom/r7b72CGGWxiOa1FZInDRQ/jkJ0yRchlV8UeGu61cEBSCMF3WB6a1ON1AG9EHEUuRZHKhLo1jE6IBekd++VBaveNdMtoz6Z8gIQY7/YaxglXBd4ibwqi3vqgYsLlToYo= 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=JXE5XhlX; arc=none smtp.client-ip=209.85.221.44 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="JXE5XhlX" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-36796aee597so170077f8f.1 for ; Wed, 03 Jul 2024 05:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008683; x=1720613483; 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=vKX4owx3K95iTAC+SEBiaFm2gE/o+uY6tBcM1pCKsoI=; b=JXE5XhlXpGdYSSWjWmz4OcIsoTqLHamRpAUjunYHUg20ClujfePYILc0PRc+JEnON7 NXJcqnsTlVdXOtZKIquHHPCbZnMnCaeZn5AmL4/fjaL8g9NrOOZuzVGSM+cte2VevK+1 kI0xzUC2P5pufFI0Hpnu7XzN1N3RYzKpK3G9j0oX7MZkzxngi+j/SipoRItLzdEmpd1W alRKr/bBXgNsdxzVXV5o9LrDu7iQH7bE2qBzyAwW0gcM/TbwGkQKLUBmQlRGXLY6Gm4B V6ibEHvsz3Hac0bQnnYHvqa609BBCqoJFGWi8buqh+NZTFoZm9KHFiay//O4EnffQ1lE r7Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008683; x=1720613483; 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=vKX4owx3K95iTAC+SEBiaFm2gE/o+uY6tBcM1pCKsoI=; b=HFi5x9C4dZOYOmuOEERG6ayq0IlqxScHhBNx4afPJLQJWSEOaVZ5koOco5L1J3+Non MguvPt5NQMit+frQ0UnWTqy7e6xVVKZXnAE+Y9b2Sp7JgTWliIyzw8h69Og82MLhx+wf 7TvN125YebYVPPQZ+wAms5J49Vhd5eAbZwg621LHzvMzoDqNrKwknvcYbA6oYd8otUgK oC0frsysKFn/SqoUwISpsvTW3O8V8Y3spA1A/TRxPgAniYMCIyMIyJR+871IF3npFpI7 u+Osgoo5jgukKBLeuaFG/5av8tdNvIMLOoAouxxerv+61AkWObrLslxJGt2h217XrOTw bTfw== X-Forwarded-Encrypted: i=1; AJvYcCVYckEuV1hm04sOQ+QbKEZIDoIOtfQgfqkP66YZN0VlwURVD90JdrEGHdGEG+qWU59vusvejh6aLmqO9Nri7+dAN9LpY2E09+6909UR9w== X-Gm-Message-State: AOJu0YwutO4ZaDaLn0S/V7V6kpJ23bZOHetxn0/3PbYmjAGbIyR43Yh1 qfCoMv0eHGI8VVsvkhoAuBJxrJmmIazCILPVP6D/LlCoJQn4ao05K0/P9Z9DzUK6TiKpAy112qL IuPU= X-Google-Smtp-Source: AGHT+IGqluTLxpMaeApU+pNJokz5T0F4CHd4vNq0sR19A7/Trl8lK6C+BdOafaCFJJwBIDjLYOjGRw== X-Received: by 2002:a5d:6a8f:0:b0:367:958e:9822 with SMTP id ffacd0b85a97d-367958e9b0fmr781281f8f.14.1720008683326; Wed, 03 Jul 2024 05:11:23 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:22 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:11:04 +0200 Subject: [PATCH 10/11] ASoC: dapm: Simplify dapm_cnew_widget() with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-10-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1635; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=PRQQy74IKpWXY3QRzTxqKhhESPCzDa1EA9BIIyylgGQ=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/aXmraSNTcjJCjdJ7G8Qpn/Wj7KF+TwsTBT Oivb/6xzeaJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/2gAKCRDBN2bmhouD 11BgD/44ltVETo8dFBbkx5BpxYgtnLMW1PexinlwUhGnV6rJEoMiokxjT1QHF7YpnBtavF+7d56 FXFNhVMRkgrOaP//aW+RoWhx727o7KjPurvec9Yqbhvp1fZSgP2fzfaZkPIxsUosyeSu3NzPJeB 2gc2vIuwe4BFZnGIE7eG4w4OYiGLR/xZYb2dfRU6YpjHJZJnReLTu59NgvCR/8PhgHJ9u3Typvp iOxG3vJyIYvwdOpQwCX7z+GzjkFRjVVM9p1ldTLsPbdNlwQ18xcTpo39j10W8Ijc0aRgtPxhoJ6 6NiN83X57gYY6KiJb5KPUPrpB8y8UwPcofDE2PXISKRNjtpo2juJNETaGt5+9MiI6ZcNfIoynRG MPDOuvZFTU15x//703SoVXViSKKdAUzZAJxx24ZW0Co308aPReIdYK3u+qIXhk+U9S1EfdLohpS DD3UZtxoRBJCc/CuzDASsDeacECYBxmqqJ5vmKtr8dq+biTheT1CvoNE+9xs4ZFnCoYkD0FoidO 4MFJ3J8LH34qn1kaSjgJSK/PgutLunY0Bv/VX6r9/vHVvG2BGITpq6Z9j4qLnXQ7oj2No5WitBi hl+ZIAONea82+MTev2qbmrxX0F0NsGwJdELbV/zdhdvgupKk7cZLdZvlyjKaS86GO/LBpUzvhni 7zvb8cfJn3lBucg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h in dapm_cnew_widget() to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/soc-dapm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 16dad4a45443..236aa3c8eea1 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -323,9 +324,9 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget( const struct snd_soc_dapm_widget *_widget, const char *prefix) { - struct snd_soc_dapm_widget *w; - - w = kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); + struct snd_soc_dapm_widget *w __free(kfree) = kmemdup(_widget, + sizeof(*_widget), + GFP_KERNEL); if (!w) return NULL; @@ -333,20 +334,18 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget( w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, _widget->name); else w->name = kstrdup_const(_widget->name, GFP_KERNEL); - if (!w->name) { - kfree(w); + if (!w->name) return NULL; - } if (_widget->sname) { w->sname = kstrdup_const(_widget->sname, GFP_KERNEL); if (!w->sname) { kfree_const(w->name); - kfree(w); return NULL; } } - return w; + + return_ptr(w); } struct dapm_kcontrol_data { From patchwork Wed Jul 3 12:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 810866 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 E9ED117D892 for ; Wed, 3 Jul 2024 12:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008688; cv=none; b=OrxjjDLd/2oi9xYNHTdiPnfhTJhiUf7Q8NtqZT1nXs91yKksxQ6t89zDFUmi9LPx0Vd3/jeE6bjZKKZbFric80/5VWL78m5LhMez9Q7+wNnAP5Zk8BTUJbSGbg5AQtv1iyoMd3hfICgp9Z4dHLG8hc/ZTMplpvOF7aYjABknR90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720008688; c=relaxed/simple; bh=ocz/1r0t2NeXjhVsBlqlh8PIa6EhEItAnc8FRU38Kqk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nf+dfKVlF8lVu3cHnKg5nslFdGx5MFTstUW0jGw5E9wD0+5IucBW+BFr3Ge6dSAKgnyszMgPISqdZzb85cbyqofLuNXMNMn0tDFw0FE40a9HT7S4laSqpjUKr7nHgktc2czhwx4XFGXzivRZvTuApp9vqV0y94NGaH7q0x28siI= 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=rH6AgwOR; arc=none smtp.client-ip=209.85.167.47 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="rH6AgwOR" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-52e9a920e73so462614e87.2 for ; Wed, 03 Jul 2024 05:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720008685; x=1720613485; 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=dztGUki9Ak6jIf4+9h9y7V5UCrSXr1J8tuwOdQ2U8CA=; b=rH6AgwORQ8vFCIqqAFZBjFXWRzAzgRCGfyqrqho6o6gwsFUo548aFqS5dMnziwXZW0 HcYIkezGd0WwySxKf20jcAUAZIvMHmScyZjwA8Q6SGH6PVznZWs90KEh7Bbx+/XO6E6i WXf6BtNL90Wikdf8hCOJOVs14eI7HBvAYkQZ+DSnCl0H3yjsvTNlGZzeyDl/+s7oD1C3 4uGDwLUbqrKVqMX5fkDllEDpRXaaPFarsORlLyG1Mo3nUwhxrHN+NbhNpHRcpuD/oK/m umjM815zsqhnht1q3EwuqwQpcbwbDoC7BwNMDP1rDP/oVLpLjt+jm6ifPVXtc1WW+ZXo FLNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720008685; x=1720613485; 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=dztGUki9Ak6jIf4+9h9y7V5UCrSXr1J8tuwOdQ2U8CA=; b=S3Uz6zHMU7NoAGBuvh3FvAM9rEVOfrV6dVAOYQDONYP6bsA1Z+k0VHyXPDzawy6nF4 Bgd1wz7keN8v7ZJTQ/nr/2MmvUOzV8F8lLpIR2HLDg6AqLSmTMDOCK1/WMmdvTsksBe8 W2pMryAEMWGaEipaoPCF65Tco9PJGbPmsPISVjbWJvwDTjcaHNlEWrVhuUj8pteXkp8w asIMEQf0cXZngqeIGnQ5mdvcLImRMGgiaz/sMwtDViE/ILVWcBjMvCF6VKURn+92rEam GEtqk9P4kIZr+6jv2H8SCKQWGwEXI9TvUZ12t+4/5uhLeDWbfEU32+aQon7pox3/FFKz u2JQ== X-Forwarded-Encrypted: i=1; AJvYcCUrQFMcz+BL1raXWxfjGoj94cpuUy9L2sK+vjyQebniTEtF8U5GH1DOZPQ/6U9IO64nLbzs6YDz6Y8OEtJsS4OIKsLpwDP8B641voAIZA== X-Gm-Message-State: AOJu0YyJKD5oaS+kpGweUkP1kv1QT0v0Oh0YVX9omXzcMt6CsxJy5zya hHFQPGXyxwDMDdX5bIMmBw2V7I61WxbkzUntmAHV7SAhQ2UFiibuDu/hFbBhXzDdachzsRZzAgV P7Yo= X-Google-Smtp-Source: AGHT+IGNlkQo2U/mD/9Q0gW4rGoUl/Mk1IXpMr281TpcdB+aTLXI1fJpFBZHFvhjmGczWXJCD0A4og== X-Received: by 2002:a05:6512:3a83:b0:52c:dcea:86e2 with SMTP id 2adb3069b0e04-52e82646dd4mr9034143e87.1.1720008684737; Wed, 03 Jul 2024 05:11:24 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm15716222f8f.94.2024.07.03.05.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 05:11:24 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 14:11:05 +0200 Subject: [PATCH 11/11] ASoC: dapm: Simplify snd_soc_dai_link_event_pre_pmu() with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-asoc-cleanup-h-v1-11-71219dfd0aef@linaro.org> References: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> In-Reply-To: <20240703-asoc-cleanup-h-v1-0-71219dfd0aef@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3431; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ocz/1r0t2NeXjhVsBlqlh8PIa6EhEItAnc8FRU38Kqk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhT/bjwP82Ll7/Nq3E6/J1YP7S7FSG2p3Rdr/N yTrQYiInu+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoU/2wAKCRDBN2bmhouD 1zcRD/94Lda9sMm0G7QiNx3/BCP8Knn4BEHAJ/1nV+02XXqBJHOiIM3wg/uwJtiTzlQntM24Zat 3teyDWqFA5YYeSe/86lkREkefYyFQ6nWFGq9QH4Q32fVGpdhJb2gwSRGtvwO4zoLGQIBwsOa83U xJy5HJyg4qpx2OHbyncoymS4fSR2mtmnymx9SHl95mAExMKX2g4M55KsGv6fYXnHoZ9EcY+KJVd OG1OKvBm8oBBmlpa+gReQhOEqfYNtGZey3+gwHPah/Nsn4sojeFzQ0rRgwejELXxNPiHICokR87 gSiA0O6A8jGF6Vy8AdzcFbJEFyxOOXIHMnVXT2x4TaDEGdG9VZzEP9ZPnPg9dAsLjQEbwnGBKxk 6VdqN3VG25DGsYpM5Rmj6G4CSJ10qj1wkgeC41xYHTuPKr+2IpEbU03h7Q4+B4aR88dL+VYmFC0 zRFI0B4nNnyDI+Ea4V5itvg1aIb5HVy4IQbRHTeKQ/iLMrwanzWCn1yZsRBLGPswwxqUdBHX3cK xBIceH3GYOF/+WCN62NKbu5J/JxkH2Bn19S22rIajO2ZZAbBjFMeqhRRUon0YI3GqXO0CreBtwl th5pGtju3/Yx8jL8jEVmDKS++OBMCrMPOtjZeo9ypw2ddzgy9EKDqolk6u3XB3b3LScGGh9xZDV 4125OyJ7qHqKw0w== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h in snd_soc_dai_link_event_pre_pmu() to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- sound/soc/soc-dapm.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 236aa3c8eea1..fa6f19d26c78 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3882,11 +3882,10 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_path *path; struct snd_soc_dai *source, *sink; struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct snd_pcm_hw_params *params = NULL; const struct snd_soc_pcm_stream *config = NULL; struct snd_pcm_runtime *runtime = NULL; unsigned int fmt; - int ret = 0; + int ret; /* * NOTE @@ -3897,15 +3896,14 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, * stuff that increases stack usage. * So, we use kzalloc()/kfree() for params in this function. */ - params = kzalloc(sizeof(*params), GFP_KERNEL); + struct snd_pcm_hw_params *params __free(kfree) = kzalloc(sizeof(*params), + GFP_KERNEL); if (!params) return -ENOMEM; runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); - if (!runtime) { - ret = -ENOMEM; - goto out; - } + if (!runtime) + return -ENOMEM; substream->runtime = runtime; @@ -3915,7 +3913,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, ret = snd_soc_dai_startup(source, substream); if (ret < 0) - goto out; + return ret; snd_soc_dai_activate(source, substream->stream); } @@ -3926,7 +3924,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, ret = snd_soc_dai_startup(sink, substream); if (ret < 0) - goto out; + return ret; snd_soc_dai_activate(sink, substream->stream); } @@ -3941,16 +3939,14 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, config = rtd->dai_link->c2c_params + rtd->c2c_params_select; if (!config) { dev_err(w->dapm->dev, "ASoC: link config missing\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } /* Be a little careful as we don't want to overflow the mask array */ if (!config->formats) { dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } fmt = ffs(config->formats) - 1; @@ -3971,7 +3967,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, ret = snd_soc_dai_hw_params(source, substream, params); if (ret < 0) - goto out; + return ret; dapm_update_dai_unlocked(substream, params, source); } @@ -3982,7 +3978,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, ret = snd_soc_dai_hw_params(sink, substream, params); if (ret < 0) - goto out; + return ret; dapm_update_dai_unlocked(substream, params, sink); } @@ -3992,11 +3988,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, runtime->channels = params_channels(params); runtime->rate = params_rate(params); -out: - /* see above NOTE */ - kfree(params); - - return ret; + return 0; } static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,