Commit 04c5d5a4 authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 5205388d
...@@ -134,7 +134,7 @@ struct snd_compr_ops { ...@@ -134,7 +134,7 @@ struct snd_compr_ops {
/** /**
* struct snd_compr: Compressed device * struct snd_compr: Compressed device
* @name: DSP device name * @name: DSP device name
* @dev: Device pointer * @dev: associated device instance
* @ops: pointer to DSP callbacks * @ops: pointer to DSP callbacks
* @private_data: pointer to DSP pvt data * @private_data: pointer to DSP pvt data
* @card: sound card pointer * @card: sound card pointer
...@@ -144,7 +144,7 @@ struct snd_compr_ops { ...@@ -144,7 +144,7 @@ struct snd_compr_ops {
*/ */
struct snd_compr { struct snd_compr {
const char *name; const char *name;
struct device *dev; struct device dev;
struct snd_compr_ops *ops; struct snd_compr_ops *ops;
void *private_data; void *private_data;
struct snd_card *card; struct snd_card *card;
......
...@@ -868,12 +868,13 @@ static int snd_compress_dev_register(struct snd_device *device) ...@@ -868,12 +868,13 @@ static int snd_compress_dev_register(struct snd_device *device)
return -EBADFD; return -EBADFD;
compr = device->device_data; compr = device->device_data;
sprintf(str, "comprC%iD%i", compr->card->number, compr->device);
pr_debug("reg %s for device %s, direction %d\n", str, compr->name, pr_debug("reg %s for device %s, direction %d\n", str, compr->name,
compr->direction); compr->direction);
/* register compressed device */ /* register compressed device */
ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card, ret = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_COMPRESS,
compr->device, &snd_compr_file_ops, compr, str); compr->card, compr->device,
&snd_compr_file_ops, compr,
&compr->dev, NULL, NULL);
if (ret < 0) { if (ret < 0) {
pr_err("snd_register_device failed\n %d", ret); pr_err("snd_register_device failed\n %d", ret);
return ret; return ret;
...@@ -892,6 +893,15 @@ static int snd_compress_dev_disconnect(struct snd_device *device) ...@@ -892,6 +893,15 @@ static int snd_compress_dev_disconnect(struct snd_device *device)
return 0; return 0;
} }
static int snd_compress_dev_free(struct snd_device *device)
{
struct snd_compr *compr;
compr = device->device_data;
put_device(&compr->dev);
return 0;
}
/* /*
* snd_compress_new: create new compress device * snd_compress_new: create new compress device
* @card: sound card pointer * @card: sound card pointer
...@@ -903,7 +913,7 @@ int snd_compress_new(struct snd_card *card, int device, ...@@ -903,7 +913,7 @@ int snd_compress_new(struct snd_card *card, int device,
int dirn, struct snd_compr *compr) int dirn, struct snd_compr *compr)
{ {
static struct snd_device_ops ops = { static struct snd_device_ops ops = {
.dev_free = NULL, .dev_free = snd_compress_dev_free,
.dev_register = snd_compress_dev_register, .dev_register = snd_compress_dev_register,
.dev_disconnect = snd_compress_dev_disconnect, .dev_disconnect = snd_compress_dev_disconnect,
}; };
...@@ -911,6 +921,10 @@ int snd_compress_new(struct snd_card *card, int device, ...@@ -911,6 +921,10 @@ int snd_compress_new(struct snd_card *card, int device,
compr->card = card; compr->card = card;
compr->device = device; compr->device = device;
compr->direction = dirn; compr->direction = dirn;
snd_device_initialize(&compr->dev, card);
dev_set_name(&compr->dev, "comprC%iD%i", card->number, device);
return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops); return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops);
} }
EXPORT_SYMBOL_GPL(snd_compress_new); EXPORT_SYMBOL_GPL(snd_compress_new);
...@@ -948,7 +962,7 @@ int snd_compress_register(struct snd_compr *device) ...@@ -948,7 +962,7 @@ int snd_compress_register(struct snd_compr *device)
{ {
int retval; int retval;
if (device->name == NULL || device->dev == NULL || device->ops == NULL) if (device->name == NULL || device->ops == NULL)
return -EINVAL; return -EINVAL;
pr_debug("Registering compressed device %s\n", device->name); pr_debug("Registering compressed device %s\n", device->name);
......
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