[PATCH] ide: Restore drvdata after device_attach failure

From: Hans de Goede
Date: Thu Aug 16 2012 - 07:23:30 EST


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 <hdegoede@xxxxxxxxxx>
---
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


--------------060800000801090903000904--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/