All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Siddh Raman Pant <code@siddh.me>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 04/10] drm/print: Fix support for NULL as first argument of drm_dbg_*
Date: Wed, 21 Dec 2022 11:41:07 +0200	[thread overview]
Message-ID: <87edst2ix8.fsf@intel.com> (raw)
In-Reply-To: <3ebf0d61ad5e82875a4493108602e62429306b14.1671566741.git.code@siddh.me>

On Wed, 21 Dec 2022, Siddh Raman Pant <code@siddh.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@siddh.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

  parent reply	other threads:[~2022-12-21  9:41 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 20:16 [PATCH 00/10] drm: Remove usage of deprecated DRM_* macros Siddh Raman Pant
2022-12-20 20:16 ` Siddh Raman Pant
2022-12-20 20:16 ` [PATCH 01/10] drm: Remove usage of deprecated DRM_INFO Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-21  9:49   ` Jani Nikula
2022-12-21 10:02     ` Thomas Zimmermann
2022-12-20 20:16 ` [PATCH 02/10] drm: Remove usage of deprecated DRM_NOTE Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-20 20:16 ` [PATCH 03/10] drm: Remove usage of deprecated DRM_ERROR Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-20 20:16 ` [PATCH 04/10] drm/print: Fix support for NULL as first argument of drm_dbg_* Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-21  9:08   ` Thomas Zimmermann
2022-12-21  9:08     ` Thomas Zimmermann
2022-12-21 15:38     ` Siddh Raman Pant
2022-12-21 15:38       ` Siddh Raman Pant
2022-12-21  9:41   ` Jani Nikula [this message]
2022-12-21 15:35     ` Siddh Raman Pant
2022-12-21 15:35       ` Siddh Raman Pant
2022-12-20 20:16 ` [PATCH 05/10] drm: Remove usage of deprecated DRM_DEBUG Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-21  5:53   ` kernel test robot
2022-12-21  5:53     ` kernel test robot
2022-12-21 12:06   ` kernel test robot
2022-12-21 12:06     ` kernel test robot
2022-12-20 20:16 ` [PATCH 06/10] drm: Remove usage of deprecated DRM_DEBUG_DRIVER Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-21 10:00   ` Jani Nikula
2022-12-21 10:00     ` Jani Nikula
2022-12-21 10:13     ` Thomas Zimmermann
2022-12-23 17:54       ` jim.cromie
2022-12-23 17:54         ` jim.cromie
2022-12-20 20:16 ` [PATCH 07/10] drm: Remove usage of deprecated DRM_DEBUG_KMS Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-21 11:56   ` kernel test robot
2022-12-21 11:56     ` kernel test robot
2022-12-20 20:16 ` [PATCH 08/10] drm: Remove usage of deprecated DRM_DEBUG_PRIME Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-20 20:16 ` [PATCH 09/10] drm/drm_blend: Remove usage of deprecated DRM_DEBUG_ATOMIC Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-22  9:46   ` Simon Ser
2022-12-22  9:46     ` Simon Ser
2022-12-20 20:16 ` [PATCH 10/10] drm/drm_lease: Remove usage of deprecated DRM_DEBUG_LEASE Siddh Raman Pant
2022-12-20 20:16   ` Siddh Raman Pant
2022-12-21 10:53   ` Simon Ser
2022-12-21 10:53     ` Simon Ser
2022-12-21  9:16 ` [PATCH 00/10] drm: Remove usage of deprecated DRM_* macros Thomas Zimmermann
2022-12-21  9:16   ` Thomas Zimmermann
2022-12-21 10:01   ` Jani Nikula
2022-12-21 15:57   ` Siddh Raman Pant
2022-12-21 15:57     ` Siddh Raman Pant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edst2ix8.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=code@siddh.me \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.