summaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2010-12-13 14:08:52 -0600
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-03 15:10:18 -0800
commita5462516aa9942bd68c8769d4bcefa8a7c718300 (patch)
treef13126cc825173266f7ad3cb514698418faa7074 /drivers/base/core.c
parentebf53826e105f488f4f628703a108e98940d1dc5 (diff)
driver-core: document restrictions on device_rename()
Add text, courtesy of Kay Sievers, that provides some background on device_rename() and why it shouldn't be used. Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 080e9ca1101..9cd3b5cfcc4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1551,7 +1551,34 @@ EXPORT_SYMBOL_GPL(device_destroy);
* on the same device to ensure that new_name is valid and
* won't conflict with other devices.
*
- * "Never use this function, bad things will happen" - gregkh
+ * Note: Don't call this function. Currently, the networking layer calls this
+ * function, but that will change. The following text from Kay Sievers offers
+ * some insight:
+ *
+ * Renaming devices is racy at many levels, symlinks and other stuff are not
+ * replaced atomically, and you get a "move" uevent, but it's not easy to
+ * connect the event to the old and new device. Device nodes are not renamed at
+ * all, there isn't even support for that in the kernel now.
+ *
+ * In the meantime, during renaming, your target name might be taken by another
+ * driver, creating conflicts. Or the old name is taken directly after you
+ * renamed it -- then you get events for the same DEVPATH, before you even see
+ * the "move" event. It's just a mess, and nothing new should ever rely on
+ * kernel device renaming. Besides that, it's not even implemented now for
+ * other things than (driver-core wise very simple) network devices.
+ *
+ * We are currently about to change network renaming in udev to completely
+ * disallow renaming of devices in the same namespace as the kernel uses,
+ * because we can't solve the problems properly, that arise with swapping names
+ * of multiple interfaces without races. Means, renaming of eth[0-9]* will only
+ * be allowed to some other name than eth[0-9]*, for the aforementioned
+ * reasons.
+ *
+ * Make up a "real" name in the driver before you register anything, or add
+ * some other attributes for userspace to find the device, or use udev to add
+ * symlinks -- but never rename kernel devices later, it's a complete mess. We
+ * don't even want to get into that and try to implement the missing pieces in
+ * the core. We really have other pieces to fix in the driver core mess. :)
*/
int device_rename(struct device *dev, const char *new_name)
{