lkml.org 
[lkml]   [2006]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: patch bus_add_device-losing-an-error-return-from-the-probe-method.patch added to gregkh-2.6 tree
Dmitry Torokhov wrote:

> You need to let go of the model that driver that drives hardware also
> do the device discovery and it will all fall into place.

It's not possible to sanely let go of that model. ISA discovery involves
(as an example) poking at the same I/O ports as using does, meaning you
will have to share a request_region() over discovery and use for one --
you can't decouple that due to obvious races.

>> Anyways, the additional method would, I feel, be the conceptually
>> cleanest approach. Practically speaking though, simply doing a manual
>> probe and only calling platform_register() after everything is found to
>> be present and accounted for is not much of a problem either.
>>
>
> Unfortunately it breaks manual driver binding/unbinding through sysfs
> so I don't think it is a good long-term solution.

Yes. I don't see a significantly cleaner solution then than the slightly
hackish "using drvdata as a private success flag" that I posted before.
Example patch versus snd_adlib attached again. This seems to work well.

Takashi: do you agree? If the probe() method return is not going to be
propagated up, there are few other options.

(Continuing the loop on IS_ERR(device) is then also a bit questionable
again as the IS_ERR then signifies an eror in the bowels of the device
model, but I feel it's still the correct thing to do)

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++;
}
\
 
 \ /
  Last update: 2006-04-05 23:23    [W:0.049 / U:0.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site