diff options
author | Len Brown <len.brown@intel.com> | 2006-01-07 03:50:18 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2006-01-07 03:50:18 -0500 |
commit | ed03f430cdc8c802652467e9097606fedc2c7abc (patch) | |
tree | 30941ec1e6f93e99358fefe18175e5dd800a4379 /sound/drivers/mtpav.c | |
parent | ed349a8a0a780ed27e2a765f16cee54d9b63bfee (diff) | |
parent | 6f957eaf79356a32e838f5f262ee9a60544b1d5b (diff) | |
download | op-kernel-dev-ed03f430cdc8c802652467e9097606fedc2c7abc.zip op-kernel-dev-ed03f430cdc8c802652467e9097606fedc2c7abc.tar.gz |
Pull pnpacpi into acpica branch
Diffstat (limited to 'sound/drivers/mtpav.c')
-rw-r--r-- | sound/drivers/mtpav.c | 306 |
1 files changed, 149 insertions, 157 deletions
diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index e9d52c6..b7a0b42 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -53,6 +53,8 @@ #include <sound/driver.h> #include <linux/init.h> #include <linux/interrupt.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/ioport.h> #include <linux/moduleparam.h> @@ -93,6 +95,8 @@ MODULE_PARM_DESC(irq, "Parallel IRQ # for MotuMTPAV MIDI."); module_param(hwports, int, 0444); MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI."); +static struct platform_device *device; + /* * defines */ @@ -125,17 +129,17 @@ MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI."); /* */ -typedef struct mtpav_port { +struct mtpav_port { u8 number; u8 hwport; u8 mode; u8 running_status; - snd_rawmidi_substream_t *input; - snd_rawmidi_substream_t *output; -} mtpav_port_t; + struct snd_rawmidi_substream *input; + struct snd_rawmidi_substream *output; +}; -typedef struct mtpav { - snd_card_t *card; +struct mtpav { + struct snd_card *card; unsigned long port; struct resource *res_port; int irq; /* interrupt (for inputs) */ @@ -143,24 +147,18 @@ typedef struct mtpav { int share_irq; /* number of accesses to input interrupts */ int istimer; /* number of accesses to timer interrupts */ struct timer_list timer; /* timer interrupts for outputs */ - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int num_ports; /* number of hw ports (1-8) */ - mtpav_port_t ports[NUMPORTS]; /* all ports including computer, adat and bc */ + struct mtpav_port ports[NUMPORTS]; /* all ports including computer, adat and bc */ u32 inmidiport; /* selected input midi port */ u32 inmidistate; /* during midi command 0xf5 */ u32 outmidihwport; /* selected output midi hw port */ -} mtpav_t; +}; /* - * global instance - * hey, we handle at most only one card.. - */ -static mtpav_t *mtp_card; - -/* * possible hardware ports (selected by 0xf5 port message) * 0x00 all ports * 0x01 .. 0x08 this MTP's ports 1..8 @@ -183,7 +181,7 @@ static mtpav_t *mtp_card; #define MTPAV_PIDX_BROADCAST 2 -static int translate_subdevice_to_hwport(mtpav_t *chip, int subdev) +static int translate_subdevice_to_hwport(struct mtpav *chip, int subdev) { if (subdev < 0) return 0x01; /* invalid - use port 0 as default */ @@ -198,7 +196,7 @@ static int translate_subdevice_to_hwport(mtpav_t *chip, int subdev) return 0; /* all ports */ } -static int translate_hwport_to_subdevice(mtpav_t *chip, int hwport) +static int translate_hwport_to_subdevice(struct mtpav *chip, int hwport) { int p; if (hwport <= 0x00) /* all ports */ @@ -223,7 +221,7 @@ static int translate_hwport_to_subdevice(mtpav_t *chip, int hwport) /* */ -static u8 snd_mtpav_getreg(mtpav_t *chip, u16 reg) +static u8 snd_mtpav_getreg(struct mtpav *chip, u16 reg) { u8 rval = 0; @@ -241,19 +239,16 @@ static u8 snd_mtpav_getreg(mtpav_t *chip, u16 reg) /* */ -static void snd_mtpav_mputreg(mtpav_t *chip, u16 reg, u8 val) +static inline void snd_mtpav_mputreg(struct mtpav *chip, u16 reg, u8 val) { - if (reg == DREG) { - outb(val, chip->port + DREG); - } else if (reg == CREG) { - outb(val, chip->port + CREG); - } + if (reg == DREG || reg == CREG) + outb(val, chip->port + reg); } /* */ -static void snd_mtpav_wait_rfdhi(mtpav_t *chip) +static void snd_mtpav_wait_rfdhi(struct mtpav *chip) { int counts = 10000; u8 sbyte; @@ -265,7 +260,7 @@ static void snd_mtpav_wait_rfdhi(mtpav_t *chip) } } -static void snd_mtpav_send_byte(mtpav_t *chip, u8 byte) +static void snd_mtpav_send_byte(struct mtpav *chip, u8 byte) { u8 tcbyt; u8 clrwrite; @@ -291,8 +286,9 @@ static void snd_mtpav_send_byte(mtpav_t *chip, u8 byte) */ /* call this with spin lock held */ -static void snd_mtpav_output_port_write(mtpav_port_t *port, - snd_rawmidi_substream_t *substream) +static void snd_mtpav_output_port_write(struct mtpav *mtp_card, + struct mtpav_port *portp, + struct snd_rawmidi_substream *substream) { u8 outbyte; @@ -303,34 +299,35 @@ static void snd_mtpav_output_port_write(mtpav_port_t *port, // send port change command if necessary - if (port->hwport != mtp_card->outmidihwport) { - mtp_card->outmidihwport = port->hwport; + if (portp->hwport != mtp_card->outmidihwport) { + mtp_card->outmidihwport = portp->hwport; snd_mtpav_send_byte(mtp_card, 0xf5); - snd_mtpav_send_byte(mtp_card, port->hwport); - //snd_printk("new outport: 0x%x\n", (unsigned int) port->hwport); + snd_mtpav_send_byte(mtp_card, portp->hwport); + //snd_printk("new outport: 0x%x\n", (unsigned int) portp->hwport); - if (!(outbyte & 0x80) && port->running_status) - snd_mtpav_send_byte(mtp_card, port->running_status); + if (!(outbyte & 0x80) && portp->running_status) + snd_mtpav_send_byte(mtp_card, portp->running_status); } // send data do { if (outbyte & 0x80) - port->running_status = outbyte; + portp->running_status = outbyte; snd_mtpav_send_byte(mtp_card, outbyte); } while (snd_rawmidi_transmit(substream, &outbyte, 1) == 1); } -static void snd_mtpav_output_write(snd_rawmidi_substream_t * substream) +static void snd_mtpav_output_write(struct snd_rawmidi_substream *substream) { - mtpav_port_t *port = &mtp_card->ports[substream->number]; + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; spin_lock_irqsave(&mtp_card->spinlock, flags); - snd_mtpav_output_port_write(port, substream); + snd_mtpav_output_port_write(mtp_card, portp, substream); spin_unlock_irqrestore(&mtp_card->spinlock, flags); } @@ -339,7 +336,7 @@ static void snd_mtpav_output_write(snd_rawmidi_substream_t * substream) * mtpav control */ -static void snd_mtpav_portscan(mtpav_t *chip) // put mtp into smart routing mode +static void snd_mtpav_portscan(struct mtpav *chip) // put mtp into smart routing mode { u8 p; @@ -353,12 +350,12 @@ static void snd_mtpav_portscan(mtpav_t *chip) // put mtp into smart routing mode /* */ -static int snd_mtpav_input_open(snd_rawmidi_substream_t * substream) +static int snd_mtpav_input_open(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; - //printk("mtpav port: %d opened\n", (int) substream->number); spin_lock_irqsave(&mtp_card->spinlock, flags); portp->mode |= MTPAV_MODE_INPUT_OPENED; portp->input = substream; @@ -371,20 +368,17 @@ static int snd_mtpav_input_open(snd_rawmidi_substream_t * substream) /* */ -static int snd_mtpav_input_close(snd_rawmidi_substream_t *substream) +static int snd_mtpav_input_close(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; - - //printk("mtpav port: %d closed\n", (int) portp); spin_lock_irqsave(&mtp_card->spinlock, flags); - - portp->mode &= (~MTPAV_MODE_INPUT_OPENED); + portp->mode &= ~MTPAV_MODE_INPUT_OPENED; portp->input = NULL; if (--mtp_card->share_irq == 0) snd_mtpav_mputreg(mtp_card, CREG, 0); // disable pport interrupts - spin_unlock_irqrestore(&mtp_card->spinlock, flags); return 0; } @@ -392,10 +386,11 @@ static int snd_mtpav_input_close(snd_rawmidi_substream_t *substream) /* */ -static void snd_mtpav_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_mtpav_input_trigger(struct snd_rawmidi_substream *substream, int up) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); if (up) @@ -414,7 +409,7 @@ static void snd_mtpav_input_trigger(snd_rawmidi_substream_t * substream, int up) static void snd_mtpav_output_timer(unsigned long data) { unsigned long flags; - mtpav_t *chip = (mtpav_t *)data; + struct mtpav *chip = (struct mtpav *)data; int p; spin_lock_irqsave(&chip->spinlock, flags); @@ -423,25 +418,22 @@ static void snd_mtpav_output_timer(unsigned long data) add_timer(&chip->timer); /* process each port */ for (p = 0; p <= chip->num_ports * 2 + MTPAV_PIDX_BROADCAST; p++) { - mtpav_port_t *portp = &mtp_card->ports[p]; + struct mtpav_port *portp = &chip->ports[p]; if ((portp->mode & MTPAV_MODE_OUTPUT_TRIGGERED) && portp->output) - snd_mtpav_output_port_write(portp, portp->output); + snd_mtpav_output_port_write(chip, portp, portp->output); } spin_unlock_irqrestore(&chip->spinlock, flags); } /* spinlock held! */ -static void snd_mtpav_add_output_timer(mtpav_t *chip) +static void snd_mtpav_add_output_timer(struct mtpav *chip) { - init_timer(&chip->timer); - chip->timer.function = snd_mtpav_output_timer; - chip->timer.data = (unsigned long) mtp_card; chip->timer.expires = 1 + jiffies; add_timer(&chip->timer); } /* spinlock held! */ -static void snd_mtpav_remove_output_timer(mtpav_t *chip) +static void snd_mtpav_remove_output_timer(struct mtpav *chip) { del_timer(&chip->timer); } @@ -449,10 +441,11 @@ static void snd_mtpav_remove_output_timer(mtpav_t *chip) /* */ -static int snd_mtpav_output_open(snd_rawmidi_substream_t * substream) +static int snd_mtpav_output_open(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); portp->mode |= MTPAV_MODE_OUTPUT_OPENED; @@ -464,13 +457,14 @@ static int snd_mtpav_output_open(snd_rawmidi_substream_t * substream) /* */ -static int snd_mtpav_output_close(snd_rawmidi_substream_t * substream) +static int snd_mtpav_output_close(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); - portp->mode &= (~MTPAV_MODE_OUTPUT_OPENED); + portp->mode &= ~MTPAV_MODE_OUTPUT_OPENED; portp->output = NULL; spin_unlock_irqrestore(&mtp_card->spinlock, flags); return 0; @@ -479,14 +473,15 @@ static int snd_mtpav_output_close(snd_rawmidi_substream_t * substream) /* */ -static void snd_mtpav_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_mtpav_output_trigger(struct snd_rawmidi_substream *substream, int up) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); if (up) { - if (! (portp->mode & MTPAV_MODE_OUTPUT_TRIGGERED)) { + if (! (portp->mode & MTPAV_MODE_OUTPUT_TRIGGERED)) { if (mtp_card->istimer++ == 0) snd_mtpav_add_output_timer(mtp_card); portp->mode |= MTPAV_MODE_OUTPUT_TRIGGERED; @@ -506,23 +501,20 @@ static void snd_mtpav_output_trigger(snd_rawmidi_substream_t * substream, int up * midi interrupt for inputs */ -static void snd_mtpav_inmidi_process(mtpav_t *mcrd, u8 inbyte) +static void snd_mtpav_inmidi_process(struct mtpav *mcrd, u8 inbyte) { - mtpav_port_t *portp; + struct mtpav_port *portp; if ((int)mcrd->inmidiport > mcrd->num_ports * 2 + MTPAV_PIDX_BROADCAST) return; portp = &mcrd->ports[mcrd->inmidiport]; - if (portp->mode & MTPAV_MODE_INPUT_TRIGGERED) { + if (portp->mode & MTPAV_MODE_INPUT_TRIGGERED) snd_rawmidi_receive(portp->input, &inbyte, 1); - } } -static void snd_mtpav_inmidi_h(mtpav_t * mcrd, u8 inbyte) +static void snd_mtpav_inmidi_h(struct mtpav *mcrd, u8 inbyte) { - snd_assert(mcrd, return); - if (inbyte >= 0xf8) { /* real-time midi code */ snd_mtpav_inmidi_process(mcrd, inbyte); @@ -540,7 +532,7 @@ static void snd_mtpav_inmidi_h(mtpav_t * mcrd, u8 inbyte) } } -static void snd_mtpav_read_bytes(mtpav_t * mcrd) +static void snd_mtpav_read_bytes(struct mtpav *mcrd) { u8 clrread, setread; u8 mtp_read_byte; @@ -580,9 +572,8 @@ static void snd_mtpav_read_bytes(mtpav_t * mcrd) static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs) { - mtpav_t *mcard = dev_id; + struct mtpav *mcard = dev_id; - //printk("irqh()\n"); spin_lock(&mcard->spinlock); snd_mtpav_read_bytes(mcard); spin_unlock(&mcard->spinlock); @@ -592,14 +583,14 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs) /* * get ISA resources */ -static int snd_mtpav_get_ISA(mtpav_t * mcard) +static int __init snd_mtpav_get_ISA(struct mtpav * mcard) { if ((mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI")) == NULL) { snd_printk("MTVAP port 0x%lx is busy\n", port); return -EBUSY; } mcard->port = port; - if (request_irq(irq, snd_mtpav_irqh, SA_INTERRUPT, "MOTU MTPAV", (void *)mcard)) { + if (request_irq(irq, snd_mtpav_irqh, SA_INTERRUPT, "MOTU MTPAV", mcard)) { snd_printk("MTVAP IRQ %d busy\n", irq); return -EBUSY; } @@ -611,13 +602,13 @@ static int snd_mtpav_get_ISA(mtpav_t * mcard) /* */ -static snd_rawmidi_ops_t snd_mtpav_output = { +static struct snd_rawmidi_ops snd_mtpav_output = { .open = snd_mtpav_output_open, .close = snd_mtpav_output_close, .trigger = snd_mtpav_output_trigger, }; -static snd_rawmidi_ops_t snd_mtpav_input = { +static struct snd_rawmidi_ops snd_mtpav_input = { .open = snd_mtpav_input_open, .close = snd_mtpav_input_close, .trigger = snd_mtpav_input_trigger, @@ -628,7 +619,8 @@ static snd_rawmidi_ops_t snd_mtpav_input = { * get RAWMIDI resources */ -static void snd_mtpav_set_name(mtpav_t *chip, snd_rawmidi_substream_t *substream) +static void __init snd_mtpav_set_name(struct mtpav *chip, + struct snd_rawmidi_substream *substream) { if (substream->number >= 0 && substream->number < chip->num_ports) sprintf(substream->name, "MTP direct %d", (substream->number % chip->num_ports) + 1); @@ -642,21 +634,18 @@ static void snd_mtpav_set_name(mtpav_t *chip, snd_rawmidi_substream_t *substream strcpy(substream->name, "MTP broadcast"); } -static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) +static int __init snd_mtpav_get_RAWMIDI(struct mtpav *mcard) { - int rval = 0; - snd_rawmidi_t *rawmidi; - snd_rawmidi_substream_t *substream; + int rval; + struct snd_rawmidi *rawmidi; + struct snd_rawmidi_substream *substream; struct list_head *list; - //printk("entering snd_mtpav_get_RAWMIDI\n"); - if (hwports < 1) - mcard->num_ports = 1; + hwports = 1; else if (hwports > 8) - mcard->num_ports = 8; - else - mcard->num_ports = hwports; + hwports = 8; + mcard->num_ports = hwports; if ((rval = snd_rawmidi_new(mcard->card, "MotuMIDI", 0, mcard->num_ports * 2 + MTPAV_PIDX_BROADCAST + 1, @@ -664,14 +653,15 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) &mcard->rmidi)) < 0) return rval; rawmidi = mcard->rmidi; + rawmidi->private_data = mcard; list_for_each(list, &rawmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_mtpav_set_name(mcard, substream); substream->ops = &snd_mtpav_input; } list_for_each(list, &rawmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_mtpav_set_name(mcard, substream); substream->ops = &snd_mtpav_output; mcard->ports[substream->number].hwport = translate_subdevice_to_hwport(mcard, substream->number); @@ -679,36 +669,15 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) rawmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; sprintf(rawmidi->name, "MTP AV MIDI"); - //printk("exiting snd_mtpav_get_RAWMIDI() \n"); return 0; } /* */ -static mtpav_t *new_mtpav(void) -{ - mtpav_t *ncrd = kzalloc(sizeof(*ncrd), GFP_KERNEL); - if (ncrd != NULL) { - spin_lock_init(&ncrd->spinlock); - - init_timer(&ncrd->timer); - ncrd->card = NULL; - ncrd->irq = -1; - ncrd->share_irq = 0; - - ncrd->inmidiport = 0xffffffff; - ncrd->inmidistate = 0; - ncrd->outmidihwport = 0xffffffff; - } - return ncrd; -} - -/* - */ - -static void free_mtpav(mtpav_t * crd) +static void snd_mtpav_free(struct snd_card *card) { + struct mtpav *crd = card->private_data; unsigned long flags; spin_lock_irqsave(&crd->spinlock, flags); @@ -718,78 +687,101 @@ static void free_mtpav(mtpav_t * crd) if (crd->irq >= 0) free_irq(crd->irq, (void *)crd); release_and_free_resource(crd->res_port); - kfree(crd); } /* */ - -static int __init alsa_card_mtpav_init(void) +static int __init snd_mtpav_probe(struct platform_device *dev) { - int err = 0; - char longname_buffer[80]; + struct snd_card *card; + int err; + struct mtpav *mtp_card; - mtp_card = new_mtpav(); - if (mtp_card == NULL) + card = snd_card_new(index, id, THIS_MODULE, sizeof(*mtp_card)); + if (! card) return -ENOMEM; - mtp_card->card = snd_card_new(index, id, THIS_MODULE, 0); - if (mtp_card->card == NULL) { - free_mtpav(mtp_card); - return -ENOMEM; - } + mtp_card = card->private_data; + spin_lock_init(&mtp_card->spinlock); + init_timer(&mtp_card->timer); + mtp_card->card = card; + mtp_card->irq = -1; + mtp_card->share_irq = 0; + mtp_card->inmidiport = 0xffffffff; + mtp_card->inmidistate = 0; + mtp_card->outmidihwport = 0xffffffff; + init_timer(&mtp_card->timer); + mtp_card->timer.function = snd_mtpav_output_timer; + mtp_card->timer.data = (unsigned long) mtp_card; + + card->private_free = snd_mtpav_free; err = snd_mtpav_get_ISA(mtp_card); - //printk("snd_mtpav_get_ISA returned: %d\n", err); if (err < 0) goto __error; - strcpy(mtp_card->card->driver, "MTPAV"); - strcpy(mtp_card->card->shortname, "MTPAV on parallel port"); - memset(longname_buffer, 0, sizeof(longname_buffer)); - sprintf(longname_buffer, "MTPAV on parallel port at"); + strcpy(card->driver, "MTPAV"); + strcpy(card->shortname, "MTPAV on parallel port"); + snprintf(card->longname, sizeof(card->longname), + "MTPAV on parallel port at 0x%lx", port); err = snd_mtpav_get_RAWMIDI(mtp_card); - //snd_printk("snd_mtapv_get_RAWMIDI returned: %d\n", err); if (err < 0) goto __error; - if ((err = snd_card_set_generic_dev(mtp_card->card)) < 0) - goto __error; - - err = snd_card_register(mtp_card->card); // don't snd_card_register until AFTER all cards reources done! + snd_mtpav_portscan(mtp_card); - //printk("snd_card_register returned %d\n", err); + snd_card_set_dev(card, &dev->dev); + err = snd_card_register(mtp_card->card); if (err < 0) goto __error; - - snd_mtpav_portscan(mtp_card); - + platform_set_drvdata(dev, card); printk(KERN_INFO "Motu MidiTimePiece on parallel port irq: %d ioport: 0x%lx\n", irq, port); - return 0; - __error: - snd_card_free(mtp_card->card); - free_mtpav(mtp_card); + __error: + snd_card_free(card); return err; } -/* - */ +static int snd_mtpav_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} -static void __exit alsa_card_mtpav_exit(void) +#define SND_MTPAV_DRIVER "snd_mtpav" + +static struct platform_driver snd_mtpav_driver = { + .probe = snd_mtpav_probe, + .remove = snd_mtpav_remove, + .driver = { + .name = SND_MTPAV_DRIVER + }, +}; + +static int __init alsa_card_mtpav_init(void) { - if (mtp_card == NULL) - return; - if (mtp_card->card) - snd_card_free(mtp_card->card); - free_mtpav(mtp_card); + int err; + + if ((err = platform_driver_register(&snd_mtpav_driver)) < 0) + return err; + + device = platform_device_register_simple(SND_MTPAV_DRIVER, -1, NULL, 0); + if (IS_ERR(device)) { + platform_driver_unregister(&snd_mtpav_driver); + return PTR_ERR(device); + } + return 0; } -/* - */ +static void __exit alsa_card_mtpav_exit(void) +{ + platform_device_unregister(device); + platform_driver_unregister(&snd_mtpav_driver); +} module_init(alsa_card_mtpav_init) module_exit(alsa_card_mtpav_exit) |