drm/sysfs: protect sysfs removal code against being run twice.
authorDave Airlie <airlied@redhat.com>
Mon, 20 Feb 2012 14:15:02 +0000 (14:15 +0000)
committerDave Airlie <airlied@redhat.com>
Thu, 15 Mar 2012 13:35:31 +0000 (13:35 +0000)
a step towards correct hot unplug for USB devices, we need to
remove the userspace facing bits at the unplug time for correct
udev operation.

Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_sysfs.c

index 62c3675045ac72462eedc6a18b375a1b33eb498d..5a7bd51fc3d842be78c6fd07f72a84a554e3ae12 100644 (file)
@@ -454,6 +454,8 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
 {
        int i;
 
+       if (!connector->kdev.parent)
+               return;
        DRM_DEBUG("removing \"%s\" from sysfs\n",
                  drm_get_connector_name(connector));
 
@@ -461,6 +463,7 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
                device_remove_file(&connector->kdev, &connector_attrs[i]);
        sysfs_remove_bin_file(&connector->kdev.kobj, &edid_attr);
        device_unregister(&connector->kdev);
+       connector->kdev.parent = NULL;
 }
 EXPORT_SYMBOL(drm_sysfs_connector_remove);
 
@@ -533,7 +536,9 @@ err_out:
  */
 void drm_sysfs_device_remove(struct drm_minor *minor)
 {
-       device_unregister(&minor->kdev);
+       if (minor->kdev.parent)
+               device_unregister(&minor->kdev);
+       minor->kdev.parent = NULL;
 }