Skip to contentSkip to conversation

ASoC: SDCA: Tidy up some memory allocations

PATCH In review Charles Keepax 2 participants 2 messages Jan 15

Subsystems (3)
lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

PATCH 1/1 ASoC: SDCA: Tidy up some memory allocations

It is slightly better to deference the type being allocate for a sizeof rather than manually using the type. Saves effort if types change in the future. This results in no functional changes, just tidies up the style of the code a little.

---
 sound/soc/sdca/sdca_fdl.c       | 2 +-
 sound/soc/sdca/sdca_functions.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/sdca/sdca_fdl.c +1 -1
index 3180ebd07c400..8bee9f23c4739 100644
@@ -487,7 +487,7 @@ int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt)
 	struct device *dev = interrupt->dev;
 	struct fdl_state *fdl_state;
 
-	fdl_state = devm_kzalloc(dev, sizeof(struct fdl_state), GFP_KERNEL);
+	fdl_state = devm_kzalloc(dev, sizeof(*fdl_state), GFP_KERNEL);
 	if (!fdl_state)
 		return -ENOMEM;
 
sound/soc/sdca/sdca_functions.c +3 -3
index acac066f1d8dc..80c71116e6d4c 100644
@@ -952,7 +952,7 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
 	}
 
 	control->values = devm_kcalloc(dev, hweight64(control->cn_list),
-				       sizeof(int), GFP_KERNEL);
+				       sizeof(*control->values), GFP_KERNEL);
 	if (!control->values)
 		return -ENOMEM;
 
@@ -2048,7 +2048,7 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,
 	fwnode_property_read_u32_array(function_node, "mipi-sdca-file-set-id-list",
 				       filesets_list, num_sets);
 
-	sets = devm_kcalloc(dev, num_sets, sizeof(struct sdca_fdl_set), GFP_KERNEL);
+	sets = devm_kcalloc(dev, num_sets, sizeof(*sets), GFP_KERNEL);
 	if (!sets)
 		return -ENOMEM;
 
@@ -2074,7 +2074,7 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,
 		dev_dbg(dev, "fileset: %#x\n", filesets_list[i]);
 
 		files = devm_kcalloc(dev, num_entries / mult_fileset,
-				     sizeof(struct sdca_fdl_file), GFP_KERNEL);
+				     sizeof(*files), GFP_KERNEL);
 		if (!files)
 			return -ENOMEM;
 
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 6 lines · Charles Keepax

It is slightly better to deference the type being allocate for a sizeof rather than manually using the type. Saves effort if types change in the future. This results in no functional changes, just tidies up the style of the code a little.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SDCA: Tidy up some memory allocations

      commit: 61d2a7699ab39d448f44919ef15c16187e6f70ec

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark