Commit dcccdd93 authored by Rene Herman's avatar Rene Herman Committed by Jaroslav Kysela

[ALSA] unregister platform device again if probe was unsuccessful

Unregister the platform device again if the probe was unsuccessful.

This restores the behaviour of not loading the driver on probe() failure.
Signed-off-by: default avatarRene Herman <rene.herman@keyaccess.nl>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d0ac642d
...@@ -195,6 +195,10 @@ static int __init alsa_card_ad1848_init(void) ...@@ -195,6 +195,10 @@ static int __init alsa_card_ad1848_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -43,8 +43,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device) ...@@ -43,8 +43,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device)
struct snd_card *card; struct snd_card *card;
struct snd_opl3 *opl3; struct snd_opl3 *opl3;
int error; int error, i = device->id;
int i = device->id;
if (port[i] == SNDRV_AUTO_PORT) { if (port[i] == SNDRV_AUTO_PORT) {
snd_printk(KERN_ERR DRV_NAME ": please specify port\n"); snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
...@@ -95,8 +94,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device) ...@@ -95,8 +94,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device)
return 0; return 0;
out1: snd_card_free(card); out1: snd_card_free(card);
out0: error = -EINVAL; /* FIXME: should be the original error code */ out0: return error;
return error;
} }
static int __devexit snd_adlib_remove(struct platform_device *device) static int __devexit snd_adlib_remove(struct platform_device *device)
...@@ -134,6 +132,11 @@ static int __init alsa_card_adlib_init(void) ...@@ -134,6 +132,11 @@ static int __init alsa_card_adlib_init(void)
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -701,6 +701,10 @@ static int __init alsa_card_cmi8330_init(void) ...@@ -701,6 +701,10 @@ static int __init alsa_card_cmi8330_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
cards++; cards++;
} }
......
...@@ -211,6 +211,10 @@ static int __init alsa_card_cs4231_init(void) ...@@ -211,6 +211,10 @@ static int __init alsa_card_cs4231_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -782,6 +782,10 @@ static int __init alsa_card_cs423x_init(void) ...@@ -782,6 +782,10 @@ static int __init alsa_card_cs423x_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
snd_cs423x_devices++; snd_cs423x_devices++;
} }
......
...@@ -215,6 +215,10 @@ static int __init alsa_card_es1688_init(void) ...@@ -215,6 +215,10 @@ static int __init alsa_card_es1688_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -2393,6 +2393,10 @@ static int __init alsa_card_es18xx_init(void) ...@@ -2393,6 +2393,10 @@ static int __init alsa_card_es18xx_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
cards++; cards++;
} }
......
...@@ -255,6 +255,10 @@ static int __init alsa_card_gusclassic_init(void) ...@@ -255,6 +255,10 @@ static int __init alsa_card_gusclassic_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -365,6 +365,10 @@ static int __init alsa_card_gusextreme_init(void) ...@@ -365,6 +365,10 @@ static int __init alsa_card_gusextreme_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -392,6 +392,10 @@ static int __init alsa_card_gusmax_init(void) ...@@ -392,6 +392,10 @@ static int __init alsa_card_gusmax_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -949,6 +949,10 @@ static int __init alsa_card_interwave_init(void) ...@@ -949,6 +949,10 @@ static int __init alsa_card_interwave_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
cards++; cards++;
} }
......
...@@ -964,6 +964,10 @@ static int __init alsa_card_opl3sa2_init(void) ...@@ -964,6 +964,10 @@ static int __init alsa_card_opl3sa2_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
snd_opl3sa2_devices++; snd_opl3sa2_devices++;
} }
......
...@@ -1436,8 +1436,11 @@ static int __init alsa_card_miro_init(void) ...@@ -1436,8 +1436,11 @@ static int __init alsa_card_miro_init(void)
if ((error = platform_driver_register(&snd_miro_driver)) < 0) if ((error = platform_driver_register(&snd_miro_driver)) < 0)
return error; return error;
device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
if (! IS_ERR(device)) if (! IS_ERR(device)) {
return 0; if (platform_get_drvdata(device))
return 0;
platform_device_unregister(device);
}
#ifdef MODULE #ifdef MODULE
printk(KERN_ERR "no miro soundcard found\n"); printk(KERN_ERR "no miro soundcard found\n");
#endif #endif
......
...@@ -2099,8 +2099,11 @@ static int __init alsa_card_opti9xx_init(void) ...@@ -2099,8 +2099,11 @@ static int __init alsa_card_opti9xx_init(void)
return error; return error;
device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
if (!IS_ERR(device)) { if (!IS_ERR(device)) {
snd_opti9xx_platform_device = device; if (platform_get_drvdata(device)) {
return 0; snd_opti9xx_platform_device = device;
return 0;
}
platform_device_unregister(device);
} }
platform_driver_unregister(&snd_opti9xx_driver); platform_driver_unregister(&snd_opti9xx_driver);
} }
......
...@@ -722,6 +722,10 @@ static int __init alsa_card_sb16_init(void) ...@@ -722,6 +722,10 @@ static int __init alsa_card_sb16_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
cards++; cards++;
} }
......
...@@ -266,6 +266,10 @@ static int __init alsa_card_sb8_init(void) ...@@ -266,6 +266,10 @@ static int __init alsa_card_sb8_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -368,6 +368,10 @@ static int __init alsa_card_sgalaxy_init(void) ...@@ -368,6 +368,10 @@ static int __init alsa_card_sgalaxy_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
devices[i] = device; devices[i] = device;
cards++; cards++;
} }
......
...@@ -1438,6 +1438,10 @@ static int __init sscape_manual_probe(void) ...@@ -1438,6 +1438,10 @@ static int __init sscape_manual_probe(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
} }
return 0; return 0;
......
...@@ -724,6 +724,10 @@ static int __init alsa_card_wavefront_init(void) ...@@ -724,6 +724,10 @@ static int __init alsa_card_wavefront_init(void)
i, NULL, 0); i, NULL, 0);
if (IS_ERR(device)) if (IS_ERR(device))
continue; continue;
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
continue;
}
platform_devices[i] = device; platform_devices[i] = device;
cards++; cards++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment