]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: hda/component: Use guard() for mutex locks
authorTakashi Iwai <tiwai@suse.de>
Wed, 27 Aug 2025 07:28:55 +0000 (09:28 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 09:52:15 +0000 (11:52 +0200)
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
sound/hda/codecs/side-codecs/hda_component.c
sound/hda/codecs/side-codecs/hda_component.h

index 71860e2d637716147b7b8e29c67273150d2a4523..bcf47a301697cdf0368f5d9675fa237af2b13d28 100644 (file)
@@ -21,13 +21,12 @@ void hda_component_acpi_device_notify(struct hda_component_parent *parent,
        struct hda_component *comp;
        int i;
 
-       mutex_lock(&parent->mutex);
+       guard(mutex)(&parent->mutex);
        for (i = 0; i < ARRAY_SIZE(parent->comps); i++) {
                comp = hda_component_from_index(parent, i);
                if (comp->dev && comp->acpi_notify)
                        comp->acpi_notify(acpi_device_handle(comp->adev), event, comp->dev);
        }
-       mutex_unlock(&parent->mutex);
 }
 EXPORT_SYMBOL_NS_GPL(hda_component_acpi_device_notify, "SND_HDA_SCODEC_COMPONENT");
 
@@ -89,7 +88,7 @@ void hda_component_manager_playback_hook(struct hda_component_parent *parent, in
        struct hda_component *comp;
        int i;
 
-       mutex_lock(&parent->mutex);
+       guard(mutex)(&parent->mutex);
        for (i = 0; i < ARRAY_SIZE(parent->comps); i++) {
                comp = hda_component_from_index(parent, i);
                if (comp->dev && comp->pre_playback_hook)
@@ -105,7 +104,6 @@ void hda_component_manager_playback_hook(struct hda_component_parent *parent, in
                if (comp->dev && comp->post_playback_hook)
                        comp->post_playback_hook(comp->dev, action);
        }
-       mutex_unlock(&parent->mutex);
 }
 EXPORT_SYMBOL_NS_GPL(hda_component_manager_playback_hook, "SND_HDA_SCODEC_COMPONENT");
 
@@ -138,16 +136,11 @@ 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 ret;
-
        /* Init shared and component specific data */
        memset(parent->comps, 0, sizeof(parent->comps));
 
-       mutex_lock(&parent->mutex);
-       ret = component_bind_all(hda_codec_dev(cdc), parent);
-       mutex_unlock(&parent->mutex);
-
-       return ret;
+       guard(mutex)(&parent->mutex);
+       return component_bind_all(hda_codec_dev(cdc), parent);
 }
 EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, "SND_HDA_SCODEC_COMPONENT");
 
index 7ee37154749fe37f40ed7b7cc936e6ccd42794e2..075137a73baec53363fee04eb0bf91e30fa34724 100644 (file)
@@ -95,9 +95,8 @@ static inline struct hda_component *hda_component_from_index(struct hda_componen
 static inline void hda_component_manager_unbind(struct hda_codec *cdc,
                                                struct hda_component_parent *parent)
 {
-       mutex_lock(&parent->mutex);
+       guard(mutex)(&parent->mutex);
        component_unbind_all(hda_codec_dev(cdc), parent);
-       mutex_unlock(&parent->mutex);
 }
 
 #endif /* ifndef __HDA_COMPONENT_H__ */