@@ -175,6 +175,8 @@ static void spi_drv_shutdown(struct device *dev)
*/
int spi_register_driver(struct spi_driver *sdrv)
{
+ int ret;
+
sdrv->driver.bus = &spi_bus_type;
if (sdrv->probe)
sdrv->driver.probe = spi_drv_probe;
@@ -182,7 +184,12 @@ int spi_register_driver(struct spi_driver *sdrv)
sdrv->driver.remove = spi_drv_remove;
if (sdrv->shutdown)
sdrv->driver.shutdown = spi_drv_shutdown;
- return driver_register(&sdrv->driver);
+
+ ret = driver_register(&sdrv->driver);
+ if (!ret)
+ driver_unregister(&sdrv->driver);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(spi_register_driver);