>From 00f700ef4dd5fa335f725361aa683388c9b8ec4f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 16 Aug 2012 13:23:30 +0200 Subject: [PATCH] ide: Restore drvdata after device_attach failure Since commit 0998d063: "device-core: Ensure drvdata = NULL when no driver is bound", device_attach will clear a device's drvdata if the driver failed to bind to it. In the ide subsystem however drvdata is not used to store driver data, but rather to store per device bus_driver data. So for now restore drvdata after calling device_register(), so that drvdata will still point to the per device bus_driver data after a driver probe failure. In the long run the ide subsystem should probably be fixed to not abuse drvdata in this way, as this clearly is not how drvdata is intended to be used. Signed-off-by: Hans de Goede --- drivers/ide/ide-probe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 068cef0..be1981b 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -1015,6 +1015,12 @@ static void hwif_register_devices(ide_hwif_t *hwif) if (ret < 0) printk(KERN_WARNING "IDE: %s: device_register error: " "%d\n", __func__, ret); + /* + * device_register() will have cleared drvdata on + * device_attach failure, but we use drvdata to store per + * device bus info, rather then for driver info, so restore it. + */ + dev_set_drvdata(dev, drive); } } -- 1.7.11.4