summaryrefslogtreecommitdiff
path: root/drivers/media/usb/em28xx/em28xx-audio.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-05 18:21:07 +0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-11 13:56:46 +0400
commit47677e51e2a4040c204d7971a5103592600185b1 (patch)
tree58196e42f5ad37ee12333a69593d444f0d1e10de /drivers/media/usb/em28xx/em28xx-audio.c
parent88e4fcda55e07278fcf5f6eea684685ffc0633e2 (diff)
downloadlinux-47677e51e2a4040c204d7971a5103592600185b1.tar.xz
[media] em28xx: Only deallocate struct em28xx after finishing all extensions
We can't free struct em28xx while one of the extensions is still using it. So, add a kref() to control it, freeing it only after the extensions fini calls. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-audio.c')
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 0f5b6f3e7a3f..f75c0a5494d6 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -301,6 +301,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
goto err;
}
+ kref_get(&dev->ref);
dev->adev.users++;
mutex_unlock(&dev->lock);
@@ -341,6 +342,7 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
substream->runtime->dma_area = NULL;
}
mutex_unlock(&dev->lock);
+ kref_put(&dev->ref, em28xx_free_device);
return 0;
}
@@ -895,6 +897,8 @@ static int em28xx_audio_init(struct em28xx *dev)
em28xx_info("Binding audio extension\n");
+ kref_get(&dev->ref);
+
printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus "
"Rechberger\n");
printk(KERN_INFO
@@ -967,7 +971,7 @@ static int em28xx_audio_fini(struct em28xx *dev)
if (dev == NULL)
return 0;
- if (dev->has_alsa_audio != 1) {
+ if (!dev->has_alsa_audio) {
/* This device does not support the extension (in this case
the device is expecting the snd-usb-audio module or
doesn't have analog audio support at all) */
@@ -986,6 +990,7 @@ static int em28xx_audio_fini(struct em28xx *dev)
dev->adev.sndcard = NULL;
}
+ kref_put(&dev->ref, em28xx_free_device);
return 0;
}