sound: oxygen: make the owner module a parameter of the probe function

Move the owner field out of the oxygen_model structure and make it
a parameter of oxygen_pci_probe(), because the actual owner module does
not depend on the card model.  Furthermore, moving it out of the model
structure allows us to create the card structure before the actual model
is known.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Clemens Ladisch 2009-02-19 08:37:13 +01:00 committed by Takashi Iwai
parent a5e0e970c0
commit bb71858853
5 changed files with 6 additions and 10 deletions

View file

@ -151,7 +151,6 @@ static const struct oxygen_model model_hifier = {
.shortname = "C-Media CMI8787", .shortname = "C-Media CMI8787",
.longname = "C-Media Oxygen HD Audio", .longname = "C-Media Oxygen HD Audio",
.chip = "CMI8788", .chip = "CMI8788",
.owner = THIS_MODULE,
.init = hifier_init, .init = hifier_init,
.control_filter = hifier_control_filter, .control_filter = hifier_control_filter,
.cleanup = hifier_cleanup, .cleanup = hifier_cleanup,
@ -185,7 +184,7 @@ static int __devinit hifier_probe(struct pci_dev *pci,
++dev; ++dev;
return -ENOENT; return -ENOENT;
} }
err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier, 0); err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE, &model_hifier, 0);
if (err >= 0) if (err >= 0)
++dev; ++dev;
return err; return err;

View file

@ -315,7 +315,6 @@ static const struct oxygen_model model_generic = {
.shortname = "C-Media CMI8788", .shortname = "C-Media CMI8788",
.longname = "C-Media Oxygen HD Audio", .longname = "C-Media Oxygen HD Audio",
.chip = "CMI8788", .chip = "CMI8788",
.owner = THIS_MODULE,
.probe = generic_probe, .probe = generic_probe,
.init = generic_init, .init = generic_init,
.cleanup = generic_cleanup, .cleanup = generic_cleanup,
@ -353,7 +352,7 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci,
++dev; ++dev;
return -ENOENT; return -ENOENT;
} }
err = oxygen_pci_probe(pci, index[dev], id[dev], err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
&model_generic, pci_id->driver_data); &model_generic, pci_id->driver_data);
if (err >= 0) if (err >= 0)
++dev; ++dev;

View file

@ -62,7 +62,6 @@ struct oxygen_model {
const char *shortname; const char *shortname;
const char *longname; const char *longname;
const char *chip; const char *chip;
struct module *owner;
int (*probe)(struct oxygen *chip, unsigned long driver_data); int (*probe)(struct oxygen *chip, unsigned long driver_data);
void (*init)(struct oxygen *chip); void (*init)(struct oxygen *chip);
int (*control_filter)(struct snd_kcontrol_new *template); int (*control_filter)(struct snd_kcontrol_new *template);
@ -134,6 +133,7 @@ struct oxygen {
/* oxygen_lib.c */ /* oxygen_lib.c */
int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
struct module *owner,
const struct oxygen_model *model, const struct oxygen_model *model,
unsigned long driver_data); unsigned long driver_data);
void oxygen_pci_remove(struct pci_dev *pci); void oxygen_pci_remove(struct pci_dev *pci);

View file

@ -452,6 +452,7 @@ static void oxygen_card_free(struct snd_card *card)
} }
int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
struct module *owner,
const struct oxygen_model *model, const struct oxygen_model *model,
unsigned long driver_data) unsigned long driver_data)
{ {
@ -459,7 +460,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, model->owner, err = snd_card_create(index, id, owner,
sizeof(*chip) + model->model_data_size, &card); sizeof(*chip) + model->model_data_size, &card);
if (err < 0) if (err < 0)
return err; return err;

View file

@ -816,7 +816,6 @@ static int xonar_model_probe(struct oxygen *chip, unsigned long driver_data)
static const struct oxygen_model model_xonar_d2 = { static const struct oxygen_model model_xonar_d2 = {
.longname = "Asus Virtuoso 200", .longname = "Asus Virtuoso 200",
.chip = "AV200", .chip = "AV200",
.owner = THIS_MODULE,
.probe = xonar_model_probe, .probe = xonar_model_probe,
.init = xonar_d2_init, .init = xonar_d2_init,
.control_filter = xonar_d2_control_filter, .control_filter = xonar_d2_control_filter,
@ -849,7 +848,6 @@ static const struct oxygen_model model_xonar_d2 = {
static const struct oxygen_model model_xonar_d1 = { static const struct oxygen_model model_xonar_d1 = {
.longname = "Asus Virtuoso 100", .longname = "Asus Virtuoso 100",
.chip = "AV200", .chip = "AV200",
.owner = THIS_MODULE,
.probe = xonar_model_probe, .probe = xonar_model_probe,
.init = xonar_d1_init, .init = xonar_d1_init,
.control_filter = xonar_d1_control_filter, .control_filter = xonar_d1_control_filter,
@ -878,7 +876,6 @@ static const struct oxygen_model model_xonar_d1 = {
static const struct oxygen_model model_xonar_hdav = { static const struct oxygen_model model_xonar_hdav = {
.longname = "Asus Virtuoso 200", .longname = "Asus Virtuoso 200",
.chip = "AV200", .chip = "AV200",
.owner = THIS_MODULE,
.probe = xonar_model_probe, .probe = xonar_model_probe,
.init = xonar_hdav_init, .init = xonar_hdav_init,
.cleanup = xonar_hdav_cleanup, .cleanup = xonar_hdav_cleanup,
@ -925,7 +922,7 @@ static int __devinit xonar_probe(struct pci_dev *pci,
return -ENOENT; return -ENOENT;
} }
BUG_ON(pci_id->driver_data >= ARRAY_SIZE(models)); BUG_ON(pci_id->driver_data >= ARRAY_SIZE(models));
err = oxygen_pci_probe(pci, index[dev], id[dev], err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
models[pci_id->driver_data], models[pci_id->driver_data],
pci_id->driver_data); pci_id->driver_data);
if (err >= 0) if (err >= 0)