Skip to content

Commit 04c5d5a

Browse files
committed
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 <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5205388 commit 04c5d5a

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

include/sound/compress_driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct snd_compr_ops {
134134
/**
135135
* struct snd_compr: Compressed device
136136
* @name: DSP device name
137-
* @dev: Device pointer
137+
* @dev: associated device instance
138138
* @ops: pointer to DSP callbacks
139139
* @private_data: pointer to DSP pvt data
140140
* @card: sound card pointer
@@ -144,7 +144,7 @@ struct snd_compr_ops {
144144
*/
145145
struct snd_compr {
146146
const char *name;
147-
struct device *dev;
147+
struct device dev;
148148
struct snd_compr_ops *ops;
149149
void *private_data;
150150
struct snd_card *card;

sound/core/compress_offload.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,13 @@ static int snd_compress_dev_register(struct snd_device *device)
868868
return -EBADFD;
869869
compr = device->device_data;
870870

871-
sprintf(str, "comprC%iD%i", compr->card->number, compr->device);
872871
pr_debug("reg %s for device %s, direction %d\n", str, compr->name,
873872
compr->direction);
874873
/* register compressed device */
875-
ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card,
876-
compr->device, &snd_compr_file_ops, compr, str);
874+
ret = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_COMPRESS,
875+
compr->card, compr->device,
876+
&snd_compr_file_ops, compr,
877+
&compr->dev, NULL, NULL);
877878
if (ret < 0) {
878879
pr_err("snd_register_device failed\n %d", ret);
879880
return ret;
@@ -892,6 +893,15 @@ static int snd_compress_dev_disconnect(struct snd_device *device)
892893
return 0;
893894
}
894895

896+
static 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+
895905
/*
896906
* snd_compress_new: create new compress device
897907
* @card: sound card pointer
@@ -903,14 +913,18 @@ int snd_compress_new(struct snd_card *card, int device,
903913
int dirn, struct snd_compr *compr)
904914
{
905915
static struct snd_device_ops ops = {
906-
.dev_free = NULL,
916+
.dev_free = snd_compress_dev_free,
907917
.dev_register = snd_compress_dev_register,
908918
.dev_disconnect = snd_compress_dev_disconnect,
909919
};
910920

911921
compr->card = card;
912922
compr->device = device;
913923
compr->direction = dirn;
924+
925+
snd_device_initialize(&compr->dev, card);
926+
dev_set_name(&compr->dev, "comprC%iD%i", card->number, device);
927+
914928
return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops);
915929
}
916930
EXPORT_SYMBOL_GPL(snd_compress_new);
@@ -948,7 +962,7 @@ int snd_compress_register(struct snd_compr *device)
948962
{
949963
int retval;
950964

951-
if (device->name == NULL || device->dev == NULL || device->ops == NULL)
965+
if (device->name == NULL || device->ops == NULL)
952966
return -EINVAL;
953967

954968
pr_debug("Registering compressed device %s\n", device->name);

0 commit comments

Comments
 (0)