Skip to content

Commit 9d96b91

Browse files
tdzgregkh
authored andcommitted
drm/mgag200: Bind I2C lifetime to DRM device
commit eb1ae34 upstream. Managed cleanup with devm_add_action_or_reset() will release the I2C adapter when the underlying Linux device goes away. But the connector still refers to it, so this cleanup leaves behind a stale pointer in struct drm_connector.ddc. Bind the lifetime of the I2C adapter to the connector's lifetime by using DRM's managed release. When the DRM device goes away (after the Linux device) DRM will first clean up the connector and then clean up the I2C adapter. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Fixes: b279df2 ("drm/mgag200: Switch I2C code to managed cleanup") Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Jocelyn Falempe <jfalempe@redhat.com> Cc: Dave Airlie <airlied@redhat.com> Cc: dri-devel@lists.freedesktop.org Cc: <stable@vger.kernel.org> # v6.0+ Link: https://patchwork.freedesktop.org/patch/msgid/20240513125620.6337-3-tzimmermann@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 667f01b commit 9d96b91

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/gpu/drm/mgag200/mgag200_i2c.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <linux/i2c.h>
3232
#include <linux/pci.h>
3333

34+
#include <drm/drm_managed.h>
35+
3436
#include "mgag200_drv.h"
3537

3638
static int mga_i2c_read_gpio(struct mga_device *mdev)
@@ -86,7 +88,7 @@ static int mga_gpio_getscl(void *data)
8688
return (mga_i2c_read_gpio(mdev) & i2c->clock) ? 1 : 0;
8789
}
8890

89-
static void mgag200_i2c_release(void *res)
91+
static void mgag200_i2c_release(struct drm_device *dev, void *res)
9092
{
9193
struct mga_i2c_chan *i2c = res;
9294

@@ -125,5 +127,5 @@ int mgag200_i2c_init(struct mga_device *mdev, struct mga_i2c_chan *i2c)
125127
if (ret)
126128
return ret;
127129

128-
return devm_add_action_or_reset(dev->dev, mgag200_i2c_release, i2c);
130+
return drmm_add_action_or_reset(dev, mgag200_i2c_release, i2c);
129131
}

0 commit comments

Comments
 (0)