Driver Core: fix bug in device_rename() for SYSFS_DEPRECATED=y
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 26 Oct 2007 18:07:44 +0000 (20:07 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 31 Oct 2007 04:52:33 +0000 (21:52 -0700)
This should fix the sysfs warnings that renaming network devices is
causing to show up with CONFIG_SYSFS_DEPRECATED=y

The code just shouldn't run if class devices are real directories, it's
an update for the symlink in the class directory. Nobody noticed that as
long as the creation of sysfs files silently failed, and we both missed
it before the merge, because we don't run SYSFS_DEPRECATED=y.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: David Miller <davem@davemloft.net>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/core.c

index c1343414d285e29f57fe17e089e635be20af3aed..3f4d6aa139909e49ac77541bdd8b94f46979dae2 100644 (file)
@@ -1228,18 +1228,18 @@ int device_rename(struct device *dev, char *new_name)
                        sysfs_remove_link(&dev->parent->kobj, old_class_name);
                }
        }
-#endif
-
+#else
        if (dev->class) {
                sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
                error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
                                          dev->bus_id);
                if (error) {
-                       /* Uh... how to unravel this if restoring can fail? */
                        dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n",
                                __FUNCTION__, error);
                }
        }
+#endif
+
 out:
        put_device(dev);