Skip to content

Commit

Permalink
ALSA: hda: hda_component: Move codec field into the parent
Browse files Browse the repository at this point in the history
There is one codec shared across all of the bound HDA components and a
copy is usually stashed in the amp driver so it doesn't need to be in
every hda_component.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/20240617154105.108635-4-simont@opensource.cirrus.com
  • Loading branch information
Simon Trimmer authored and Takashi Iwai committed Jun 18, 2024
1 parent 1adf910 commit 3b2a858
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
7 changes: 4 additions & 3 deletions sound/pci/hda/cs35l41_hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,10 +1436,11 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas
mutex_lock(&cs35l41->fw_mutex);

comp->dev = dev;
cs35l41->codec = parent->codec;
if (!cs35l41->acpi_subsystem_id)
cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x",
comp->codec->core.subsystem_id);
cs35l41->codec = comp->codec;
cs35l41->codec->core.subsystem_id);

strscpy(comp->name, dev_name(dev), sizeof(comp->name));

cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT;
Expand Down Expand Up @@ -1470,7 +1471,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas
mutex_unlock(&cs35l41->fw_mutex);

sleep_flags = lock_system_sleep();
if (!device_link_add(&comp->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS))
if (!device_link_add(&cs35l41->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS))
dev_warn(dev, "Unable to create device link\n");
unlock_system_sleep(sleep_flags);

Expand Down
2 changes: 1 addition & 1 deletion sound/pci/hda/cs35l56_hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ static int cs35l56_hda_bind(struct device *dev, struct device *master, void *mas
return -EBUSY;

comp->dev = dev;
cs35l56->codec = comp->codec;
cs35l56->codec = parent->codec;
strscpy(comp->name, dev_name(dev), sizeof(comp->name));
comp->playback_hook = cs35l56_hda_playback_hook;

Expand Down
5 changes: 1 addition & 4 deletions sound/pci/hda/hda_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,9 @@ static int hda_comp_match_dev_name(struct device *dev, void *data)
int hda_component_manager_bind(struct hda_codec *cdc,
struct hda_component_parent *parent)
{
int i;

/* Init shared and component specific data */
memset(parent, 0, sizeof(*parent));
for (i = 0; i < ARRAY_SIZE(parent->comps); i++)
parent->comps[i].codec = cdc;
parent->codec = cdc;

return component_bind_all(hda_codec_dev(cdc), parent);
}
Expand Down
2 changes: 1 addition & 1 deletion sound/pci/hda/hda_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
struct hda_component {
struct device *dev;
char name[HDA_MAX_NAME_SIZE];
struct hda_codec *codec;
struct acpi_device *adev;
bool acpi_notifications_supported;
void (*acpi_notify)(acpi_handle handle, u32 event, struct device *dev);
Expand All @@ -29,6 +28,7 @@ struct hda_component {
};

struct hda_component_parent {
struct hda_codec *codec;
struct hda_component comps[HDA_MAX_COMPONENTS];
};

Expand Down
2 changes: 1 addition & 1 deletion sound/pci/hda/tas2781_hda_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ static int tas2781_hda_bind(struct device *dev, struct device *master,
if (comp->dev)
return -EBUSY;

codec = comp->codec;
codec = parent->codec;
subid = codec->core.subsystem_id >> 16;

switch (subid) {
Expand Down

0 comments on commit 3b2a858

Please sign in to comment.