@@ -1364,17 +1364,112 @@ extern struct dentry *snd_soc_debugfs_root;
13641364
13651365extern const struct dev_pm_ops snd_soc_pm_ops ;
13661366
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 )
1376+ {
1377+ mutex_lock_nested (& card -> dapm_mutex , SND_SOC_DAPM_CLASS_ROOT );
1378+ }
1379+
1380+ static inline void _snd_soc_dapm_mutex_lock_c (struct snd_soc_card * card )
1381+ {
1382+ mutex_lock_nested (& card -> dapm_mutex , SND_SOC_DAPM_CLASS_RUNTIME );
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 )
13691437{
1370- mutex_lock_nested ( & dapm -> card -> dapm_mutex , SND_SOC_DAPM_CLASS_RUNTIME );
1438+ mutex_unlock ( & card -> pcm_mutex );
13711439}
13721440
1373- static inline void snd_soc_dapm_mutex_unlock (struct snd_soc_dapm_context * dapm )
1441+ static inline void _snd_soc_dpcm_mutex_assert_held_c (struct snd_soc_card * card )
13741442{
1375- mutex_unlock ( & dapm -> card -> dapm_mutex );
1443+ lockdep_assert_held ( & card -> pcm_mutex );
13761444}
13771445
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)
1472+
13781473#include <sound/soc-component.h>
13791474#include <sound/soc-card.h>
13801475#include <sound/soc-jack.h>
0 commit comments