* [PATCH 4/5] drm: Add a drm_drv_enabled() helper function
@ 2021-11-03 10:54 Javier Martinez Canillas
0 siblings, 0 replies; only message in thread
From: Javier Martinez Canillas @ 2021-11-03 10:54 UTC (permalink / raw)
To: linux-kernel
Cc: Pekka Paalanen, Thomas Zimmermann, Peter Robinson, Daniel Vetter,
Neal Gompa, Michel Dänzer, Javier Martinez Canillas
DRM drivers can use this to determine whether they can be enabled or not.
For now it's just a wrapper around drm_modeset_disabled() but having the
indirection level will allow to add other conditions besides "nomodeset".
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
include/drm/drm_drv.h | 1 +
2 files changed, 22 insertions(+)
diff --git drivers/gpu/drm/drm_drv.c drivers/gpu/drm/drm_drv.c
index 8214a0b1ab7f..70ef08941e06 100644
--- drivers/gpu/drm/drm_drv.c
+++ drivers/gpu/drm/drm_drv.c
@@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)
}
EXPORT_SYMBOL(drm_dev_set_unique);
+/**
+ * drm_drv_enabled - Checks if a DRM driver can be enabled
+ * @driver: DRM driver to check
+ *
+ * Checks whether a DRM driver can be enabled or not. This may be the case
+ * if the "nomodeset" kernel command line parameter is used.
+ *
+ * Returns:
+ * True if the DRM driver is enabled and false otherwise.
+ */
+bool drm_drv_enabled(const struct drm_driver *driver)
+{
+ if (drm_modeset_disabled()) {
+ DRM_INFO("%s driver is disabled\n", driver->name);
+ return false;
+ }
+
+ return true;
+}
+EXPORT_SYMBOL(drm_drv_enabled);
+
/*
* DRM Core
* The DRM core module initializes all global DRM objects and makes them
diff --git include/drm/drm_drv.h include/drm/drm_drv.h
index 0cd95953cdf5..48f2b6eec012 100644
--- include/drm/drm_drv.h
+++ include/drm/drm_drv.h
@@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
int drm_dev_set_unique(struct drm_device *dev, const char *name);
+bool drm_drv_enabled(const struct drm_driver *driver);
#endif
--
2.33.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-03 10:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 10:54 [PATCH 4/5] drm: Add a drm_drv_enabled() helper function Javier Martinez Canillas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®