[PATCH] pnp: mpu401: adjust pnp_register_driver signature
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Mon, 27 Mar 2006 09:17:04 +0000 (01:17 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 27 Mar 2006 16:44:53 +0000 (08:44 -0800)
This series of patches removes the assumption that pnp_register_driver()
returns the number of devices claimed.  Returning the count is unreliable
because devices may be hot-plugged in the future.  (Many devices don't support
hot-plug, of course, but PNP in general does.)

This changes the convention to "zero for success, or a negative error value,"
which matches pci_register_driver(), acpi_bus_register_driver(), and
platform_driver_register().

If drivers need to know the number of devices, they can count calls to their
.probe() methods.

This patch:

Remove the assumption that pnp_register_driver() returns the number of devices
claimed.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Adam Belay <ambx1@neo.rr.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
sound/drivers/mpu401/mpu401.c

index 9d10d79e27afca0f9e3574497efe1816e137f269..9ea3059a706499cd0da280fa63c1ce60f7ae1923 100644 (file)
@@ -59,7 +59,8 @@ module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
 
 static struct platform_device *platform_devices[SNDRV_CARDS];
-static int pnp_registered = 0;
+static int pnp_registered;
+static unsigned int snd_mpu401_devices;
 
 static int snd_mpu401_create(int dev, struct snd_card **rcard)
 {
@@ -197,6 +198,7 @@ static int __devinit snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev,
                }
                snd_card_set_dev(card, &pnp_dev->dev);
                pnp_set_drvdata(pnp_dev, card);
+               snd_mpu401_devices++;
                ++dev;
                return 0;
        }
@@ -234,12 +236,11 @@ static void __init_or_module snd_mpu401_unregister_all(void)
 
 static int __init alsa_card_mpu401_init(void)
 {
-       int i, err, devices;
+       int i, err;
 
        if ((err = platform_driver_register(&snd_mpu401_driver)) < 0)
                return err;
 
-       devices = 0;
        for (i = 0; i < SNDRV_CARDS; i++) {
                struct platform_device *device;
                if (! enable[i])
@@ -255,14 +256,13 @@ static int __init alsa_card_mpu401_init(void)
                        goto errout;
                }
                platform_devices[i] = device;
-               devices++;
+               snd_mpu401_devices++;
        }
-       if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) {
+       err = pnp_register_driver(&snd_mpu401_pnp_driver);
+       if (!err)
                pnp_registered = 1;
-               devices += err;
-       }
 
-       if (!devices) {
+       if (!snd_mpu401_devices) {
 #ifdef MODULE
                printk(KERN_ERR "MPU-401 device not found or device busy\n");
 #endif