Skip to content

Commit f4dfc44

Browse files
rodrigosiqueiraalexdeucher
authored andcommitted
drm/amd/pm: Use devm_i2c_add_adapter() in the i2c init
Instead of using i2c_add_adapter() and i2c_del_adapter(), replace them with devm_i2c_add_adapter() to simplify the i2c logic. Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 63137c7 commit f4dfc44

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,33 +1641,22 @@ static int aldebaran_i2c_control_init(struct smu_context *smu)
16411641
control->quirks = &aldebaran_i2c_control_quirks;
16421642
i2c_set_adapdata(control, smu_i2c);
16431643

1644-
res = i2c_add_adapter(control);
1644+
res = devm_i2c_add_adapter(adev->dev, control);
16451645
if (res) {
16461646
DRM_ERROR("Failed to register hw i2c, err: %d\n", res);
1647-
goto Out_err;
1647+
return res;
16481648
}
16491649

16501650
adev->pm.ras_eeprom_i2c_bus = &adev->pm.smu_i2c[0].adapter;
16511651
adev->pm.fru_eeprom_i2c_bus = &adev->pm.smu_i2c[0].adapter;
16521652

16531653
return 0;
1654-
Out_err:
1655-
i2c_del_adapter(control);
1656-
1657-
return res;
16581654
}
16591655

16601656
static void aldebaran_i2c_control_fini(struct smu_context *smu)
16611657
{
16621658
struct amdgpu_device *adev = smu->adev;
1663-
int i;
1664-
1665-
for (i = 0; i < MAX_SMU_I2C_BUSES; i++) {
1666-
struct amdgpu_smu_i2c_bus *smu_i2c = &adev->pm.smu_i2c[i];
1667-
struct i2c_adapter *control = &smu_i2c->adapter;
16681659

1669-
i2c_del_adapter(control);
1670-
}
16711660
adev->pm.ras_eeprom_i2c_bus = NULL;
16721661
adev->pm.fru_eeprom_i2c_bus = NULL;
16731662
}

0 commit comments

Comments
 (0)