Skip to content

Commit 439158c

Browse files
rodrigosiqueiraalexdeucher
authored andcommitted
drm/amd/pm: Use devm_i2c_add_adapter() in the Arcturus smu
The I2C init for Arcturus uses i2c_add_adapter() and i2c_del_adapter(), this commit replaces the use of these two functions with devm_i2c_add_adapter(). Notice that Arcturus 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 f4dfc44 commit 439158c

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,38 +1745,23 @@ static int arcturus_i2c_control_init(struct smu_context *smu)
17451745
snprintf(control->name, sizeof(control->name), "AMDGPU SMU %d", i);
17461746
i2c_set_adapdata(control, smu_i2c);
17471747

1748-
res = i2c_add_adapter(control);
1748+
res = devm_i2c_add_adapter(adev->dev, control);
17491749
if (res) {
17501750
DRM_ERROR("Failed to register hw i2c, err: %d\n", res);
1751-
goto Out_err;
1751+
return res;
17521752
}
17531753
}
17541754

17551755
adev->pm.ras_eeprom_i2c_bus = &adev->pm.smu_i2c[0].adapter;
17561756
adev->pm.fru_eeprom_i2c_bus = &adev->pm.smu_i2c[1].adapter;
17571757

17581758
return 0;
1759-
Out_err:
1760-
for ( ; i >= 0; i--) {
1761-
struct amdgpu_smu_i2c_bus *smu_i2c = &adev->pm.smu_i2c[i];
1762-
struct i2c_adapter *control = &smu_i2c->adapter;
1763-
1764-
i2c_del_adapter(control);
1765-
}
1766-
return res;
17671759
}
17681760

17691761
static void arcturus_i2c_control_fini(struct smu_context *smu)
17701762
{
17711763
struct amdgpu_device *adev = smu->adev;
1772-
int i;
17731764

1774-
for (i = 0; i < MAX_SMU_I2C_BUSES; i++) {
1775-
struct amdgpu_smu_i2c_bus *smu_i2c = &adev->pm.smu_i2c[i];
1776-
struct i2c_adapter *control = &smu_i2c->adapter;
1777-
1778-
i2c_del_adapter(control);
1779-
}
17801765
adev->pm.ras_eeprom_i2c_bus = NULL;
17811766
adev->pm.fru_eeprom_i2c_bus = NULL;
17821767
}

0 commit comments

Comments
 (0)