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

ASoC: cleanup mutex lock

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

ASoC is using many type of mutex lock, but
some of them has helper function, but some doesn't.
Or, it has helper function, but is static.

This patch-set adds helper function and use it.

+216 -127
+16 -1
include/sound/soc-card.h
··· 9 9 #define __SOC_CARD_H 10 10 11 11 enum snd_soc_card_subclass { 12 - SND_SOC_CARD_CLASS_INIT = 0, 12 + SND_SOC_CARD_CLASS_ROOT = 0, 13 13 SND_SOC_CARD_CLASS_RUNTIME = 1, 14 14 }; 15 + 16 + static inline void snd_soc_card_mutex_lock_root(struct snd_soc_card *card) 17 + { 18 + mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_ROOT); 19 + } 20 + 21 + static inline void snd_soc_card_mutex_lock(struct snd_soc_card *card) 22 + { 23 + mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 24 + } 25 + 26 + static inline void snd_soc_card_mutex_unlock(struct snd_soc_card *card) 27 + { 28 + mutex_unlock(&card->mutex); 29 + } 15 30 16 31 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, 17 32 const char *name);
-5
include/sound/soc-dapm.h
··· 527 527 SND_SOC_DAPM_TYPE_COUNT 528 528 }; 529 529 530 - enum snd_soc_dapm_subclass { 531 - SND_SOC_DAPM_CLASS_INIT = 0, 532 - SND_SOC_DAPM_CLASS_RUNTIME = 1, 533 - }; 534 - 535 530 /* 536 531 * DAPM audio route definition. 537 532 *
+100 -5
include/sound/soc.h
··· 1364 1364 1365 1365 extern const struct dev_pm_ops snd_soc_pm_ops; 1366 1366 1367 - /* Helper functions */ 1368 - static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm) 1367 + /* 1368 + * DAPM helper functions 1369 + */ 1370 + enum snd_soc_dapm_subclass { 1371 + SND_SOC_DAPM_CLASS_ROOT = 0, 1372 + SND_SOC_DAPM_CLASS_RUNTIME = 1, 1373 + }; 1374 + 1375 + static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card) 1369 1376 { 1370 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 1377 + mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT); 1371 1378 } 1372 1379 1373 - static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) 1380 + static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card) 1374 1381 { 1375 - mutex_unlock(&dapm->card->dapm_mutex); 1382 + mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 1376 1383 } 1384 + 1385 + static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card) 1386 + { 1387 + mutex_unlock(&card->dapm_mutex); 1388 + } 1389 + 1390 + static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card) 1391 + { 1392 + lockdep_assert_held(&card->dapm_mutex); 1393 + } 1394 + 1395 + static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm) 1396 + { 1397 + _snd_soc_dapm_mutex_lock_root_c(dapm->card); 1398 + } 1399 + 1400 + static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm) 1401 + { 1402 + _snd_soc_dapm_mutex_lock_c(dapm->card); 1403 + } 1404 + 1405 + static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm) 1406 + { 1407 + _snd_soc_dapm_mutex_unlock_c(dapm->card); 1408 + } 1409 + 1410 + static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm) 1411 + { 1412 + _snd_soc_dapm_mutex_assert_held_c(dapm->card); 1413 + } 1414 + 1415 + #define snd_soc_dapm_mutex_lock_root(x) _Generic((x), \ 1416 + struct snd_soc_card * : _snd_soc_dapm_mutex_lock_root_c, \ 1417 + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_root_d)(x) 1418 + #define snd_soc_dapm_mutex_lock(x) _Generic((x), \ 1419 + struct snd_soc_card * : _snd_soc_dapm_mutex_lock_c, \ 1420 + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_d)(x) 1421 + #define snd_soc_dapm_mutex_unlock(x) _Generic((x), \ 1422 + struct snd_soc_card * : _snd_soc_dapm_mutex_unlock_c, \ 1423 + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_unlock_d)(x) 1424 + #define snd_soc_dapm_mutex_assert_held(x) _Generic((x), \ 1425 + struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \ 1426 + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x) 1427 + 1428 + /* 1429 + * PCM helper functions 1430 + */ 1431 + static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card) 1432 + { 1433 + mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); 1434 + } 1435 + 1436 + static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card) 1437 + { 1438 + mutex_unlock(&card->pcm_mutex); 1439 + } 1440 + 1441 + static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card) 1442 + { 1443 + lockdep_assert_held(&card->pcm_mutex); 1444 + } 1445 + 1446 + static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd) 1447 + { 1448 + _snd_soc_dpcm_mutex_lock_c(rtd->card); 1449 + } 1450 + 1451 + static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd) 1452 + { 1453 + _snd_soc_dpcm_mutex_unlock_c(rtd->card); 1454 + } 1455 + 1456 + static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd) 1457 + { 1458 + _snd_soc_dpcm_mutex_assert_held_c(rtd->card); 1459 + } 1460 + 1461 + #define snd_soc_dpcm_mutex_lock(x) _Generic((x), \ 1462 + struct snd_soc_card * : _snd_soc_dpcm_mutex_lock_c, \ 1463 + struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_lock_r)(x) 1464 + 1465 + #define snd_soc_dpcm_mutex_unlock(x) _Generic((x), \ 1466 + struct snd_soc_card * : _snd_soc_dpcm_mutex_unlock_c, \ 1467 + struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_unlock_r)(x) 1468 + 1469 + #define snd_soc_dpcm_mutex_assert_held(x) _Generic((x), \ 1470 + struct snd_soc_card * : _snd_soc_dpcm_mutex_assert_held_c, \ 1471 + struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_assert_held_r)(x) 1377 1472 1378 1473 #include <sound/soc-component.h> 1379 1474 #include <sound/soc-card.h>
+6 -6
sound/soc/soc-component.c
··· 550 550 struct snd_soc_component *component; 551 551 int i, ret = 0; 552 552 553 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 553 + snd_soc_dpcm_mutex_lock(rtd); 554 554 555 555 for_each_rtd_components(rtd, i, component) { 556 556 if (component->driver->compress_ops && ··· 561 561 } 562 562 } 563 563 564 - mutex_unlock(&rtd->card->pcm_mutex); 564 + snd_soc_dpcm_mutex_unlock(rtd); 565 565 566 566 return soc_component_ret(component, ret); 567 567 } ··· 574 574 struct snd_soc_component *component; 575 575 int i, ret = 0; 576 576 577 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 577 + snd_soc_dpcm_mutex_lock(rtd); 578 578 579 579 for_each_rtd_components(rtd, i, component) { 580 580 if (component->driver->compress_ops && ··· 585 585 } 586 586 } 587 587 588 - mutex_unlock(&rtd->card->pcm_mutex); 588 + snd_soc_dpcm_mutex_unlock(rtd); 589 589 590 590 return soc_component_ret(component, ret); 591 591 } ··· 638 638 struct snd_soc_component *component; 639 639 int i, ret = 0; 640 640 641 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 641 + snd_soc_dpcm_mutex_lock(rtd); 642 642 643 643 for_each_rtd_components(rtd, i, component) { 644 644 if (component->driver->compress_ops && ··· 649 649 } 650 650 } 651 651 652 - mutex_unlock(&rtd->card->pcm_mutex); 652 + snd_soc_dpcm_mutex_unlock(rtd); 653 653 654 654 return soc_component_ret(component, ret); 655 655 }
+30 -30
sound/soc/soc-compress.c
··· 62 62 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 63 63 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ 64 64 65 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 65 + snd_soc_dpcm_mutex_lock(rtd); 66 66 67 67 if (!rollback) 68 68 snd_soc_runtime_deactivate(rtd, stream); ··· 84 84 if (!rollback) 85 85 snd_soc_dapm_stream_stop(rtd, stream); 86 86 87 - mutex_unlock(&rtd->card->pcm_mutex); 87 + snd_soc_dpcm_mutex_unlock(rtd); 88 88 89 89 snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback); 90 90 ··· 107 107 if (ret < 0) 108 108 goto err_no_lock; 109 109 110 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 110 + snd_soc_dpcm_mutex_lock(rtd); 111 111 112 112 ret = snd_soc_dai_compr_startup(cpu_dai, cstream); 113 113 if (ret < 0) ··· 123 123 124 124 snd_soc_runtime_activate(rtd, stream); 125 125 err: 126 - mutex_unlock(&rtd->card->pcm_mutex); 126 + snd_soc_dpcm_mutex_unlock(rtd); 127 127 err_no_lock: 128 128 if (ret < 0) 129 129 soc_compr_clean(cstream, 1); ··· 140 140 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ 141 141 int ret; 142 142 143 - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 143 + snd_soc_card_mutex_lock(fe->card); 144 144 145 145 ret = dpcm_path_get(fe, stream, &list); 146 146 if (ret < 0) 147 147 goto be_err; 148 148 149 - mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); 149 + snd_soc_dpcm_mutex_lock(fe); 150 150 151 151 /* calculate valid and active FE <-> BE dpcms */ 152 152 dpcm_process_paths(fe, stream, &list, 1); ··· 182 182 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 183 183 184 184 snd_soc_runtime_activate(fe, stream); 185 - mutex_unlock(&fe->card->pcm_mutex); 185 + snd_soc_dpcm_mutex_unlock(fe); 186 186 187 - mutex_unlock(&fe->card->mutex); 187 + snd_soc_card_mutex_unlock(fe->card); 188 188 189 189 return 0; 190 190 ··· 196 196 dpcm_path_put(&list); 197 197 be_err: 198 198 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 199 - mutex_unlock(&fe->card->mutex); 199 + snd_soc_card_mutex_unlock(fe->card); 200 200 return ret; 201 201 } 202 202 ··· 207 207 struct snd_soc_dpcm *dpcm; 208 208 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ 209 209 210 - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 210 + snd_soc_card_mutex_lock(fe->card); 211 211 212 - mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); 212 + snd_soc_dpcm_mutex_lock(fe); 213 213 snd_soc_runtime_deactivate(fe, stream); 214 214 215 215 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; ··· 229 229 230 230 dpcm_be_disconnect(fe, stream); 231 231 232 - mutex_unlock(&fe->card->pcm_mutex); 232 + snd_soc_dpcm_mutex_unlock(fe); 233 233 234 234 snd_soc_link_compr_shutdown(cstream, 0); 235 235 ··· 237 237 238 238 snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0); 239 239 240 - mutex_unlock(&fe->card->mutex); 240 + snd_soc_card_mutex_unlock(fe->card); 241 241 return 0; 242 242 } 243 243 ··· 249 249 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ 250 250 int ret; 251 251 252 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 252 + snd_soc_dpcm_mutex_lock(rtd); 253 253 254 254 ret = snd_soc_component_compr_trigger(cstream, cmd); 255 255 if (ret < 0) ··· 269 269 } 270 270 271 271 out: 272 - mutex_unlock(&rtd->card->pcm_mutex); 272 + snd_soc_dpcm_mutex_unlock(rtd); 273 273 return ret; 274 274 } 275 275 ··· 284 284 cmd == SND_COMPR_TRIGGER_DRAIN) 285 285 return snd_soc_component_compr_trigger(cstream, cmd); 286 286 287 - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 287 + snd_soc_card_mutex_lock(fe->card); 288 288 289 289 ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd); 290 290 if (ret < 0) ··· 315 315 316 316 out: 317 317 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 318 - mutex_unlock(&fe->card->mutex); 318 + snd_soc_card_mutex_unlock(fe->card); 319 319 return ret; 320 320 } 321 321 ··· 327 327 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ 328 328 int ret; 329 329 330 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 330 + snd_soc_dpcm_mutex_lock(rtd); 331 331 332 332 /* 333 333 * First we call set_params for the CPU DAI, then the component ··· 352 352 353 353 /* cancel any delayed stream shutdown that is pending */ 354 354 rtd->pop_wait = 0; 355 - mutex_unlock(&rtd->card->pcm_mutex); 355 + snd_soc_dpcm_mutex_unlock(rtd); 356 356 357 357 cancel_delayed_work_sync(&rtd->delayed_work); 358 358 359 359 return 0; 360 360 361 361 err: 362 - mutex_unlock(&rtd->card->pcm_mutex); 362 + snd_soc_dpcm_mutex_unlock(rtd); 363 363 return ret; 364 364 } 365 365 ··· 373 373 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ 374 374 int ret; 375 375 376 - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 376 + snd_soc_card_mutex_lock(fe->card); 377 377 378 378 /* 379 379 * Create an empty hw_params for the BE as the machine driver must ··· 404 404 ret = snd_soc_link_compr_set_params(cstream); 405 405 if (ret < 0) 406 406 goto out; 407 - mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); 407 + snd_soc_dpcm_mutex_lock(fe); 408 408 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); 409 - mutex_unlock(&fe->card->pcm_mutex); 409 + snd_soc_dpcm_mutex_unlock(fe); 410 410 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; 411 411 412 412 out: 413 413 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 414 - mutex_unlock(&fe->card->mutex); 414 + snd_soc_card_mutex_unlock(fe->card); 415 415 return ret; 416 416 } 417 417 ··· 422 422 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); 423 423 int ret = 0; 424 424 425 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 425 + snd_soc_dpcm_mutex_lock(rtd); 426 426 427 427 ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params); 428 428 if (ret < 0) ··· 430 430 431 431 ret = snd_soc_component_compr_get_params(cstream, params); 432 432 err: 433 - mutex_unlock(&rtd->card->pcm_mutex); 433 + snd_soc_dpcm_mutex_unlock(rtd); 434 434 return ret; 435 435 } 436 436 ··· 440 440 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); 441 441 int ret; 442 442 443 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 443 + snd_soc_dpcm_mutex_lock(rtd); 444 444 445 445 ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes); 446 446 if (ret < 0) ··· 448 448 449 449 ret = snd_soc_component_compr_ack(cstream, bytes); 450 450 err: 451 - mutex_unlock(&rtd->card->pcm_mutex); 451 + snd_soc_dpcm_mutex_unlock(rtd); 452 452 return ret; 453 453 } 454 454 ··· 459 459 int ret; 460 460 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); 461 461 462 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 462 + snd_soc_dpcm_mutex_lock(rtd); 463 463 464 464 ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp); 465 465 if (ret < 0) ··· 467 467 468 468 ret = snd_soc_component_compr_pointer(cstream, tstamp); 469 469 out: 470 - mutex_unlock(&rtd->card->pcm_mutex); 470 + snd_soc_dpcm_mutex_unlock(rtd); 471 471 return ret; 472 472 } 473 473
+4 -4
sound/soc/soc-core.c
··· 348 348 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 349 349 int playback = SNDRV_PCM_STREAM_PLAYBACK; 350 350 351 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 351 + snd_soc_dpcm_mutex_lock(rtd); 352 352 353 353 dev_dbg(rtd->dev, 354 354 "ASoC: pop wq checking: %s status: %s waiting: %s\n", ··· 364 364 SND_SOC_DAPM_STREAM_STOP); 365 365 } 366 366 367 - mutex_unlock(&rtd->card->pcm_mutex); 367 + snd_soc_dpcm_mutex_unlock(rtd); 368 368 } 369 369 EXPORT_SYMBOL_GPL(snd_soc_close_delayed_work); 370 370 ··· 1938 1938 int ret; 1939 1939 1940 1940 mutex_lock(&client_mutex); 1941 - mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); 1941 + snd_soc_card_mutex_lock_root(card); 1942 1942 1943 1943 snd_soc_dapm_init(&card->dapm, card, NULL); 1944 1944 ··· 2093 2093 if (ret < 0) 2094 2094 soc_cleanup_card_resources(card); 2095 2095 2096 - mutex_unlock(&card->mutex); 2096 + snd_soc_card_mutex_unlock(card); 2097 2097 mutex_unlock(&client_mutex); 2098 2098 2099 2099 return ret;
+58 -61
sound/soc/soc-dapm.c
··· 150 150 static void dapm_assert_locked(struct snd_soc_dapm_context *dapm) 151 151 { 152 152 if (snd_soc_card_is_instantiated(dapm->card)) 153 - lockdep_assert_held(&dapm->card->dapm_mutex); 153 + snd_soc_dapm_mutex_assert_held(dapm); 154 154 } 155 155 156 156 static void pop_wait(u32 pop_time) ··· 302 302 { 303 303 struct snd_soc_dapm_widget *w; 304 304 305 - mutex_lock(&card->dapm_mutex); 305 + snd_soc_dapm_mutex_lock_root(card); 306 306 307 307 for_each_card_widgets(card, w) { 308 308 if (w->is_ep) { ··· 314 314 } 315 315 } 316 316 317 - mutex_unlock(&card->dapm_mutex); 317 + snd_soc_dapm_mutex_unlock(card); 318 318 } 319 319 EXPORT_SYMBOL_GPL(dapm_mark_endpoints_dirty); 320 320 ··· 604 604 { 605 605 struct snd_soc_dapm_widget *w; 606 606 607 - lockdep_assert_held(&card->dapm_mutex); 607 + snd_soc_dapm_mutex_assert_held(card); 608 608 609 609 memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); 610 610 ··· 1302 1302 int paths; 1303 1303 int ret; 1304 1304 1305 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 1305 + snd_soc_dapm_mutex_lock(card); 1306 1306 1307 1307 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 1308 1308 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); ··· 1322 1322 paths = ret; 1323 1323 1324 1324 trace_snd_soc_dapm_connected(paths, stream); 1325 - mutex_unlock(&card->dapm_mutex); 1325 + snd_soc_dapm_mutex_unlock(card); 1326 1326 1327 1327 return paths; 1328 1328 } ··· 1952 1952 enum snd_soc_bias_level bias; 1953 1953 int ret; 1954 1954 1955 - lockdep_assert_held(&card->dapm_mutex); 1955 + snd_soc_dapm_mutex_assert_held(card); 1956 1956 1957 1957 trace_snd_soc_dapm_start(card); 1958 1958 ··· 2090 2090 size_t count, loff_t *ppos) 2091 2091 { 2092 2092 struct snd_soc_dapm_widget *w = file->private_data; 2093 - struct snd_soc_card *card = w->dapm->card; 2094 2093 enum snd_soc_dapm_direction dir, rdir; 2095 2094 char *buf; 2096 2095 int in, out; ··· 2100 2101 if (!buf) 2101 2102 return -ENOMEM; 2102 2103 2103 - mutex_lock(&card->dapm_mutex); 2104 + snd_soc_dapm_mutex_lock_root(w->dapm); 2104 2105 2105 2106 /* Supply widgets are not handled by is_connected_{input,output}_ep() */ 2106 2107 if (w->is_supply) { ··· 2144 2145 } 2145 2146 } 2146 2147 2147 - mutex_unlock(&card->dapm_mutex); 2148 + snd_soc_dapm_mutex_unlock(w->dapm); 2148 2149 2149 2150 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 2150 2151 ··· 2265 2266 int found = 0; 2266 2267 bool connect; 2267 2268 2268 - lockdep_assert_held(&card->dapm_mutex); 2269 + snd_soc_dapm_mutex_assert_held(card); 2269 2270 2270 2271 /* find dapm widget path assoc with kcontrol */ 2271 2272 dapm_kcontrol_for_each_path(path, kcontrol) { ··· 2292 2293 struct snd_soc_card *card = dapm->card; 2293 2294 int ret; 2294 2295 2295 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2296 + snd_soc_dapm_mutex_lock(card); 2296 2297 card->update = update; 2297 2298 ret = soc_dapm_mux_update_power(card, kcontrol, mux, e); 2298 2299 card->update = NULL; 2299 - mutex_unlock(&card->dapm_mutex); 2300 + snd_soc_dapm_mutex_unlock(card); 2300 2301 if (ret > 0) 2301 2302 snd_soc_dpcm_runtime_update(card); 2302 2303 return ret; ··· 2311 2312 struct snd_soc_dapm_path *path; 2312 2313 int found = 0; 2313 2314 2314 - lockdep_assert_held(&card->dapm_mutex); 2315 + snd_soc_dapm_mutex_assert_held(card); 2315 2316 2316 2317 /* find dapm widget path assoc with kcontrol */ 2317 2318 dapm_kcontrol_for_each_path(path, kcontrol) { ··· 2357 2358 struct snd_soc_card *card = dapm->card; 2358 2359 int ret; 2359 2360 2360 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2361 + snd_soc_dapm_mutex_lock(card); 2361 2362 card->update = update; 2362 2363 ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1); 2363 2364 card->update = NULL; 2364 - mutex_unlock(&card->dapm_mutex); 2365 + snd_soc_dapm_mutex_unlock(card); 2365 2366 if (ret > 0) 2366 2367 snd_soc_dpcm_runtime_update(card); 2367 2368 return ret; ··· 2440 2441 struct snd_soc_dai *codec_dai; 2441 2442 int i, count = 0; 2442 2443 2443 - mutex_lock(&rtd->card->dapm_mutex); 2444 + snd_soc_dapm_mutex_lock_root(rtd->card); 2444 2445 2445 2446 for_each_rtd_codec_dais(rtd, i, codec_dai) { 2446 2447 struct snd_soc_component *cmpnt = codec_dai->component; ··· 2448 2449 count = dapm_widget_show_component(cmpnt, buf, count); 2449 2450 } 2450 2451 2451 - mutex_unlock(&rtd->card->dapm_mutex); 2452 + snd_soc_dapm_mutex_unlock(rtd->card); 2452 2453 2453 2454 return count; 2454 2455 } ··· 2631 2632 { 2632 2633 int ret; 2633 2634 2634 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2635 + snd_soc_dapm_mutex_lock(dapm); 2635 2636 ret = snd_soc_dapm_sync_unlocked(dapm); 2636 - mutex_unlock(&dapm->card->dapm_mutex); 2637 + snd_soc_dapm_mutex_unlock(dapm); 2637 2638 return ret; 2638 2639 } 2639 2640 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync); ··· 2702 2703 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 2703 2704 int ret; 2704 2705 2705 - mutex_lock_nested(&rtd->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2706 + snd_soc_dapm_mutex_lock(rtd->card); 2706 2707 ret = dapm_update_dai_unlocked(substream, params, dai); 2707 - mutex_unlock(&rtd->card->dapm_mutex); 2708 + snd_soc_dapm_mutex_unlock(rtd->card); 2708 2709 2709 2710 return ret; 2710 2711 } ··· 3089 3090 { 3090 3091 int i, ret = 0; 3091 3092 3092 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3093 + snd_soc_dapm_mutex_lock(dapm); 3093 3094 for (i = 0; i < num; i++) { 3094 3095 int r = snd_soc_dapm_add_route(dapm, route); 3095 3096 if (r < 0) 3096 3097 ret = r; 3097 3098 route++; 3098 3099 } 3099 - mutex_unlock(&dapm->card->dapm_mutex); 3100 + snd_soc_dapm_mutex_unlock(dapm); 3100 3101 3101 3102 return ret; 3102 3103 } ··· 3115 3116 { 3116 3117 int i; 3117 3118 3118 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3119 + snd_soc_dapm_mutex_lock(dapm); 3119 3120 for (i = 0; i < num; i++) { 3120 3121 snd_soc_dapm_del_route(dapm, route); 3121 3122 route++; 3122 3123 } 3123 - mutex_unlock(&dapm->card->dapm_mutex); 3124 + snd_soc_dapm_mutex_unlock(dapm); 3124 3125 3125 3126 return 0; 3126 3127 } ··· 3193 3194 int i; 3194 3195 int ret = 0; 3195 3196 3196 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); 3197 + snd_soc_dapm_mutex_lock_root(dapm); 3197 3198 for (i = 0; i < num; i++) { 3198 3199 int err = snd_soc_dapm_weak_route(dapm, route); 3199 3200 if (err) 3200 3201 ret = err; 3201 3202 route++; 3202 3203 } 3203 - mutex_unlock(&dapm->card->dapm_mutex); 3204 + snd_soc_dapm_mutex_unlock(dapm); 3204 3205 3205 3206 return ret; 3206 3207 } ··· 3219 3220 struct snd_soc_dapm_widget *w; 3220 3221 unsigned int val; 3221 3222 3222 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); 3223 + snd_soc_dapm_mutex_lock_root(card); 3223 3224 3224 3225 for_each_card_widgets(card, w) 3225 3226 { ··· 3231 3232 sizeof(struct snd_kcontrol *), 3232 3233 GFP_KERNEL); 3233 3234 if (!w->kcontrols) { 3234 - mutex_unlock(&card->dapm_mutex); 3235 + snd_soc_dapm_mutex_unlock(card); 3235 3236 return -ENOMEM; 3236 3237 } 3237 3238 } ··· 3274 3275 } 3275 3276 3276 3277 dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP); 3277 - mutex_unlock(&card->dapm_mutex); 3278 + snd_soc_dapm_mutex_unlock(card); 3278 3279 return 0; 3279 3280 } 3280 3281 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); ··· 3292 3293 struct snd_ctl_elem_value *ucontrol) 3293 3294 { 3294 3295 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); 3295 - struct snd_soc_card *card = dapm->card; 3296 3296 struct soc_mixer_control *mc = 3297 3297 (struct soc_mixer_control *)kcontrol->private_value; 3298 3298 int reg = mc->reg; ··· 3302 3304 unsigned int invert = mc->invert; 3303 3305 unsigned int reg_val, val, rval = 0; 3304 3306 3305 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3307 + snd_soc_dapm_mutex_lock(dapm); 3306 3308 if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) { 3307 3309 reg_val = soc_dapm_read(dapm, reg); 3308 3310 val = (reg_val >> shift) & mask; ··· 3319 3321 if (snd_soc_volsw_is_stereo(mc)) 3320 3322 rval = (reg_val >> width) & mask; 3321 3323 } 3322 - mutex_unlock(&card->dapm_mutex); 3324 + snd_soc_dapm_mutex_unlock(dapm); 3323 3325 3324 3326 if (invert) 3325 3327 ucontrol->value.integer.value[0] = max - val; ··· 3377 3379 rval = max - rval; 3378 3380 } 3379 3381 3380 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3382 + snd_soc_dapm_mutex_lock(card); 3381 3383 3382 3384 /* This assumes field width < (bits in unsigned int / 2) */ 3383 3385 if (width > sizeof(unsigned int) * 8 / 2) ··· 3419 3421 card->update = NULL; 3420 3422 } 3421 3423 3422 - mutex_unlock(&card->dapm_mutex); 3424 + snd_soc_dapm_mutex_unlock(card); 3423 3425 3424 3426 if (ret > 0) 3425 3427 snd_soc_dpcm_runtime_update(card); ··· 3441 3443 struct snd_ctl_elem_value *ucontrol) 3442 3444 { 3443 3445 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); 3444 - struct snd_soc_card *card = dapm->card; 3445 3446 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 3446 3447 unsigned int reg_val, val; 3447 3448 3448 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3449 + snd_soc_dapm_mutex_lock(dapm); 3449 3450 if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { 3450 3451 reg_val = soc_dapm_read(dapm, e->reg); 3451 3452 } else { 3452 3453 reg_val = dapm_kcontrol_get_value(kcontrol); 3453 3454 } 3454 - mutex_unlock(&card->dapm_mutex); 3455 + snd_soc_dapm_mutex_unlock(dapm); 3455 3456 3456 3457 val = (reg_val >> e->shift_l) & e->mask; 3457 3458 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); ··· 3497 3500 mask |= e->mask << e->shift_r; 3498 3501 } 3499 3502 3500 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3503 + snd_soc_dapm_mutex_lock(card); 3501 3504 3502 3505 change = dapm_kcontrol_set_value(kcontrol, val); 3503 3506 ··· 3518 3521 card->update = NULL; 3519 3522 } 3520 3523 3521 - mutex_unlock(&card->dapm_mutex); 3524 + snd_soc_dapm_mutex_unlock(card); 3522 3525 3523 3526 if (ret > 0) 3524 3527 snd_soc_dpcm_runtime_update(card); ··· 3559 3562 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); 3560 3563 const char *pin = (const char *)kcontrol->private_value; 3561 3564 3562 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3565 + snd_soc_dapm_mutex_lock(card); 3563 3566 3564 3567 ucontrol->value.integer.value[0] = 3565 3568 snd_soc_dapm_get_pin_status(&card->dapm, pin); 3566 3569 3567 - mutex_unlock(&card->dapm_mutex); 3570 + snd_soc_dapm_mutex_unlock(card); 3568 3571 3569 3572 return 0; 3570 3573 } ··· 3583 3586 const char *pin = (const char *)kcontrol->private_value; 3584 3587 int ret; 3585 3588 3586 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3589 + snd_soc_dapm_mutex_lock(card); 3587 3590 ret = __snd_soc_dapm_set_pin(&card->dapm, pin, 3588 3591 !!ucontrol->value.integer.value[0]); 3589 - mutex_unlock(&card->dapm_mutex); 3592 + snd_soc_dapm_mutex_unlock(card); 3590 3593 3591 3594 snd_soc_dapm_sync(&card->dapm); 3592 3595 return ret; ··· 3759 3762 { 3760 3763 struct snd_soc_dapm_widget *w; 3761 3764 3762 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3765 + snd_soc_dapm_mutex_lock(dapm); 3763 3766 w = snd_soc_dapm_new_control_unlocked(dapm, widget); 3764 - mutex_unlock(&dapm->card->dapm_mutex); 3767 + snd_soc_dapm_mutex_unlock(dapm); 3765 3768 3766 3769 return w; 3767 3770 } ··· 3784 3787 int i; 3785 3788 int ret = 0; 3786 3789 3787 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); 3790 + snd_soc_dapm_mutex_lock_root(dapm); 3788 3791 for (i = 0; i < num; i++) { 3789 3792 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); 3790 3793 if (IS_ERR(w)) { ··· 3793 3796 } 3794 3797 widget++; 3795 3798 } 3796 - mutex_unlock(&dapm->card->dapm_mutex); 3799 + snd_soc_dapm_mutex_unlock(dapm); 3797 3800 return ret; 3798 3801 } 3799 3802 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls); ··· 4496 4499 { 4497 4500 struct snd_soc_card *card = rtd->card; 4498 4501 4499 - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 4502 + snd_soc_dapm_mutex_lock(card); 4500 4503 soc_dapm_stream_event(rtd, stream, event); 4501 - mutex_unlock(&card->dapm_mutex); 4504 + snd_soc_dapm_mutex_unlock(card); 4502 4505 } 4503 4506 4504 4507 void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream) ··· 4559 4562 { 4560 4563 int ret; 4561 4564 4562 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 4565 + snd_soc_dapm_mutex_lock(dapm); 4563 4566 4564 4567 ret = snd_soc_dapm_set_pin(dapm, pin, 1); 4565 4568 4566 - mutex_unlock(&dapm->card->dapm_mutex); 4569 + snd_soc_dapm_mutex_unlock(dapm); 4567 4570 4568 4571 return ret; 4569 4572 } ··· 4627 4630 { 4628 4631 int ret; 4629 4632 4630 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 4633 + snd_soc_dapm_mutex_lock(dapm); 4631 4634 4632 4635 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin); 4633 4636 4634 - mutex_unlock(&dapm->card->dapm_mutex); 4637 + snd_soc_dapm_mutex_unlock(dapm); 4635 4638 4636 4639 return ret; 4637 4640 } ··· 4671 4674 { 4672 4675 int ret; 4673 4676 4674 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 4677 + snd_soc_dapm_mutex_lock(dapm); 4675 4678 4676 4679 ret = snd_soc_dapm_set_pin(dapm, pin, 0); 4677 4680 4678 - mutex_unlock(&dapm->card->dapm_mutex); 4681 + snd_soc_dapm_mutex_unlock(dapm); 4679 4682 4680 4683 return ret; 4681 4684 } ··· 4722 4725 { 4723 4726 int ret; 4724 4727 4725 - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 4728 + snd_soc_dapm_mutex_lock(dapm); 4726 4729 4727 4730 ret = snd_soc_dapm_set_pin(dapm, pin, 0); 4728 4731 4729 - mutex_unlock(&dapm->card->dapm_mutex); 4732 + snd_soc_dapm_mutex_unlock(dapm); 4730 4733 4731 4734 return ret; 4732 4735 } ··· 4823 4826 LIST_HEAD(down_list); 4824 4827 int powerdown = 0; 4825 4828 4826 - mutex_lock(&card->dapm_mutex); 4829 + snd_soc_dapm_mutex_lock_root(card); 4827 4830 4828 4831 for_each_card_widgets(dapm->card, w) { 4829 4832 if (w->dapm != dapm) ··· 4848 4851 SND_SOC_BIAS_STANDBY); 4849 4852 } 4850 4853 4851 - mutex_unlock(&card->dapm_mutex); 4854 + snd_soc_dapm_mutex_unlock(card); 4852 4855 } 4853 4856 4854 4857 /*
+2 -15
sound/soc/soc-pcm.c
··· 49 49 return ret; 50 50 } 51 51 52 - static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd) 53 - { 54 - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); 55 - } 56 - 57 - static inline void snd_soc_dpcm_mutex_unlock(struct snd_soc_pcm_runtime *rtd) 58 - { 59 - mutex_unlock(&rtd->card->pcm_mutex); 60 - } 61 - 62 - #define snd_soc_dpcm_mutex_assert_held(rtd) \ 63 - lockdep_assert_held(&(rtd)->card->pcm_mutex) 64 - 65 52 static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd, 66 53 int stream) 67 54 { ··· 2651 2664 struct snd_soc_pcm_runtime *fe; 2652 2665 int ret = 0; 2653 2666 2654 - mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); 2667 + snd_soc_dpcm_mutex_lock(card); 2655 2668 /* shutdown all old paths first */ 2656 2669 for_each_card_rtds(card, fe) { 2657 2670 ret = soc_dpcm_fe_runtime_update(fe, 0); ··· 2667 2680 } 2668 2681 2669 2682 out: 2670 - mutex_unlock(&card->pcm_mutex); 2683 + snd_soc_dpcm_mutex_unlock(card); 2671 2684 return ret; 2672 2685 } 2673 2686 EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update);