1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
|
/*
* Generic driver for serial MIDI adapters
* Copyright (c) by Jaroslav Kysela <perex@suse.cz>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* The adaptor module parameter allows you to select:
* 0 - Roland SoundCanvas (use outs paratemer to specify count of output ports)
*/
#include <sound/driver.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include <asm/uaccess.h>
#include <sound/core.h>
#include <sound/rawmidi.h>
#include <sound/initval.h>
#include <linux/delay.h>
#define SNDRV_SERIAL_MAX_OUTS 16 /* min 16 */
#define TX_BUF_SIZE 256
#define SERIAL_ADAPTOR_SOUNDCANVAS 0 /* Roland Soundcanvas; F5 NN selects part */
#define SERIAL_ADAPTOR_MS124T 1 /* Midiator MS-124T */
#define SERIAL_ADAPTOR_MS124W_SA 2 /* Midiator MS-124W in S/A mode */
#define SERIAL_ADAPTOR_MS124W_MB 3 /* Midiator MS-124W in M/B mode */
#define SERIAL_ADAPTOR_MAX SERIAL_ADAPTOR_MS124W_MB
EXPORT_NO_SYMBOLS;
MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
MODULE_DESCRIPTION("Serial MIDI");
MODULE_LICENSE("GPL");
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
static char *sdev[SNDRV_CARDS] = {"/dev/ttyS0", [1 ... (SNDRV_CARDS - 1)] = ""}; /* serial device */
static int speed[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 38400}; /* 9600,19200,38400,57600,115200 */
static int adaptor[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = SERIAL_ADAPTOR_SOUNDCANVAS};
static int outs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* 1 to 16 */
static int devices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* 1 to 8 */
static int handshake[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* bool */
module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for serial device.");
module_param_array(id, charp, NULL, 0444);
MODULE_PARM_DESC(id, "ID string for serial device.");
module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(enable, "Enable serial device.");
module_param_array(sdev, charp, NULL, 0444);
MODULE_PARM_DESC(sdev, "Device file string for serial device.");
module_param_array(speed, int, NULL, 0444);
MODULE_PARM_DESC(speed, "Speed in bauds.");
module_param_array(adaptor, int, NULL, 0444);
MODULE_PARM_DESC(adaptor, "Type of adaptor.");
module_param_array(outs, int, NULL, 0444);
MODULE_PARM_DESC(outs, "Number of MIDI outputs.");
module_param_array(devices, int, NULL, 0444);
MODULE_PARM_DESC(devices, "Number of devices to attach to the card.");
module_param_array(handshake, int, NULL, 0444);
MODULE_PARM_DESC(handshake, "Do handshaking.");
#define SERIAL_MODE_NOT_OPENED (0)
#define SERIAL_MODE_BIT_INPUT (0)
#define SERIAL_MODE_BIT_OUTPUT (1)
#define SERIAL_MODE_BIT_INPUT_TRIGGERED (2)
#define SERIAL_MODE_BIT_OUTPUT_TRIGGERED (3)
typedef struct _snd_serialmidi {
struct snd_card *card;
char *sdev; /* serial device name (e.g. /dev/ttyS0) */
int dev_idx;
unsigned int speed; /* speed in bauds */
unsigned int adaptor; /* see SERIAL_ADAPTOR_ */
unsigned long mode; /* see SERIAL_MODE_* */
unsigned int outs; /* count of outputs */
unsigned char prev_status[SNDRV_SERIAL_MAX_OUTS];
struct snd_rawmidi *rmidi; /* rawmidi device */
struct snd_rawmidi_substream *substream_input;
struct snd_rawmidi_substream *substream_output;
struct file *file;
struct tty_struct *tty;
struct mutex open_lock;
void (*old_receive_buf)(struct tty_struct *, const unsigned char *cp, char *fp, int count);
void (*old_write_wakeup)(struct tty_struct *);
int old_exclusive;
int old_low_latency;
int handshake;
unsigned char tx_buf[TX_BUF_SIZE];
} serialmidi_t;
static struct platform_device *devptrs[SNDRV_CARDS];
static void ldisc_receive_buf(struct tty_struct *, const unsigned char *cp, char *fp, int count);
static void ldisc_write_wakeup(struct tty_struct *);
static int tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct inode * inode = file->f_dentry->d_inode;
mm_segment_t fs;
int retval;
if (file->f_op == NULL)
return -ENXIO;
fs = get_fs();
set_fs(get_ds());
retval = file->f_op->ioctl(inode, file, cmd, arg);
set_fs(fs);
return retval;
}
static int open_tty(serialmidi_t *serial, unsigned int mode)
{
int retval = 0;
struct tty_struct *tty;
struct termios old_termios, *ntermios;
struct tty_driver *driver;
int ldisc, speed, cflag;
mutex_lock(&serial->open_lock);
if (serial->tty) {
set_bit(mode, &serial->mode);
goto __end;
}
if (IS_ERR(serial->file = filp_open(serial->sdev, O_RDWR|O_NONBLOCK, 0))) {
retval = PTR_ERR(serial->file);
serial->file = NULL;
goto __end;
}
tty = (struct tty_struct *)serial->file->private_data;
if (tty == NULL || tty->magic != TTY_MAGIC) {
snd_printk(KERN_ERR "device %s has not valid tty", serial->sdev);
retval = -EIO;
goto __end;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) /* correct version? */
driver = tty->driver;
#else
driver = &tty->driver;
#endif
if (driver == NULL || driver->set_termios == NULL) {
snd_printk(KERN_ERR "tty %s has not set_termios", serial->sdev);
retval = -EIO;
goto __end;
}
#ifdef CONFIG_HAVE_TTY_COUNT_ATOMIC
if (atomic_read(&tty->count) > 1) {
#else
if (tty->count > 1) {
#endif
snd_printk(KERN_ERR "tty %s is already used", serial->sdev);
retval = -EBUSY;
goto __end;
}
/* select N_TTY line discipline (for sure) */
ldisc = N_TTY;
if ((retval = tty_ioctl(serial->file, TIOCSETD, (unsigned long)&ldisc)) < 0) {
snd_printk(KERN_ERR "TIOCSETD (N_TTY) failed for tty %s", serial->sdev);
goto __end;
}
/* sanity check, we use disc_data for own purposes */
if (tty->disc_data != NULL) {
snd_printk(KERN_ERR "disc_data are used for tty %s", serial->sdev);
goto __end;
}
switch (serial->speed) {
case 9600:
speed = B9600;
break;
case 19200:
speed = B19200;
break;
case 38400:
speed = B38400;
break;
case 57600:
speed = B57600;
break;
case 115200:
default:
speed = B115200;
break;
}
if (serial->handshake)
cflag = speed | CREAD | CSIZE | CS8 | CRTSCTS | HUPCL;
else
cflag = speed | CREAD | CSIZE | CS8 | HUPCL;
switch (serial->adaptor) {
case SERIAL_ADAPTOR_MS124W_SA:
case SERIAL_ADAPTOR_MS124W_MB:
case SERIAL_ADAPTOR_MS124T:
/* TODO */
break;
}
old_termios = *tty->termios;
ntermios = tty->termios;
ntermios->c_lflag = NOFLSH;
ntermios->c_iflag = IGNBRK | IGNPAR;
ntermios->c_oflag = 0;
ntermios->c_cflag = cflag;
ntermios->c_cc[VEOL] = 0; /* '\r'; */
ntermios->c_cc[VERASE] = 0;
ntermios->c_cc[VKILL] = 0;
ntermios->c_cc[VMIN] = 0;
ntermios->c_cc[VTIME] = 0;
(*driver->set_termios)(tty, &old_termios);
serial->tty = tty;
/* some magic here, we need own receive_buf */
/* it would be probably better to create own line discipline */
/* but this solution is sufficient at the time */
tty->disc_data = serial;
serial->old_receive_buf = tty->ldisc.receive_buf;
tty->ldisc.receive_buf = ldisc_receive_buf;
serial->old_write_wakeup = tty->ldisc.write_wakeup;
tty->ldisc.write_wakeup = ldisc_write_wakeup;
serial->old_low_latency = tty->low_latency;
tty->low_latency = 1;
serial->old_exclusive = test_bit(TTY_EXCLUSIVE, &tty->flags);
set_bit(TTY_EXCLUSIVE, &tty->flags);
set_bit(mode, &serial->mode);
retval = 0;
__end:
if (retval < 0) {
if (serial->file) {
filp_close(serial->file, NULL);
serial->file = NULL;
}
}
mutex_unlock(&serial->open_lock);
return retval;
}
static int close_tty(serialmidi_t *serial, unsigned int mode)
{
unsigned int imode = mode == SERIAL_MODE_BIT_INPUT ?
SERIAL_MODE_BIT_OUTPUT : SERIAL_MODE_BIT_INPUT;
struct tty_struct *tty;
mutex_lock(&serial->open_lock);
clear_bit(mode, &serial->mode);
if (test_bit(imode, &serial->mode))
goto __end;
tty = serial->tty;
if (tty->disc_data == serial)
tty->disc_data = NULL;
if (tty && tty->ldisc.receive_buf == ldisc_receive_buf) {
tty->low_latency = serial->old_low_latency;
tty->ldisc.receive_buf = serial->old_receive_buf;
if (serial->old_exclusive)
set_bit(TTY_EXCLUSIVE, &tty->flags);
else
clear_bit(TTY_EXCLUSIVE, &tty->flags);
}
filp_close(serial->file, NULL);
serial->tty = NULL;
serial->file = NULL;
__end:
mutex_unlock(&serial->open_lock);
return 0;
}
static void ldisc_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
{
serialmidi_t *serial = tty->disc_data;
if (serial == NULL)
return;
if (!test_bit(SERIAL_MODE_BIT_INPUT_TRIGGERED, &serial->mode))
return;
snd_rawmidi_receive(serial->substream_input, cp, count);
}
static void tx_loop(serialmidi_t *serial)
{
struct tty_struct *tty;
char *buf = serial->tx_buf;
int count;
struct tty_driver *driver;
tty = serial->tty;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) /* correct version? */
driver = tty->driver;
#else
driver = &tty->driver;
#endif
if (driver == NULL)
return;
if (down_trylock(&tty->atomic_write))
return;
while (1) {
count = driver->write_room(tty);
if (count <= 0) {
up(&tty->atomic_write);
return;
}
count = count > TX_BUF_SIZE ? TX_BUF_SIZE : count;
count = snd_rawmidi_transmit_peek(serial->substream_output, buf, count);
if (count > 0) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
driver->write(tty, buf, count);
#else
count = driver->write(tty, 0, buf, count);
#endif
snd_rawmidi_transmit_ack(serial->substream_output, count);
} else {
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
break;
}
}
up(&tty->atomic_write);
}
static void ldisc_write_wakeup(struct tty_struct *tty)
{
serialmidi_t *serial = tty->disc_data;
tx_loop(serial);
}
static void snd_serialmidi_output_trigger(struct snd_rawmidi_substream *substream, int up)
{
serialmidi_t *serial = substream->rmidi->private_data;
if (up) {
set_bit(SERIAL_MODE_BIT_OUTPUT_TRIGGERED, &serial->mode);
set_bit(TTY_DO_WRITE_WAKEUP, &serial->tty->flags);
tx_loop(serial);
} else {
clear_bit(TTY_DO_WRITE_WAKEUP, &serial->tty->flags);
clear_bit(SERIAL_MODE_BIT_OUTPUT_TRIGGERED, &serial->mode);
}
}
static void snd_serialmidi_input_trigger(struct snd_rawmidi_substream *substream, int up)
{
serialmidi_t *serial = substream->rmidi->private_data;
if (up) {
set_bit(SERIAL_MODE_BIT_INPUT_TRIGGERED, &serial->mode);
} else {
clear_bit(SERIAL_MODE_BIT_INPUT_TRIGGERED, &serial->mode);
}
}
static int snd_serialmidi_output_open(struct snd_rawmidi_substream *substream)
{
serialmidi_t *serial = substream->rmidi->private_data;
int err;
if ((err = open_tty(serial, SERIAL_MODE_BIT_OUTPUT)) < 0)
return err;
serial->substream_output = substream;
return 0;
}
static int snd_serialmidi_output_close(struct snd_rawmidi_substream *substream)
{
serialmidi_t *serial = substream->rmidi->private_data;
serial->substream_output = NULL;
return close_tty(serial, SERIAL_MODE_BIT_OUTPUT);
}
static int snd_serialmidi_input_open(struct snd_rawmidi_substream *substream)
{
serialmidi_t *serial = substream->rmidi->private_data;
int err;
if ((err = open_tty(serial, SERIAL_MODE_BIT_INPUT)) < 0)
return err;
serial->substream_input = substream;
return 0;
}
static int snd_serialmidi_input_close(struct snd_rawmidi_substream *substream)
{
serialmidi_t *serial = substream->rmidi->private_data;
serial->substream_input = NULL;
return close_tty(serial, SERIAL_MODE_BIT_INPUT);
}
static struct snd_rawmidi_ops snd_serialmidi_output =
{
.open = snd_serialmidi_output_open,
.close = snd_serialmidi_output_close,
.trigger = snd_serialmidi_output_trigger,
};
static struct snd_rawmidi_ops snd_serialmidi_input =
{
.open = snd_serialmidi_input_open,
.close = snd_serialmidi_input_close,
.trigger = snd_serialmidi_input_trigger,
};
static int snd_serialmidi_free(serialmidi_t *serial)
{
if (serial->sdev);
kfree(serial->sdev);
kfree(serial);
return 0;
}
static int snd_serialmidi_dev_free(struct snd_device *device)
{
serialmidi_t *serial = device->device_data;
return snd_serialmidi_free(serial);
}
static int __init snd_serialmidi_rmidi(serialmidi_t *serial)
{
struct snd_rawmidi *rrawmidi;
int err;
if ((err = snd_rawmidi_new(serial->card, "UART Serial MIDI", serial->dev_idx, serial->outs, 1, &rrawmidi)) < 0)
return err;
snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_serialmidi_input);
snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_serialmidi_output);
snprintf(rrawmidi->name, sizeof(rrawmidi->name), "%s %d", serial->card->shortname, serial->dev_idx);
rrawmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
SNDRV_RAWMIDI_INFO_INPUT |
SNDRV_RAWMIDI_INFO_DUPLEX;
rrawmidi->private_data = serial;
serial->rmidi = rrawmidi;
return 0;
}
static int __init snd_serialmidi_create(struct snd_card *card, const char *sdev,
unsigned int speed, unsigned int adaptor,
unsigned int outs, int idx, int hshake)
{
static struct snd_device_ops ops = {
.dev_free = snd_serialmidi_dev_free,
};
serialmidi_t *serial;
int err;
switch (adaptor) {
case SERIAL_ADAPTOR_SOUNDCANVAS:
break;
case SERIAL_ADAPTOR_MS124T:
case SERIAL_ADAPTOR_MS124W_SA:
outs = 1;
break;
case SERIAL_ADAPTOR_MS124W_MB:
outs = 16;
break;
default:
snd_printk(KERN_ERR "Adaptor type is out of range 0-%d (%d)\n",
SERIAL_ADAPTOR_MAX, adaptor);
return -ENODEV;
}
if (outs < 1)
outs = 1;
else if (outs > 16)
outs = 16;
if ((serial = kzalloc(sizeof(*serial), GFP_KERNEL)) == NULL)
return -ENOMEM;
mutex_init(&serial->open_lock);
serial->card = card;
serial->dev_idx = idx;
serial->sdev = kstrdup(sdev, GFP_KERNEL);
if (serial->sdev == NULL) {
snd_serialmidi_free(serial);
return -ENOMEM;
}
serial->adaptor = adaptor;
serial->speed = speed;
serial->outs = outs;
serial->handshake = hshake;
memset(serial->prev_status, 0x80, sizeof(unsigned char) * SNDRV_SERIAL_MAX_OUTS);
/* Register device */
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, serial, &ops)) < 0) {
snd_serialmidi_free(serial);
return err;
}
if ((err = snd_serialmidi_rmidi(serial)) < 0) {
snd_device_free(card, serial);
return err;
}
return 0;
}
static int __init snd_serial_probe(struct platform_device *devptr)
{
struct snd_card *card;
int err;
int dev = devptr->id;
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
if (card == NULL)
return -ENOMEM;
strcpy(card->driver, "Serial MIDI");
if (id[dev] && *id[dev])
snprintf(card->shortname, sizeof(card->shortname), "%s", id[dev]);
else
strcpy(card->shortname, card->driver);
if (devices[dev] > 1) {
int i, start_dev;
char devname[32];
/* assign multiple devices to a single card */
if (devices[dev] > 8) {
printk(KERN_ERR "serialmidi: invalid devices %d\n", devices[dev]);
snd_card_free(card);
return -EINVAL;
}
/* device name mangling */
strncpy(devname, sdev[dev], sizeof(devname));
devname[31] = 0;
i = strlen(devname);
if (i > 0) i--;
if (devname[i] >= '0' && devname[i] <= '9') {
for (; i > 0; i--)
if (devname[i] < '0' || devname[i] > '9') {
i++;
break;
}
start_dev = simple_strtoul(devname + i, NULL, 0);
devname[i] = 0;
} else
start_dev = 0;
for (i = 0; i < devices[dev]; i++) {
char devname2[33];
sprintf(devname2, "%s%d", devname, start_dev + i);
if ((err = snd_serialmidi_create(card, devname2, speed[dev],
adaptor[dev], outs[dev], i,
handshake[dev])) < 0) {
snd_card_free(card);
return err;
}
}
} else {
if ((err = snd_serialmidi_create(card, sdev[dev], speed[dev],
adaptor[dev], outs[dev], 0,
handshake[dev])) < 0) {
snd_card_free(card);
return err;
}
}
sprintf(card->longname, "%s at %s", card->shortname, sdev[dev]);
snd_card_set_dev(card, &devptr->dev);
if ((err = snd_card_register(card)) < 0) {
snd_card_free(card);
return err;
}
platform_set_drvdata(devptr, card);
return 0;
}
static int snd_serial_remove(struct platform_device *devptr)
{
snd_card_free(platform_get_drvdata(devptr));
platform_set_drvdata(devptr, NULL);
return 0;
}
#define SND_SERIAL_DRIVER "snd_serial"
static struct platform_driver snd_serial_driver = {
.probe = snd_serial_probe,
.remove = snd_serial_remove,
.driver = {
.name = SND_SERIAL_DRIVER
},
};
static void __init_or_module snd_serial_unregister_all(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(devices); ++i)
platform_device_unregister(devptrs[i]);
platform_driver_unregister(&snd_serial_driver);
}
static int __init alsa_card_serialmidi_init(void)
{
int i, cards, err;
if ((err = platform_driver_register(&snd_serial_driver)) < 0)
return err;
cards = 0;
for (i = 0; i < SNDRV_CARDS; i++) {
struct platform_device *device;
if (! enable[i])
continue;
device = platform_device_register_simple(SND_SERIAL_DRIVER,
i, NULL, 0);
if (IS_ERR(device)) {
err = PTR_ERR(device);
goto errout;
}
devptrs[i] = device;
cards++;
}
if (!cards) {
#ifdef MODULE
printk(KERN_ERR "serial MIDI device not found or device busy\n");
#endif
err = -ENODEV;
goto errout;
}
return 0;
errout:
snd_serial_unregister_all();
return err;
}
static void __exit alsa_card_serialmidi_exit(void)
{
snd_serial_unregister_all();
}
module_init(alsa_card_serialmidi_init)
module_exit(alsa_card_serialmidi_exit)
|