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

ALSA: x86: 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/20250829151335.7342-7-tiwai@suse.de

+5 -11
+5 -11
sound/x86/intel_hdmi_audio.c
··· 554 554 555 555 memset(ucontrol->value.integer.value, 0, 556 556 sizeof(long) * HAD_MAX_CHANNEL); 557 - mutex_lock(&intelhaddata->mutex); 558 - if (!intelhaddata->chmap->chmap) { 559 - mutex_unlock(&intelhaddata->mutex); 557 + guard(mutex)(&intelhaddata->mutex); 558 + if (!intelhaddata->chmap->chmap) 560 559 return 0; 561 - } 562 560 563 561 chmap = intelhaddata->chmap->chmap; 564 562 for (i = 0; i < chmap->channels; i++) 565 563 ucontrol->value.integer.value[i] = chmap->map[i]; 566 - mutex_unlock(&intelhaddata->mutex); 567 564 568 565 return 0; 569 566 } ··· 1391 1394 { 1392 1395 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); 1393 1396 1394 - mutex_lock(&intelhaddata->mutex); 1397 + guard(mutex)(&intelhaddata->mutex); 1395 1398 ucontrol->value.iec958.status[0] = (intelhaddata->aes_bits >> 0) & 0xff; 1396 1399 ucontrol->value.iec958.status[1] = (intelhaddata->aes_bits >> 8) & 0xff; 1397 1400 ucontrol->value.iec958.status[2] = 1398 1401 (intelhaddata->aes_bits >> 16) & 0xff; 1399 1402 ucontrol->value.iec958.status[3] = 1400 1403 (intelhaddata->aes_bits >> 24) & 0xff; 1401 - mutex_unlock(&intelhaddata->mutex); 1402 1404 return 0; 1403 1405 } 1404 1406 ··· 1422 1426 (ucontrol->value.iec958.status[1] << 8) | 1423 1427 (ucontrol->value.iec958.status[2] << 16) | 1424 1428 (ucontrol->value.iec958.status[3] << 24); 1425 - mutex_lock(&intelhaddata->mutex); 1429 + guard(mutex)(&intelhaddata->mutex); 1426 1430 if (intelhaddata->aes_bits != val) { 1427 1431 intelhaddata->aes_bits = val; 1428 1432 changed = 1; 1429 1433 } 1430 - mutex_unlock(&intelhaddata->mutex); 1431 1434 return changed; 1432 1435 } 1433 1436 ··· 1443 1448 { 1444 1449 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); 1445 1450 1446 - mutex_lock(&intelhaddata->mutex); 1451 + guard(mutex)(&intelhaddata->mutex); 1447 1452 memcpy(ucontrol->value.bytes.data, intelhaddata->eld, 1448 1453 HDMI_MAX_ELD_BYTES); 1449 - mutex_unlock(&intelhaddata->mutex); 1450 1454 return 0; 1451 1455 } 1452 1456