[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87edst2ix8.fsf@intel.com>
Date: Wed, 21 Dec 2022 11:41:07 +0200
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Siddh Raman Pant <code@...dh.me>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
dri-devel <dri-devel@...ts.freedesktop.org>
Subject: Re: [PATCH 04/10] drm/print: Fix support for NULL as first argument
of drm_dbg_*
On Wed, 21 Dec 2022, Siddh Raman Pant <code@...dh.me> wrote:
> Comments say macros DRM_DEBUG_* are deprecated in favor of
> drm_dbg_*(NULL, ...), but they have broken support for it,
> as the macro will result in `(NULL) ? (NULL)->dev : NULL`.
What's wrong with that?
>
> Thus, fix them by casting input drm to a temporary struct ptr,
> with the same convention as in __DRM_DEFINE_DBG_RATELIMITED.
>
> Signed-off-by: Siddh Raman Pant <code@...dh.me>
> ---
> include/drm/drm_print.h | 89 ++++++++++++++++++++++++++++++++---------
> 1 file changed, 69 insertions(+), 20 deletions(-)
>
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index a44fb7ef257f..53702d830291 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -486,26 +486,75 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
> __drm_printk((drm), err, _ratelimited, "*ERROR* " fmt, ##__VA_ARGS__)
>
>
> -#define drm_dbg_core(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__)
> -#define drm_dbg_driver(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
> -#define drm_dbg_kms(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__)
> -#define drm_dbg_prime(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
> -#define drm_dbg_atomic(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
> -#define drm_dbg_vbl(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__)
> -#define drm_dbg_state(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__)
> -#define drm_dbg_lease(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
> -#define drm_dbg_dp(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__)
> -#define drm_dbg_drmres(drm, fmt, ...) \
> - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
> +#define drm_dbg_core(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_CORE, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_driver(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_DRIVER, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_kms(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_KMS, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_prime(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_PRIME, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_atomic(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_ATOMIC, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_vbl(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_VBL, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_state(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_STATE, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_lease(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_LEASE, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_dp(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_DP, \
> + fmt, ##__VA_ARGS__); \
> +})
> +
> +#define drm_dbg_drmres(drm, fmt, ...) \
> +({ \
> + const struct drm_device *drm_ = (drm); \
> + drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_DRMRES, \
> + fmt, ##__VA_ARGS__); \
> +})
>
> #define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARGS__)
--
Jani Nikula, Intel Open Source Graphics Center
Powered by blists - more mailing lists