MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
static struct platform_device *platform_devices[SNDRV_CARDS];
-static int pnp_registered;
-static unsigned int snd_mpu401_devices;
+static int pnp_registered = 0;
static int snd_mpu401_create(int dev, struct snd_card **rcard)
{
MODULE_DEVICE_TABLE(pnp, snd_mpu401_pnpids);
-static int __devinit snd_mpu401_pnp(int dev, struct pnp_dev *device,
+static int __init snd_mpu401_pnp(int dev, struct pnp_dev *device,
const struct pnp_device_id *id)
{
if (!pnp_port_valid(device, 0) ||
}
snd_card_set_dev(card, &pnp_dev->dev);
pnp_set_drvdata(pnp_dev, card);
- snd_mpu401_devices++;
++dev;
return 0;
}
static int __init alsa_card_mpu401_init(void)
{
- int i, err;
+ int i, err, devices;
if ((err = platform_driver_register(&snd_mpu401_driver)) < 0)
return err;
- for (i = 0; i < SNDRV_CARDS; i++) {
+ devices = 0;
+ for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
struct platform_device *device;
- if (! enable[i])
- continue;
#ifdef CONFIG_PNP
if (pnp[i])
continue;
#endif
device = platform_device_register_simple(SND_MPU401_DRIVER,
i, NULL, 0);
- if (IS_ERR(device))
- continue;
+ if (IS_ERR(device)) {
+ err = PTR_ERR(device);
+ goto errout;
+ }
platform_devices[i] = device;
- snd_mpu401_devices++;
+ devices++;
}
- err = pnp_register_driver(&snd_mpu401_pnp_driver);
- if (!err)
+ if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) {
pnp_registered = 1;
+ devices += err;
+ }
- if (!snd_mpu401_devices) {
+ if (!devices) {
#ifdef MODULE
printk(KERN_ERR "MPU-401 device not found or device busy\n");
#endif
- snd_mpu401_unregister_all();
- return -ENODEV;
+ err = -ENODEV;
+ goto errout;
}
return 0;
+
+ errout:
+ snd_mpu401_unregister_all();
+ return err;
}
static void __exit alsa_card_mpu401_exit(void)