When discussing the load/unload issue in amdgpu and its fix [1], Robert Beckett suggested the use of devm_i2c_add_adapter(). This function is part of Devres [2], and it simplifies resource management when the driver is detached. Aside from reducing boilerplate, it also reduces maintenance effort and minimizes the likelihood of future load/unload issues associated with i2c.
With this idea in mind, this series replaces all the i2c_add_adapter() and i2c_del_adapter() with devm_i2c_add_adapter() in amdgpu. The first patch is focused on DM, the second patch focuses on the generic amdgpu_i2c, and all the other patches are part of the SMU (they share a similar code). [1] - https://gitlab.freedesktop.org/agd5f/linux/-/commit/89923fb7ead4fdd37b78dd49962d9bb5892403e6 [2] - https://docs.kernel.org/driver-api/driver-model/devres.html Thanks Rodrigo Siqueira (10): drm/amd/display: Use devm_i2c_add_adapter to simplify i2c cleanup logic drm/amdgpu/amdgpu_i2c: Use devm_i2c_add_adapter instead of i2c_add_adapter drm/amdgpu: Use devm_i2c_add_adapter() in SMU V11 drm/amd/pm: Use devm_i2c_add_adapter() in the i2c init drm/amd/pm: Use devm_i2c_add_adapter() in the Arcturus smu drm/amd/pm: Use devm_i2c_add_adapter() in the Navi10 smu drm/amd/pm: Use devm_i2c_add_adapter() in the Sienna smu drm/amd/pm: Use devm_i2c_add_adapter() in the V13 smu drm/amd/pm: Use devm_i2c_add_adapter() in the V13_0_6 smu drm/amd/pm: Use devm_i2c_add_adapter() in the V14_0_2 smu drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 18 +++------------- drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c | 5 +---- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 ++----------------- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 19 ++--------------- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 19 ++--------------- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 19 ++--------------- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 15 ++----------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 19 ++--------------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 19 ++--------------- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 19 ++--------------- 10 files changed, 20 insertions(+), 153 deletions(-) -- 2.50.1
