Commit 62fbf98d authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] clean up es968, fix build

parent 15377d7c
...@@ -23,11 +23,7 @@ ...@@ -23,11 +23,7 @@
#include <sound/driver.h> #include <sound/driver.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/time.h> #include <linux/time.h>
#ifndef LINUX_ISAPNP_H #include <linux/pnp.h>
#include <linux/isapnp.h>
#define isapnp_card pci_bus
#define isapnp_dev pci_dev
#endif
#include <sound/core.h> #include <sound/core.h>
#define SNDRV_GET_ID #define SNDRV_GET_ID
#include <sound/initval.h> #include <sound/initval.h>
...@@ -35,6 +31,8 @@ ...@@ -35,6 +31,8 @@
#define chip_t sb_t #define chip_t sb_t
#define PFX "es968: "
MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
MODULE_DESCRIPTION("ESS AudioDrive ES968"); MODULE_DESCRIPTION("ESS AudioDrive ES968");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -68,32 +66,18 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver."); ...@@ -68,32 +66,18 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver.");
MODULE_PARM_SYNTAX(dma8, SNDRV_DMA8_DESC); MODULE_PARM_SYNTAX(dma8, SNDRV_DMA8_DESC);
struct snd_card_es968 { struct snd_card_es968 {
#ifdef __ISAPNP__ struct pnp_dev *dev;
struct isapnp_dev *dev;
#endif /* __ISAPNP__ */
}; };
static snd_card_t *snd_es968_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static struct pnp_card_id snd_es968_pnpids[] __devinitdata = {
{ .id = "ESS0968", .devs = { { "@@@0968" }, } },
#ifdef __ISAPNP__ { .id = "", } /* end */
static struct isapnp_card *snd_es968_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR;
static const struct isapnp_card_id *snd_es968_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR;
static struct isapnp_card_id snd_es968_pnpids[] __devinitdata = {
{
ISAPNP_CARD_ID('E','S','S',0x0968),
.devs = { ISAPNP_DEVICE_ID('E','S','S',0x0968), }
},
{ ISAPNP_CARD_END, }
}; };
ISAPNP_CARD_TABLE(snd_es968_pnpids); MODULE_DEVICE_TABLE(pnp_card, snd_es968_pnpids);
#endif /* __ISAPNP__ */
#define DRIVER_NAME "snd-card-es968" #define DRIVER_NAME "snd-card-es968"
static void snd_card_es968_interrupt(int irq, void *dev_id, static void snd_card_es968_interrupt(int irq, void *dev_id,
struct pt_regs *regs) struct pt_regs *regs)
{ {
...@@ -106,64 +90,50 @@ static void snd_card_es968_interrupt(int irq, void *dev_id, ...@@ -106,64 +90,50 @@ static void snd_card_es968_interrupt(int irq, void *dev_id,
} }
} }
#ifdef __ISAPNP__ static int __devinit snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard,
static int __init snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard) struct pnp_card_link *card,
const struct pnp_card_id *id)
{ {
const struct isapnp_card_id *id = snd_es968_isapnp_id[dev]; struct pnp_dev *pdev;
struct isapnp_card *card = snd_es968_isapnp_cards[dev]; struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table));
struct isapnp_dev *pdev; int err;
if (!cfg)
acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); return -ENOMEM;
if (acard->dev->active) { acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
acard->dev = NULL; if (acard->dev == NULL) {
return -EBUSY; kfree(cfg);
return -ENODEV;
} }
pdev = acard->dev; pdev = acard->dev;
if (pdev->prepare(pdev)<0)
return -EAGAIN;
pnp_init_resource_table(cfg);
/* override resources */
if (port[dev] != SNDRV_AUTO_PORT) if (port[dev] != SNDRV_AUTO_PORT)
isapnp_resource_change(&pdev->resource[0], port[dev], 16); pnp_resource_change(&cfg->port_resource[0], port[dev], 16);
if (dma8[dev] != SNDRV_AUTO_DMA) if (dma8[dev] != SNDRV_AUTO_DMA)
isapnp_resource_change(&pdev->dma_resource[0], dma8[dev], pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 1);
1);
if (irq[dev] != SNDRV_AUTO_IRQ) if (irq[dev] != SNDRV_AUTO_IRQ)
isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);
if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0)
if (pdev->activate(pdev)<0) { printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n");
snd_printk("AUDIO isapnp configure failure\n"); err = pnp_activate_dev(pdev);
return -EBUSY; if (err < 0) {
printk(KERN_ERR PFX "AUDIO pnp configure failure\n");
return err;
} }
port[dev] = pnp_port_start(pdev, 0);
dma8[dev] = pnp_dma(pdev, 1);
irq[dev] = pnp_irq(pdev, 0);
port[dev] = pdev->resource[0].start; kfree(cfg);
dma8[dev] = pdev->dma_resource[0].start;
irq[dev] = pdev->irq_resource[0].start;
return 0; return 0;
} }
static void snd_card_es968_deactivate(struct snd_card_es968 *acard) static int __init snd_card_es968_probe(int dev,
{ struct pnp_card_link *pcard,
if (acard->dev) { const struct pnp_card_id *pid)
acard->dev->deactivate(acard->dev);
acard->dev = NULL;
}
}
#endif /* __ISAPNP__ */
static void snd_card_es968_free(snd_card_t *card)
{
struct snd_card_es968 *acard = (struct snd_card_es968 *)card->private_data;
if (acard) {
#ifdef __ISAPNP__
snd_card_es968_deactivate(acard);
#endif /* __ISAPNP__ */
}
}
static int __init snd_card_es968_probe(int dev)
{ {
int error; int error;
sb_t *chip; sb_t *chip;
...@@ -174,18 +144,10 @@ static int __init snd_card_es968_probe(int dev) ...@@ -174,18 +144,10 @@ static int __init snd_card_es968_probe(int dev)
sizeof(struct snd_card_es968))) == NULL) sizeof(struct snd_card_es968))) == NULL)
return -ENOMEM; return -ENOMEM;
acard = (struct snd_card_es968 *)card->private_data; acard = (struct snd_card_es968 *)card->private_data;
card->private_free = snd_card_es968_free; if ((error = snd_card_es968_isapnp(dev, acard, pcard, pid))) {
#ifdef __ISAPNP__
if ((error = snd_card_es968_isapnp(dev, acard))) {
snd_card_free(card); snd_card_free(card);
return error; return error;
} }
#else
snd_printk("you have to enable PnP support ...\n");
snd_card_free(card);
return -ENOSYS;
#endif /* __ISAPNP__ */
if ((error = snd_sbdsp_create(card, port[dev], if ((error = snd_sbdsp_create(card, port[dev],
irq[dev], irq[dev],
...@@ -221,13 +183,12 @@ static int __init snd_card_es968_probe(int dev) ...@@ -221,13 +183,12 @@ static int __init snd_card_es968_probe(int dev)
snd_card_free(card); snd_card_free(card);
return error; return error;
} }
snd_es968_cards[dev] = card; pnp_set_card_drvdata(pcard, card);
return 0; return 0;
} }
#ifdef __ISAPNP__ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card,
static int __init snd_es968_isapnp_detect(struct isapnp_card *card, const struct pnp_card_id *id)
const struct isapnp_card_id *id)
{ {
static int dev; static int dev;
int res; int res;
...@@ -235,9 +196,7 @@ static int __init snd_es968_isapnp_detect(struct isapnp_card *card, ...@@ -235,9 +196,7 @@ static int __init snd_es968_isapnp_detect(struct isapnp_card *card,
for ( ; dev < SNDRV_CARDS; dev++) { for ( ; dev < SNDRV_CARDS; dev++) {
if (!enable[dev]) if (!enable[dev])
continue; continue;
snd_es968_isapnp_cards[dev] = card; res = snd_card_es968_probe(dev, card, id);
snd_es968_isapnp_id[dev] = id;
res = snd_card_es968_probe(dev);
if (res < 0) if (res < 0)
return res; return res;
dev++; dev++;
...@@ -245,30 +204,31 @@ static int __init snd_es968_isapnp_detect(struct isapnp_card *card, ...@@ -245,30 +204,31 @@ static int __init snd_es968_isapnp_detect(struct isapnp_card *card,
} }
return -ENODEV; return -ENODEV;
} }
#endif /* __ISAPNP__ */
static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
{
snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);
snd_card_disconnect(card);
snd_card_free_in_thread(card);
}
static struct pnp_card_driver es968_pnpc_driver = {
.flags = PNP_DRIVER_RES_DISABLE,
.name = "es968",
.id_table = snd_es968_pnpids,
.probe = snd_es968_pnp_detect,
.remove = __devexit_p(snd_es968_pnp_remove),
};
static int __init alsa_card_es968_init(void) static int __init alsa_card_es968_init(void)
{ {
int cards = 0; return (pnp_register_card_driver(&es968_pnpc_driver) ? 0 : -ENODEV);
#ifdef __ISAPNP__
cards += isapnp_probe_cards(snd_es968_pnpids, snd_es968_isapnp_detect);
#else
snd_printk("you have to enable ISA PnP support.\n");
#endif
#ifdef MODULE
if (!cards)
snd_printk("no ES968 based soundcards found\n");
#endif
return cards ? 0 : -ENODEV;
} }
static void __exit alsa_card_es968_exit(void) static void __exit alsa_card_es968_exit(void)
{ {
int dev; pnp_unregister_card_driver(&es968_pnpc_driver);
for (dev = 0; dev < SNDRV_CARDS; dev++)
snd_card_free(snd_es968_cards[dev]);
} }
module_init(alsa_card_es968_init) module_init(alsa_card_es968_init)
......
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