aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2010-12-13 15:08:52 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-03 18:10:18 -0500
commita5462516aa9942bd68c8769d4bcefa8a7c718300 (patch)
treef13126cc825173266f7ad3cb514698418faa7074 /drivers/base
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')
-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 080e9ca11017..9cd3b5cfcc42 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1551,7 +1551,34 @@ EXPORT_SYMBOL_GPL(device_destroy);
1551 * on the same device to ensure that new_name is valid and 1551 * on the same device to ensure that new_name is valid and
1552 * won't conflict with other devices. 1552 * won't conflict with other devices.
1553 * 1553 *
1554 * "Never use this function, bad things will happen" - gregkh 1554 * Note: Don't call this function. Currently, the networking layer calls this
1555 * function, but that will change. The following text from Kay Sievers offers
1556 * some insight:
1557 *
1558 * Renaming devices is racy at many levels, symlinks and other stuff are not
1559 * replaced atomically, and you get a "move" uevent, but it's not easy to
1560 * connect the event to the old and new device. Device nodes are not renamed at
1561 * all, there isn't even support for that in the kernel now.
1562 *
1563 * In the meantime, during renaming, your target name might be taken by another
1564 * driver, creating conflicts. Or the old name is taken directly after you
1565 * renamed it -- then you get events for the same DEVPATH, before you even see
1566 * the "move" event. It's just a mess, and nothing new should ever rely on
1567 * kernel device renaming. Besides that, it's not even implemented now for
1568 * other things than (driver-core wise very simple) network devices.
1569 *
1570 * We are currently about to change network renaming in udev to completely
1571 * disallow renaming of devices in the same namespace as the kernel uses,
1572 * because we can't solve the problems properly, that arise with swapping names
1573 * of multiple interfaces without races. Means, renaming of eth[0-9]* will only
1574 * be allowed to some other name than eth[0-9]*, for the aforementioned
1575 * reasons.
1576 *
1577 * Make up a "real" name in the driver before you register anything, or add
1578 * some other attributes for userspace to find the device, or use udev to add
1579 * symlinks -- but never rename kernel devices later, it's a complete mess. We
1580 * don't even want to get into that and try to implement the missing pieces in
1581 * the core. We really have other pieces to fix in the driver core mess. :)
1555 */ 1582 */
1556int device_rename(struct device *dev, const char *new_name) 1583int device_rename(struct device *dev, const char *new_name)
1557{ 1584{