aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-01-30 02:16:35 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-02 08:42:45 -0500
commit04c5d5a430fca046cffac099a3f41e74816939da (patch)
treeef729f9772a7bd0673dede15fb64a62d8e3e6284 /sound/core
parent5205388d2d6dbdc5cb743c4e3f61acb9a5e5794f (diff)
ALSA: compress: Embed struct device
Like previous patches, this one embeds the struct device into struct snd_compr. As the dev field wasn't used beforehand, it's reused as the new device struct. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/compress_offload.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 89028fab64fd..cb58c3f7f80c 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -868,12 +868,13 @@ static int snd_compress_dev_register(struct snd_device *device)
868 return -EBADFD; 868 return -EBADFD;
869 compr = device->device_data; 869 compr = device->device_data;
870 870
871 sprintf(str, "comprC%iD%i", compr->card->number, compr->device);
872 pr_debug("reg %s for device %s, direction %d\n", str, compr->name, 871 pr_debug("reg %s for device %s, direction %d\n", str, compr->name,
873 compr->direction); 872 compr->direction);
874 /* register compressed device */ 873 /* register compressed device */
875 ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card, 874 ret = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_COMPRESS,
876 compr->device, &snd_compr_file_ops, compr, str); 875 compr->card, compr->device,
876 &snd_compr_file_ops, compr,
877 &compr->dev, NULL, NULL);
877 if (ret < 0) { 878 if (ret < 0) {
878 pr_err("snd_register_device failed\n %d", ret); 879 pr_err("snd_register_device failed\n %d", ret);
879 return ret; 880 return ret;
@@ -892,6 +893,15 @@ static int snd_compress_dev_disconnect(struct snd_device *device)
892 return 0; 893 return 0;
893} 894}
894 895
896static int snd_compress_dev_free(struct snd_device *device)
897{
898 struct snd_compr *compr;
899
900 compr = device->device_data;
901 put_device(&compr->dev);
902 return 0;
903}
904
895/* 905/*
896 * snd_compress_new: create new compress device 906 * snd_compress_new: create new compress device
897 * @card: sound card pointer 907 * @card: sound card pointer
@@ -903,7 +913,7 @@ int snd_compress_new(struct snd_card *card, int device,
903 int dirn, struct snd_compr *compr) 913 int dirn, struct snd_compr *compr)
904{ 914{
905 static struct snd_device_ops ops = { 915 static struct snd_device_ops ops = {
906 .dev_free = NULL, 916 .dev_free = snd_compress_dev_free,
907 .dev_register = snd_compress_dev_register, 917 .dev_register = snd_compress_dev_register,
908 .dev_disconnect = snd_compress_dev_disconnect, 918 .dev_disconnect = snd_compress_dev_disconnect,
909 }; 919 };
@@ -911,6 +921,10 @@ int snd_compress_new(struct snd_card *card, int device,
911 compr->card = card; 921 compr->card = card;
912 compr->device = device; 922 compr->device = device;
913 compr->direction = dirn; 923 compr->direction = dirn;
924
925 snd_device_initialize(&compr->dev, card);
926 dev_set_name(&compr->dev, "comprC%iD%i", card->number, device);
927
914 return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops); 928 return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops);
915} 929}
916EXPORT_SYMBOL_GPL(snd_compress_new); 930EXPORT_SYMBOL_GPL(snd_compress_new);
@@ -948,7 +962,7 @@ int snd_compress_register(struct snd_compr *device)
948{ 962{
949 int retval; 963 int retval;
950 964
951 if (device->name == NULL || device->dev == NULL || device->ops == NULL) 965 if (device->name == NULL || device->ops == NULL)
952 return -EINVAL; 966 return -EINVAL;
953 967
954 pr_debug("Registering compressed device %s\n", device->name); 968 pr_debug("Registering compressed device %s\n", device->name);