diff options
Diffstat (limited to 'sound/virtio')
-rw-r--r-- | sound/virtio/Makefile | 2 | ||||
-rw-r--r-- | sound/virtio/virtio_card.c | 24 | ||||
-rw-r--r-- | sound/virtio/virtio_kctl.c | 8 | ||||
-rw-r--r-- | sound/virtio/virtio_pcm.c | 21 |
4 files changed, 30 insertions, 25 deletions
diff --git a/sound/virtio/Makefile b/sound/virtio/Makefile index a839f8c8b5e6..3ca41b3c8b95 100644 --- a/sound/virtio/Makefile +++ b/sound/virtio/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_SND_VIRTIO) += virtio_snd.o -virtio_snd-objs := \ +virtio_snd-y := \ virtio_card.o \ virtio_chmap.o \ virtio_ctl_msg.o \ diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c index 2da20c625247..965209e1d872 100644 --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c @@ -110,25 +110,22 @@ static void virtsnd_event_notify_cb(struct virtqueue *vqueue) static int virtsnd_find_vqs(struct virtio_snd *snd) { struct virtio_device *vdev = snd->vdev; - static vq_callback_t *callbacks[VIRTIO_SND_VQ_MAX] = { - [VIRTIO_SND_VQ_CONTROL] = virtsnd_ctl_notify_cb, - [VIRTIO_SND_VQ_EVENT] = virtsnd_event_notify_cb, - [VIRTIO_SND_VQ_TX] = virtsnd_pcm_tx_notify_cb, - [VIRTIO_SND_VQ_RX] = virtsnd_pcm_rx_notify_cb - }; - static const char *names[VIRTIO_SND_VQ_MAX] = { - [VIRTIO_SND_VQ_CONTROL] = "virtsnd-ctl", - [VIRTIO_SND_VQ_EVENT] = "virtsnd-event", - [VIRTIO_SND_VQ_TX] = "virtsnd-tx", - [VIRTIO_SND_VQ_RX] = "virtsnd-rx" + struct virtqueue_info vqs_info[VIRTIO_SND_VQ_MAX] = { + [VIRTIO_SND_VQ_CONTROL] = { "virtsnd-ctl", + virtsnd_ctl_notify_cb }, + [VIRTIO_SND_VQ_EVENT] = { "virtsnd-event", + virtsnd_event_notify_cb }, + [VIRTIO_SND_VQ_TX] = { "virtsnd-tx", + virtsnd_pcm_tx_notify_cb }, + [VIRTIO_SND_VQ_RX] = { "virtsnd-rx", + virtsnd_pcm_rx_notify_cb }, }; struct virtqueue *vqs[VIRTIO_SND_VQ_MAX] = { 0 }; unsigned int i; unsigned int n; int rc; - rc = virtio_find_vqs(vdev, VIRTIO_SND_VQ_MAX, vqs, callbacks, names, - NULL); + rc = virtio_find_vqs(vdev, VIRTIO_SND_VQ_MAX, vqs, vqs_info, NULL); if (rc) { dev_err(&vdev->dev, "failed to initialize virtqueues\n"); return rc; @@ -438,7 +435,6 @@ static unsigned int features[] = { static struct virtio_driver virtsnd_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .feature_table = features, .feature_table_size = ARRAY_SIZE(features), diff --git a/sound/virtio/virtio_kctl.c b/sound/virtio/virtio_kctl.c index 7aa79c05b464..ffb903d56297 100644 --- a/sound/virtio/virtio_kctl.c +++ b/sound/virtio/virtio_kctl.c @@ -47,7 +47,7 @@ static const unsigned int g_v2a_mask_map[] = { static int virtsnd_kctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct virtio_snd *snd = kcontrol->private_data; + struct virtio_snd *snd = snd_kcontrol_chip(kcontrol); struct virtio_kctl *kctl = &snd->kctls[kcontrol->private_value]; struct virtio_snd_ctl_info *kinfo = &snd->kctl_infos[kcontrol->private_value]; @@ -102,7 +102,7 @@ static int virtsnd_kctl_info(struct snd_kcontrol *kcontrol, static int virtsnd_kctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uvalue) { - struct virtio_snd *snd = kcontrol->private_data; + struct virtio_snd *snd = snd_kcontrol_chip(kcontrol); struct virtio_snd_ctl_info *kinfo = &snd->kctl_infos[kcontrol->private_value]; unsigned int type = le32_to_cpu(kinfo->type); @@ -175,7 +175,7 @@ on_failure: static int virtsnd_kctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uvalue) { - struct virtio_snd *snd = kcontrol->private_data; + struct virtio_snd *snd = snd_kcontrol_chip(kcontrol); struct virtio_snd_ctl_info *kinfo = &snd->kctl_infos[kcontrol->private_value]; unsigned int type = le32_to_cpu(kinfo->type); @@ -239,7 +239,7 @@ static int virtsnd_kctl_put(struct snd_kcontrol *kcontrol, static int virtsnd_kctl_tlv_op(struct snd_kcontrol *kcontrol, int op_flag, unsigned int size, unsigned int __user *utlv) { - struct virtio_snd *snd = kcontrol->private_data; + struct virtio_snd *snd = snd_kcontrol_chip(kcontrol); struct virtio_snd_msg *msg; struct virtio_snd_ctl_hdr *hdr; unsigned int *tlv; diff --git a/sound/virtio/virtio_pcm.c b/sound/virtio/virtio_pcm.c index 967e4c45be9b..2f7c5e709f07 100644 --- a/sound/virtio/virtio_pcm.c +++ b/sound/virtio/virtio_pcm.c @@ -339,6 +339,21 @@ int virtsnd_pcm_parse_cfg(struct virtio_snd *snd) if (!snd->substreams) return -ENOMEM; + /* + * Initialize critical substream fields early in case we hit an + * error path and end up trying to clean up uninitialized structures + * elsewhere. + */ + for (i = 0; i < snd->nsubstreams; ++i) { + struct virtio_pcm_substream *vss = &snd->substreams[i]; + + vss->snd = snd; + vss->sid = i; + INIT_WORK(&vss->elapsed_period, virtsnd_pcm_period_elapsed); + init_waitqueue_head(&vss->msg_empty); + spin_lock_init(&vss->lock); + } + info = kcalloc(snd->nsubstreams, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -352,12 +367,6 @@ int virtsnd_pcm_parse_cfg(struct virtio_snd *snd) struct virtio_pcm_substream *vss = &snd->substreams[i]; struct virtio_pcm *vpcm; - vss->snd = snd; - vss->sid = i; - INIT_WORK(&vss->elapsed_period, virtsnd_pcm_period_elapsed); - init_waitqueue_head(&vss->msg_empty); - spin_lock_init(&vss->lock); - rc = virtsnd_pcm_build_hw(vss, &info[i]); if (rc) goto on_exit; |