Skip to content

Commit a2cce09

Browse files
author
Thomas Zimmermann
committed
drm/ast: Convert I2C code to managed cleanup
Release the I2C adapter as part of the DRM device cleanup. Remove ast's dedicated helper for struct drm_connector_funcs.destroy. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 55dc449 commit a2cce09

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <drm/drm_gem_atomic_helper.h>
4141
#include <drm/drm_gem_framebuffer_helper.h>
4242
#include <drm/drm_gem_vram_helper.h>
43+
#include <drm/drm_managed.h>
4344
#include <drm/drm_plane_helper.h>
4445
#include <drm/drm_probe_helper.h>
4546
#include <drm/drm_simple_kms_helper.h>
@@ -48,7 +49,6 @@
4849
#include "ast_tables.h"
4950

5051
static struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev);
51-
static void ast_i2c_destroy(struct ast_i2c_chan *i2c);
5252

5353
static inline void ast_load_palette_index(struct ast_private *ast,
5454
u8 index, u8 red, u8 green,
@@ -1300,14 +1300,6 @@ static enum drm_mode_status ast_mode_valid(struct drm_connector *connector,
13001300
return flags;
13011301
}
13021302

1303-
static void ast_connector_destroy(struct drm_connector *connector)
1304-
{
1305-
struct ast_connector *ast_connector = to_ast_connector(connector);
1306-
1307-
ast_i2c_destroy(ast_connector->i2c);
1308-
drm_connector_cleanup(connector);
1309-
}
1310-
13111303
static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
13121304
.get_modes = ast_get_modes,
13131305
.mode_valid = ast_mode_valid,
@@ -1316,7 +1308,7 @@ static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
13161308
static const struct drm_connector_funcs ast_connector_funcs = {
13171309
.reset = drm_atomic_helper_connector_reset,
13181310
.fill_modes = drm_helper_probe_single_connector_modes,
1319-
.destroy = ast_connector_destroy,
1311+
.destroy = drm_connector_cleanup,
13201312
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
13211313
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
13221314
};
@@ -1493,6 +1485,14 @@ static void set_data(void *i2c_priv, int data)
14931485
}
14941486
}
14951487

1488+
static void ast_i2c_release(struct drm_device *dev, void *res)
1489+
{
1490+
struct ast_i2c_chan *i2c = res;
1491+
1492+
i2c_del_adapter(&i2c->adapter);
1493+
kfree(i2c);
1494+
}
1495+
14961496
static struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev)
14971497
{
14981498
struct ast_i2c_chan *i2c;
@@ -1521,19 +1521,15 @@ static struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev)
15211521
ret = i2c_bit_add_bus(&i2c->adapter);
15221522
if (ret) {
15231523
drm_err(dev, "Failed to register bit i2c\n");
1524-
goto out_free;
1524+
goto out_kfree;
15251525
}
15261526

1527+
ret = drmm_add_action_or_reset(dev, ast_i2c_release, i2c);
1528+
if (ret)
1529+
return NULL;
15271530
return i2c;
1528-
out_free:
1529-
kfree(i2c);
1530-
return NULL;
1531-
}
15321531

1533-
static void ast_i2c_destroy(struct ast_i2c_chan *i2c)
1534-
{
1535-
if (!i2c)
1536-
return;
1537-
i2c_del_adapter(&i2c->adapter);
1532+
out_kfree:
15381533
kfree(i2c);
1534+
return NULL;
15391535
}

0 commit comments

Comments
 (0)