[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z2BZrpx9Bhr6q1C8@louis-chauvet-laptop>
Date: Mon, 16 Dec 2024 17:47:42 +0100
From: Louis Chauvet <louis.chauvet@...tlin.com>
To: Luca Ceresoli <luca.ceresoli@...tlin.com>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND v3 3/4] drm/mode_object: add
drm_mode_object_read_refcount()
On 16/12/24 - 17:40, Luca Ceresoli wrote:
> Add a wrapper to kref_read() just like the ones already in place for
> kref_get() and kref_put(). This will be used for sanity checks on object
> lifetime.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@...tlin.com>
Acked-by: Louis Chauvet <louis.chauvet@...tlin.com>
Thanks,
Louis Chauvet
> ---
>
> Changed in v3:
>
> * use conventions for 'Returns' doc syntax
> * ditch DRM_DEBUG() and as a consequence rework and simplify the entire
> function
> * fix function name in kerneldoc
> ---
> drivers/gpu/drm/drm_mode_object.c | 17 +++++++++++++++++
> include/drm/drm_mode_object.h | 1 +
> 2 files changed, 18 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
> index df4cc0e8e263d5887a799cf1a61d998234be7158..b9a16aceb926782eb033434eb6967ce9fd2e94f7 100644
> --- a/drivers/gpu/drm/drm_mode_object.c
> +++ b/drivers/gpu/drm/drm_mode_object.c
> @@ -217,6 +217,23 @@ void drm_mode_object_get(struct drm_mode_object *obj)
> }
> EXPORT_SYMBOL(drm_mode_object_get);
>
> +/**
> + * drm_mode_object_read_refcount - read the refcount for a mode object
> + * @obj: DRM mode object
> + *
> + * Returns:
> + * The current object refcount if it is a refcounted modeset object, or 0
> + * for any other object.
> + */
> +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj)
> +{
> + if (obj->free_cb)
> + return kref_read(&obj->refcount);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_object_read_refcount);
> +
> /**
> * drm_object_attach_property - attach a property to a modeset object
> * @obj: drm modeset object
> diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
> index c68edbd126d04d51221f50aa2b4166475543b59f..3d2c739e703888bf4520c61594d480f128d50e56 100644
> --- a/include/drm/drm_mode_object.h
> +++ b/include/drm/drm_mode_object.h
> @@ -123,6 +123,7 @@ struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
> uint32_t id, uint32_t type);
> void drm_mode_object_get(struct drm_mode_object *obj);
> void drm_mode_object_put(struct drm_mode_object *obj);
> +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj);
>
> int drm_object_property_set_value(struct drm_mode_object *obj,
> struct drm_property *property,
>
> --
> 2.34.1
>
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists