Skip to content

Commit e7af416

Browse files
rfvirgilbroonie
authored andcommitted
firmware: cs_dsp: Remove unused struct list_head from cs_dsp_coeff_ctl
Remove two unused pointers from struct cs_dsp_coeff_ctl by taking the struct list_head out of struct cs_dsp_alg_region. On a x86_64 build this saves 16 bytes per control. Each cs_dsp_coeff_ctl instance needs to keep information about the algorithm region it refers to. This is done by embedding an instance of struct cs_dsp_alg_region. But cs_dsp_alg_region was also used to store entries in a list of algorithm regions, and so had a struct list_head object for that purpose. This list_head object is not used with the embedded object in struct cs_dsp_alg_region so was just wasted bytes. A new struct cs_dsp_alg_region_list_item has been defined for creating the list of algorithm regions. It contains a struct cs_dsp_alg_region and a struct list_head. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20250616103052.66537-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 000d8b9 commit e7af416

2 files changed

Lines changed: 25 additions & 22 deletions

File tree

drivers/firmware/cirrus/cs_dsp.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ static const struct cs_dsp_ops cs_dsp_adsp2_ops[];
311311
static const struct cs_dsp_ops cs_dsp_halo_ops;
312312
static const struct cs_dsp_ops cs_dsp_halo_ao_ops;
313313

314+
struct cs_dsp_alg_region_list_item {
315+
struct list_head list;
316+
struct cs_dsp_alg_region alg_region;
317+
};
318+
314319
struct cs_dsp_buf {
315320
struct list_head list;
316321
void *buf;
@@ -1752,13 +1757,13 @@ static void *cs_dsp_read_algs(struct cs_dsp *dsp, size_t n_algs,
17521757
struct cs_dsp_alg_region *cs_dsp_find_alg_region(struct cs_dsp *dsp,
17531758
int type, unsigned int id)
17541759
{
1755-
struct cs_dsp_alg_region *alg_region;
1760+
struct cs_dsp_alg_region_list_item *item;
17561761

17571762
lockdep_assert_held(&dsp->pwr_lock);
17581763

1759-
list_for_each_entry(alg_region, &dsp->alg_regions, list) {
1760-
if (id == alg_region->alg && type == alg_region->type)
1761-
return alg_region;
1764+
list_for_each_entry(item, &dsp->alg_regions, list) {
1765+
if (id == item->alg_region.alg && type == item->alg_region.type)
1766+
return &item->alg_region;
17621767
}
17631768

17641769
return NULL;
@@ -1769,35 +1774,35 @@ static struct cs_dsp_alg_region *cs_dsp_create_region(struct cs_dsp *dsp,
17691774
int type, __be32 id,
17701775
__be32 ver, __be32 base)
17711776
{
1772-
struct cs_dsp_alg_region *alg_region;
1777+
struct cs_dsp_alg_region_list_item *item;
17731778

1774-
alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL);
1775-
if (!alg_region)
1779+
item = kzalloc(sizeof(*item), GFP_KERNEL);
1780+
if (!item)
17761781
return ERR_PTR(-ENOMEM);
17771782

1778-
alg_region->type = type;
1779-
alg_region->alg = be32_to_cpu(id);
1780-
alg_region->ver = be32_to_cpu(ver);
1781-
alg_region->base = be32_to_cpu(base);
1783+
item->alg_region.type = type;
1784+
item->alg_region.alg = be32_to_cpu(id);
1785+
item->alg_region.ver = be32_to_cpu(ver);
1786+
item->alg_region.base = be32_to_cpu(base);
17821787

1783-
list_add_tail(&alg_region->list, &dsp->alg_regions);
1788+
list_add_tail(&item->list, &dsp->alg_regions);
17841789

17851790
if (dsp->wmfw_ver > 0)
1786-
cs_dsp_ctl_fixup_base(dsp, alg_region);
1791+
cs_dsp_ctl_fixup_base(dsp, &item->alg_region);
17871792

1788-
return alg_region;
1793+
return &item->alg_region;
17891794
}
17901795

17911796
static void cs_dsp_free_alg_regions(struct cs_dsp *dsp)
17921797
{
1793-
struct cs_dsp_alg_region *alg_region;
1798+
struct cs_dsp_alg_region_list_item *item;
17941799

17951800
while (!list_empty(&dsp->alg_regions)) {
1796-
alg_region = list_first_entry(&dsp->alg_regions,
1797-
struct cs_dsp_alg_region,
1798-
list);
1799-
list_del(&alg_region->list);
1800-
kfree(alg_region);
1801+
item = list_first_entry(&dsp->alg_regions,
1802+
struct cs_dsp_alg_region_list_item,
1803+
list);
1804+
list_del(&item->list);
1805+
kfree(item);
18011806
}
18021807
}
18031808

include/linux/firmware/cirrus/cs_dsp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ struct cs_dsp_region {
6464

6565
/**
6666
* struct cs_dsp_alg_region - Describes a logical algorithm region in DSP address space
67-
* @list: List node for internal use
6867
* @alg: Algorithm id
6968
* @ver: Expected algorithm version
7069
* @type: Memory region type
7170
* @base: Address of region
7271
*/
7372
struct cs_dsp_alg_region {
74-
struct list_head list;
7573
unsigned int alg;
7674
unsigned int ver;
7775
int type;

0 commit comments

Comments
 (0)