Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <rf@opensource.cirrus.com>
Fixes: fd895a74dc1d ("ALSA: hda: realtek: Move hda_component implementation to module")
Link: https://lore.kernel.org/r/20240508100347.47283-1-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Richard Fitzgerald and committed by
Takashi Iwai
ec6f32bc 172811e3

+18 -7
+15 -1
sound/pci/hda/hda_component.c
··· 123 123 return !strcmp(d + n, tmp); 124 124 } 125 125 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 + 126 141 int hda_component_manager_init(struct hda_codec *cdc, 127 142 struct hda_component *comps, int count, 128 143 const char *bus, const char *hid, ··· 158 143 sm->hid = hid; 159 144 sm->match_str = match_str; 160 145 sm->index = i; 161 - comps[i].codec = cdc; 162 146 component_match_add(dev, &match, hda_comp_match_dev_name, sm); 163 147 } 164 148
+2 -5
sound/pci/hda/hda_component.h
··· 75 75 void hda_component_manager_free(struct hda_codec *cdc, 76 76 const struct component_master_ops *ops); 77 77 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); 83 80 84 81 static inline void hda_component_manager_unbind(struct hda_codec *cdc, 85 82 struct hda_component *comps)
+1 -1
sound/pci/hda/patch_realtek.c
··· 6785 6785 struct alc_spec *spec = cdc->spec; 6786 6786 int ret; 6787 6787 6788 - ret = hda_component_manager_bind(cdc, spec->comps); 6788 + ret = hda_component_manager_bind(cdc, spec->comps, ARRAY_SIZE(spec->comps)); 6789 6789 if (ret) 6790 6790 return ret; 6791 6791