Skip to content

Commit 0f36a3c

Browse files
rodrigosiqueiraalexdeucher
authored andcommitted
drm/amdgpu/amdgpu_i2c: Use devm_i2c_add_adapter instead of i2c_add_adapter
This commit replaces i2c_add_adapter() with devm_i2c_add_adapter() and removes part of the cleanup logic since the new function handles the i2c removal. Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 5b3eca0 commit 0f36a3c

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ struct amdgpu_i2c_chan *amdgpu_i2c_create(struct drm_device *dev,
184184
snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
185185
"AMDGPU i2c hw bus %s", name);
186186
i2c->adapter.algo = &amdgpu_atombios_i2c_algo;
187-
ret = i2c_add_adapter(&i2c->adapter);
187+
ret = devm_i2c_add_adapter(dev->dev, &i2c->adapter);
188188
if (ret)
189189
goto out_free;
190190
} else {
@@ -215,15 +215,6 @@ struct amdgpu_i2c_chan *amdgpu_i2c_create(struct drm_device *dev,
215215

216216
}
217217

218-
void amdgpu_i2c_destroy(struct amdgpu_i2c_chan *i2c)
219-
{
220-
if (!i2c)
221-
return;
222-
WARN_ON(i2c->has_aux);
223-
i2c_del_adapter(&i2c->adapter);
224-
kfree(i2c);
225-
}
226-
227218
void amdgpu_i2c_init(struct amdgpu_device *adev)
228219
{
229220
if (!adev->is_atom_fw) {
@@ -248,12 +239,9 @@ void amdgpu_i2c_fini(struct amdgpu_device *adev)
248239
{
249240
int i;
250241

251-
for (i = 0; i < AMDGPU_MAX_I2C_BUS; i++) {
252-
if (adev->i2c_bus[i]) {
253-
amdgpu_i2c_destroy(adev->i2c_bus[i]);
242+
for (i = 0; i < AMDGPU_MAX_I2C_BUS; i++)
243+
if (adev->i2c_bus[i])
254244
adev->i2c_bus[i] = NULL;
255-
}
256-
}
257245
}
258246

259247
/* looks up bus based on id */

0 commit comments

Comments
 (0)