diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c index c148256..be9d0b5 100644 --- a/linux-core/drm_sysfs.c +++ b/linux-core/drm_sysfs.c @@ -245,14 +245,15 @@ int drm_sysfs_connector_add(struct drm_connector *connector) struct drm_device *dev = connector->dev; int ret = 0, i, j; - if (device_is_registered(&connector->kdev)) - return 0; + /* We shouldn't get called more than once for the same connector */ + BUG_ON(device_is_registered(&connector->kdev)); connector->kdev.parent = &dev->primary->kdev; connector->kdev.class = drm_class; connector->kdev.release = drm_sysfs_device_release; - DRM_DEBUG("adding \"%s\" to sysfs\n", drm_get_connector_name(connector)); + DRM_DEBUG("adding \"%s\" (%p) to sysfs\n", + drm_get_connector_name(connector), connector); snprintf(connector->kdev.bus_id, BUS_ID_SIZE, "card%d-%s", dev->primary->index, drm_get_connector_name(connector)); @@ -301,10 +302,9 @@ void drm_sysfs_connector_remove(struct drm_connector *connector) { int i; - if (!device_is_registered(&connector->kdev)) - return; + DRM_DEBUG("removing \"%s\" (%p) from sysfs\n", + drm_get_connector_name(connector), connector); - DRM_DEBUG("removing \"%s\" from sysfs\n", drm_get_connector_name(connector)); for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) device_remove_file(&connector->kdev, &connector_attrs[i]); sysfs_remove_bin_file(&connector->kdev.kobj, &edid_attr); @@ -362,6 +362,10 @@ int drm_sysfs_device_add(struct drm_minor *minor) snprintf(minor->kdev.bus_id, BUS_ID_SIZE, minor_str, minor->index); + DRM_DEBUG("registering %s\n", minor->kdev.bus_id); + + BUG_ON(device_is_registered(&minor->kdev)); + err = device_register(&minor->kdev); if (err) { DRM_ERROR("device add failed: %d\n", err); diff --git a/linux-core/intel_sdvo.c b/linux-core/intel_sdvo.c index ef67ef9..f0a47e2 100644 --- a/linux-core/intel_sdvo.c +++ b/linux-core/intel_sdvo.c @@ -1036,10 +1036,8 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) else i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); - if (i2cbus == NULL) { - intel_sdvo_destroy(connector); - return; - } + if (!i2cbus) + goto err_connector; sdvo_priv->i2c_bus = i2cbus; @@ -1061,8 +1059,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) { DRM_DEBUG("No SDVO device found on SDVO%c\n", output_device == SDVOB ? 'B' : 'C'); - intel_sdvo_destroy(connector); - return; + goto err_i2c; } } @@ -1107,8 +1104,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n", SDVO_NAME(sdvo_priv), bytes[0], bytes[1]); - intel_sdvo_destroy(connector); - return; + goto err_i2c; } drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type); @@ -1143,6 +1139,15 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) sdvo_priv->caps.output_flags & (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); - intel_output->ddc_bus = i2cbus; + intel_output->ddc_bus = i2cbus; + + return; +err_i2c: + intel_i2c_destroy(intel_output->i2c_bus); +err_connector: + drm_connector_cleanup(connector); + kfree(intel_output); + + return; }