Commit 58f30d65 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm: Build pcm notifier code conditionally

The PCM notifier code is used only by OSS emulation layer, so we can
build it conditionally for reducing the size.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 239480ab
...@@ -531,13 +531,6 @@ struct snd_pcm { ...@@ -531,13 +531,6 @@ struct snd_pcm {
#endif #endif
}; };
struct snd_pcm_notify {
int (*n_register) (struct snd_pcm * pcm);
int (*n_disconnect) (struct snd_pcm * pcm);
int (*n_unregister) (struct snd_pcm * pcm);
struct list_head list;
};
/* /*
* Registering * Registering
*/ */
...@@ -552,7 +545,15 @@ int snd_pcm_new_internal(struct snd_card *card, const char *id, int device, ...@@ -552,7 +545,15 @@ int snd_pcm_new_internal(struct snd_card *card, const char *id, int device,
struct snd_pcm **rpcm); struct snd_pcm **rpcm);
int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count); int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
struct snd_pcm_notify {
int (*n_register) (struct snd_pcm * pcm);
int (*n_disconnect) (struct snd_pcm * pcm);
int (*n_unregister) (struct snd_pcm * pcm);
struct list_head list;
};
int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree); int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);
#endif
/* /*
* Native I/O * Native I/O
......
...@@ -36,8 +36,10 @@ MODULE_DESCRIPTION("Midlevel PCM code for ALSA."); ...@@ -36,8 +36,10 @@ MODULE_DESCRIPTION("Midlevel PCM code for ALSA.");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static LIST_HEAD(snd_pcm_devices); static LIST_HEAD(snd_pcm_devices);
static LIST_HEAD(snd_pcm_notify_list);
static DEFINE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
static LIST_HEAD(snd_pcm_notify_list);
#endif
static int snd_pcm_free(struct snd_pcm *pcm); static int snd_pcm_free(struct snd_pcm *pcm);
static int snd_pcm_dev_free(struct snd_device *device); static int snd_pcm_dev_free(struct snd_device *device);
...@@ -884,16 +886,23 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) ...@@ -884,16 +886,23 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
put_device(&pstr->dev); put_device(&pstr->dev);
} }
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
#define pcm_call_notify(pcm, call) \
do { \
struct snd_pcm_notify *_notify; \
list_for_each_entry(_notify, &snd_pcm_notify_list, list) \
_notify->call(pcm); \
} while (0)
#else
#define pcm_call_notify(pcm, call) /* NOP */
#endif
static int snd_pcm_free(struct snd_pcm *pcm) static int snd_pcm_free(struct snd_pcm *pcm)
{ {
struct snd_pcm_notify *notify;
if (!pcm) if (!pcm)
return 0; return 0;
if (!pcm->internal) { if (!pcm->internal)
list_for_each_entry(notify, &snd_pcm_notify_list, list) pcm_call_notify(pcm, n_unregister);
notify->n_unregister(pcm);
}
if (pcm->private_free) if (pcm->private_free)
pcm->private_free(pcm); pcm->private_free(pcm);
snd_pcm_lib_preallocate_free_for_all(pcm); snd_pcm_lib_preallocate_free_for_all(pcm);
...@@ -1069,7 +1078,6 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -1069,7 +1078,6 @@ static int snd_pcm_dev_register(struct snd_device *device)
{ {
int cidx, err; int cidx, err;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
struct snd_pcm_notify *notify;
struct snd_pcm *pcm; struct snd_pcm *pcm;
if (snd_BUG_ON(!device || !device->device_data)) if (snd_BUG_ON(!device || !device->device_data))
...@@ -1107,8 +1115,7 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -1107,8 +1115,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
snd_pcm_timer_init(substream); snd_pcm_timer_init(substream);
} }
list_for_each_entry(notify, &snd_pcm_notify_list, list) pcm_call_notify(pcm, n_register);
notify->n_register(pcm);
unlock: unlock:
mutex_unlock(&register_mutex); mutex_unlock(&register_mutex);
...@@ -1118,7 +1125,6 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -1118,7 +1125,6 @@ static int snd_pcm_dev_register(struct snd_device *device)
static int snd_pcm_dev_disconnect(struct snd_device *device) static int snd_pcm_dev_disconnect(struct snd_device *device)
{ {
struct snd_pcm *pcm = device->device_data; struct snd_pcm *pcm = device->device_data;
struct snd_pcm_notify *notify;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int cidx; int cidx;
...@@ -1138,8 +1144,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) ...@@ -1138,8 +1144,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
} }
} }
if (!pcm->internal) { if (!pcm->internal) {
list_for_each_entry(notify, &snd_pcm_notify_list, list) pcm_call_notify(pcm, n_disconnect);
notify->n_disconnect(pcm);
} }
for (cidx = 0; cidx < 2; cidx++) { for (cidx = 0; cidx < 2; cidx++) {
if (!pcm->internal) if (!pcm->internal)
...@@ -1151,6 +1156,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) ...@@ -1151,6 +1156,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
return 0; return 0;
} }
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
/** /**
* snd_pcm_notify - Add/remove the notify list * snd_pcm_notify - Add/remove the notify list
* @notify: PCM notify list * @notify: PCM notify list
...@@ -1183,6 +1189,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) ...@@ -1183,6 +1189,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
return 0; return 0;
} }
EXPORT_SYMBOL(snd_pcm_notify); EXPORT_SYMBOL(snd_pcm_notify);
#endif /* CONFIG_SND_PCM_OSS */
#ifdef CONFIG_SND_PROC_FS #ifdef CONFIG_SND_PROC_FS
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment