From patchwork Mon Sep 16 08:48:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13805125 Received: from mout.web.de (mout.web.de [212.227.15.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B926D38DC7; Mon, 16 Sep 2024 08:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726476525; cv=none; b=t0isVNUSksJiIc+d8IiUV4PbLDs9AkQRu+MM8gQxYRJrChUlutL/gSRw7ofI16Tid47QfgrHZSY3ku+UrDRWyVtVFeJcX8VxsFIk+PYiR8ldTdf5c9owDjsS5XQHBJQ9KnZsiB3YM6Kkt2+hnuReQjeRsTwc6A/lPnbExdJB+jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726476525; c=relaxed/simple; bh=J8UOI948OnWKs+xB+/aTA/QkwoSDFz2PUm4e+MA95+8=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=lPmruHU74VymdRJm+7uReMN6quFyJrvbOy4paR6umedsIMq6RVCHOE+wyjxojHm73V8drTWngDeDl4h766IwjwsNWt4AVcak1WXsApQYIf7mCTtb7h0ahmcGEjkEtKlWKIYAT9vodzt3mtBgVvvDR5fdRKZFnca/JcW8/9i7J94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=Y29PE2Ey; arc=none smtp.client-ip=212.227.15.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="Y29PE2Ey" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1726476501; x=1727081301; i=markus.elfring@web.de; bh=Ab2q8+aP9Waj4HBePxRO2QM9D8hRDpA/gAZWi0kJcZs=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:From:To: Cc:References:In-Reply-To:Content-Type:Content-Transfer-Encoding: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=Y29PE2EyGcEdwpfkBO2kxl6hAr9YTu2Ol6HnU8A6v6qma9xVO/8oV1PQYoLKEOWz 4Uj+U6ZzF/2hppw/IOgHam4SUjGb2YXLP5Ms4oa7dtLA6pV0l+u7x7H0KjBRLxoNo jHXDvbNwPiA1iBi7NtwXl4w2HRiGVXg06m2Dfg+vOfLBP5Du/pdZ1KecG9Dq1F4DR a7W9MblL2mc+ESAzJ2LI+SqlXEwLil7pKbLaM0X0vUbXSKZU4pf0arzYYqjwWZseN Aoj42SQ3cGzdmYu+ZNcZfnKNkH8VofX8xZ0n9msQn0q1vIAbOVC3uYDQVWGbqfcDe +K8mifZq8ZWezp0f+A== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M5j1q-1swA51028Y-009uIL; Mon, 16 Sep 2024 10:48:21 +0200 Message-ID: Date: Mon, 16 Sep 2024 10:48:18 +0200 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] ASoC: tas5805m: Use scope-based resource management in tas5805m_i2c_probe() From: Markus Elfring To: linux-sound@vger.kernel.org, Daniel Beer , Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai Cc: LKML , Dmitry Torokhov , Julia Lawall References: Content-Language: en-GB In-Reply-To: X-Provags-ID: V03:K1:L6Nm2Bprgo6+Yuv52zM3x6fUbQwtIzeKwHMbTHtwYjFlASRENcY YKWIo0XBuxKo8Df9xwmxOiyO5IWEd60WKVv3IFPlng8fSTPxEzH1qhADfNruIylwUPOcl9I Ld2uruGAiuExayFvQsNPwXRFtykhmVSvFh4BIoGPZveY7if7vBgTBudBzeQP2MVwdHg2JaD 0n+hH6KA02WoYabh6sjsw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:dD+/aa3tqcY=;FhUY5rbxoKQk5olwezu74i1vYq7 lR85TcOFwU4ewjXv+kMq/PB7hR55/7lzf8u6lnsSQkdqaDKJtHwzX5O0fwXD/S1fNdroR/24d l9rC5+A85qYhVrxFZ39Gch5puOm6NBptVnA2oaUsPMfdIal5PYqxVJZvjxtYxV5O2Yub+c+HM tQq4w7sXvl92moe1k7jK/rteBe5SPiMP03Lbk5ayzRbDzyzU5lPHFxof0OZQ2P6YURD9R8mN8 b0x5CPF84QxAInUoURHC686OAi/iswHCifec99WM/j1rD8gj6vIWkZwQ2HwmpsOSZIDO+6xvF tDITfQj5cOzNvN7xvpG42PPu7OXzKexUg2Mbb6DzdmkM38dh9CdqZmg3iUirSV1/AaIkDFpe+ DHWioQe2WdUDewN4Y/ZkyU9H+wJY3VPpkU43RjW4/hGpdoy0Xx9jQ7WNGcnwueQx9KBYAhE0d MG9fzetDYcfXXcN/iON2xCsWH81Tfp1Lc87DlXW+tTVdoMfZcYJ2aX4PYECpRhsCdMeN8U1oz se3xY+Hhyt/kTN2+fGEHGPsLYXDaT/d/DPhJ/IDEPd6vnu396OaybPmLzOj3v74GMcpZxNIUY drRZED5VYyzxPFFaGYlLUlz62ySs/1DgSTocLCaUOM+5p/sJA41p5yYGp2sMYVdgZLvwAc5E7 yufuPhfwZ95sjyeGQ6b6sMuL1JXhNGnyJSPJN2lN3qzr/kvcRMK4mHmEuC/1IRClffa+zfYHM +TT0yTPsexrsT1xwPteyfX50NfIzhVzeDaQH4arMiiV9UHholCWHq1VnHFerc8RDfKq8t22IQ Faxfx3dDWEvMN1u/z9YPa77g== From: Markus Elfring Date: Mon, 16 Sep 2024 10:11:59 +0200 Scope-based resource management became supported also for another programming interface by contributions of Dmitry Torokhov on 2024-01-17. See also the commit 8dde8fa0cc3edce73c050b9882d06c1a575f6402 ("firmware_loader: introduce __free() cleanup hanler"). * Thus use the attribute “__free(firmware)”. * Reduce the scope for the local variable “fw”. * Omit explicit release_firmware() calls accordingly. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- sound/soc/codecs/tas5805m.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) -- 2.46.0 diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c index 3b53eba38a0b..f37eec960364 100644 --- a/sound/soc/codecs/tas5805m.c +++ b/sound/soc/codecs/tas5805m.c @@ -464,7 +464,6 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c) struct tas5805m_priv *tas5805m; char filename[128]; const char *config_name; - const struct firmware *fw; int ret; regmap = devm_regmap_init_i2c(i2c, &tas5805m_regmap); @@ -509,24 +508,24 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c) snprintf(filename, sizeof(filename), "tas5805m_dsp_%s.bin", config_name); - ret = request_firmware(&fw, filename, dev); - if (ret) - return ret; - if ((fw->size < 2) || (fw->size & 1)) { - dev_err(dev, "firmware is invalid\n"); - release_firmware(fw); - return -EINVAL; - } + { + struct firmware const *fw __free(firmware) = NULL; - tas5805m->dsp_cfg_len = fw->size; - tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL); - if (!tas5805m->dsp_cfg_data) { - release_firmware(fw); - return -ENOMEM; - } + ret = request_firmware(&fw, filename, dev); + if (ret) + return ret; + + if ((fw->size < 2) || (fw->size & 1)) { + dev_err(dev, "firmware is invalid\n"); + return -EINVAL; + } - release_firmware(fw); + tas5805m->dsp_cfg_len = fw->size; + tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL); + if (!tas5805m->dsp_cfg_data) + return -ENOMEM; + } /* Do the first part of the power-on here, while we can expect * the I2S interface to be quiet. We must raise PDN# and then From patchwork Mon Sep 16 08:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13805126 Received: from mout.web.de (mout.web.de [212.227.15.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB27D13C8E8; Mon, 16 Sep 2024 08:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726476641; cv=none; b=uAosv+DkSfwBz5mU9+q2CiUJiREMyBFglou2s/a1XlwR+Yf5rPbB0xFVIAKHVRaDKm9jtAwWTzqDlRbg4Q6JeeG5QZ9b86v6HIu0SFF/Rb+KnZPj5JMR/WzSly0iam3Xubh0lz1ja9LKGSZW+KFQfl7bR/QwVLARFFUWwWiLqrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726476641; c=relaxed/simple; bh=t+IQ9RTWxdzVYuVdIhvfKJXVAtXQvpZ4skDYvaDknGU=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=s+ffUbluFKxq3C63pHHryaTaYESx4FhQo8c3dZaU9cTH4HWi53ltad9fFY2yPiqDJK5JHS/ydhnJyoWcFSbe0kGxvQSqUkX9l3hR2lSJEpunpUaKsbeS57mpIX+h6HPxVVmU19X6+Zu8xpROTA4MX+gdJPS0rdB2vpeAlkJEwAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=Pzd199Zt; arc=none smtp.client-ip=212.227.15.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="Pzd199Zt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1726476627; x=1727081427; i=markus.elfring@web.de; bh=Cdh2sCthxJLXSaRFkitknB67DXkRE1TaqYOdeu6G4HA=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:From:To: Cc:References:In-Reply-To:Content-Type:Content-Transfer-Encoding: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=Pzd199ZtFvk5zroQrvRvsWBon6K6Qg0OoRt1Q/jxMBViCdHVcvuUSW75j0lufMHK Kc5B7hxeK010ar7xQVnYA3E2r1PLezddPbTfIxijHD9BE4XMUobMZJVHuxxo6ZOSp ZvW42L8oolv0oAEhJuxPFko5PRFDvdLQzaivTy4H9D1hkNEbGIMh+Tfw9Zd08MAC/ kY1lWgofEUaJmg9R4q3+h7G5pAQCWRW1cip1QtObBwFMr2m8p8F21T2x6wz+Kze7e P3ZR+YAxO5efpFPqGsXY4pPIyPTSFiiUcLfQc76dOHjgnGm5n0B4inb19SSU5OByM FJAs/ppsXZmIaCZ17Q== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mf3qY-1sMpMP1V0c-00jF6P; Mon, 16 Sep 2024 10:50:27 +0200 Message-ID: <6a6c87d3-9e4f-4980-ae06-b0d5e16dd0c0@web.de> Date: Mon, 16 Sep 2024 10:50:26 +0200 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] ASoC: tas5805m: Improve a size determination in tas5805m_i2c_probe() From: Markus Elfring To: linux-sound@vger.kernel.org, Daniel Beer , Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai Cc: LKML , Dmitry Torokhov , Julia Lawall References: Content-Language: en-GB In-Reply-To: X-Provags-ID: V03:K1:eDizXtHr60xTMZBo2z3uuH8kBSZwS0zyTfYJUn0VJ9XiL/Ihu3X BAvRLOycnnhnzi6YcJGjLCXTEOjpX8+dsInfgQNrh2V4p2fSzF9FGOYJznToZaFQhlXlbGe v1f+Cx3PexFNN51Tlrn8aOwLLqEkCR3mkX/fiS9xEk7ClGSMySOqetUERytbELJG6ClZ4Jk rddQ5osIBoihXEtMGdIww== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:GYJePe2PaRQ=;OXTG5OmtR568fIFs5X4a5WyJS0a LbP1Vfd+u5n7ZAVnJY+JEc1E6UMpERU1o6qdMJfOzi9Va7nl0bg3lhkEt6SFPwiUDx7sTzaqr LRqf8g4sCEyQsqi7KogTTJx/OXb4WEXCPrAS3Zg4LZhk0EW9TVAg4dqqtKWSy15hHz1tmixR6 cR6/F7OaYttkgY1shPJSFt8f7fCgXUwSptw9BCdGMP8t2l4G0xWFi9t69fCeKiW15RgSqx8KD LlDHPPxHOy47UO0Fp2hONg9Qh5DquVAejDsBtnlu7E5HP8J4z4Dv6MOiFjHFanJP5dywz7Wc1 /h5aYswwRLRYKYwvH4Yx9FFq6ucF3ohvrG3MlUAvZIW7JpMgx2sPZbfwBYKezexd71JZmQeOY hb5d1VsK57/27R5a1XJDt/7cYyTPAsmOsJhkrIavbv00oikQLxaNOgac3PMvHdryJHiiHdJH0 waDvQqp3Q7HvMH8fN7pXZImp8M84QWmhO8Fa92E8v2APMH2F0tF04uoGQ0TqHJRDjDWzOhREb SJyfFj9GzE9QBX6gdD/Z9XAPwt8L91nx12vJtit7GdobMXe2DyVr3DeNYJn9pViWjjEnTuP/U 979+DZMBYeGadeLT57FTa5veGdG2SF70jwaEirNiFmAY8Ifn7iWXsGAUlTrMNvgwlp6fuJjmm ZpQIlQ5xZrdGirbaRo/+hFoRdynMIVgJJVdqgJusTXfIAky3uIROBHjJ/99lf0qulx79RYFGN ZoWOxbzrvS+5vZ5cNMbz47sa+JKY71WHVxl4nMs9lrHvWLKl0OoxWBrMpAMxXaUkO3eMuJLdp j4+tYiAZyE68Gp5AQgztbVuA== From: Markus Elfring Date: Mon, 16 Sep 2024 10:20:12 +0200 Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- sound/soc/codecs/tas5805m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.46.0 diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c index f37eec960364..d4f028451071 100644 --- a/sound/soc/codecs/tas5805m.c +++ b/sound/soc/codecs/tas5805m.c @@ -473,7 +473,7 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c) return ret; } - tas5805m = devm_kzalloc(dev, sizeof(struct tas5805m_priv), GFP_KERNEL); + tas5805m = devm_kzalloc(dev, sizeof(*tas5805m), GFP_KERNEL); if (!tas5805m) return -ENOMEM;