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

Configure Feed

Select the types of activity you want to include in your feed.

Cleanup in rockchip_sai.c

Merge series from Pei Xiao <xiaopei01@kylinos.cn>:

1.Simplify the condition logic in
2.Use helper function devm_clk_get_enabled()

+13 -38
+13 -38
sound/soc/rockchip/rockchip_sai.c
··· 378 378 static void rockchip_sai_xfer_stop(struct rk_sai_dev *sai, int stream) 379 379 { 380 380 unsigned int msk = 0, val = 0, clr = 0; 381 - bool playback; 382 - bool capture; 383 - 384 - if (stream < 0) { 385 - playback = true; 386 - capture = true; 387 - } else if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 388 - playback = true; 389 - capture = false; 390 - } else { 391 - playback = true; 392 - capture = false; 393 - } 381 + bool capture = stream == SNDRV_PCM_STREAM_CAPTURE || stream < 0; 382 + bool playback = stream == SNDRV_PCM_STREAM_PLAYBACK || stream < 0; 383 + /* could be <= 0 but we don't want to depend on enum values */ 394 384 395 385 if (playback) { 396 386 msk |= SAI_XFER_TXS_MASK; ··· 1427 1437 if (irq > 0) { 1428 1438 ret = devm_request_irq(&pdev->dev, irq, rockchip_sai_isr, 1429 1439 IRQF_SHARED, node->name, sai); 1430 - if (ret) { 1440 + if (ret) 1431 1441 return dev_err_probe(&pdev->dev, ret, 1432 1442 "Failed to request irq %d\n", irq); 1433 - } 1434 1443 } else { 1435 1444 dev_dbg(&pdev->dev, "Asked for an IRQ but got %d\n", irq); 1436 1445 } 1437 1446 1438 1447 sai->mclk = devm_clk_get(&pdev->dev, "mclk"); 1439 - if (IS_ERR(sai->mclk)) { 1448 + if (IS_ERR(sai->mclk)) 1440 1449 return dev_err_probe(&pdev->dev, PTR_ERR(sai->mclk), 1441 1450 "Failed to get mclk\n"); 1442 - } 1443 1451 1444 - sai->hclk = devm_clk_get(&pdev->dev, "hclk"); 1445 - if (IS_ERR(sai->hclk)) { 1452 + sai->hclk = devm_clk_get_enabled(&pdev->dev, "hclk"); 1453 + if (IS_ERR(sai->hclk)) 1446 1454 return dev_err_probe(&pdev->dev, PTR_ERR(sai->hclk), 1447 1455 "Failed to get hclk\n"); 1448 - } 1449 - 1450 - ret = clk_prepare_enable(sai->hclk); 1451 - if (ret) 1452 - return dev_err_probe(&pdev->dev, ret, "Failed to enable hclk\n"); 1453 1456 1454 1457 regmap_read(sai->regmap, SAI_VERSION, &sai->version); 1455 1458 1456 1459 ret = rockchip_sai_init_dai(sai, res, &dai); 1457 - if (ret) { 1458 - dev_err(&pdev->dev, "Failed to initialize DAI: %d\n", ret); 1459 - goto err_disable_hclk; 1460 - } 1460 + if (ret) 1461 + return dev_err_probe(&pdev->dev, ret, "Failed to initialize DAI\n"); 1461 1462 1462 1463 ret = rockchip_sai_parse_paths(sai, node); 1463 - if (ret) { 1464 - dev_err(&pdev->dev, "Failed to parse paths: %d\n", ret); 1465 - goto err_disable_hclk; 1466 - } 1464 + if (ret) 1465 + return dev_err_probe(&pdev->dev, ret, "Failed to parse paths\n"); 1467 1466 1468 1467 /* 1469 1468 * From here on, all register accesses need to be wrapped in ··· 1463 1484 devm_pm_runtime_enable(&pdev->dev); 1464 1485 pm_runtime_get_noresume(&pdev->dev); 1465 1486 ret = rockchip_sai_runtime_resume(&pdev->dev); 1466 - if (ret) { 1467 - dev_err(&pdev->dev, "Failed to resume device: %pe\n", ERR_PTR(ret)); 1468 - goto err_disable_hclk; 1469 - } 1487 + if (ret) 1488 + return dev_err_probe(&pdev->dev, ret, "Failed to resume device\n"); 1470 1489 1471 1490 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 1472 1491 if (ret) { ··· 1491 1514 /* If we're !CONFIG_PM, we get -ENOSYS and disable manually */ 1492 1515 if (pm_runtime_put(&pdev->dev)) 1493 1516 rockchip_sai_runtime_suspend(&pdev->dev); 1494 - err_disable_hclk: 1495 - clk_disable_unprepare(sai->hclk); 1496 1517 1497 1518 return ret; 1498 1519 }