From: Simon Trimmer <simont@opensource.cirrus.com>
To: <tiwai@suse.com>
Cc: <linux-sound@vger.kernel.org>, <alsa-devel@alsa-project.org>,
<linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>,
<soyer@irl.hu>, <shenghao-ding@ti.com>, <kevin-lu@ti.com>,
<baojun.xu@ti.com>, Simon Trimmer <simont@opensource.cirrus.com>
Subject: [PATCH 3/4] ALSA: hda: hda_component: Move codec field into the parent
Date: Mon, 17 Jun 2024 16:41:04 +0100 [thread overview]
Message-ID: <20240617154105.108635-4-simont@opensource.cirrus.com> (raw)
In-Reply-To: <20240617154105.108635-1-simont@opensource.cirrus.com>
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>
---
sound/pci/hda/cs35l41_hda.c | 7 ++++---
sound/pci/hda/cs35l56_hda.c | 2 +-
sound/pci/hda/hda_component.c | 5 +----
sound/pci/hda/hda_component.h | 2 +-
sound/pci/hda/tas2781_hda_i2c.c | 2 +-
5 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 32c9d95150ba..9c45d5953c80 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -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;
@@ -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);
diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c
index abe415795d90..53dee0286ee1 100644
--- a/sound/pci/hda/cs35l56_hda.c
+++ b/sound/pci/hda/cs35l56_hda.c
@@ -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;
diff --git a/sound/pci/hda/hda_component.c b/sound/pci/hda/hda_component.c
index 8c11c8b37799..1a9950b76866 100644
--- a/sound/pci/hda/hda_component.c
+++ b/sound/pci/hda/hda_component.c
@@ -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);
}
diff --git a/sound/pci/hda/hda_component.h b/sound/pci/hda/hda_component.h
index e547e1f1e674..dd4dabeae9ee 100644
--- a/sound/pci/hda/hda_component.h
+++ b/sound/pci/hda/hda_component.h
@@ -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);
@@ -29,6 +28,7 @@ struct hda_component {
};
struct hda_component_parent {
+ struct hda_codec *codec;
struct hda_component comps[HDA_MAX_COMPONENTS];
};
diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c
index 2794acd4c9ab..7fab19f85968 100644
--- a/sound/pci/hda/tas2781_hda_i2c.c
+++ b/sound/pci/hda/tas2781_hda_i2c.c
@@ -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) {
--
2.34.1
next prev parent reply other threads:[~2024-06-17 15:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 15:41 [PATCH v3 0/4] ALSA: hda: Improvements to hda_component Simon Trimmer
2024-06-17 15:41 ` [PATCH 1/4] ALSA: hda: hda_component: Introduce component parent structure Simon Trimmer
2024-06-17 15:41 ` [PATCH 2/4] ALSA: hda: hda_component: Change codecs to use " Simon Trimmer
2024-06-17 15:41 ` Simon Trimmer [this message]
2024-06-17 15:41 ` [PATCH 4/4] ALSA: hda: hda_component: Protect shared data with a mutex Simon Trimmer
2024-06-18 9:53 ` [PATCH v3 0/4] ALSA: hda: Improvements to hda_component Takashi Iwai
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=20240617154105.108635-4-simont@opensource.cirrus.com \
--to=simont@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=baojun.xu@ti.com \
--cc=kevin-lu@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=shenghao-ding@ti.com \
--cc=soyer@irl.hu \
--cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.