]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: SDCA: Tidy up some memory allocations
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Thu, 15 Jan 2026 11:46:07 +0000 (11:46 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 15 Jan 2026 12:46:10 +0000 (12:46 +0000)
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.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20260115114607.271990-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sdca/sdca_fdl.c
sound/soc/sdca/sdca_functions.c

index 3180ebd07c4007adc070dacdc39344d3db7e7697..8bee9f23c4739f2c32dbe29173df7d81e97f9a9f 100644 (file)
@@ -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;
 
index acac066f1d8dc9b466e9965f6190ccf61cbdbd29..80c71116e6d4c69cfeaa2a8eedf564f58145ecfc 100644 (file)
@@ -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;