Skip to content

Commit 5b3eca0

Browse files
rodrigosiqueiraalexdeucher
authored andcommitted
drm/amd/display: Use devm_i2c_add_adapter to simplify i2c cleanup logic
This commit replaces the utilization of i2c_add/del_adapter() with devm_i2c_add_adapter() to reduce the amount of boilerplate. Using devm_i2c_add_adapter() has the advantage of removing the manual manipulation of the I2C adapter. Suggested-by: Robert Beckett <bob.beckett@collabora.com> Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 70db83e commit 5b3eca0

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ static int dm_oem_i2c_hw_init(struct amdgpu_device *adev)
29452945
return -ENOMEM;
29462946
}
29472947

2948-
r = i2c_add_adapter(&oem_i2c->base);
2948+
r = devm_i2c_add_adapter(adev->dev, &oem_i2c->base);
29492949
if (r) {
29502950
drm_info(adev_to_drm(adev), "Failed to register oem i2c\n");
29512951
kfree(oem_i2c);
@@ -2957,17 +2957,6 @@ static int dm_oem_i2c_hw_init(struct amdgpu_device *adev)
29572957
return 0;
29582958
}
29592959

2960-
static void dm_oem_i2c_hw_fini(struct amdgpu_device *adev)
2961-
{
2962-
struct amdgpu_display_manager *dm = &adev->dm;
2963-
2964-
if (dm->oem_i2c) {
2965-
i2c_del_adapter(&dm->oem_i2c->base);
2966-
kfree(dm->oem_i2c);
2967-
dm->oem_i2c = NULL;
2968-
}
2969-
}
2970-
29712960
/**
29722961
* dm_hw_init() - Initialize DC device
29732962
* @ip_block: Pointer to the amdgpu_ip_block for this hw instance.
@@ -3018,8 +3007,6 @@ static int dm_hw_fini(struct amdgpu_ip_block *ip_block)
30183007
{
30193008
struct amdgpu_device *adev = ip_block->adev;
30203009

3021-
dm_oem_i2c_hw_fini(adev);
3022-
30233010
amdgpu_dm_hpd_fini(adev);
30243011

30253012
amdgpu_dm_irq_fini(adev);
@@ -7373,10 +7360,6 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
73737360
drm_dp_cec_unregister_connector(&aconnector->dm_dp_aux.aux);
73747361
drm_connector_unregister(connector);
73757362
drm_connector_cleanup(connector);
7376-
if (aconnector->i2c) {
7377-
i2c_del_adapter(&aconnector->i2c->base);
7378-
kfree(aconnector->i2c);
7379-
}
73807363
kfree(aconnector->dm_dp_aux.aux.name);
73817364

73827365
kfree(connector);
@@ -8734,7 +8717,7 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
87348717
}
87358718

87368719
aconnector->i2c = i2c;
8737-
res = i2c_add_adapter(&i2c->base);
8720+
res = devm_i2c_add_adapter(dm->adev->dev, &i2c->base);
87388721

87398722
if (res) {
87408723
drm_err(adev_to_drm(dm->adev), "Failed to register hw i2c %d\n", link->link_index);

0 commit comments

Comments
 (0)