mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
ALSA: hda: Use the new helper for PCM instance refcount
HD-audio core driver has some open-code for managing the refcount for PCM instances, and it can be replaced gracefully with the new helpers. Only a code cleanup, no functional changes. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260610154538.51076-4-tiwai@suse.de
This commit is contained in:
parent
2fa8d8b6c1
commit
53af356c45
|
|
@ -188,8 +188,7 @@ struct hda_codec {
|
|||
|
||||
/* PCM to create, set by hda_codec_ops.build_pcms callback */
|
||||
struct list_head pcm_list_head;
|
||||
refcount_t pcm_ref;
|
||||
wait_queue_head_t remove_sleep;
|
||||
struct snd_refcount pcm_ref;
|
||||
|
||||
/* codec specific info */
|
||||
void *spec;
|
||||
|
|
@ -439,9 +438,12 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec);
|
|||
|
||||
static inline void snd_hda_codec_pcm_get(struct hda_pcm *pcm)
|
||||
{
|
||||
refcount_inc(&pcm->codec->pcm_ref);
|
||||
snd_refcount_get(&pcm->codec->pcm_ref);
|
||||
}
|
||||
static inline void snd_hda_codec_pcm_put(struct hda_pcm *pcm)
|
||||
{
|
||||
snd_refcount_put(&pcm->codec->pcm_ref);
|
||||
}
|
||||
void snd_hda_codec_pcm_put(struct hda_pcm *pcm);
|
||||
|
||||
int snd_hda_codec_prepare(struct hda_codec *codec,
|
||||
struct hda_pcm_stream *hinfo,
|
||||
|
|
|
|||
|
|
@ -162,8 +162,7 @@ static int hda_codec_driver_remove(struct device *dev)
|
|||
|
||||
snd_hda_codec_disconnect_pcms(codec);
|
||||
snd_hda_jack_tbl_disconnect(codec);
|
||||
if (!refcount_dec_and_test(&codec->pcm_ref))
|
||||
wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
|
||||
snd_refcount_sync(&codec->pcm_ref);
|
||||
snd_power_sync_ref(codec->bus->card);
|
||||
|
||||
if (driver->ops->remove)
|
||||
|
|
|
|||
|
|
@ -689,13 +689,6 @@ get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid)
|
|||
/*
|
||||
* PCM device
|
||||
*/
|
||||
void snd_hda_codec_pcm_put(struct hda_pcm *pcm)
|
||||
{
|
||||
if (refcount_dec_and_test(&pcm->codec->pcm_ref))
|
||||
wake_up(&pcm->codec->remove_sleep);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_put);
|
||||
|
||||
struct hda_pcm *snd_hda_codec_pcm_new(struct hda_codec *codec,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
|
|
@ -716,7 +709,7 @@ struct hda_pcm *snd_hda_codec_pcm_new(struct hda_codec *codec,
|
|||
}
|
||||
|
||||
list_add_tail(&pcm->list, &codec->pcm_list_head);
|
||||
refcount_inc(&codec->pcm_ref);
|
||||
snd_hda_codec_pcm_get(pcm);
|
||||
return pcm;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_new);
|
||||
|
|
@ -787,7 +780,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
|
|||
remove_conn_list(codec);
|
||||
snd_hdac_regmap_exit(&codec->core);
|
||||
codec->configured = 0;
|
||||
refcount_set(&codec->pcm_ref, 1); /* reset refcount */
|
||||
snd_refcount_init(&codec->pcm_ref); /* reset refcount */
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup_for_unbind);
|
||||
|
||||
|
|
@ -927,8 +920,7 @@ snd_hda_codec_device_init(struct hda_bus *bus, unsigned int codec_addr,
|
|||
INIT_LIST_HEAD(&codec->conn_list);
|
||||
INIT_LIST_HEAD(&codec->pcm_list_head);
|
||||
INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
|
||||
refcount_set(&codec->pcm_ref, 1);
|
||||
init_waitqueue_head(&codec->remove_sleep);
|
||||
snd_refcount_init(&codec->pcm_ref);
|
||||
|
||||
return codec;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user