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

ALSA: hda/component: Use guard() for mutex locks

Replace the manual mutex lock/unlock pairs with guard().

Only code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250827072916.31933-16-tiwai@suse.de

+5 -13
+4 -11
sound/hda/codecs/side-codecs/hda_component.c
··· 21 21 struct hda_component *comp; 22 22 int i; 23 23 24 - mutex_lock(&parent->mutex); 24 + guard(mutex)(&parent->mutex); 25 25 for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { 26 26 comp = hda_component_from_index(parent, i); 27 27 if (comp->dev && comp->acpi_notify) 28 28 comp->acpi_notify(acpi_device_handle(comp->adev), event, comp->dev); 29 29 } 30 - mutex_unlock(&parent->mutex); 31 30 } 32 31 EXPORT_SYMBOL_NS_GPL(hda_component_acpi_device_notify, "SND_HDA_SCODEC_COMPONENT"); 33 32 ··· 88 89 struct hda_component *comp; 89 90 int i; 90 91 91 - mutex_lock(&parent->mutex); 92 + guard(mutex)(&parent->mutex); 92 93 for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { 93 94 comp = hda_component_from_index(parent, i); 94 95 if (comp->dev && comp->pre_playback_hook) ··· 104 105 if (comp->dev && comp->post_playback_hook) 105 106 comp->post_playback_hook(comp->dev, action); 106 107 } 107 - mutex_unlock(&parent->mutex); 108 108 } 109 109 EXPORT_SYMBOL_NS_GPL(hda_component_manager_playback_hook, "SND_HDA_SCODEC_COMPONENT"); 110 110 ··· 136 138 int hda_component_manager_bind(struct hda_codec *cdc, 137 139 struct hda_component_parent *parent) 138 140 { 139 - int ret; 140 - 141 141 /* Init shared and component specific data */ 142 142 memset(parent->comps, 0, sizeof(parent->comps)); 143 143 144 - mutex_lock(&parent->mutex); 145 - ret = component_bind_all(hda_codec_dev(cdc), parent); 146 - mutex_unlock(&parent->mutex); 147 - 148 - return ret; 144 + guard(mutex)(&parent->mutex); 145 + return component_bind_all(hda_codec_dev(cdc), parent); 149 146 } 150 147 EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, "SND_HDA_SCODEC_COMPONENT"); 151 148
+1 -2
sound/hda/codecs/side-codecs/hda_component.h
··· 95 95 static inline void hda_component_manager_unbind(struct hda_codec *cdc, 96 96 struct hda_component_parent *parent) 97 97 { 98 - mutex_lock(&parent->mutex); 98 + guard(mutex)(&parent->mutex); 99 99 component_unbind_all(hda_codec_dev(cdc), parent); 100 - mutex_unlock(&parent->mutex); 101 100 } 102 101 103 102 #endif /* ifndef __HDA_COMPONENT_H__ */