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

ALSA: ac97: Fix assignment in if condition

AC97 codec driver code contains a lot of assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-35-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+228 -114
+136 -69
sound/pci/ac97/ac97_codec.c
··· 1286 1286 1287 1287 if (snd_ac97_try_bit(ac97, reg, 15)) { 1288 1288 sprintf(name, "%s Switch", pfx); 1289 - if ((err = snd_ac97_cmute_new_stereo(card, name, reg, 1290 - check_stereo, check_amix, 1291 - ac97)) < 0) 1289 + err = snd_ac97_cmute_new_stereo(card, name, reg, 1290 + check_stereo, check_amix, 1291 + ac97); 1292 + if (err < 0) 1292 1293 return err; 1293 1294 } 1294 1295 check_volume_resolution(ac97, reg, &lo_max, &hi_max); 1295 1296 if (lo_max) { 1296 1297 sprintf(name, "%s Volume", pfx); 1297 - if ((err = snd_ac97_cvol_new(card, name, reg, lo_max, hi_max, ac97)) < 0) 1298 + err = snd_ac97_cvol_new(card, name, reg, lo_max, hi_max, ac97); 1299 + if (err < 0) 1298 1300 return err; 1299 1301 } 1300 1302 return 0; ··· 1335 1333 /* build center controls */ 1336 1334 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER)) 1337 1335 && !(ac97->flags & AC97_AD_MULTI)) { 1338 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_center[0], ac97))) < 0) 1336 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_center[0], ac97)); 1337 + if (err < 0) 1339 1338 return err; 1340 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_center[1], ac97))) < 0) 1339 + err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_center[1], ac97)); 1340 + if (err < 0) 1341 1341 return err; 1342 1342 snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 0, &max); 1343 1343 kctl->private_value &= ~(0xff << 16); ··· 1351 1347 /* build LFE controls */ 1352 1348 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER+1)) 1353 1349 && !(ac97->flags & AC97_AD_MULTI)) { 1354 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_lfe[0], ac97))) < 0) 1350 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_lfe[0], ac97)); 1351 + if (err < 0) 1355 1352 return err; 1356 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_lfe[1], ac97))) < 0) 1353 + err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_lfe[1], ac97)); 1354 + if (err < 0) 1357 1355 return err; 1358 1356 snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 8, &max); 1359 1357 kctl->private_value &= ~(0xff << 16); ··· 1368 1362 if ((snd_ac97_try_volume_mix(ac97, AC97_SURROUND_MASTER)) 1369 1363 && !(ac97->flags & AC97_AD_MULTI)) { 1370 1364 /* Surround Master (0x38) is with stereo mutes */ 1371 - if ((err = snd_ac97_cmix_new_stereo(card, "Surround Playback", 1372 - AC97_SURROUND_MASTER, 1, 0, 1373 - ac97)) < 0) 1365 + err = snd_ac97_cmix_new_stereo(card, "Surround Playback", 1366 + AC97_SURROUND_MASTER, 1, 0, 1367 + ac97); 1368 + if (err < 0) 1374 1369 return err; 1375 1370 } 1376 1371 1377 1372 /* build headphone controls */ 1378 1373 if (snd_ac97_try_volume_mix(ac97, AC97_HEADPHONE)) { 1379 - if ((err = snd_ac97_cmix_new(card, "Headphone Playback", 1380 - AC97_HEADPHONE, 0, ac97)) < 0) 1374 + err = snd_ac97_cmix_new(card, "Headphone Playback", 1375 + AC97_HEADPHONE, 0, ac97); 1376 + if (err < 0) 1381 1377 return err; 1382 1378 } 1383 1379 1384 1380 /* build master mono controls */ 1385 1381 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_MONO)) { 1386 - if ((err = snd_ac97_cmix_new(card, "Master Mono Playback", 1387 - AC97_MASTER_MONO, 0, ac97)) < 0) 1382 + err = snd_ac97_cmix_new(card, "Master Mono Playback", 1383 + AC97_MASTER_MONO, 0, ac97); 1384 + if (err < 0) 1388 1385 return err; 1389 1386 } 1390 1387 ··· 1395 1386 if (!(ac97->flags & AC97_HAS_NO_TONE)) { 1396 1387 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_TONE)) { 1397 1388 for (idx = 0; idx < 2; idx++) { 1398 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_tone[idx], ac97))) < 0) 1389 + kctl = snd_ac97_cnew(&snd_ac97_controls_tone[idx], ac97); 1390 + err = snd_ctl_add(card, kctl); 1391 + if (err < 0) 1399 1392 return err; 1400 1393 if (ac97->id == AC97_ID_YMF743 || 1401 1394 ac97->id == AC97_ID_YMF753) { ··· 1413 1402 if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && 1414 1403 ((ac97->flags & AC97_HAS_PC_BEEP) || 1415 1404 snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) { 1416 - for (idx = 0; idx < 2; idx++) 1417 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97))) < 0) 1405 + for (idx = 0; idx < 2; idx++) { 1406 + kctl = snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97); 1407 + err = snd_ctl_add(card, kctl); 1408 + if (err < 0) 1418 1409 return err; 1410 + } 1419 1411 set_tlv_db_scale(kctl, db_scale_4bit); 1420 1412 snd_ac97_write_cache( 1421 1413 ac97, ··· 1431 1417 /* build Phone controls */ 1432 1418 if (!(ac97->flags & AC97_HAS_NO_PHONE)) { 1433 1419 if (snd_ac97_try_volume_mix(ac97, AC97_PHONE)) { 1434 - if ((err = snd_ac97_cmix_new(card, "Phone Playback", 1435 - AC97_PHONE, 1, ac97)) < 0) 1420 + err = snd_ac97_cmix_new(card, "Phone Playback", 1421 + AC97_PHONE, 1, ac97); 1422 + if (err < 0) 1436 1423 return err; 1437 1424 } 1438 1425 } ··· 1441 1426 /* build MIC controls */ 1442 1427 if (!(ac97->flags & AC97_HAS_NO_MIC)) { 1443 1428 if (snd_ac97_try_volume_mix(ac97, AC97_MIC)) { 1444 - if ((err = snd_ac97_cmix_new(card, "Mic Playback", 1445 - AC97_MIC, 1, ac97)) < 0) 1429 + err = snd_ac97_cmix_new(card, "Mic Playback", 1430 + AC97_MIC, 1, ac97); 1431 + if (err < 0) 1446 1432 return err; 1447 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_boost, ac97))) < 0) 1433 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_boost, ac97)); 1434 + if (err < 0) 1448 1435 return err; 1449 1436 } 1450 1437 } 1451 1438 1452 1439 /* build Line controls */ 1453 1440 if (snd_ac97_try_volume_mix(ac97, AC97_LINE)) { 1454 - if ((err = snd_ac97_cmix_new(card, "Line Playback", 1455 - AC97_LINE, 1, ac97)) < 0) 1441 + err = snd_ac97_cmix_new(card, "Line Playback", 1442 + AC97_LINE, 1, ac97); 1443 + if (err < 0) 1456 1444 return err; 1457 1445 } 1458 1446 1459 1447 /* build CD controls */ 1460 1448 if (!(ac97->flags & AC97_HAS_NO_CD)) { 1461 1449 if (snd_ac97_try_volume_mix(ac97, AC97_CD)) { 1462 - if ((err = snd_ac97_cmix_new(card, "CD Playback", 1463 - AC97_CD, 1, ac97)) < 0) 1450 + err = snd_ac97_cmix_new(card, "CD Playback", 1451 + AC97_CD, 1, ac97); 1452 + if (err < 0) 1464 1453 return err; 1465 1454 } 1466 1455 } ··· 1472 1453 /* build Video controls */ 1473 1454 if (!(ac97->flags & AC97_HAS_NO_VIDEO)) { 1474 1455 if (snd_ac97_try_volume_mix(ac97, AC97_VIDEO)) { 1475 - if ((err = snd_ac97_cmix_new(card, "Video Playback", 1476 - AC97_VIDEO, 1, ac97)) < 0) 1456 + err = snd_ac97_cmix_new(card, "Video Playback", 1457 + AC97_VIDEO, 1, ac97); 1458 + if (err < 0) 1477 1459 return err; 1478 1460 } 1479 1461 } ··· 1482 1462 /* build Aux controls */ 1483 1463 if (!(ac97->flags & AC97_HAS_NO_AUX)) { 1484 1464 if (snd_ac97_try_volume_mix(ac97, AC97_AUX)) { 1485 - if ((err = snd_ac97_cmix_new(card, "Aux Playback", 1486 - AC97_AUX, 1, ac97)) < 0) 1465 + err = snd_ac97_cmix_new(card, "Aux Playback", 1466 + AC97_AUX, 1, ac97); 1467 + if (err < 0) 1487 1468 return err; 1488 1469 } 1489 1470 } ··· 1496 1475 init_val = 0x9f9f; 1497 1476 else 1498 1477 init_val = 0x9f1f; 1499 - for (idx = 0; idx < 2; idx++) 1500 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_pcm[idx], ac97))) < 0) 1478 + for (idx = 0; idx < 2; idx++) { 1479 + kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_pcm[idx], ac97); 1480 + err = snd_ctl_add(card, kctl); 1481 + if (err < 0) 1501 1482 return err; 1483 + } 1502 1484 set_tlv_db_scale(kctl, db_scale_5bit); 1503 1485 ac97->spec.ad18xx.pcmreg[0] = init_val; 1504 1486 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) { 1505 - for (idx = 0; idx < 2; idx++) 1506 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_surround[idx], ac97))) < 0) 1487 + for (idx = 0; idx < 2; idx++) { 1488 + kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_surround[idx], ac97); 1489 + err = snd_ctl_add(card, kctl); 1490 + if (err < 0) 1507 1491 return err; 1492 + } 1508 1493 set_tlv_db_scale(kctl, db_scale_5bit); 1509 1494 ac97->spec.ad18xx.pcmreg[1] = init_val; 1510 1495 } 1511 1496 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) { 1512 - for (idx = 0; idx < 2; idx++) 1513 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_center[idx], ac97))) < 0) 1497 + for (idx = 0; idx < 2; idx++) { 1498 + kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_center[idx], ac97); 1499 + err = snd_ctl_add(card, kctl); 1500 + if (err < 0) 1514 1501 return err; 1502 + } 1515 1503 set_tlv_db_scale(kctl, db_scale_5bit); 1516 - for (idx = 0; idx < 2; idx++) 1517 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_lfe[idx], ac97))) < 0) 1504 + for (idx = 0; idx < 2; idx++) { 1505 + kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_lfe[idx], ac97); 1506 + err = snd_ctl_add(card, kctl); 1507 + if (err < 0) 1518 1508 return err; 1509 + } 1519 1510 set_tlv_db_scale(kctl, db_scale_5bit); 1520 1511 ac97->spec.ad18xx.pcmreg[2] = init_val; 1521 1512 } ··· 1548 1515 1549 1516 /* build Capture controls */ 1550 1517 if (!(ac97->flags & AC97_HAS_NO_REC_GAIN)) { 1551 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_src, ac97))) < 0) 1518 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_src, ac97)); 1519 + if (err < 0) 1552 1520 return err; 1553 1521 if (snd_ac97_try_bit(ac97, AC97_REC_GAIN, 15)) { 1554 1522 err = snd_ac97_cmute_new(card, "Capture Switch", ··· 1557 1523 if (err < 0) 1558 1524 return err; 1559 1525 } 1560 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97))) < 0) 1526 + kctl = snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97); 1527 + err = snd_ctl_add(card, kctl); 1528 + if (err < 0) 1561 1529 return err; 1562 1530 set_tlv_db_scale(kctl, db_scale_rec_gain); 1563 1531 snd_ac97_write_cache(ac97, AC97_REC_SEL, 0x0000); ··· 1567 1531 } 1568 1532 /* build MIC Capture controls */ 1569 1533 if (snd_ac97_try_volume_mix(ac97, AC97_REC_GAIN_MIC)) { 1570 - for (idx = 0; idx < 2; idx++) 1571 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_mic_capture[idx], ac97))) < 0) 1534 + for (idx = 0; idx < 2; idx++) { 1535 + kctl = snd_ac97_cnew(&snd_ac97_controls_mic_capture[idx], ac97); 1536 + err = snd_ctl_add(card, kctl); 1537 + if (err < 0) 1572 1538 return err; 1539 + } 1573 1540 set_tlv_db_scale(kctl, db_scale_rec_gain); 1574 1541 snd_ac97_write_cache(ac97, AC97_REC_GAIN_MIC, 0x0000); 1575 1542 } 1576 1543 1577 1544 /* build PCM out path & mute control */ 1578 1545 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 15)) { 1579 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_PCM_OUT], ac97))) < 0) 1546 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_PCM_OUT], ac97)); 1547 + if (err < 0) 1580 1548 return err; 1581 1549 } 1582 1550 1583 1551 /* build Simulated Stereo Enhancement control */ 1584 1552 if (ac97->caps & AC97_BC_SIM_STEREO) { 1585 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT], ac97))) < 0) 1553 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT], ac97)); 1554 + if (err < 0) 1586 1555 return err; 1587 1556 } 1588 1557 1589 1558 /* build 3D Stereo Enhancement control */ 1590 1559 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 13)) { 1591 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_3D], ac97))) < 0) 1560 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_3D], ac97)); 1561 + if (err < 0) 1592 1562 return err; 1593 1563 } 1594 1564 1595 1565 /* build Loudness control */ 1596 1566 if (ac97->caps & AC97_BC_LOUDNESS) { 1597 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS], ac97))) < 0) 1567 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS], ac97)); 1568 + if (err < 0) 1598 1569 return err; 1599 1570 } 1600 1571 1601 1572 /* build Mono output select control */ 1602 1573 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 9)) { 1603 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MONO], ac97))) < 0) 1574 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MONO], ac97)); 1575 + if (err < 0) 1604 1576 return err; 1605 1577 } 1606 1578 1607 1579 /* build Mic select control */ 1608 1580 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 8)) { 1609 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MIC], ac97))) < 0) 1581 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MIC], ac97)); 1582 + if (err < 0) 1610 1583 return err; 1611 1584 } 1612 1585 1613 1586 /* build ADC/DAC loopback control */ 1614 1587 if (enable_loopback && snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 7)) { 1615 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOOPBACK], ac97))) < 0) 1588 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOOPBACK], ac97)); 1589 + if (err < 0) 1616 1590 return err; 1617 1591 } 1618 1592 ··· 1638 1592 snd_ac97_write(ac97, AC97_3D_CONTROL, val); 1639 1593 val = snd_ac97_read(ac97, AC97_3D_CONTROL); 1640 1594 val = val == 0x0606; 1641 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) 1595 + kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); 1596 + err = snd_ctl_add(card, kctl); 1597 + if (err < 0) 1642 1598 return err; 1643 1599 if (val) 1644 1600 kctl->private_value = AC97_3D_CONTROL | (9 << 8) | (7 << 16); 1645 - if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[1], ac97))) < 0) 1601 + kctl = snd_ac97_cnew(&snd_ac97_controls_3d[1], ac97); 1602 + err = snd_ctl_add(card, kctl); 1603 + if (err < 0) 1646 1604 return err; 1647 1605 if (val) 1648 1606 kctl->private_value = AC97_3D_CONTROL | (1 << 8) | (7 << 16); ··· 1663 1613 1664 1614 if ((ac97->ext_id & AC97_EI_SPDIF) && !(ac97->scaps & AC97_SCAP_NO_SPDIF)) { 1665 1615 if (ac97->build_ops->build_spdif) { 1666 - if ((err = ac97->build_ops->build_spdif(ac97)) < 0) 1616 + err = ac97->build_ops->build_spdif(ac97); 1617 + if (err < 0) 1667 1618 return err; 1668 1619 } else { 1669 - for (idx = 0; idx < 5; idx++) 1670 - if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_spdif[idx], ac97))) < 0) 1620 + for (idx = 0; idx < 5; idx++) { 1621 + err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_spdif[idx], ac97)); 1622 + if (err < 0) 1671 1623 return err; 1624 + } 1672 1625 if (ac97->build_ops->build_post_spdif) { 1673 - if ((err = ac97->build_ops->build_post_spdif(ac97)) < 0) 1626 + err = ac97->build_ops->build_post_spdif(ac97); 1627 + if (err < 0) 1674 1628 return err; 1675 1629 } 1676 1630 /* set default PCM S/PDIF params */ ··· 1686 1632 } 1687 1633 1688 1634 /* build chip specific controls */ 1689 - if (ac97->build_ops->build_specific) 1690 - if ((err = ac97->build_ops->build_specific(ac97)) < 0) 1635 + if (ac97->build_ops->build_specific) { 1636 + err = ac97->build_ops->build_specific(ac97); 1637 + if (err < 0) 1691 1638 return err; 1639 + } 1692 1640 1693 1641 if (snd_ac97_try_bit(ac97, AC97_POWERDOWN, 15)) { 1694 1642 kctl = snd_ac97_cnew(&snd_ac97_control_eapd, ac97); ··· 1698 1642 return -ENOMEM; 1699 1643 if (ac97->scaps & AC97_SCAP_INV_EAPD) 1700 1644 set_inv_eapd(ac97, kctl); 1701 - if ((err = snd_ctl_add(card, kctl)) < 0) 1645 + err = snd_ctl_add(card, kctl); 1646 + if (err < 0) 1702 1647 return err; 1703 1648 } 1704 1649 ··· 1721 1664 snd_ac97_write(ac97, AC97_MISC_AFE, 0x0); 1722 1665 1723 1666 /* build modem switches */ 1724 - for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_modem_switches); idx++) 1725 - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ac97_controls_modem_switches[idx], ac97))) < 0) 1667 + for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_modem_switches); idx++) { 1668 + err = snd_ctl_add(card, snd_ctl_new1(&snd_ac97_controls_modem_switches[idx], ac97)); 1669 + if (err < 0) 1726 1670 return err; 1671 + } 1727 1672 1728 1673 /* build chip specific controls */ 1729 - if (ac97->build_ops->build_specific) 1730 - if ((err = ac97->build_ops->build_specific(ac97)) < 0) 1674 + if (ac97->build_ops->build_specific) { 1675 + err = ac97->build_ops->build_specific(ac97); 1676 + if (err < 0) 1731 1677 return err; 1678 + } 1732 1679 1733 1680 return 0; 1734 1681 } ··· 1977 1916 bus->clock = 48000; 1978 1917 spin_lock_init(&bus->bus_lock); 1979 1918 snd_ac97_bus_proc_init(bus); 1980 - if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { 1919 + err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops); 1920 + if (err < 0) { 1981 1921 snd_ac97_bus_free(bus); 1982 1922 return err; 1983 1923 } ··· 2006 1944 dev_set_name(&ac97->dev, "%d-%d:%s", 2007 1945 ac97->bus->card->number, ac97->num, 2008 1946 snd_ac97_get_short_name(ac97)); 2009 - if ((err = device_register(&ac97->dev)) < 0) { 1947 + err = device_register(&ac97->dev); 1948 + if (err < 0) { 2010 1949 ac97_err(ac97, "Can't register ac97 bus\n"); 2011 1950 ac97->dev.bus = NULL; 2012 1951 return err; ··· 2158 2095 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO) && !(ac97->scaps & AC97_SCAP_AUDIO)) { 2159 2096 /* test if we can write to the record gain volume register */ 2160 2097 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a06); 2161 - if (((err = snd_ac97_read(ac97, AC97_REC_GAIN)) & 0x7fff) == 0x0a06) 2098 + err = snd_ac97_read(ac97, AC97_REC_GAIN); 2099 + if ((err & 0x7fff) == 0x0a06) 2162 2100 ac97->scaps |= AC97_SCAP_AUDIO; 2163 2101 } 2164 2102 if (ac97->scaps & AC97_SCAP_AUDIO) { ··· 2312 2248 } 2313 2249 } 2314 2250 sprintf(comp, "AC97a:%08x", ac97->id); 2315 - if ((err = snd_component_add(card, comp)) < 0) { 2251 + err = snd_component_add(card, comp); 2252 + if (err < 0) { 2316 2253 snd_ac97_free(ac97); 2317 2254 return err; 2318 2255 } ··· 2333 2268 } 2334 2269 } 2335 2270 sprintf(comp, "AC97m:%08x", ac97->id); 2336 - if ((err = snd_component_add(card, comp)) < 0) { 2271 + err = snd_component_add(card, comp); 2272 + if (err < 0) { 2337 2273 snd_ac97_free(ac97); 2338 2274 return err; 2339 2275 } ··· 2346 2280 if (ac97_is_audio(ac97)) 2347 2281 update_power_regs(ac97); 2348 2282 snd_ac97_proc_init(ac97); 2349 - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ac97, &ops)) < 0) { 2283 + err = snd_device_new(card, SNDRV_DEV_CODEC, ac97, &ops); 2284 + if (err < 0) { 2350 2285 snd_ac97_free(ac97); 2351 2286 return err; 2352 2287 }
+92 -45
sound/pci/ac97/ac97_patch.c
··· 29 29 { 30 30 int idx, err; 31 31 32 - for (idx = 0; idx < count; idx++) 33 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97))) < 0) 32 + for (idx = 0; idx < count; idx++) { 33 + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97)); 34 + if (err < 0) 34 35 return err; 36 + } 35 37 return 0; 36 38 } 37 39 ··· 418 416 { 419 417 int err; 420 418 421 - if ((err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif))) < 0) 419 + err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif)); 420 + if (err < 0) 422 421 return err; 423 422 return 0; 424 423 } ··· 464 461 int err, i; 465 462 466 463 for (i = 0; i < ARRAY_SIZE(wm97xx_snd_ac97_controls); i++) { 467 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0) 464 + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97)); 465 + if (err < 0) 468 466 return err; 469 467 } 470 468 snd_ac97_write_cache(ac97, AC97_WM97XX_FMIXER_VOL, 0x0808); ··· 495 491 { 496 492 int err, i; 497 493 for (i = 0; i < ARRAY_SIZE(wm9704_snd_ac97_controls); i++) { 498 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97))) < 0) 494 + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97)); 495 + if (err < 0) 499 496 return err; 500 497 } 501 498 /* patch for DVD noise */ ··· 636 631 int err, i; 637 632 638 633 for (i = 0; i < ARRAY_SIZE(wm9711_snd_ac97_controls); i++) { 639 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97))) < 0) 634 + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97)); 635 + if (err < 0) 640 636 return err; 641 637 } 642 638 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808); ··· 804 798 int err, i; 805 799 806 800 for (i = 0; i < ARRAY_SIZE(wm13_snd_ac97_controls_3d); i++) { 807 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97))) < 0) 801 + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97)); 802 + if (err < 0) 808 803 return err; 809 804 } 810 805 return 0; ··· 816 809 int err, i; 817 810 818 811 for (i = 0; i < ARRAY_SIZE(wm13_snd_ac97_controls); i++) { 819 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97))) < 0) 812 + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97)); 813 + if (err < 0) 820 814 return err; 821 815 } 822 816 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808); ··· 891 883 struct snd_kcontrol *kctl; 892 884 int err; 893 885 894 - if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) 886 + err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97)); 887 + if (err < 0) 895 888 return err; 896 889 strcpy(kctl->id.name, "3D Control Sigmatel - Depth"); 897 890 kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 2, 3, 0); ··· 905 896 struct snd_kcontrol *kctl; 906 897 int err; 907 898 908 - if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) 899 + kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); 900 + err = snd_ctl_add(ac97->bus->card, kctl); 901 + if (err < 0) 909 902 return err; 910 903 strcpy(kctl->id.name, "3D Control Sigmatel - Depth"); 911 904 kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 0, 3, 0); 912 - if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) 905 + kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); 906 + err = snd_ctl_add(ac97->bus->card, kctl); 907 + if (err < 0) 913 908 return err; 914 909 strcpy(kctl->id.name, "3D Control Sigmatel - Rear Depth"); 915 910 kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 2, 3, 0); ··· 940 927 int err; 941 928 942 929 snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003); 943 - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) 944 - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1)) < 0) 930 + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) { 931 + err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1); 932 + if (err < 0) 945 933 return err; 946 - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) 947 - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1)) < 0) 934 + } 935 + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) { 936 + err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1); 937 + if (err < 0) 948 938 return err; 949 - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) 950 - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1)) < 0) 939 + } 940 + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) { 941 + err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1); 942 + if (err < 0) 951 943 return err; 952 - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) 953 - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1)) < 0) 944 + } 945 + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) { 946 + err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1); 947 + if (err < 0) 954 948 return err; 949 + } 955 950 return 0; 956 951 } 957 952 ··· 1005 984 snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL); 1006 985 1007 986 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback"); 1008 - if ((err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1)) < 0) 987 + err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1); 988 + if (err < 0) 1009 989 return err; 1010 990 return patch_sigmatel_stac97xx_specific(ac97); 1011 991 } ··· 1284 1262 int err; 1285 1263 1286 1264 /* con mask, pro mask, default */ 1287 - if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0) 1265 + err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3); 1266 + if (err < 0) 1288 1267 return err; 1289 1268 /* switch, spsa */ 1290 - if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1)) < 0) 1269 + err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1); 1270 + if (err < 0) 1291 1271 return err; 1292 1272 switch (ac97->id & AC97_ID_CS_MASK) { 1293 1273 case AC97_ID_CS4205: 1294 - if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1)) < 0) 1274 + err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1); 1275 + if (err < 0) 1295 1276 return err; 1296 1277 break; 1297 1278 } ··· 1349 1324 int err; 1350 1325 1351 1326 /* con mask, pro mask, default */ 1352 - if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0) 1327 + err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3); 1328 + if (err < 0) 1353 1329 return err; 1354 1330 /* switch */ 1355 - if ((err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1)) < 0) 1331 + err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1); 1332 + if (err < 0) 1356 1333 return err; 1357 1334 /* set default PCM S/PDIF params */ 1358 1335 /* consumer,PCM audio,no copyright,no preemphasis,PCM coder,original,48000Hz */ ··· 1619 1592 { 1620 1593 int err; 1621 1594 1622 - if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0) 1595 + err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885)); 1596 + if (err < 0) 1623 1597 return err; 1624 1598 reset_tlv(ac97, "Headphone Playback Volume", 1625 1599 db_scale_6bit_6db_max); ··· 1903 1875 { 1904 1876 int err; 1905 1877 1906 - if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) 1878 + err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); 1879 + if (err < 0) 1907 1880 return err; 1908 1881 if (check_list(ac97, ad1981_jacks_denylist)) 1909 1882 return 0; ··· 2089 2060 { 2090 2061 int err; 2091 2062 2092 - if ((err = patch_ad1888_specific(ac97)) < 0) 2063 + err = patch_ad1888_specific(ac97); 2064 + if (err < 0) 2093 2065 return err; 2094 2066 return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); 2095 2067 } ··· 2198 2168 "Master Surround Playback"); 2199 2169 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); 2200 2170 2201 - if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) 2171 + err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); 2172 + if (err < 0) 2202 2173 return err; 2203 2174 2204 2175 return patch_build_controls(ac97, snd_ac97_ad1985_controls, ··· 2491 2460 { 2492 2461 int err; 2493 2462 2494 - if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) 2463 + err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); 2464 + if (err < 0) 2495 2465 return err; 2496 2466 2497 2467 return patch_build_controls(ac97, snd_ac97_ad1986_controls, ··· 2614 2582 { 2615 2583 int err; 2616 2584 2617 - if ((err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650))) < 0) 2585 + err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650)); 2586 + if (err < 0) 2618 2587 return err; 2619 2588 if (ac97->ext_id & AC97_EI_SPDIF) { 2620 - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650))) < 0) 2589 + err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650)); 2590 + if (err < 0) 2621 2591 return err; 2622 2592 } 2623 2593 if (ac97->id != AC97_ID_ALC650F) ··· 2769 2735 { 2770 2736 int err; 2771 2737 2772 - if ((err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655))) < 0) 2738 + err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655)); 2739 + if (err < 0) 2773 2740 return err; 2774 2741 if (ac97->ext_id & AC97_EI_SPDIF) { 2775 - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0) 2742 + err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655)); 2743 + if (err < 0) 2776 2744 return err; 2777 2745 } 2778 2746 return 0; ··· 2883 2847 { 2884 2848 int err; 2885 2849 2886 - if ((err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850))) < 0) 2850 + err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850)); 2851 + if (err < 0) 2887 2852 return err; 2888 2853 if (ac97->ext_id & AC97_EI_SPDIF) { 2889 - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0) 2854 + err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655)); 2855 + if (err < 0) 2890 2856 return err; 2891 2857 } 2892 2858 return 0; ··· 3475 3437 struct snd_kcontrol *kctl; 3476 3438 int err; 3477 3439 3478 - if (snd_ac97_try_bit(ac97, 0x5a, 9)) 3479 - if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1)) < 0) 3440 + if (snd_ac97_try_bit(ac97, 0x5a, 9)) { 3441 + err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1); 3442 + if (err < 0) 3480 3443 return err; 3481 - if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1)) < 0) 3444 + } 3445 + err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1); 3446 + if (err < 0) 3482 3447 return err; 3483 3448 3484 3449 /* There is already a misnamed master switch. Rename it. */ ··· 3851 3810 static int patch_it2646_specific(struct snd_ac97 * ac97) 3852 3811 { 3853 3812 int err; 3854 - if ((err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646))) < 0) 3813 + err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646)); 3814 + if (err < 0) 3855 3815 return err; 3856 - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646))) < 0) 3816 + err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646)); 3817 + if (err < 0) 3857 3818 return err; 3858 3819 return 0; 3859 3820 } ··· 3888 3845 static int patch_si3036_specific(struct snd_ac97 * ac97) 3889 3846 { 3890 3847 int idx, err; 3891 - for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_si3036); idx++) 3892 - if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97))) < 0) 3848 + for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_si3036); idx++) { 3849 + err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97)); 3850 + if (err < 0) 3893 3851 return err; 3852 + } 3894 3853 return 0; 3895 3854 } 3896 3855 ··· 3957 3912 static int patch_ucb1400_specific(struct snd_ac97 * ac97) 3958 3913 { 3959 3914 int idx, err; 3960 - for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_ucb1400); idx++) 3961 - if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97))) < 0) 3915 + for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_ucb1400); idx++) { 3916 + err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97)); 3917 + if (err < 0) 3962 3918 return err; 3919 + } 3963 3920 return 0; 3964 3921 } 3965 3922