Skip to content

Commit ec6f32b

Browse files
rfvirgiltiwai
authored andcommitted
ALSA: hda: hda_component: Initialize shared data during bind callback
Move the initialization of the shared struct hda_component array into hda_component_manager_bind(). The purpose of the manager bind() callback is to allow it to perform initialization before binding in the component drivers. This is the correct place to initialize the shared data. The original implementation initialized the shared data in hda_component_manager_init(). This is only done once during probe() of the manager driver. So if the component binding was unbound and then rebound, the shared data would not be re-initialized. Signed-off-by: Richard Fitzgerald <[email protected]> Fixes: fd895a7 ("ALSA: hda: realtek: Move hda_component implementation to module") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 172811e commit ec6f32b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

sound/pci/hda/hda_component.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ static int hda_comp_match_dev_name(struct device *dev, void *data)
123123
return !strcmp(d + n, tmp);
124124
}
125125

126+
int hda_component_manager_bind(struct hda_codec *cdc,
127+
struct hda_component *comps, int count)
128+
{
129+
int i;
130+
131+
/* Init shared data */
132+
for (i = 0; i < count; ++i) {
133+
memset(&comps[i], 0, sizeof(comps[i]));
134+
comps[i].codec = cdc;
135+
}
136+
137+
return component_bind_all(hda_codec_dev(cdc), comps);
138+
}
139+
EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, SND_HDA_SCODEC_COMPONENT);
140+
126141
int hda_component_manager_init(struct hda_codec *cdc,
127142
struct hda_component *comps, int count,
128143
const char *bus, const char *hid,
@@ -143,7 +158,6 @@ int hda_component_manager_init(struct hda_codec *cdc,
143158
sm->hid = hid;
144159
sm->match_str = match_str;
145160
sm->index = i;
146-
comps[i].codec = cdc;
147161
component_match_add(dev, &match, hda_comp_match_dev_name, sm);
148162
}
149163

sound/pci/hda/hda_component.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,8 @@ int hda_component_manager_init(struct hda_codec *cdc,
7575
void hda_component_manager_free(struct hda_codec *cdc,
7676
const struct component_master_ops *ops);
7777

78-
static inline int hda_component_manager_bind(struct hda_codec *cdc,
79-
struct hda_component *comps)
80-
{
81-
return component_bind_all(hda_codec_dev(cdc), comps);
82-
}
78+
int hda_component_manager_bind(struct hda_codec *cdc,
79+
struct hda_component *comps, int count);
8380

8481
static inline void hda_component_manager_unbind(struct hda_codec *cdc,
8582
struct hda_component *comps)

sound/pci/hda/patch_realtek.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6785,7 +6785,7 @@ static int comp_bind(struct device *dev)
67856785
struct alc_spec *spec = cdc->spec;
67866786
int ret;
67876787

6788-
ret = hda_component_manager_bind(cdc, spec->comps);
6788+
ret = hda_component_manager_bind(cdc, spec->comps, ARRAY_SIZE(spec->comps));
67896789
if (ret)
67906790
return ret;
67916791

0 commit comments

Comments
 (0)