From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <lgirdwood@gmail.com>, <pierre-louis.bossart@linux.dev>,
<yung-chuan.liao@linux.intel.com>,
<peter.ujfalusi@linux.intel.com>, <linux-sound@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>
Subject: [PATCH 2/6] ASoC: SDCA: Use __free() to manage local buffers
Date: Wed, 12 Mar 2025 17:22:01 +0000 [thread overview]
Message-ID: <20250312172205.4152686-3-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20250312172205.4152686-1-ckeepax@opensource.cirrus.com>
Use the cleanup.h helpers to manage some local buffers, this cleans up
the error paths a little.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/sdca/sdca_functions.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index 133cbde17ef48..4ee98d8fe89ed 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -913,9 +913,9 @@ static int find_sdca_entity_pde(struct device *dev,
{
static const int mult_delay = 3;
struct sdca_entity_pde *power = &entity->pde;
+ u32 *delay_list __free(kfree) = NULL;
struct sdca_pde_delay *delays;
int num_delays;
- u32 *delay_list;
int i, j;
num_delays = fwnode_property_count_u32(entity_node,
@@ -962,8 +962,6 @@ static int find_sdca_entity_pde(struct device *dev,
power->num_max_delay = num_delays;
power->max_delay = delays;
- kfree(delay_list);
-
return 0;
}
@@ -1022,8 +1020,8 @@ static int find_sdca_entities(struct device *dev,
struct fwnode_handle *function_node,
struct sdca_function_data *function)
{
+ u32 *entity_list __free(kfree) = NULL;
struct sdca_entity *entities;
- u32 *entity_list;
int num_entities;
int i, ret;
@@ -1054,8 +1052,6 @@ static int find_sdca_entities(struct device *dev,
for (i = 0; i < num_entities; i++)
entities[i].id = entity_list[i];
- kfree(entity_list);
-
/* now read subproperties */
for (i = 0; i < num_entities; i++) {
char entity_property[SDCA_PROPERTY_LENGTH];
@@ -1170,8 +1166,8 @@ static int find_sdca_entity_connection_pde(struct device *dev,
struct sdca_entity *entity)
{
struct sdca_entity_pde *power = &entity->pde;
+ u32 *managed_list __free(kfree) = NULL;
struct sdca_entity **managed;
- u32 *managed_list;
int num_managed;
int i;
@@ -1205,15 +1201,12 @@ static int find_sdca_entity_connection_pde(struct device *dev,
if (!managed[i]) {
dev_err(dev, "%s: failed to find entity with id %#x\n",
entity->label, managed_list[i]);
- kfree(managed_list);
return -EINVAL;
}
dev_info(dev, "%s -> %s\n", managed[i]->label, entity->label);
}
- kfree(managed_list);
-
power->num_managed = num_managed;
power->managed = managed;
@@ -1453,9 +1446,9 @@ static int find_sdca_clusters(struct device *dev,
struct fwnode_handle *function_node,
struct sdca_function_data *function)
{
+ u32 *cluster_list __free(kfree) = NULL;
struct sdca_cluster *clusters;
int num_clusters;
- u32 *cluster_list;
int i, ret;
num_clusters = fwnode_property_count_u32(function_node, "mipi-sdca-cluster-id-list");
@@ -1484,8 +1477,6 @@ static int find_sdca_clusters(struct device *dev,
for (i = 0; i < num_clusters; i++)
clusters[i].id = cluster_list[i];
- kfree(cluster_list);
-
/* now read subproperties */
for (i = 0; i < num_clusters; i++) {
char cluster_property[SDCA_PROPERTY_LENGTH];
--
2.39.5
next prev parent reply other threads:[~2025-03-12 17:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 17:21 [PATCH 0/6] Some minor SDCA preparation Charles Keepax
2025-03-12 17:22 ` [PATCH 1/6] ASoC: SDCA: Tidy up initialization write parsing Charles Keepax
2025-03-12 17:22 ` Charles Keepax [this message]
2025-03-12 17:22 ` [PATCH 3/6] ASoC: SDCA: Allow naming of imp def controls Charles Keepax
2025-03-12 17:22 ` [PATCH 4/6] ASoC: SDCA: Add type flag for Controls Charles Keepax
2025-03-12 17:22 ` [PATCH 5/6] ASoC: SDCA: Add SDCA Control Range data access helper Charles Keepax
2025-03-12 17:22 ` [PATCH 6/6] ASoC: SDCA: Add support for GE Entity properties Charles Keepax
2025-03-17 21:54 ` [PATCH 0/6] Some minor SDCA preparation Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250312172205.4152686-3-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox