These functions mostly do the same thing so unify them into one. Only destroy i2c adapters that have actually been created. gma_i2c_destroy() is now also called for PSB. Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@xxxxxxxxx> --- drivers/gpu/drm/gma500/cdv_intel_lvds.c | 14 +------------- drivers/gpu/drm/gma500/gma_lvds.c | 15 +++++++++++++++ drivers/gpu/drm/gma500/gma_lvds.h | 1 + drivers/gpu/drm/gma500/psb_intel_lvds.c | 13 +------------ 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c b/drivers/gpu/drm/gma500/cdv_intel_lvds.c index 2ba635513401..c492f1b3c8ea 100644 --- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c +++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c @@ -39,17 +39,6 @@ #define PSB_BACKLIGHT_PWM_CTL_SHIFT (16) #define PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE) -static void cdv_intel_lvds_destroy(struct drm_connector *connector) -{ - struct gma_connector *gma_connector = to_gma_connector(connector); - struct gma_encoder *gma_encoder = gma_attached_encoder(connector); - - gma_i2c_destroy(to_gma_i2c_chan(connector->ddc)); - gma_i2c_destroy(gma_encoder->i2c_bus); - drm_connector_cleanup(connector); - kfree(gma_connector); -} - static int cdv_intel_lvds_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t value) @@ -115,7 +104,7 @@ static const struct drm_connector_funcs cdv_intel_lvds_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .set_property = cdv_intel_lvds_set_property, - .destroy = cdv_intel_lvds_destroy, + .destroy = gma_lvds_destroy, }; /* @@ -261,7 +250,6 @@ void cdv_intel_lvds_init(struct drm_device *dev, /** * Set up I2C bus - * FIXME: distroy i2c_bus when exit */ gma_encoder->i2c_bus = gma_i2c_create(dev, GPIOB, "LVDSBLC_B"); if (!gma_encoder->i2c_bus) { diff --git a/drivers/gpu/drm/gma500/gma_lvds.c b/drivers/gpu/drm/gma500/gma_lvds.c index 3b48999105d1..9238cad5fac8 100644 --- a/drivers/gpu/drm/gma500/gma_lvds.c +++ b/drivers/gpu/drm/gma500/gma_lvds.c @@ -374,3 +374,18 @@ const struct drm_connector_helper_funcs gma_lvds_connector_helper_funcs = { .best_encoder = gma_best_encoder, }; +void gma_lvds_destroy(struct drm_connector *connector) +{ + struct gma_connector *gma_connector = to_gma_connector(connector); + struct gma_encoder *gma_encoder = gma_attached_encoder(connector); + + if (connector->ddc) + gma_i2c_destroy(to_gma_i2c_chan(connector->ddc)); + + if (gma_encoder->i2c_bus) + gma_i2c_destroy(gma_encoder->i2c_bus); + + drm_connector_cleanup(connector); + kfree(gma_connector); +} + diff --git a/drivers/gpu/drm/gma500/gma_lvds.h b/drivers/gpu/drm/gma500/gma_lvds.h index dcba810dc470..835305c900d8 100644 --- a/drivers/gpu/drm/gma500/gma_lvds.h +++ b/drivers/gpu/drm/gma500/gma_lvds.h @@ -30,6 +30,7 @@ bool gma_lvds_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *adjusted_mode); void gma_lvds_prepare(struct drm_encoder *encoder); void gma_lvds_commit(struct drm_encoder *encoder); +void gma_lvds_destroy(struct drm_connector *connector); extern const struct drm_encoder_helper_funcs gma_lvds_helper_funcs; extern const struct drm_connector_helper_funcs gma_lvds_connector_helper_funcs; diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c b/drivers/gpu/drm/gma500/psb_intel_lvds.c index ea5f2f078a7f..76742925b760 100644 --- a/drivers/gpu/drm/gma500/psb_intel_lvds.c +++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c @@ -132,16 +132,6 @@ void psb_intel_lvds_set_brightness(struct drm_device *dev, int level) psb_lvds_pwm_set_brightness(dev, level); } -void psb_intel_lvds_destroy(struct drm_connector *connector) -{ - struct gma_connector *gma_connector = to_gma_connector(connector); - struct gma_i2c_chan *ddc_bus = to_gma_i2c_chan(connector->ddc); - - gma_i2c_destroy(ddc_bus); - drm_connector_cleanup(connector); - kfree(gma_connector); -} - int psb_intel_lvds_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t value) @@ -214,7 +204,7 @@ const struct drm_connector_funcs psb_intel_lvds_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .set_property = psb_intel_lvds_set_property, - .destroy = psb_intel_lvds_destroy, + .destroy = gma_lvds_destroy, }; /** @@ -304,7 +294,6 @@ void psb_intel_lvds_init(struct drm_device *dev, /* * Set up I2C bus - * FIXME: distroy i2c_bus when exit */ gma_encoder->i2c_bus = gma_i2c_create(dev, GPIOB, "LVDSBLC_B"); if (!gma_encoder->i2c_bus) { -- 2.36.1