40
40
#include <drm/drm_gem_atomic_helper.h>
41
41
#include <drm/drm_gem_framebuffer_helper.h>
42
42
#include <drm/drm_gem_vram_helper.h>
43
+ #include <drm/drm_managed.h>
43
44
#include <drm/drm_plane_helper.h>
44
45
#include <drm/drm_probe_helper.h>
45
46
#include <drm/drm_simple_kms_helper.h>
48
49
#include "ast_tables.h"
49
50
50
51
static struct ast_i2c_chan * ast_i2c_create (struct drm_device * dev );
51
- static void ast_i2c_destroy (struct ast_i2c_chan * i2c );
52
52
53
53
static inline void ast_load_palette_index (struct ast_private * ast ,
54
54
u8 index , u8 red , u8 green ,
@@ -1300,14 +1300,6 @@ static enum drm_mode_status ast_mode_valid(struct drm_connector *connector,
1300
1300
return flags ;
1301
1301
}
1302
1302
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
-
1311
1303
static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
1312
1304
.get_modes = ast_get_modes ,
1313
1305
.mode_valid = ast_mode_valid ,
@@ -1316,7 +1308,7 @@ static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
1316
1308
static const struct drm_connector_funcs ast_connector_funcs = {
1317
1309
.reset = drm_atomic_helper_connector_reset ,
1318
1310
.fill_modes = drm_helper_probe_single_connector_modes ,
1319
- .destroy = ast_connector_destroy ,
1311
+ .destroy = drm_connector_cleanup ,
1320
1312
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state ,
1321
1313
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state ,
1322
1314
};
@@ -1493,6 +1485,14 @@ static void set_data(void *i2c_priv, int data)
1493
1485
}
1494
1486
}
1495
1487
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
+
1496
1496
static struct ast_i2c_chan * ast_i2c_create (struct drm_device * dev )
1497
1497
{
1498
1498
struct ast_i2c_chan * i2c ;
@@ -1521,19 +1521,15 @@ static struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev)
1521
1521
ret = i2c_bit_add_bus (& i2c -> adapter );
1522
1522
if (ret ) {
1523
1523
drm_err (dev , "Failed to register bit i2c\n" );
1524
- goto out_free ;
1524
+ goto out_kfree ;
1525
1525
}
1526
1526
1527
+ ret = drmm_add_action_or_reset (dev , ast_i2c_release , i2c );
1528
+ if (ret )
1529
+ return NULL ;
1527
1530
return i2c ;
1528
- out_free :
1529
- kfree (i2c );
1530
- return NULL ;
1531
- }
1532
1531
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 :
1538
1533
kfree (i2c );
1534
+ return NULL ;
1539
1535
}
0 commit comments