Commit 6ed91157 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai

sound: oxygen: allocate model_data dynamically

Allocate the model-specific data dynamically instead of including it in
the memory block of the card structure.  This will allow us to determine
the actual model after the card creation.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent bb718588
...@@ -446,6 +446,7 @@ static void oxygen_card_free(struct snd_card *card) ...@@ -446,6 +446,7 @@ static void oxygen_card_free(struct snd_card *card)
free_irq(chip->irq, chip); free_irq(chip->irq, chip);
flush_scheduled_work(); flush_scheduled_work();
chip->model.cleanup(chip); chip->model.cleanup(chip);
kfree(chip->model_data);
mutex_destroy(&chip->mutex); mutex_destroy(&chip->mutex);
pci_release_regions(chip->pci); pci_release_regions(chip->pci);
pci_disable_device(chip->pci); pci_disable_device(chip->pci);
...@@ -460,8 +461,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, ...@@ -460,8 +461,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
struct oxygen *chip; struct oxygen *chip;
int err; int err;
err = snd_card_create(index, id, owner, err = snd_card_create(index, id, owner, sizeof(*chip), &card);
sizeof(*chip) + model->model_data_size, &card);
if (err < 0) if (err < 0)
return err; return err;
...@@ -470,7 +470,6 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, ...@@ -470,7 +470,6 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
chip->pci = pci; chip->pci = pci;
chip->irq = -1; chip->irq = -1;
chip->model = *model; chip->model = *model;
chip->model_data = chip + 1;
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
mutex_init(&chip->mutex); mutex_init(&chip->mutex);
INIT_WORK(&chip->spdif_input_bits_work, INIT_WORK(&chip->spdif_input_bits_work,
...@@ -496,6 +495,15 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, ...@@ -496,6 +495,15 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
} }
chip->addr = pci_resource_start(pci, 0); chip->addr = pci_resource_start(pci, 0);
if (chip->model.model_data_size) {
chip->model_data = kmalloc(chip->model.model_data_size,
GFP_KERNEL);
if (!chip->model_data) {
err = -ENOMEM;
goto err_pci_regions;
}
}
pci_set_master(pci); pci_set_master(pci);
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
card->private_free = oxygen_card_free; card->private_free = oxygen_card_free;
......
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