From patchwork Wed Jul 3 10:15:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A0A0C2BD09 for ; Wed, 3 Jul 2024 10:37:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1FF3C14DD; Wed, 3 Jul 2024 12:37:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1FF3C14DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720003062; bh=spgt4+9qxflitv4UZ9Bu05Oaf5uCcTTFwks7tVlyyyk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cDWudupS4qlEtq0O7H2ywA1hpcYd9uQoqqCynyPZKwliZiV1kqoFrS21efDo0hDc3 tvKOBx7aIaBMZ8LXZ4/t5RxKa3KRBw1qtm2lTdoGsAul2JoqfeCnLOQziXwNQqW8DH 6y519DI5b1yERPnvAoRlXUSVIHtiNI9TJpNQh64k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E5AA1F8062D; Wed, 3 Jul 2024 12:36:42 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B2751F8062E; Wed, 3 Jul 2024 12:36:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1C44F8014C; Wed, 3 Jul 2024 12:28:44 +0200 (CEST) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 151FBF80587 for ; Wed, 3 Jul 2024 12:18:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 151FBF80587 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=K+PTQuUk Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a729d9d7086so87463266b.0 for ; Wed, 03 Jul 2024 03:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001773; x=1720606573; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aNI2ho20l/ka7Xx+ilkgiXagRPnJI8t8zqq0ZnfN4sg=; b=K+PTQuUkpn5wrr1Ig17/bWTrZyqfJdLe1COwTrDsBEvqYGeUs3sDFHKqB5sqoCwJfp ESweC0I2cbTanGimUPNS01Sy49A+6EfyLTGLShxc5+DgiI+tza+9aUFS0LiAwzPbVuF3 8+hvyZwx+WjnSzlD7jY+pcdu5krUnL7RuAeFTxcTLX7Wo08k3uVGRzB7nffY1/GpW/fL ObdEpSVVjmrUhkCBYi5Gz687y151X9bSp7ZNJXmYZIGGJ5w7Q1d7tSZ83FCUH7mNhymF PZjwGHh9GyodU/y0RMyd5DjwJrrWkn1MXOhg7IqG4P2GqdeNLaQJyMm3xbna72DXSd2+ SbRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001773; x=1720606573; 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=aNI2ho20l/ka7Xx+ilkgiXagRPnJI8t8zqq0ZnfN4sg=; b=WWDjCsqRvh5L2hTHTh+wbjcjRC34/eXtPxIduWOa7gP7zNwh0qaGDSuVdVtBoKoOX3 HjPlGdo1WyRp/X/BlL2t6z+ItCBOx7Ao5r7+pJ+Zs3DBKx33PHsHCl6umfsdRrnFJMyt dF5uYr3zQx0TePTWoYIBwVHhQngM1sTe6DCBBaTS0L3zhC+Wh/PA2z1YDPZtIsoJc4CT Udwp0tqilCf4OI3JnyWmccYQW9Z8r0E1171bVuTPbsLznPED0+esjYZHwLxBccZzhGnb uDNtaKtKPgKiuc309ipkY769Tbew2BmizJ1YremsNVmo/GVDIcVdcB7P/4ENjNzS/oVD EW9w== X-Gm-Message-State: AOJu0Yxhx7NgdM2VQdqrDJKNHDZ7cb0z0iqmlFEFFbLZD6dO7PyoxaCJ /i4yGBXF0c+H/1ueeClg4zX9SNIa/kgtLdQpszt5n30fsYl64NJrT5i/AjwZf9I4xRiM6QTMG9s 52G4= X-Google-Smtp-Source: AGHT+IFwvHMeiG1PusuzlYb/BFpwlNvMyLpyqwyCsLc+99Ds2Xl5m1ldYJi49+/zg/u8Ua72v8fKPg== X-Received: by 2002:a17:906:4755:b0:a6e:f869:d718 with SMTP id a640c23a62f3a-a77a244253fmr95689866b.21.1720001772744; Wed, 03 Jul 2024 03:16:12 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:12 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:53 +0200 Subject: [PATCH 1/9] soundwire: amd: simplify return path in hw_params MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-1-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1011; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=spgt4+9qxflitv4UZ9Bu05Oaf5uCcTTFwks7tVlyyyk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTizydiWsNiK1lACRmuFWUvFUfjVVfPft6QQ GqZjW9cjMWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk4gAKCRDBN2bmhouD 1+OyEACYUGyGkiAqfA3VhOQNjJGbNBY3zshL3OR4Dp0zNhFrvG213/9aF09o5CoUJdjL9OVYlT8 cULDGKCXWhkP7sj//ZtO64dP/cCN7IHWvboimzJjdyzFIRmOU0F8yPJLpWT+5H94tqeYscQXZbk hVZKYfKfY2UIDtdTU3fvoyve0UovB+45qay3vJoU++UFxKYkOG1dsDn7QrkCSfe8NQWs7SEO45B fp84f6O8pyMo/Ukj+yHj9r0y7LneFQsDHpGjBkq6dzYbnWKmc9CVzFXiuzBLL585b/PX7BQqr3u cD5tJDKSDoe4vF+JIN4JgMDoTKvw7Yud5ryMhjMN7EIhSVBkmLET0UIeOkwB//YGBRdev4rE8lV yHSuBZQF72sQfk/GOwl//j74lQbIjoGJbXz1JqaV9PXJWm34wz9saXzWcd8fddpmfo4eQk8gCwE 7Ak8qXCX1cN8I23mA9Qm9aEV7WXzaNa3uou/yEyRMIeKIPjqsKslRBpYzViomKA2L2SzCA4FMgr bE6y04hLFzcFwlVJA5JtNirAuQMwiY5TZaCY62upQRXUPWa+YOAILvBCYA7AaL04W0dO4kDH9+4 C8py4dpNKxikSvBMwPx0Isnori7dK3OWCOqjQp56TGnQYDbSuiy+rdNfJ2zqWBHl2T5PNWrPr/j 54nNNwjTZSABXGA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: 76BEDNRDVVKO7URFSDBO7REGP6UALM2S X-Message-ID-Hash: 76BEDNRDVVKO7URFSDBO7REGP6UALM2S X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Remove unused error path (label+goto) to make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/amd_manager.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 795e223f7e5c..4470fda83c5c 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -627,10 +627,8 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, /* Port configuration */ pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); - if (!pconfig) { - ret = -ENOMEM; - goto error; - } + if (!pconfig) + return -ENOMEM; pconfig->num = dai->id; pconfig->ch_mask = (1 << ch) - 1; @@ -640,7 +638,7 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, dev_err(amd_manager->dev, "add manager to stream failed:%d\n", ret); kfree(pconfig); -error: + return ret; } From patchwork Wed Jul 3 10:15:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7CCEC30653 for ; Wed, 3 Jul 2024 10:36:50 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 35E0CF54; Wed, 3 Jul 2024 12:36:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 35E0CF54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720003009; bh=Ol678uS9dQ4xA1iTWHOJsbF5rd2bR0cJ9zqotT/ChuY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RU0HmyXvdjMNy08vmchN9ervVF5e3SjCqSuJwqt+dLPD9YB6cLyjQXR8H104EsVwq nKOqMnlrCqfNiqwxaFgWqCFNuUnI0isSQvu6fji29NP8SgHPKCuIg3qcNwP1lOAUOX kBUeQ9Q+YNAfACNDgouDJSAqVMLZGcm0+iUfoSVU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74110F805EF; Wed, 3 Jul 2024 12:35:55 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B43B0F805FC; Wed, 3 Jul 2024 12:35:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 294AAF8014C; Wed, 3 Jul 2024 12:28:36 +0200 (CEST) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C43C0F80568 for ; Wed, 3 Jul 2024 12:18:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C43C0F80568 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ye+F+Q7e Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a724958f118so636293666b.0 for ; Wed, 03 Jul 2024 03:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001774; x=1720606574; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Eewbky52yFyCjHy8tFMyxq78GyiBRf7ePSPsH7UZe34=; b=ye+F+Q7e0TbLT3h2+IT8y0lrUx0r5oa4U9NkRdH9nhfKtdQBHTg654hkYmVGzTfgMP WBQ56dfyvE/5pHzyn43WQ1w0XFS9veqa3A7RnoVOtLqTQ3Ms9D4vBBTeVyqeI576kpoE VgipjkDkArsejLVXPfeyzaYqMw+koLf9QGgpcGNOJtMWa85js23PYCg3aSYqy6OihwUU b55MZ2BqIQR7KgeH3VFkpAIRtFpjOB2knq4eCUAdQv48NRjr0cs5GL0fw43cOqNF5uH3 6b6cMW1br3k2tDdzEhpEXz95RgRChDg6SD2I0AK672M2q1MH59sBA2XqI7m5bY8fMyKC 9eYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001774; x=1720606574; 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=Eewbky52yFyCjHy8tFMyxq78GyiBRf7ePSPsH7UZe34=; b=gkKn2FwVou+sBC8wsPUD1GSm97lerW0scGqEbQXwZ3gK0CFIrBSIbhb5MiTf7v/O3d cGCM/CjAG711V8BIqv6MXgM0Ay15lx/MW6xncJeyYyLXtajFcIk1JjllBxACt4s4PQkW PObNiaqzt3i3lg2PuBqOb8YkcbvMBHSqdblbyvNPK7wo3K5eN4/6vX+uBEXjAl6lU7Z7 y8rekQuVtQG358xTb0e96UnsMKShN0ErxE5Duggzpb8iHyPlJAqmH9H9Py6YTjhVTI9f B413e4fXiQ4QTaKIcaBfjyOiRJ21c1kmolqhueco8nAexPoW/L9J201GJC9nNtftXawQ AItA== X-Gm-Message-State: AOJu0Yz7GbePCJUG6CSxr0DO6M1/m9/2K6gVbMxz6G8V7/BBVpf+3Nid MP1RR8f4G/DmDuhNIsIK2BPV3mV2b87nCjW54A2IaBB4nRnttZN6i8pHiBL7QLU= X-Google-Smtp-Source: AGHT+IHmjbSzPCX5JxTEYJT9gZmcA5MeHmQoPhQv3t1ZxolhjaIIPWitPETXciwwLMO8r6zR017fKw== X-Received: by 2002:a17:906:229b:b0:a72:4281:bc72 with SMTP id a640c23a62f3a-a75144dd493mr756319266b.63.1720001774022; Wed, 03 Jul 2024 03:16:14 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:13 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:54 +0200 Subject: [PATCH 2/9] soundwire: amd: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-2-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1555; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Ol678uS9dQ4xA1iTWHOJsbF5rd2bR0cJ9zqotT/ChuY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTjzmj5Rr2bqkWjyjn3muBzm30I9Ht2Qp4oK 8nKJxeL+OeJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk4wAKCRDBN2bmhouD 1y66D/0fKO4gzBi5mD4kXweROjCrsgr94HyHuatSkmOW3tA8yr7ADL+1MGVFenX3CB99m3Gm70l NY0xWe5alMpLkQbelrBouC402XM7AHvM7m9epYbZjFjMT3mjZwweYcwfoQhQqq0j6g+xh87mL7t bMnnl8UWMlW6ipJciZsNQvh5weMNCkPawFUQPzy1wb+LmDX1Tzk3SN0NnXAAf0oz6wJU6PE/V7M hFE4hJ+SQzmWuDPykGrCRi+nxcT4FI4APLYoctY/kTxpD1IPSvYuu4n4jnc6+D0UqdLgWqkOesh dC5ECkcu6fzWdbGSMNkLyxcpScB1RjsNGChYAi5kVxIb0uSDqjIlveUOYFSzT96yu11HZ36kdZC dsRbP6BoKv1st4oV9na3f5lNADHUIEp2Rbn7xigza3o1Dey13i8ce1UNYp8HITxK7A4DGg6HaTt qc3Zhd7kLWksAuPlDVXI6QtMzY9nwvSGynRMNcVj/WiqixBElXJ8pdHnVIU/h3pjOLEtWzO0Eyw os/K+v6q907S3H481NDaFYj3PHMlmcr2PEOk3z3WzC1DVWaC+M+28uyT3CkNWR+fst9QaBVESA0 xgav4X5dmMRz0OXimVABXLLjYQPpt9zNEKy1lgrqzfHmvrmPyfREPioPwPTnqM74t3jfasBhGEG D/zwGI5F4jvh55Q== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: 37MWSODQUZCYO4MF2S7FEN5NX52OLB4S X-Message-ID-Hash: 37MWSODQUZCYO4MF2S7FEN5NX52OLB4S X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/amd_manager.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 4470fda83c5c..0d01849c3586 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -603,7 +604,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai); struct sdw_amd_dai_runtime *dai_runtime; struct sdw_stream_config sconfig; - struct sdw_port_config *pconfig; int ch, dir; int ret; @@ -626,7 +626,8 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, sconfig.bps = snd_pcm_format_width(params_format(params)); /* Port configuration */ - pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); + struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig), + GFP_KERNEL); if (!pconfig) return -ENOMEM; @@ -637,8 +638,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, if (ret) dev_err(amd_manager->dev, "add manager to stream failed:%d\n", ret); - kfree(pconfig); - return ret; } From patchwork Wed Jul 3 10:15: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: 13721901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 539F1C31D97 for ; Wed, 3 Jul 2024 10:37:28 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6DC971930; Wed, 3 Jul 2024 12:37:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6DC971930 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720003046; bh=Nwe0xlKfiyDOaLPbyz9qVTptKB4D1oRYsTHNGpFlOMk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Qcz08paUCnhOborTrphvK3AXfGP3ht5eD8Atrso5iFx9GNazQ1xqYWEuaDlfyxjNS EllDuZNuerP7F7C/kcN7aTgtjCkDLyLPfhQ/eDfBvQCysDEmpKEoArp9pFq2Hp7S+r 3Q8DWcqzVCvIY1+jMyBUGzDbV6858EXGmWYZqBhY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F00CDF805BF; Wed, 3 Jul 2024 12:36:34 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 1E945F805A0; Wed, 3 Jul 2024 12:36:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9165FF8014C; Wed, 3 Jul 2024 12:28:43 +0200 (CEST) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0607FF804FC for ; Wed, 3 Jul 2024 12:18:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0607FF804FC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=oOtJJHcB Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a725282b926so587854466b.0 for ; Wed, 03 Jul 2024 03:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001775; x=1720606575; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GfTnFwv4IUNzXvE0oSrrhVXmiYatYs6QJJBq0PCSPdk=; b=oOtJJHcBMvtoNcCkcFOoEwOSfK96X3fRM3kWvdVGIRsc2L0k2s666KmXIeEpLh97mE /HJxE5x2AOQdMgZuTXjvJV8Yck9XrGF/F6EFhqxqCdC0jua36T//cr4zvF/vYFV/IL1o fl8I2Kk6WECImhjSPxre+DqIA6u+l9FZpV8OAUtZSDy0C5LPdAXZTamxoMC6QOJpk4ir BSKNvrROMl7JG7vvvJdyw68zeRPBBkJuN4Adwhjcy7D6uYMZ9Zh+ob5dq518ND2gK6hm FjU8UqGPy94MdBpr1AZkif8t/C5SMgvgoBbgKLsA/ngl4zodsFvs1UaOKVxLIKUtaFbT P15Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001775; x=1720606575; 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=GfTnFwv4IUNzXvE0oSrrhVXmiYatYs6QJJBq0PCSPdk=; b=PTdcGJ3n74dEnqQisMQZkKLJhamI166t1yoHgjcD+6rq0YPnbjQCPq7qxnIQ5cXmNM bEJ8mNWLj6G6TW3G7Rp3l1dz/BuuCSHQjsVx/zQOlIBzi5B8KtnXtAv3R81oQJX+CiLA Ikyde35VrkzFOZO8mxMOwFnQfWqtafsnVZcohTkzhqI0lQkzoD7Igj6gGxiU+X7z7IN0 sCaU85sSjjCku1w5hPWuJ087gP+0xcDjYBAL5VMH5vSf2cbYIEIawHQOHg4b4bRTycgx d+dYGRWj9G2l3Hx4fxtHl1gYc/AYwjbtv/fOMLvF8jMzYailhYNOao4a56zorZC92zAT noYQ== X-Gm-Message-State: AOJu0Yz4VNDBsTy96pDy6qAGW4VQ5cd2J/EjPYdL/x9yV31awPC5CKdz spHACaTrv/KMu7hOWEcH0mP3Ah9FJv0slvJstQ2MFkxXOiChKBkLASYcRoQlyLM= X-Google-Smtp-Source: AGHT+IHEpkDA1cTbqIue4QyD+vUx5qAFNk1xfrPOtv5WQ36h5sxJbjzXsmByi+3O7e+BsSkBPh3SRg== X-Received: by 2002:a17:906:3106:b0:a6f:5609:9552 with SMTP id a640c23a62f3a-a75142d873cmr807100666b.10.1720001775533; Wed, 03 Jul 2024 03:16:15 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:14 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:55 +0200 Subject: [PATCH 3/9] soundwire: amd_init: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-3-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1703; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Nwe0xlKfiyDOaLPbyz9qVTptKB4D1oRYsTHNGpFlOMk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTkpUkUyMw//T6vaBK4PU7FEkGwJPparyv6X fM0Zahd6duJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk5AAKCRDBN2bmhouD 18xzD/9s6VRQ9i414HlaH5OFxg36sEnNg9LfehqxzJuG0E7kt3XaAmMcYoA2rR7Ffn83iw+4AJu 5ItCS9iNlNtl+pXecAinp547m3YU6QH1PiZCNXpIfF7ETnnj7tbP3D442qaKDJ1Q96eOpO73EkY dSDeTNjC9wr6k4vgLpUqr4Rz5Y63SBEZm9E5WBHcCgTI3Zu0ha5hOuKGd1Z1qRuQCpN8UWWZt0F hn1NOznUQ6VPaZTkkCyv1RQWyncGN5t74p65+LRuPP577dlgq1gH9OQLEin9e1zCF72Rz/iyvxq KFTu69tQpmmNfSVh3rpOl81860NqcReO9+DQnBPSeKLxHSn1H/cM4RavuXiEozPfyQaJaTdufRr tstL3LTVrdanQrVXR+d8uLH0q/Ylu4ESxP8RJqGTeomCgkVdxD+/9JBvFM7LExRuW6bUlMeyCfu tvu7tx6CKGuv6CRwLEHIguOp1ZrXuoIB+YMvM3Q1ii5ZFflcKOXHINYDfzEjUWrnTt071E0csmC oun40ZtnuDT0yUI9Ll+DilLTcM/aIAkPp2YMtYlrsf/NLs/O0sxanFychJhb+0ZFxVR8veVRgaS rKvmhypzuD+87RRhi5Z4fzp6Fu3ox+wAg2N+8PTw6eHp3qKty+v30+ZCm5U5d4uWX7og5ZssvXo l9JutBGgyHSEYmg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: QACDJIZV3E264M2IVCT6J3AXRCENSQD5 X-Message-ID-Hash: QACDJIZV3E264M2IVCT6J3AXRCENSQD5 X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/amd_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/amd_init.c b/drivers/soundwire/amd_init.c index 4cd26f3a21f5..db040f435059 100644 --- a/drivers/soundwire/amd_init.c +++ b/drivers/soundwire/amd_init.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -69,7 +70,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) { struct sdw_amd_ctx *ctx; struct acpi_device *adev; - struct resource *sdw_res; struct acp_sdw_pdata sdw_pdata[2]; struct platform_device_info pdevinfo[2]; u32 link_mask; @@ -104,7 +104,8 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) ctx->count = count; ctx->link_mask = res->link_mask; - sdw_res = kzalloc(sizeof(*sdw_res), GFP_KERNEL); + struct resource *sdw_res __free(kfree) = kzalloc(sizeof(*sdw_res), + GFP_KERNEL); if (!sdw_res) { kfree(ctx); return NULL; @@ -132,7 +133,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) if (IS_ERR(ctx->pdev[index])) goto err; } - kfree(sdw_res); return ctx; err: while (index--) { @@ -142,7 +142,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) platform_device_unregister(ctx->pdev[index]); } - kfree(sdw_res); kfree(ctx); return NULL; } From patchwork Wed Jul 3 10:15: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: 13721777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8900C30653 for ; Wed, 3 Jul 2024 10:31:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AF4BA10BE; Wed, 3 Jul 2024 12:31:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AF4BA10BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720002715; bh=6uKd3zEd6o2IBq3WPpQXHIDwXFMOpWhIbBFNpjD55Eg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=h6tFJtLyCKy0rNs/FdY4AGatWLom/M18RJ8nypg7JNp0kO56kz7KXwoH6Bh4GYV1T wrld+jrSk9Jom4iFHoJd4Cwm4nWFrZ/CvtPkDB/NwJhKMXEjoRWKbRBZmNA1/lIIU2 lqUP+dko91wA9vf+gJaq1TUV2/KAskdiqSzPwow8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4498FF805E2; Wed, 3 Jul 2024 12:30:48 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 40384F80600; Wed, 3 Jul 2024 12:30:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E4F0F8014C; Wed, 3 Jul 2024 12:28:18 +0200 (CEST) Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7B514F80272 for ; Wed, 3 Jul 2024 12:18:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7B514F80272 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=fBTw6Ki2 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a724b3a32d2so608304866b.2 for ; Wed, 03 Jul 2024 03:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001776; x=1720606576; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2RGXPX/CSKzMjftTA4WDyZ6uPyqorccsRYB38Y+ET/0=; b=fBTw6Ki2KK/QoaKEwRBEP2YyeW33xWR+m5yRj7pqRIuVRuSBRlG0WIj/HyWtm0MeS7 enOBGySKAxNf6GMx0XDy8072KvlwBcEjP01s2CiiphMwKcQjLCUbD1HZ5kZBIxzU18if vmT2K97N515w4hPnPEjY1DCF65iEYuWOMO2wBkVOlYhMS8N4Rn3ESUvsZ08ZJBOp1Vc2 B3MZDhwxLdKQ39WLxqb0mM1Lqfp/9EErNY1/T7F84jAONiUrVI5JwLTLBih6MA71uvVU WMltOlEIKrOLLjT6OTJ7hfkyH+d92VqW/diwEVMKDsphG2DSEh7o9K5EQEeMPJoOxO8J cBQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001776; x=1720606576; 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=2RGXPX/CSKzMjftTA4WDyZ6uPyqorccsRYB38Y+ET/0=; b=hHg+dT3OtwqQV1jdxM0KpLdUo+3XHzIdH+lZg9mAseiJubdoS5P2wmlq869nZfcRJO f9rm4N4w/PhMQ6pv6ih+ZMnNMDKTnBGhMEe+z89XPCo5WFXY+NTa75UXs95gFwrqqYEu 91CZzLudtR7iZLQsHYeq3paI7avzQS0mJs/OkM4B/FK5qcRH6mUyfzcHb50LBxRvUjPQ A4G9jFjqY26V6dhS/7xNEyvGHJpep+sUn6+jBkvtw+FQ/sduPIVXOc7HnNQlAY/r7c1n cDSMgL+e20D7L3eS3SXDfHKqlfMnW+gpvI58hKbzyRYYVNQ8qyg6rSIMKwfJvF8Msybf IsgA== X-Gm-Message-State: AOJu0YyKDQgf0VPKtWzYDJChiPreFNsDihAffxj2DcLPo37aP1InZFa+ NvNaM44x+wbStlSuhom228VMMEhkgYliuWEy5JKV6pROFOhofydVxRVcH6YcojQ= X-Google-Smtp-Source: AGHT+IFpjC/UncuvZVsjweNMYxrJoEVZ09OWbbmaVadtytsY9DAfzhNDTF5hguxVUFge710PE/lfJg== X-Received: by 2002:a17:906:ce28:b0:a72:7c0d:8fdc with SMTP id a640c23a62f3a-a75144631bemr673990966b.14.1720001776609; Wed, 03 Jul 2024 03:16:16 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:16 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:56 +0200 Subject: [PATCH 4/9] soundwire: intel: simplify return path in hw_params MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-4-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1567; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=6uKd3zEd6o2IBq3WPpQXHIDwXFMOpWhIbBFNpjD55Eg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTku0e0ZPNzRqNV/p6R7MRgwqF6z2Drikr2X zBVT0McBfCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk5AAKCRDBN2bmhouD 1xzpD/47ioCRH55FERGs7W33sRBsRuCldVHnisxShW4zIspBBmfU+Jfo+bH9fEXFga5oqS8E3G3 0SOJ5ACjYR3l5UC7lYgFQBUrlLPCFehm1jIPrMcmMpMV5ub/0IPrKvGEirCejtdQ+9FazVcFd2Y oX46M4grsOcL06/LtLN9Fl2TMqs8k1B7k3kbLZZRXMLg2dmdxRqxWlMtTmPVh2l9Eo9PEhNPNdl 2ASelRKxbmfAXpHEUC7cPANXn2JXKaxdLLZf64s13ln3DA1uKQ0YpYUbs27A+hu03UwAY4zjEF7 tKCQEvedWmRFScBot2e3fBLIsuh7FfiTaT5niF4rmOpA14AutLhj3UFrTSl3Jl7oAKsR5JMU+Eg necUljx9SfZcYDYTKzjLntNsL17HBP1xFu1crn2l3iqmS43gg/Q72L2+dXP667INVwJOFPqgDHO 2PGN3gEn5WOmdt1ZyJwPsB5vBxplg8D5Eml/TXB/7e2xzUC8RyEUy0SqA9UJIUVIRt7sv7FsQYU 8MU0MYaU8coIKxU+U2lrITGfsqMXy+Gd2BrThJX3Wn1g6gDMgE/gR1VJV9duD8nhvJKPDHzKDV/ 5O0f+6QEa5+m0ColVNshZip7vZ+nsL3D5KoEXvNtneRpXGy/iy/Vi2CqQ3cxGO8KVAt5qsOvLsH ahjuM42P2e+E/zw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: 4AWZHVVETF46TKIBGRZ56OQ2YJWSDMJ2 X-Message-ID-Hash: 4AWZHVVETF46TKIBGRZ56OQ2YJWSDMJ2 X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Remove unused error path (label+goto) to make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/intel.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index 01e1a0f3ec39..b4449095b423 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -743,10 +743,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id); - if (!pdi) { - ret = -EINVAL; - goto error; - } + if (!pdi) + return -EINVAL; /* do run-time configurations for SHIM, ALH and PDI/PORT */ intel_pdi_shim_configure(sdw, pdi); @@ -763,7 +761,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, sdw->instance, pdi->intel_alh_id); if (ret) - goto error; + return ret; sconfig.direction = dir; sconfig.ch_count = ch; @@ -774,10 +772,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, /* Port configuration */ pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); - if (!pconfig) { - ret = -ENOMEM; - goto error; - } + if (!pconfig) + return -ENOMEM; pconfig->num = pdi->num; pconfig->ch_mask = (1 << ch) - 1; @@ -788,7 +784,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, dev_err(cdns->dev, "add master to stream failed:%d\n", ret); kfree(pconfig); -error: + return ret; } From patchwork Wed Jul 3 10:15: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: 13721788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35AE7C30653 for ; Wed, 3 Jul 2024 10:36:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1A2A214E8; Wed, 3 Jul 2024 12:36:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1A2A214E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720002995; bh=cOn7ju16wjK6pDolLwYz3MYYA0UeyCHv7oicnzceFGM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=dTT7F8N8z53YNQouRQqYy3G3F64GjS2rSkbz6YUHqBUQ3GOlhycd3R+Gi+sSea/sO Fh2PPy063Svul7d5qTJRIzpO+tq6GuCMV1uQbws7SrUkfLAOTUZIADCWqMzDi0slZW HXCyFOL4d/FKpb6Ac3QY2w2U9QuE6CfrT1V4fEVw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4A9DEF805C2; Wed, 3 Jul 2024 12:35:51 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A3403F805D5; Wed, 3 Jul 2024 12:35:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 96970F8025E; Wed, 3 Jul 2024 12:28:18 +0200 (CEST) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4CE14F800F8 for ; Wed, 3 Jul 2024 12:18:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4CE14F800F8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ObK6E5ix Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a75131ce948so493560766b.2 for ; Wed, 03 Jul 2024 03:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001778; x=1720606578; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q1gM5YfJ5m/5Sqzk9+V5O7T+yd7cVFhUsmikU//os+Y=; b=ObK6E5ix5+ux8HUQSow7oLyIAOG1/xwPJmBeqoRMNNJ3ZA5GIAe82u+WL1BPDAggZk UQJF847DFBvZlVPX1Xp+jOzTJBIYKsISnSF+VIavUww8tIuWu3LRH5WkIV/vmZzEN51K pjA0J4w/e3p2LVXY1htp6S4P2QFCEa6JYPaj6B/oPKig9aFpjIk+3r5KPl33J1MCCT7H 7rsmPhSNxfJcYpC7bEdR7Xie2TN1Cz1zPW+uxQNGIlWRxLeKYCxXJshHd1b99HNYS3gd 3Sa7AxZAOF2PaPNFhm28QS7bbLCvnbyDCl41O5XIcYSOZqsG00svu+tlCt3nP3fLBkFC Gp5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001778; x=1720606578; 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=Q1gM5YfJ5m/5Sqzk9+V5O7T+yd7cVFhUsmikU//os+Y=; b=sSLsdN9ggfqlCmqYseAN24QICH1VNME3TJdiRmc0u7INgrGh7HbYYImamkFu7QkX81 SzkZB7MsMOoNsRIblIudg1gboe4+JAhv11/J+lEK0hgRSbzP3vc5d/YDl/O6Hcfk+y2T iB7kFHZ3+BrInAtriYran91AjPjXkK3JtuDzwaPS4J3Vi81SWt9sgyqcHwDSxe65Yd+U /23pOaTS8O51vexfFQGWnk3iU9OmMPFRkA2DO5yLsumPc+pLDEZjEYPklnbSasn86nbf yY9wWMFD+bulih6AjsSRwe9TFUYujttscVfjFxzokGSUGC7YN27p8hT+cuuW1qs7zkmU tdgw== X-Gm-Message-State: AOJu0YxKY6XU5tYjBwixZrRD808gcMGVQLtqNQlrOH+T26chUo0UYyhG 2x72/lkzu2Hrmjv+5L6ykpEbo6ABeoCs/CF9UY4QwwPCM0nle0/7/8+lrqTkAOs= X-Google-Smtp-Source: AGHT+IHu4HDX7PNB+RrIZabjL3r10C6WAGWLrBJ/SniR7QXeM4+uEi1nx8/QXXKaEFa8XSm0LDA0qQ== X-Received: by 2002:a17:906:3716:b0:a6f:1dbb:d38b with SMTP id a640c23a62f3a-a75144309f6mr639801266b.28.1720001778032; Wed, 03 Jul 2024 03:16:18 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:17 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:57 +0200 Subject: [PATCH 5/9] soundwire: intel: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-5-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2107; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=cOn7ju16wjK6pDolLwYz3MYYA0UeyCHv7oicnzceFGM=; b=kA0DAAoBwTdm5oaLg9cByyZiAGaFJOWjVZRJlaE4+7o8j3BoA3vRf5jfJurtUc9fTi9oPNE2H 4kCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJmhSTlAAoJEME3ZuaGi4PX+Q8P/1QR pWn/0I9oFGlPVBDkeUK+8ZgI+HK4gDCXUcmphuWo3fkkIISCmpdjU1CMhUIoxw0XJS0WCo4+cA7 ftUEG6AjbJ1lt7tN+UQcgof4l1hADQ2wXlaW0CzC8Bw19MC61jGS1yJvIAGAboAYgKrQSfrsnFc XY3r4AyZc3gHF7uJIm4yqrXikozsOMttAHUoafi6f6feaTFi1a0A2ISoyT+AW+RHUfyweB1E6fg QDE2hu6HhT9ON7UzbcQgoVQkCjj1CdNOZOwBYVS6wrb/B7ORkgj3dB+WI5FnMnJM9iwLkK5QDZj LoFJzQ07N5Gi1i73wARhjBRw2b/4Oo1Mi2LL0m5N4rb4IbZtyCUfNALfhRIyu72agXKYAqzR6zI 7Idc0TQZAN69ijTjxaYsaRFJs2SRoN7Z0p2hTMzk5Jr+vw0KpfS4eXaT81AJPXRx9gv8wXIBEfj Xe9LKrsmjmOV6ZgOu8O9RJK21kVII6uvktYyW4vkAVEA8conI6TgWIQKXI3TxTPAUmmhV8QO2d5 OR255h+cU3rPAb1DtzI9iXXLTncjldmjDZyoPxA32JNyQS6fBUrEZxTt9PVlb88DKKYDBS+4Iw5 u1hdypdpA5Dqlp6VHr/Lz/y9QpgZMEKfnflUiIGuux0zBtnOfNXP6/9gCRRGyYnAAXfDJZqL7rh omplR X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: IZLQSJM6WKJPLNMAYN2KO7U7HZQBHYVC X-Message-ID-Hash: IZLQSJM6WKJPLNMAYN2KO7U7HZQBHYVC X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/intel.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index b4449095b423..421da0f86fad 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -73,12 +74,11 @@ static int intel_reg_show(struct seq_file *s_file, void *data) struct sdw_intel *sdw = s_file->private; void __iomem *s = sdw->link_res->shim; void __iomem *a = sdw->link_res->alh; - char *buf; ssize_t ret; int i, j; unsigned int links, reg; - buf = kzalloc(RD_BUF, GFP_KERNEL); + char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -129,7 +129,6 @@ static int intel_reg_show(struct seq_file *s_file, void *data) ret += intel_sprintf(a, true, buf, ret, SDW_ALH_STRMZCFG(i)); seq_printf(s_file, "%s", buf); - kfree(buf); return 0; } @@ -727,7 +726,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream, struct sdw_cdns_dai_runtime *dai_runtime; struct sdw_cdns_pdi *pdi; struct sdw_stream_config sconfig; - struct sdw_port_config *pconfig; int ch, dir; int ret; @@ -771,7 +769,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, sconfig.bps = snd_pcm_format_width(params_format(params)); /* Port configuration */ - pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); + struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig), + GFP_KERNEL); if (!pconfig) return -ENOMEM; @@ -783,8 +782,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream, if (ret) dev_err(cdns->dev, "add master to stream failed:%d\n", ret); - kfree(pconfig); - return ret; } From patchwork Wed Jul 3 10:15: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: 13721900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 476DAC30653 for ; Wed, 3 Jul 2024 10:37:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 78EBD15FB; Wed, 3 Jul 2024 12:37:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78EBD15FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720003031; bh=H6MHDzn4DJjvMx+UU3AarlEqCOFCm2kvbOhK8C4skwc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QQk+rumrolIneUcNLhUhLYcTK8sWl81ig32L8LahID1XYmmB+wmvn2/UH4c8H9Na+ tagzyFHgFbjCxTiShvwSApDeVNlZuMTxya7KtQYIUliRqlUcw1lyQInuLSeoA0WTiy gYsNvqpaNmrQbKV3uHLA7TSONHF9IWotkpnFL2/A= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CFFEFF80618; Wed, 3 Jul 2024 12:36:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D363FF80605; Wed, 3 Jul 2024 12:36:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93F34F8014C; Wed, 3 Jul 2024 12:28:41 +0200 (CEST) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1F56EF80301 for ; Wed, 3 Jul 2024 12:18:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1F56EF80301 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=nrXrx4f+ Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a7252bfe773so545889466b.1 for ; Wed, 03 Jul 2024 03:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001779; x=1720606579; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4h10YGfrwPkkGVTEjCw3qirW9g6luYJ5Y1/Sh0BpRyU=; b=nrXrx4f+mvlISO+bWo1AA9ZmS9Pi0Qps+4Qj+mi4gh8QHNCdH3LeXVO48KHYEwcJsH VvqGpIqbSwyxgklHTWSaQEKqn0HuMeumW+eB5s4sfaOh8U5oIClZ3Tim/SEhdw676lTK 9SNiNptT0ri4gj3OWd3lws4Y8LA4bmvA0xB7ufJBkfNO5NBcXuclW+3hBgfL6bg2XvXu VF3y3+7gmrvnz50YYTeuE7ujy4yFgLPmxJpqyOreL0bPw11H72F8MBZVDipcaI4eBd32 zR5sYqzJC5L2eSxdV4gxZFr4lS42pK1vqOtWiQSrmvdJokd9HocBHN10Y9aUNeil/BqR sNFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001779; x=1720606579; 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=4h10YGfrwPkkGVTEjCw3qirW9g6luYJ5Y1/Sh0BpRyU=; b=gbL+cXMWAG3P0vl0RjJ+3c5+r3uLAWRIdkBDscuemERFXnCJtemPcybBk3xN8dvRjF BqBjzKi5ktpOoFA15qKuSpH+SzfheyraZCBUzJQ7Is3N4AqQCcApApFbLDU+nMDpYPbG TUe7djLAooencdxCSt7wuobNyL9Neo/VRtEzS7ew1WNMICBx0ClxpEOZ5CkwEIi/meWs xh8k0cyiTqJZCvUgw9dYROjL0zj2S1SsL5D2dJqrLy2KySwkxaip9+1Fiv4abm3arnOp 8finGYV6NaCtVT9YcIQecwSgtQuVY0CfAfZSUiAdZ7jMkv1wsounkD0epMVGB4emzHmL j/Tw== X-Gm-Message-State: AOJu0YxhGar2zuj2c48twdt8zcUmeHgJa2dIYnFoC4+rbQG/YhqpDVTD YrDGKgR82SnActDa9IhJOijzaH09ZoAdIYTtWY9HtxqeFpLnoXEflgyPTf4IFvg= X-Google-Smtp-Source: AGHT+IE2lrUjD2pD2f+fZKLRkMjumm7fxaU+U4uTiEAcTuke1jkfQkdtKdbpoN9AyTeSI5vhJJyf4A== X-Received: by 2002:a17:907:7e85:b0:a72:9d25:8ad3 with SMTP id a640c23a62f3a-a75142d84cfmr1002976966b.9.1720001779364; Wed, 03 Jul 2024 03:16:19 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:18 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:58 +0200 Subject: [PATCH 6/9] soundwire: intel_ace2x: simplify return path in hw_params MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-6-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1648; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=H6MHDzn4DJjvMx+UU3AarlEqCOFCm2kvbOhK8C4skwc=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTmLDnJUL3FsGDF5drvgu3fqPTzR9Y/ZiOGC mlwnnfvADqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk5gAKCRDBN2bmhouD 16qGD/0RTy0gf025ZbhLA1kN/XXZ3PlVTWyAloNPGC57y/esZhOXT/qt53fssZ7KSpHzpKNERDt flw0qiIrQwaGh0tIfMFkQAgPOUX0IK+QcVX5Da4Wu2rHui3mest/vCtHs+v9GuY+ey4bGENm6Up wqF/fkwK7tNmYNBrWsNkDdSmpfLak2VaFfRqwcdS4NCcUPbDtPXin5ijO1ezNwPT7oEg6PkVnaW f87mCHd0QPF93MOCsUl8U9Df39Wloe9QZ9pn5Qh3a8IxJX9nxxcrP/dnBkXQIpbEnMwOII2doic nGobn0vQq2v1+Tte0V5hS7paQolA2IsyHfUwblLJ1yb/tn9rrbCWB9Rq9ImCTx4IKaI9FVqGJ9a dAcZaW+8Jd/xeFwQMRsnwVu+PsJPMpjrTC+4vx3/kBvqMK+e6RAK1aY+r0aoYBBUa2Y5MuwgBLa RR6JGDAO1eFUay9tABD0VU6VeHb2lT6izYKhi1FZSHW6IRa1W07dDTNQQtQZG2Wws9ATEcvliuP X+8G5QzMhXHdSUh6n53+4ZJ7xH7hHjvCv6rwtGcyAzueVoTDbNPk+COndQwODT8MomTTLf8zNva hIoHT6MEounK8Z+iGtLxmFv6ed3+RmrX0Ewuwvo315qpZIX2EpIsorjuZBuzuM/nSU8QDc+HsnT PWxuBI7PWu2MliA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: ZFZGWJJ7THHH4EIV3HVCTUOLWTIT5ZSP X-Message-ID-Hash: ZFZGWJJ7THHH4EIV3HVCTUOLWTIT5ZSP X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Remove unused error path (label+goto) to make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/intel_ace2x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index 4f78b7f99e44..f0008ff84ab4 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -325,11 +325,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, dir = SDW_DATA_DIR_TX; pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id); - - if (!pdi) { - ret = -EINVAL; - goto error; - } + if (!pdi) + return -EINVAL; /* use same definitions for alh_id as previous generations */ pdi->intel_alh_id = (sdw->instance * 16) + pdi->num + 3; @@ -350,7 +347,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, sdw->instance, pdi->intel_alh_id); if (ret) - goto error; + return ret; sconfig.direction = dir; sconfig.ch_count = ch; @@ -361,10 +358,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, /* Port configuration */ pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); - if (!pconfig) { - ret = -ENOMEM; - goto error; - } + if (!pconfig) + return -ENOMEM; pconfig->num = pdi->num; pconfig->ch_mask = (1 << ch) - 1; @@ -375,7 +370,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, dev_err(cdns->dev, "add master to stream failed:%d\n", ret); kfree(pconfig); -error: + return ret; } From patchwork Wed Jul 3 10:15: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: 13721776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C75DC41513 for ; Wed, 3 Jul 2024 10:31:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E76CA1948; Wed, 3 Jul 2024 12:31:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E76CA1948 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720002696; bh=IY1oPHTeYFkPAQIumDC8e25FwPrkJ2qyVDIkUd9B5LY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ugZ8D9lq2BishaXCbtby5CRHxYPwKEK6W5Foi8NpYPdSFD+hmES1FKf5Le/NkmrqB jaqhBc3XeJoxss+F9+Z4A8G9zJe0dbl01TM203Nb9A8w/sZHlv9DhNknC8wawRcB9h P7bjssYPYhw5kllT9JoxPWv399FAvRbrms4rxVSs= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3037EF805E4; Wed, 3 Jul 2024 12:30:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 671FBF805DA; Wed, 3 Jul 2024 12:30:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3BD0FF80589; Wed, 3 Jul 2024 12:24:00 +0200 (CEST) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 18127F8014C for ; Wed, 3 Jul 2024 12:18:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 18127F8014C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=je2nbkeh Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a751ed17b1eso77783466b.1 for ; Wed, 03 Jul 2024 03:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001781; x=1720606581; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VrtpT+q3ugRzypCVgwmAVgi8FHiU6FE6B5vA8wJQ87o=; b=je2nbkehek4hFpjObKEk7ssJ1DeFRUHRPfvrUyZNxgH6yybzWV+guubIha5x/JfH3+ 3VlaKMnsXD1vhONqJaUs/kmLix81aDoz0D1+Qm7pt3ZtxEbmKe8IzoFoSSzxWIuIt9ke E7bIuA+p5aVU5Fj1HZiB9Mien8OwmNCLeBNwE4+GpfW3dGM8aZPpxf5sKBsUMTUd+Gfz P62ngp5rjEO902M+ZXKHuD3hk5XEBEpIyhiIYWJDfVR9AjgDhxjHdLSVx+gMnYs0ibLE 922hJUikXQfwoHjzkouLPAxuyY7AWZRJspkck3yanv1dDtVsODsZHlB9RMdG2xrmajf0 2j4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001781; x=1720606581; 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=VrtpT+q3ugRzypCVgwmAVgi8FHiU6FE6B5vA8wJQ87o=; b=N4BlqNIJ1GZpJhPMkvVKTQRU4Edd9zMFSpd+s0QcV5FR61s2yTZ1b6BTXlK0a+V53P gCd0snp9tMgVf/8Msu1pKPzWzxZWWro7J2rxNess4SnpTNKuJTrBBfpNhOFMo+MHCM5J R2JtWo9ph0KhnqDXixRxMd5RnU/S2kkpqt1UozMTf31MMvyApCh95Ta9RiwNfwtVp43U iV+cZoKOLb47yvsODLQQsb49z7UKQRtNlgpUuQETbywU5tqDkyeXXlAMA4pxd+lEoVEt V0YfUq2oCoor85P6EG1Ci/f32w2qv6PIeXTJdiHxG9Zn+6/BP6RHgeGBBIV0IO9bMkh/ FWlg== X-Gm-Message-State: AOJu0YxYbvVtHYbB4qpldeCQeM1R2lKo02oL4ofWnVBbYprBBTkBd+jH hjgZXIZLZ2NEofOlyPTj1aWzuQnF/uE96qyAb+kT7x7jxYrIYnP6IW9ddDrFw44= X-Google-Smtp-Source: AGHT+IEtZoY5JzZntBzNzE4Y9+mfHfz4VIjEoXHHcvOnPR9dBqvKKOQoXhvwcg0LzXPqeLC+5E0HGw== X-Received: by 2002:a17:907:3681:b0:a72:7736:9e14 with SMTP id a640c23a62f3a-a77a2441768mr102819766b.20.1720001780715; Wed, 03 Jul 2024 03:16:20 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:20 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:15:59 +0200 Subject: [PATCH 7/9] soundwire: intel_ace2x: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-7-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1521; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=IY1oPHTeYFkPAQIumDC8e25FwPrkJ2qyVDIkUd9B5LY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTnkavgfEK5yCLUKTCxvvF4PXPL5NgXbOKSZ sWx7SD8R86JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk5wAKCRDBN2bmhouD 1xwsD/9gMhWaZZjNTAwmFUzuScG1m2CPsqiZWoBezCyR5KEDWxWf69dUBsYBPLlAYXfSHIrm5xT M8P3yDHaE9MQGJaR39xrtArAoYt2Qm3DiaOaSaxXPSH/nqNJrb3wIS56tYPbVCXevejg+elOd8C XU0lrreoxsHeEF2QpHehJJYoVpx0BlOTYe5SoExvz3gJrDYCVEt+YSYWhUqSpRii1LC0WNuBTYz GM1/9ei9HhvvhdgsnK2TMfiaYSsd9w6TDxeosIy1fXtgSHyaVYev7CIhJi4EI3o1eunWtc0nwDZ 6QtuoJGh4BMsA3jyc1Q5QxM05YkK2TzvEaaH9nnBhhfWGQYna0MiuYx4Z5uZgVdzKaxsSRbusWj nPERQk47di6YubUGrG5j1ezzyrr91UfHhW/PIvu//4uoGIytIEku+jVYdo7BSUWvl/+/kzBJkh8 J6p/UxVp/kJU5Ioz4yTpGpMDX6Z6kCyC1G2zUSs42BXVMWY3er3FkWkLRzW0PfE1n34coDePDFT K0dylCRRUQqDY1jSZsSQpFv1MKGZUS6uxDXZcWifj9ThsOn7rvhKGHtyY2roqmP8TdkrgeABAtQ iLubbXCuFNg2eHpsURlbaq8gaeZmAaNe9tjHo/bGlI7nBzLOdjqS3O6lSdFgIC49kid3mb993xN dFiR2mEyDKGSEag== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: MXQZQCEIOYEWM766FRV54Z2H22GSTPGH X-Message-ID-Hash: MXQZQCEIOYEWM766FRV54Z2H22GSTPGH X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/intel_ace2x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index f0008ff84ab4..781fe0aefa68 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -310,7 +311,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream, struct sdw_cdns_dai_runtime *dai_runtime; struct sdw_cdns_pdi *pdi; struct sdw_stream_config sconfig; - struct sdw_port_config *pconfig; int ch, dir; int ret; @@ -357,7 +357,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, sconfig.bps = snd_pcm_format_width(params_format(params)); /* Port configuration */ - pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); + struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig), + GFP_KERNEL); if (!pconfig) return -ENOMEM; @@ -369,8 +370,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream, if (ret) dev_err(cdns->dev, "add master to stream failed:%d\n", ret); - kfree(pconfig); - return ret; } From patchwork Wed Jul 3 10:16: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: 13721903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 655FCC2BD09 for ; Wed, 3 Jul 2024 10:37:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6076920C6; Wed, 3 Jul 2024 12:37:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6076920C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720003073; bh=2Hgb11TSE9fOERRmOGKvCbJsU5ExxL44Ao0bbckq9aI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=tcXyehWvVRksF+DY2+E+2TGGgCJnc6H4bZe8/ZcZuGk1pMBJJhll48azhwgFcFw3v 05omvnNIYW6eVjaz27H3pZ2nCBSfXTqK1DVB5LHvJ+rJ5ECfZYC4KK5Xk0Ue9p8zRq jUBietnsx3nrUaXPpoNPvYqIcTlWEbZkyBbPkxQk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B6F55F80587; Wed, 3 Jul 2024 12:36:48 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 793A6F805F1; Wed, 3 Jul 2024 12:36:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B12C9F8014C; Wed, 3 Jul 2024 12:28:51 +0200 (CEST) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F1DC8F80588 for ; Wed, 3 Jul 2024 12:18:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F1DC8F80588 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZTazhEE0 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a751ed17b1eso77786266b.1 for ; Wed, 03 Jul 2024 03:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001782; x=1720606582; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3joTjD/EvzvybWiPdLIbHTzIsLTnwS1UMLvS3hxDr3Y=; b=ZTazhEE0qrjzKbzhYn+8TUdXMDVhQa9kz5jRdT1PkbzIpCPKihF0qIBy5ghTg33w+M 3bU6hJkzgd0vKkkhaL3r3MN8od5LAvJYZm0XKlMpIUp9X0O4VaXzYQAfmf/xPTU9bmBQ O/F4ji63InLu6yRKbnAwBW/To1Y+vQe3EREJ0Iqfo+aP2QRPV0ZVd6HRUMKw+l5XtjO9 Iutzvk3KjIvLDilzTNypK70DWQHbEFSO6Eh3U7ryeZ26k6Jb1A1IMunnZTQ4JyRYX6dU MtHffuK8riMquflTYd9FOvtfDdnNx1oa+yHe+4e6AIwYon/3EuonhFZuDCLRyBr4WvTr pnmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001782; x=1720606582; 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=3joTjD/EvzvybWiPdLIbHTzIsLTnwS1UMLvS3hxDr3Y=; b=P23Yi8Zzprt+wU2Zn7OznqzcaOAwxIF0dWc+Sg38nWJhXb1YWLcyzn0Pg73HfnhbIC EfUeimhGh1n6KVUdzvHEa6ccTFs7gxmRe++e7USHJNfExTeSglbLOdv1klfQB+rz3+E3 nqrirk3ff46S4Dy0D7ZNE9eKp5yyVjPy0aNTkh63qwr1aE21p30NGFSWPmip2qZU0MMv xRrcOG6n/a93DMPBYyD/hE5vtycJqoIh/bN7175pe3rBc9KoX7Xj74B9pi0KmtDjqfFg n1GrQmUqHoKtnb3gXtTd1jKFDBmyGHWo5fYbjc2tVLcmeTQhpHmvbeJ1AtBHh/Gl1Ozj h2kA== X-Gm-Message-State: AOJu0YxduNNm+0AY6ZeRq0ElODH3W3nMHFHqu0hkdHGHYqzgt3/HpOxj gFBfc4vQZqwOfpKulWqPBpY18Bt/7i7FDpGNYHxovJv9xxuZVp60ZBhUGS9M+wU= X-Google-Smtp-Source: AGHT+IEELsiExLgIL8ViDXZhbHcr5lLNtKgOIwnhglxgd+MvGmadP9WGtD7IcS1FdBHJkN8UmxvuUQ== X-Received: by 2002:a17:906:3390:b0:a75:1923:eb2e with SMTP id a640c23a62f3a-a77a24202d2mr96155166b.14.1720001782114; Wed, 03 Jul 2024 03:16:22 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:21 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:16:00 +0200 Subject: [PATCH 8/9] soundwire: cadence: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-8-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1247; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=2Hgb11TSE9fOERRmOGKvCbJsU5ExxL44Ao0bbckq9aI=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSToVO7krJpsryvmNegqDera+Tzu8RsMQNven Pl+d2kxioeJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk6AAKCRDBN2bmhouD 10eBD/wOYMaY6NC26kuLeUu0bJQ+sYDgl1g6Q7lkH1bSLC5TO9SnH/0h4y+otOvZV67HNOwAd8N cH2zTy/Z2E+pNrHspUPiOSxzg9tDPXMpcdSSnkBvqqine3JZhibf6kXd0c73jtRcTTRleFWfMy6 J4SOVEjrRO2VSXzv+M3iNRyUC9FU3ObCHmT55JAnRdRSwf5BYLZzD9GqqWtRtfmmAP/rY5CWWRe zOEDY+edSJHyVzoANpMEySXRE5xTcQpCs/qSjW/ZXTKfLH4NNKdEgpkfP5XBQD4Q7+PdmM7c6NM FGvnKZzzhMQaB8780Awfj0aJnoQePjrz9gVJR7eqyT2OByegp3MjXPEFye5daGwyUs+A3+st2Xe s8YO29KiNQUs0XuOXqtCPgQWQaOqeyRuiojdUr9LUk4DtwwAHpctlQzpbCAKcNI+mTLCI05PsQQ hgMuEtwxzPRyV/brU8MILtqInRt7H29Rm130MdNAe4ZopUxqoLeuz3m8jtUZ7Ujn3BJWYGpi9P/ UZfv4ulXMnDaAzhV4NITyL7vL525gjJveZi9/fb0FAFnGHnO1mBVOhAFTZEt8z0+xF15ibZINOr Pfp6TunC1dFQJKp7P8LsFxDOoNeVkJJ9nFsFn1ckc9zlLHE1Ev492Zl5aDKlzYbF4nurrDdwhJ6 /PNP2BP22TZcJaQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: 5FDJEMOBIZGKUBV6MBPBNAT5QOLXNHL5 X-Message-ID-Hash: 5FDJEMOBIZGKUBV6MBPBNAT5QOLXNHL5 X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/cadence_master.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 74da99034dab..e0683a5975d1 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -6,6 +6,7 @@ * Used by Master driver */ +#include #include #include #include @@ -323,12 +324,11 @@ static ssize_t cdns_sprintf(struct sdw_cdns *cdns, static int cdns_reg_show(struct seq_file *s, void *data) { struct sdw_cdns *cdns = s->private; - char *buf; ssize_t ret; int num_ports; int i, j; - buf = kzalloc(RD_BUF, GFP_KERNEL); + char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -389,7 +389,6 @@ static int cdns_reg_show(struct seq_file *s, void *data) ret += cdns_sprintf(cdns, buf, ret, CDNS_PDI_CONFIG(i)); seq_printf(s, "%s", buf); - kfree(buf); return 0; } From patchwork Wed Jul 3 10:16: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: 13721787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D468BC2BD09 for ; Wed, 3 Jul 2024 10:36:23 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E6D971E7; Wed, 3 Jul 2024 12:36:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E6D971E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1720002981; bh=Ya6oXVz+9PSgSZgNYuY4CHXoSmhTuQFovgLfaTWUMXo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rVgoJYU67+LEzuGFJZNGMzVC+XNV8soafxA6D3AbLEZNea8bvr/6y87dwCtmLDEXY rN1oNUQ+QqYYurYqyOl4UepthkhjxAeq80mE3sTRvh0nrvvI65fuWzA991cgJJ+934 yOAhNAj5zqC8R9rQ3J2crFBfRiqYGqWON1hWzgx0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 451CBF805A9; Wed, 3 Jul 2024 12:35:42 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id AD2A2F805B5; Wed, 3 Jul 2024 12:35:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A24F8F80272; Wed, 3 Jul 2024 12:28:18 +0200 (CEST) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 914D4F8025E for ; Wed, 3 Jul 2024 12:18:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 914D4F8025E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Nco+27zy Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a75131ce948so493572566b.2 for ; Wed, 03 Jul 2024 03:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720001783; x=1720606583; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FWGT3G4dbfhnZE1xyRO5OpmfX9c0autS1uaNaBcB/Mc=; b=Nco+27zyPUlE61z2tHSteIM2GKrySj5o+zQ5nW8cXedmesWxhVaHzt1kOlOCZVfckC xGhHXFp6ePPFtSfF1TRYqke8xwELHDka7ySi40CrT6HhVHyubpYcDtanOy5VjCNUTAK7 CZaoqtNQWkPMqPHjcU3UMNXZ6lQKM6I8z/wbGkOSyEWeXcVrP8kvp6OkbGbep0KtY2Vb 1ybFaEJiUT2ia7EhFfUeanvL2ZMLNxi2iXpo84wmhv+XXKLWJ5SEQpt2axaJm7bcdHYr eoII3VvgTfm4jO2AMIKgBhKEn5U6+jkb5q8jZH7NuMA/7ia/Qxb1H8+YC347KDqi7tYV +PSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720001783; x=1720606583; 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=FWGT3G4dbfhnZE1xyRO5OpmfX9c0autS1uaNaBcB/Mc=; b=QJUSDlmximX1pHsd9XkdV6Ann4yJ1sG3oN+LK2eBX+m3tl/ONmpA8+/Edzc+jmaWv2 u7D+x1gRezDNZXDjZWWL6Q2Zq7Ow5c2mjCWqw96xzzLl4HjoU+tTSWoHQIJd7AtdvXv1 nCL7Xl+20Ga1NFurxauyBFK3I/g2Lmtno1ZjFYhSctvyovq1bWREVz/QoT5sL4Nl0eYV R2EnQLi7UBD6abwMNDbphWriXfBchxVkBJEndogYEXTQVSw1GfV7GIyy8IWBLA1/r16q V8MtgQKFd+RwzUy7+65GC8cbk7g9W59ZSfFr3s86kXIcfUb6kNQWrPthAV2ZY7ChFFfh 5KZQ== X-Gm-Message-State: AOJu0YwnlGAnK9ydtWiaFa9hfYURgDlHS7MZhRmbpYjYxltABQCyYOIk eYqrViUB2po54O5EQ96UhO0KWIukN0sc4Eow+pNSgk5N2bGc3X76rTt3nsmUa14= X-Google-Smtp-Source: AGHT+IHeLDjC6kF6SJTtMZmIDChVrcMjHv7cKLOslnjJZSeDu4JK3THQHeWo35I65yYU6QzYBGe/2g== X-Received: by 2002:a17:906:d78a:b0:a72:797f:cf6b with SMTP id a640c23a62f3a-a751441a667mr684555566b.14.1720001783179; Wed, 03 Jul 2024 03:16:23 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab06565csm494291466b.103.2024.07.03.03.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 03:16:22 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 12:16:01 +0200 Subject: [PATCH 9/9] soundwire: debugfs: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240703-soundwire-cleanup-h-v1-9-24fa0dbb948f@linaro.org> References: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> In-Reply-To: <20240703-soundwire-cleanup-h-v1-0-24fa0dbb948f@linaro.org> To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1466; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Ya6oXVz+9PSgSZgNYuY4CHXoSmhTuQFovgLfaTWUMXo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhSTppdI1vWEUj6KaRTVA6Zs6vstWpcqLtIv+K waN3oowU8eJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUk6QAKCRDBN2bmhouD 1zl7D/wMjbC9AmoPa2axlSVFNvUY7r8vuhRS+DbdDe8mpxB8IgQ0rJLwE79UYI6y2V+XB1M/OUr pnpEjT8oO1ReWJZ7Vsjj4afpKFwsE7rVsA1vaY5u2WQ/BH6ffgbqTLnywnI21WzG3sYV+/2WUoR uqOFoBoKwJqpP/J/lHojAT3lzh3sYmONwr566zGBEwdZ1C2YFYdxFOShtYoMPMNuURyykRGZqBo AMof/wpz5ye4HhCObCYiLgWzf8WpN20aEWB3Uu7UOBSkZEh9Ulv2uSmI7Mpz1QUvZbJi7g8jclU NChJjptEkFASqpAR9Yn+tB5jTjLVI3/WGRwjQz7kpdzjZgLpGRillyKU2tW22cowqWjJa3m2Ms0 Ko7JZSxhpB4nM1uToQq4mAA1wBLeekdT++gZHXbysR1hhlo/RlvMaIyA0NuC6sSVXI2alJRACCZ 4PablAUl2DVblPVLf87ps+coOxUZxvTwnOys1tGN2SpR2ezfB8U7AdZZw/OPFeoTH0Er8tsSne/ qvPYHgo3Ik/5cHU4OPozojj08uYxsh/xLgB8p4zPNqjgxt6GemeS95mJalFykAgOI6Ln+Xn2VYH M+Nt0CLbW5HwF3zwMFn7TP6+lGun/GtytwDffA6VKIpcsqdfQXle0rWej35Jbv+t/TRV4vPP49Z cyYnyniEZZzVm0A== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: O766S4ZXBFXBJBHPG7TFUOJC27I6JPLW X-Message-ID-Hash: O766S4ZXBFXBJBHPG7TFUOJC27I6JPLW X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soundwire/debugfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c index 6d253d69871d..c30f571934ee 100644 --- a/drivers/soundwire/debugfs.c +++ b/drivers/soundwire/debugfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright(c) 2017-2019 Intel Corporation. +#include #include #include #include @@ -49,18 +50,16 @@ static ssize_t sdw_sprintf(struct sdw_slave *slave, static int sdw_slave_reg_show(struct seq_file *s_file, void *data) { struct sdw_slave *slave = s_file->private; - char *buf; ssize_t ret; int i, j; - buf = kzalloc(RD_BUF, GFP_KERNEL); + char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL); if (!buf) return -ENOMEM; ret = pm_runtime_get_sync(&slave->dev); if (ret < 0 && ret != -EACCES) { pm_runtime_put_noidle(&slave->dev); - kfree(buf); return ret; } @@ -132,8 +131,6 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data) pm_runtime_mark_last_busy(&slave->dev); pm_runtime_put(&slave->dev); - kfree(buf); - return 0; } DEFINE_SHOW_ATTRIBUTE(sdw_slave_reg);