Re: patch bus_add_device-losing-an-error-return-from-the-probe-method.patchadded to gregkh-2.6 tree

From: Rene Herman
Date: Tue Apr 04 2006 - 20:22:54 EST


Rene Herman wrote:

As said before, if the behaviour makes sense for other busses, maybe propagating errors up should be dependent on a flags value somewhere that a platform-driver sets?

If platform_device_register_simple() never returns an IS_ERR() when the device is not found that means it's not a useful interface for hardware that needs to be probed for at the very least. ALSA would need to do something like, just before returning a succesfull return from the probe() method, set a global flag that the platform_device that is about to be registered is actually representing something, and freeing all platform_devices for which the flag is _not_ set again after this.

Which ofcourse means this is not at all useful. It's just working around the driver model then...

Well, we could in fact hang an unregister off device->private_data as per attached example. Wouldn't be _excessively_ ugly. Still sucks though. Having a flag somewhere in struct device_driver that a platform_driver would set and which would tell the driver model to honour the driver probe() method return seems the cleanest approach for all hardware where only the driver can now if the device is really present or not.

Ofcourse, I'm also still fine with just propagating the error up always (and if can be doing something about the ignore of -ENODEV / -ENOXIO)...

Rene. Index: local/sound/isa/adlib.c
===================================================================
--- local.orig/sound/isa/adlib.c 2006-04-05 02:00:55.000000000 +0200
+++ local/sound/isa/adlib.c 2006-04-05 02:05:45.000000000 +0200
@@ -43,8 +43,7 @@ static int __devinit snd_adlib_probe(str
struct snd_card *card;
struct snd_opl3 *opl3;

- int error;
- int i = device->id;
+ int error, i = device->id;

if (port[i] == SNDRV_AUTO_PORT) {
snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
@@ -95,8 +94,7 @@ static int __devinit snd_adlib_probe(str
return 0;

out1: snd_card_free(card);
- out0: error = -EINVAL; /* FIXME: should be the original error code */
- return error;
+out0: return error;
}

static int __devexit snd_adlib_remove(struct platform_device *device)
@@ -134,6 +132,11 @@ static int __init alsa_card_adlib_init(v
if (IS_ERR(device))
continue;

+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
+ }
+
devices[i] = device;
cards++;
}