diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2009-02-19 02:38:25 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-02-19 04:22:23 -0500 |
commit | 6ed91157093c60e26bf0215b752f07af52935afc (patch) | |
tree | c1dbc3089cb20d6f36c6fd482b998316ede73390 /sound | |
parent | bb71858853a5c9616eea98512f4075d4f081154d (diff) |
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: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/oxygen/oxygen_lib.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index b5560fa5a5e3..228f30800fd9 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c | |||
@@ -446,6 +446,7 @@ static void oxygen_card_free(struct snd_card *card) | |||
446 | free_irq(chip->irq, chip); | 446 | free_irq(chip->irq, chip); |
447 | flush_scheduled_work(); | 447 | flush_scheduled_work(); |
448 | chip->model.cleanup(chip); | 448 | chip->model.cleanup(chip); |
449 | kfree(chip->model_data); | ||
449 | mutex_destroy(&chip->mutex); | 450 | mutex_destroy(&chip->mutex); |
450 | pci_release_regions(chip->pci); | 451 | pci_release_regions(chip->pci); |
451 | pci_disable_device(chip->pci); | 452 | pci_disable_device(chip->pci); |
@@ -460,8 +461,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
460 | struct oxygen *chip; | 461 | struct oxygen *chip; |
461 | int err; | 462 | int err; |
462 | 463 | ||
463 | err = snd_card_create(index, id, owner, | 464 | err = snd_card_create(index, id, owner, sizeof(*chip), &card); |
464 | sizeof(*chip) + model->model_data_size, &card); | ||
465 | if (err < 0) | 465 | if (err < 0) |
466 | return err; | 466 | return err; |
467 | 467 | ||
@@ -470,7 +470,6 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
470 | chip->pci = pci; | 470 | chip->pci = pci; |
471 | chip->irq = -1; | 471 | chip->irq = -1; |
472 | chip->model = *model; | 472 | chip->model = *model; |
473 | chip->model_data = chip + 1; | ||
474 | spin_lock_init(&chip->reg_lock); | 473 | spin_lock_init(&chip->reg_lock); |
475 | mutex_init(&chip->mutex); | 474 | mutex_init(&chip->mutex); |
476 | INIT_WORK(&chip->spdif_input_bits_work, | 475 | INIT_WORK(&chip->spdif_input_bits_work, |
@@ -496,6 +495,15 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
496 | } | 495 | } |
497 | chip->addr = pci_resource_start(pci, 0); | 496 | chip->addr = pci_resource_start(pci, 0); |
498 | 497 | ||
498 | if (chip->model.model_data_size) { | ||
499 | chip->model_data = kmalloc(chip->model.model_data_size, | ||
500 | GFP_KERNEL); | ||
501 | if (!chip->model_data) { | ||
502 | err = -ENOMEM; | ||
503 | goto err_pci_regions; | ||
504 | } | ||
505 | } | ||
506 | |||
499 | pci_set_master(pci); | 507 | pci_set_master(pci); |
500 | snd_card_set_dev(card, &pci->dev); | 508 | snd_card_set_dev(card, &pci->dev); |
501 | card->private_free = oxygen_card_free; | 509 | card->private_free = oxygen_card_free; |