diff mbox series

[v6,8/9] drm: Add macro to export functions only when CONFIG_DRM_DEBUG_SELFTEST is enabled

Message ID 20181029171419.4512-9-alexandru-cosmin.gheorghe@arm.com (mailing list archive)
State New, archived
Headers show
Series Add method to describe tile/bit_level_packed formats | expand

Commit Message

Alexandru-Cosmin Gheorghe Oct. 29, 2018, 5:14 p.m. UTC
If we want to be able to write drmselftests for non-static core
functions that are not intended to be used by drivers we need this
functions to be exported.

This adds a macro that is tied of CONFIG_DRM_DEBUG_SELFTEST, and uses
that to export drm_internal_framebuffer_create, in order for
subsequent patches to be able to test it.

Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
---
 drivers/gpu/drm/drm_framebuffer.c | 1 +
 include/drm/drmP.h                | 6 ++++++
 2 files changed, 7 insertions(+)

Comments

Daniel Vetter Oct. 30, 2018, 9:16 a.m. UTC | #1
On Mon, Oct 29, 2018 at 05:14:43PM +0000, Alexandru-Cosmin Gheorghe wrote:
> If we want to be able to write drmselftests for non-static core
> functions that are not intended to be used by drivers we need this
> functions to be exported.
> 
> This adds a macro that is tied of CONFIG_DRM_DEBUG_SELFTEST, and uses
> that to export drm_internal_framebuffer_create, in order for
> subsequent patches to be able to test it.
> 
> Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>

Adding Brendan from kunit, maybe this is something of interest for him
too. I'm not entirely clear how he solves this little problem (or whether
kunit simply builds everything static).

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_framebuffer.c | 1 +
>  include/drm/drmP.h                | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index 167c1c4544af..fcaea8f50513 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -323,6 +323,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
>  
>  	return fb;
>  }
> +EXPORT_SYMBOL_FOR_TESTS_ONLY(drm_internal_framebuffer_create);
>  
>  /**
>   * drm_mode_addfb2 - add an FB to the graphics configuration
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 05350424a4d3..514beb2d483a 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -110,4 +110,10 @@ static inline bool drm_can_sleep(void)
>  	return true;
>  }
>  
> +#if defined(CONFIG_DRM_DEBUG_SELFTEST_MODULE)
> +#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x)
> +#else
> +#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x)
> +#endif
> +
>  #endif
> -- 
> 2.19.1
>
Chris Wilson Nov. 6, 2019, 1:53 p.m. UTC | #2
Quoting Alexandru-Cosmin Gheorghe (2018-10-29 17:14:43)
> If we want to be able to write drmselftests for non-static core
> functions that are not intended to be used by drivers we need this
> functions to be exported.
> 
> This adds a macro that is tied of CONFIG_DRM_DEBUG_SELFTEST, and uses
> that to export drm_internal_framebuffer_create, in order for
> subsequent patches to be able to test it.
> 
> Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
> ---
>  drivers/gpu/drm/drm_framebuffer.c | 1 +
>  include/drm/drmP.h                | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index 167c1c4544af..fcaea8f50513 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -323,6 +323,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
>  
>         return fb;
>  }
> +EXPORT_SYMBOL_FOR_TESTS_ONLY(drm_internal_framebuffer_create);
>  
>  /**
>   * drm_mode_addfb2 - add an FB to the graphics configuration
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 05350424a4d3..514beb2d483a 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -110,4 +110,10 @@ static inline bool drm_can_sleep(void)
>         return true;
>  }
>  
> +#if defined(CONFIG_DRM_DEBUG_SELFTEST_MODULE)
> +#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x)
> +#else
> +#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x)
> +#endif

There's no Kconfig stanza for this symbol.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 167c1c4544af..fcaea8f50513 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -323,6 +323,7 @@  drm_internal_framebuffer_create(struct drm_device *dev,
 
 	return fb;
 }
+EXPORT_SYMBOL_FOR_TESTS_ONLY(drm_internal_framebuffer_create);
 
 /**
  * drm_mode_addfb2 - add an FB to the graphics configuration
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 05350424a4d3..514beb2d483a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -110,4 +110,10 @@  static inline bool drm_can_sleep(void)
 	return true;
 }
 
+#if defined(CONFIG_DRM_DEBUG_SELFTEST_MODULE)
+#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x)
+#else
+#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x)
+#endif
+
 #endif