unregister platform device again if probe was unsuccessful
PATCH 2/2 unregister platform device again if probe was unsuccessful
Quoted 6 lines · Rene Herman
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_adlibattached 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 theIS_ERRthen signifies an eror in the bowels
of the device model, but I feel it's still the correct thing to do)
And here's the one doing the unregisters. This one could also go to stable, if you agree with the method...
I've been testing with snd_adlib, and everything seems to be working as planned, also with the bus_add_device() patch reverted. Ie, not having the hardware present (at the supplied adress) makes it fail to load, and
echo -n snd_adlib.0 >/sys/bus/platform/drivers/snd_adlib/{un,}bind
makes the driver unbind and bind correctly.
ad1848/ad1848.c | 4 ++++
adlib.c | 11 +++++++----
cmi8330.c | 4 ++++
cs423x/cs4231.c | 4 ++++
cs423x/cs4236.c | 4 ++++
es1688/es1688.c | 4 ++++
es18xx.c | 4 ++++
gus/gusclassic.c | 4 ++++
gus/gusextreme.c | 4 ++++
gus/gusmax.c | 4 ++++
gus/interwave.c | 4 ++++
opl3sa2.c | 4 ++++
opti9xx/miro.c | 7 +++++--
opti9xx/opti92x-ad1848.c | 7 +++++--
sb/sb16.c | 4 ++++
sb/sb8.c | 4 ++++
sgalaxy.c | 4 ++++
sscape.c | 4 ++++
wavefront/wavefront.c | 4 ++++
19 files changed, 81 insertions(+), 8 deletions(-)Rene
sound/isa/ad1848/ad1848.c +4 -0
@@ -195,6 +195,10 @@ static int __init alsa_card_ad1848_init( i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/cmi8330.c +4 -0
@@ -701,6 +701,10 @@ static int __init alsa_card_cmi8330_init i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; cards++; }
sound/isa/cs423x/cs4231.c +4 -0
@@ -211,6 +211,10 @@ static int __init alsa_card_cs4231_init( i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/cs423x/cs4236.c +4 -0
@@ -782,6 +782,10 @@ static int __init alsa_card_cs423x_init( i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; snd_cs423x_devices++; }
sound/isa/es1688/es1688.c +4 -0
@@ -215,6 +215,10 @@ static int __init alsa_card_es1688_init( i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/gus/gusclassic.c +4 -0
@@ -255,6 +255,10 @@ static int __init alsa_card_gusclassic_i i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/gus/gusextreme.c +4 -0
@@ -365,6 +365,10 @@ static int __init alsa_card_gusextreme_i i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/gus/gusmax.c +4 -0
@@ -392,6 +392,10 @@ static int __init alsa_card_gusmax_init( i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/gus/interwave.c +4 -0
@@ -949,6 +949,10 @@ static int __init alsa_card_interwave_in i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; cards++; }
sound/isa/opl3sa2.c +4 -0
@@ -964,6 +964,10 @@ static int __init alsa_card_opl3sa2_init i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; snd_opl3sa2_devices++; }
sound/isa/sb/sb16.c +4 -0
@@ -723,6 +723,10 @@ static int __init alsa_card_sb16_init(vo i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; cards++; }
sound/isa/sb/sb8.c +4 -0
@@ -266,6 +266,10 @@ static int __init alsa_card_sb8_init(voi i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/sgalaxy.c +4 -0
@@ -368,6 +368,10 @@ static int __init alsa_card_sgalaxy_init i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } devices[i] = device; cards++; }
sound/isa/wavefront/wavefront.c +4 -0
@@ -724,6 +724,10 @@ static int __init alsa_card_wavefront_in i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; cards++; }
sound/isa/adlib.c +7 -4
@@ -43,8 +43,7 @@ static int __devinit snd_adlib_probe(strstruct 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(strreturn 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(vif (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } + devices[i] = device; cards++; }
sound/isa/es18xx.c +4 -0
@@ -2394,6 +2394,10 @@ static int __init alsa_card_es18xx_init( i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; cards++; }
sound/isa/opti9xx/miro.c +5 -2
@@ -1436,8 +1436,11 @@ static int __init alsa_card_miro_init(voif ((error =platform_driver_register (&snd_miro_driver)) <0 )return error; device =platform_device_register_simple (DRIVER_NAME ,-1 ,NULL ,0 ); -if (!IS_ERR (device)) -return 0 ; +if (!IS_ERR (device)) { +if (platform_get_drvdata (device)) +return 0 ; +platform_device_unregister (device); + }#ifdef MODULE printk (KERN_ERR "no miro soundcard found\n" );#endif
sound/isa/opti9xx/opti92x-ad1848.c +5 -2
@@ -2099,8 +2099,11 @@ static int __init alsa_card_opti9xx_initreturn error; device =platform_device_register_simple (DRIVER_NAME ,-1 ,NULL ,0 );if (!IS_ERR (device)) { - snd_opti9xx_platform_device = device; -return 0 ; +if (platform_get_drvdata (device)) { + snd_opti9xx_platform_device = device; +return 0 ; + } +platform_device_unregister (device); }platform_driver_unregister (&snd_opti9xx_driver); }
sound/isa/sscape.c +4 -0
@@ -1438,6 +1438,10 @@ static int __init sscape_manual_probe(vo i, NULL, 0);if (IS_ERR (device))continue ; +if (!platform_get_drvdata (device)) { +platform_device_unregister (device); +continue ; + } platform_devices[i] = device; }return 0 ;