Changeset 679 for GPL/trunk/alsa-kernel/drivers/mpu401
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (5 years ago)
- Location:
- GPL/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/drivers/mpu401/mpu401.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for generic MPU-401 boards (UART mode only) 3 4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 5 * Copyright (c) 2004 by Castet Matthieu <castet.matthieu@free.fr> 5 *6 *7 * This program is free software; you can redistribute it and/or modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation; either version 2 of the License, or10 * (at your option) any later version.11 *12 * This program is distributed in the hope that it will be useful,13 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with this program; if not, write to the Free Software19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20 *21 6 */ 22 7 23 #ifdef TARGET_OS224 #include <sound/config.h>25 #endif26 8 #include <linux/init.h> 27 9 #include <linux/pnp.h> 28 10 #include <linux/err.h> 29 11 #include <linux/platform_device.h> 30 #include <linux/module param.h>12 #include <linux/module.h> 31 13 #include <sound/core.h> 32 14 #include <sound/mpu401.h> … … 43 25 #endif 44 26 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 45 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */27 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 46 28 #ifdef CONFIG_PNP 47 29 #ifndef TARGET_OS2 48 static intpnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};30 static bool pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 49 31 #else 50 32 static int pnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 54 36 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ 55 37 #ifndef TARGET_OS2 56 static intuart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};38 static bool uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 57 39 #else 58 40 static int uart_enter[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 69 51 MODULE_PARM_DESC(pnp, "PnP detection for MPU-401 device."); 70 52 #endif 71 module_param_ array(port, long, NULL, 0444);53 module_param_hw_array(port, long, ioport, NULL, 0444); 72 54 MODULE_PARM_DESC(port, "Port # for MPU-401 device."); 73 module_param_ array(irq, int, NULL, 0444);55 module_param_hw_array(irq, int, irq, NULL, 0444); 74 56 MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); 75 57 module_param_array(uart_enter, bool, NULL, 0444); … … 80 62 static unsigned int snd_mpu401_devices; 81 63 82 static int snd_mpu401_create(int dev, struct snd_card **rcard) 64 static int snd_mpu401_create(struct device *devptr, int dev, 65 struct snd_card **rcard) 83 66 { 84 67 struct snd_card *card; … … 89 72 90 73 *rcard = NULL; 91 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 74 err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE, 75 0, &card); 92 76 if (err < 0) 93 77 return err; … … 102 86 103 87 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev], 0, 104 irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, 105 NULL); 88 irq[dev], NULL); 106 89 if (err < 0) { 107 90 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); … … 117 100 } 118 101 119 static int __devinitsnd_mpu401_probe(struct platform_device *devptr)102 static int snd_mpu401_probe(struct platform_device *devptr) 120 103 { 121 104 int dev = devptr->id; … … 131 114 return -EINVAL; 132 115 } 133 err = snd_mpu401_create( dev, &card);116 err = snd_mpu401_create(&devptr->dev, dev, &card); 134 117 if (err < 0) 135 118 return err; 136 snd_card_set_dev(card, &devptr->dev);137 119 if ((err = snd_card_register(card)) < 0) { 138 120 snd_card_free(card); … … 143 125 } 144 126 145 static int __devexitsnd_mpu401_remove(struct platform_device *devptr)127 static int snd_mpu401_remove(struct platform_device *devptr) 146 128 { 147 129 snd_card_free(platform_get_drvdata(devptr)); 148 platform_set_drvdata(devptr, NULL);149 130 return 0; 150 131 } … … 154 135 static struct platform_driver snd_mpu401_driver = { 155 136 .probe = snd_mpu401_probe, 156 .remove = __devexit_p(snd_mpu401_remove),137 .remove = snd_mpu401_remove, 157 138 .driver = { 158 .name = SND_MPU401_DRIVER 139 .name = SND_MPU401_DRIVER, 159 140 }, 160 141 }; … … 165 146 #define IO_EXTENT 2 166 147 167 static struct pnp_device_id snd_mpu401_pnpids[] = {148 static const struct pnp_device_id snd_mpu401_pnpids[] = { 168 149 { .id = "PNPb006" }, 169 150 { .id = "" } … … 172 153 MODULE_DEVICE_TABLE(pnp, snd_mpu401_pnpids); 173 154 174 static int __devinitsnd_mpu401_pnp(int dev, struct pnp_dev *device,175 155 static int snd_mpu401_pnp(int dev, struct pnp_dev *device, 156 const struct pnp_device_id *id) 176 157 { 177 158 if (!pnp_port_valid(device, 0) || … … 198 179 } 199 180 200 static int __devinitsnd_mpu401_pnp_probe(struct pnp_dev *pnp_dev,201 181 static int snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, 182 const struct pnp_device_id *id) 202 183 { 203 184 static int dev; … … 211 192 if (err < 0) 212 193 return err; 213 err = snd_mpu401_create( dev, &card);194 err = snd_mpu401_create(&pnp_dev->dev, dev, &card); 214 195 if (err < 0) 215 196 return err; … … 218 199 return err; 219 200 } 220 snd_card_set_dev(card, &pnp_dev->dev);221 201 pnp_set_drvdata(pnp_dev, card); 222 202 snd_mpu401_devices++; … … 227 207 } 228 208 229 static void __devexitsnd_mpu401_pnp_remove(struct pnp_dev *dev)209 static void snd_mpu401_pnp_remove(struct pnp_dev *dev) 230 210 { 231 211 struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev); … … 239 219 .id_table = snd_mpu401_pnpids, 240 220 .probe = snd_mpu401_pnp_probe, 241 .remove = __devexit_p(snd_mpu401_pnp_remove),221 .remove = snd_mpu401_pnp_remove, 242 222 }; 243 223 #else -
GPL/trunk/alsa-kernel/drivers/mpu401/mpu401_uart.c
r399 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 4 5 * 5 6 * MPU-401 supports UART mode which is not capable generate transmit 6 * interrupts thus output is done via polling. Also, if irq < 0, then7 * interrupts thus output is done via polling. Without interrupt, 7 8 * input is done also via polling. Do not expect good performance. 8 *9 *10 * This program is free software; you can redistribute it and/or modify11 * it under the terms of the GNU General Public License as published by12 * the Free Software Foundation; either version 2 of the License, or13 * (at your option) any later version.14 *15 * This program is distributed in the hope that it will be useful,16 * but WITHOUT ANY WARRANTY; without even the implied warranty of17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18 * GNU General Public License for more details.19 *20 * You should have received a copy of the GNU General Public License21 * along with this program; if not, write to the Free Software22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA23 9 * 24 10 * 13-03-2003: … … 26 12 * are port and mmio. For other kind of I/O, set mpu->read and 27 13 * mpu->write to your own I/O functions. 28 * 29 */ 30 31 #include <asm/io.h> 14 */ 15 16 #include <linux/io.h> 32 17 #include <linux/delay.h> 33 18 #include <linux/init.h> 34 19 #include <linux/slab.h> 35 20 #include <linux/ioport.h> 21 #include <linux/module.h> 36 22 #include <linux/interrupt.h> 37 23 #include <linux/errno.h> … … 129 115 * 130 116 * Processes the interrupt for MPU401-UART i/o. 117 * 118 * Return: %IRQ_HANDLED if the interrupt was handled. %IRQ_NONE otherwise. 131 119 */ 132 120 irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id) … … 134 122 struct snd_mpu401 *mpu = dev_id; 135 123 136 if ( mpu == NULL)124 if (!mpu) 137 125 return IRQ_NONE; 138 126 _snd_mpu401_uart_interrupt(mpu); … … 148 136 * 149 137 * Processes the interrupt for MPU401-UART output. 138 * 139 * Return: %IRQ_HANDLED if the interrupt was handled. %IRQ_NONE otherwise. 150 140 */ 151 141 irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id) … … 153 143 struct snd_mpu401 *mpu = dev_id; 154 144 155 if ( mpu == NULL)145 if (!mpu) 156 146 return IRQ_NONE; 157 147 uart_interrupt_tx(mpu); … … 161 151 EXPORT_SYMBOL(snd_mpu401_uart_interrupt_tx); 162 152 153 #define from_timer(var, callback_timer, timer_fieldname) \ 154 container_of(callback_timer, struct snd_mpu401, timer_fieldname) 155 163 156 /* 164 157 * timer callback 165 158 * reprogram the timer and call the interrupt job 166 159 */ 167 static void snd_mpu401_uart_timer( unsigned long data)168 { 169 struct snd_mpu401 *mpu = (struct snd_mpu401 *)data;160 static void snd_mpu401_uart_timer(struct timer_list *t) 161 { 162 struct snd_mpu401 *mpu = from_timer(mpu, t, timer); 170 163 unsigned long flags; 171 164 172 165 spin_lock_irqsave(&mpu->timer_lock, flags); 173 166 /*mpu->mode |= MPU401_MODE_TIMER;*/ 174 mpu->timer.expires = 1 + jiffies; 175 add_timer(&mpu->timer); 167 mod_timer(&mpu->timer, 1 + jiffies); 176 168 spin_unlock_irqrestore(&mpu->timer_lock, flags); 177 169 if (mpu->rmidi) … … 188 180 spin_lock_irqsave (&mpu->timer_lock, flags); 189 181 if (mpu->timer_invoked == 0) { 182 #ifndef TARGET_OS2 183 timer_setup(&mpu->timer, snd_mpu401_uart_timer, 0); 184 mod_timer(&mpu->timer, 1 + jiffies); 185 #else 190 186 init_timer(&mpu->timer); 191 187 mpu->timer.data = (unsigned long)mpu; 192 mpu->timer.function = snd_mpu401_uart_timer;188 mpu->timer.function = (void(*)(unsigned long))snd_mpu401_uart_timer; 193 189 mpu->timer.expires = 1 + jiffies; 194 190 add_timer(&mpu->timer); 195 } 191 #endif 192 } 196 193 mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER : 197 194 MPU401_MODE_OUTPUT_TIMER; … … 375 372 while (max-- > 0) 376 373 mpu->read(mpu, MPU401D(mpu)); 377 if (mpu->i rq < 0)374 if (mpu->info_flags & MPU401_INFO_USE_TIMER) 378 375 snd_mpu401_uart_add_timer(mpu, 1); 379 376 } … … 384 381 spin_unlock_irqrestore(&mpu->input_lock, flags); 385 382 } else { 386 if (mpu->i rq < 0)383 if (mpu->info_flags & MPU401_INFO_USE_TIMER) 387 384 snd_mpu401_uart_remove_timer(mpu, 1); 388 385 clear_bit(MPU401_MODE_BIT_INPUT_TRIGGER, &mpu->mode); … … 480 477 */ 481 478 482 static struct snd_rawmidi_ops snd_mpu401_uart_output =479 static const struct snd_rawmidi_ops snd_mpu401_uart_output = 483 480 { 484 481 .open = snd_mpu401_uart_output_open, … … 487 484 }; 488 485 489 static struct snd_rawmidi_ops snd_mpu401_uart_input =486 static const struct snd_rawmidi_ops snd_mpu401_uart_input = 490 487 { 491 488 .open = snd_mpu401_uart_input_open, … … 497 494 { 498 495 struct snd_mpu401 *mpu = rmidi->private_data; 499 if (mpu->irq _flags && mpu->irq>= 0)496 if (mpu->irq >= 0) 500 497 free_irq(mpu->irq, (void *) mpu); 501 498 release_and_free_resource(mpu->res); … … 510 507 * @port: the base address of MPU401 port 511 508 * @info_flags: bitflags MPU401_INFO_XXX 512 * @irq: the irq number, -1 if no interrupt for mpu 513 * @irq_flags: the irq request flags (SA_XXX), 0 if irq was already reserved. 509 * @irq: the ISA irq number, -1 if not to be allocated 514 510 * @rrawmidi: the pointer to store the new rawmidi instance 515 511 * … … 520 516 * cast from rawmidi->private_data (with struct snd_mpu401 magic-cast). 521 517 * 522 * Return s zero if successful, or a negative error code.518 * Return: Zero if successful, or a negative error code. 523 519 */ 524 520 int snd_mpu401_uart_new(struct snd_card *card, int device, … … 526 522 unsigned long port, 527 523 unsigned int info_flags, 528 int irq, int irq_flags,524 int irq, 529 525 struct snd_rawmidi ** rrawmidi) 530 526 { … … 544 540 return err; 545 541 mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); 546 if (mpu == NULL) { 547 snd_printk(KERN_ERR "mpu401_uart: cannot allocate\n"); 548 snd_device_free(card, rmidi); 549 return -ENOMEM; 542 if (!mpu) { 543 err = -ENOMEM; 544 goto free_device; 550 545 } 551 546 rmidi->private_data = mpu; … … 555 550 spin_lock_init(&mpu->timer_lock); 556 551 mpu->hardware = hardware; 552 mpu->irq = -1; 557 553 if (! (info_flags & MPU401_INFO_INTEGRATED)) { 558 554 int res_size = hardware == MPU401_HW_PC98II ? 4 : 2; 559 555 mpu->res = request_region(port, res_size, "MPU401 UART"); 560 if ( mpu->res == NULL) {556 if (!mpu->res) { 561 557 snd_printk(KERN_ERR "mpu401_uart: " 562 558 "unable to grab port 0x%lx size %d\n", 563 559 port, res_size); 564 snd_device_free(card, rmidi);565 return -EBUSY;560 err = -EBUSY; 561 goto free_device; 566 562 } 567 563 } … … 578 574 else 579 575 mpu->cport = port + 1; 580 if (irq >= 0 && irq_flags) {581 if (request_irq(irq, snd_mpu401_uart_interrupt, irq_flags,576 if (irq >= 0) { 577 if (request_irq(irq, snd_mpu401_uart_interrupt, 0, 582 578 "MPU401 UART", (void *) mpu)) { 583 579 snd_printk(KERN_ERR "mpu401_uart: " 584 580 "unable to grab IRQ %d\n", irq); 585 snd_device_free(card, rmidi);586 return -EBUSY;581 err = -EBUSY; 582 goto free_device; 587 583 } 588 584 } 585 if (irq < 0 && !(info_flags & MPU401_INFO_IRQ_HOOK)) 586 info_flags |= MPU401_INFO_USE_TIMER; 589 587 mpu->info_flags = info_flags; 590 588 mpu->irq = irq; 591 mpu->irq_flags = irq_flags;592 589 if (card->shortname[0]) 593 590 snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI", … … 611 608 *rrawmidi = rmidi; 612 609 return 0; 610 free_device: 611 snd_device_free(card, rmidi); 612 return err; 613 613 } 614 614 615 615 EXPORT_SYMBOL(snd_mpu401_uart_new); 616 617 /*618 * INIT part619 */620 621 static int __init alsa_mpu401_uart_init(void)622 {623 return 0;624 }625 626 static void __exit alsa_mpu401_uart_exit(void)627 {628 }629 630 module_init(alsa_mpu401_uart_init)631 module_exit(alsa_mpu401_uart_exit)
Note:
See TracChangeset
for help on using the changeset viewer.