Skip to content

Commit 13f785d

Browse files
rodrigosiqueiraalexdeucher
authored andcommitted
drm/amd/pm: Use devm_i2c_add_adapter() in the Sienna smu
The I2C init for Sienna Cichlid uses i2c_add_adapter() and i2c_del_adapter(), this commit replaces the use of these two functions with devm_i2c_add_adapter(). Notice that Sienna Cichlid init initializes multiple I2C buses in a loop; if something goes wrong, the previous adapters are removed, and the amdgpu load is interrupted. Since I2C init is required for the correct load of amdgpu, it is safe to rely on devm_i2c_add_adapter() to handle any previously initialized I2C adapter. Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 9058cb7 commit 13f785d

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,10 +2648,10 @@ static int sienna_cichlid_i2c_control_init(struct smu_context *smu)
26482648
control->quirks = &sienna_cichlid_i2c_control_quirks;
26492649
i2c_set_adapdata(control, smu_i2c);
26502650

2651-
res = i2c_add_adapter(control);
2651+
res = devm_i2c_add_adapter(adev->dev, control);
26522652
if (res) {
26532653
DRM_ERROR("Failed to register hw i2c, err: %d\n", res);
2654-
goto Out_err;
2654+
return res;
26552655
}
26562656
}
26572657
/* assign the buses used for the FRU EEPROM and RAS EEPROM */
@@ -2660,27 +2660,12 @@ static int sienna_cichlid_i2c_control_init(struct smu_context *smu)
26602660
adev->pm.fru_eeprom_i2c_bus = &adev->pm.smu_i2c[0].adapter;
26612661

26622662
return 0;
2663-
Out_err:
2664-
for ( ; i >= 0; i--) {
2665-
struct amdgpu_smu_i2c_bus *smu_i2c = &adev->pm.smu_i2c[i];
2666-
struct i2c_adapter *control = &smu_i2c->adapter;
2667-
2668-
i2c_del_adapter(control);
2669-
}
2670-
return res;
26712663
}
26722664

26732665
static void sienna_cichlid_i2c_control_fini(struct smu_context *smu)
26742666
{
26752667
struct amdgpu_device *adev = smu->adev;
2676-
int i;
26772668

2678-
for (i = 0; i < MAX_SMU_I2C_BUSES; i++) {
2679-
struct amdgpu_smu_i2c_bus *smu_i2c = &adev->pm.smu_i2c[i];
2680-
struct i2c_adapter *control = &smu_i2c->adapter;
2681-
2682-
i2c_del_adapter(control);
2683-
}
26842669
adev->pm.ras_eeprom_i2c_bus = NULL;
26852670
adev->pm.fru_eeprom_i2c_bus = NULL;
26862671
}

0 commit comments

Comments
 (0)