ALSA: bcd2000: Use guard() for mutex locks
Replace the manual mutex lock/unlock pairs with guard() for code simplification. Only code refactoring, and no behavior change. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250829150724.6886-9-tiwai@suse.depull/476/head
parent
e5d3eeb426
commit
cff7acfe0b
|
|
@ -369,23 +369,19 @@ static int bcd2000_probe(struct usb_interface *interface,
|
|||
char usb_path[32];
|
||||
int err;
|
||||
|
||||
mutex_lock(&devices_mutex);
|
||||
guard(mutex)(&devices_mutex);
|
||||
|
||||
for (card_index = 0; card_index < SNDRV_CARDS; ++card_index)
|
||||
if (!test_bit(card_index, devices_used))
|
||||
break;
|
||||
|
||||
if (card_index >= SNDRV_CARDS) {
|
||||
mutex_unlock(&devices_mutex);
|
||||
if (card_index >= SNDRV_CARDS)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
err = snd_card_new(&interface->dev, index[card_index], id[card_index],
|
||||
THIS_MODULE, sizeof(*bcd2k), &card);
|
||||
if (err < 0) {
|
||||
mutex_unlock(&devices_mutex);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
bcd2k = card->private_data;
|
||||
bcd2k->dev = interface_to_usbdev(interface);
|
||||
|
|
@ -413,14 +409,12 @@ static int bcd2000_probe(struct usb_interface *interface,
|
|||
usb_set_intfdata(interface, bcd2k);
|
||||
set_bit(card_index, devices_used);
|
||||
|
||||
mutex_unlock(&devices_mutex);
|
||||
return 0;
|
||||
|
||||
probe_error:
|
||||
dev_info(&bcd2k->dev->dev, PREFIX "error during probing");
|
||||
bcd2000_free_usb_related_resources(bcd2k, interface);
|
||||
snd_card_free(card);
|
||||
mutex_unlock(&devices_mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -431,7 +425,7 @@ static void bcd2000_disconnect(struct usb_interface *interface)
|
|||
if (!bcd2k)
|
||||
return;
|
||||
|
||||
mutex_lock(&devices_mutex);
|
||||
guard(mutex)(&devices_mutex);
|
||||
|
||||
/* make sure that userspace cannot create new requests */
|
||||
snd_card_disconnect(bcd2k->card);
|
||||
|
|
@ -441,8 +435,6 @@ static void bcd2000_disconnect(struct usb_interface *interface)
|
|||
clear_bit(bcd2k->card_index, devices_used);
|
||||
|
||||
snd_card_free_when_closed(bcd2k->card);
|
||||
|
||||
mutex_unlock(&devices_mutex);
|
||||
}
|
||||
|
||||
static struct usb_driver bcd2000_driver = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue