linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javierm@redhat.com>
To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: Javier Martinez Canillas <javierm@redhat.com>,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 01/37] drm: Add drm_module_{pci,platform}_driver() helper macros
Date: Fri, 17 Dec 2021 01:37:16 +0100	[thread overview]
Message-ID: <20211217003752.3946210-2-javierm@redhat.com> (raw)
In-Reply-To: <20211217003752.3946210-1-javierm@redhat.com>

According to disable Documentation/admin-guide/kernel-parameters.txt, the
nomodeset parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, so let's add two
helper macros that can be used by DRM drivers for PCI and platform devices
to have module init functions that checks if the drivers could be loaded.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

(no changes since v1)

 include/drm/drm_drv.h | 50 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index f6159acb8856..4001d73428c5 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -29,6 +29,8 @@
 
 #include <linux/list.h>
 #include <linux/irqreturn.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
 
 #include <drm/drm_device.h>
 
@@ -604,4 +606,52 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name);
 
 extern bool drm_firmware_drivers_only(void);
 
+/**
+ * drm_pci_register_driver() - register a DRM driver for PCI devices
+ * @drv: PCI driver structure
+ *
+ * Returns zero on success or a negative errno code on failure.
+ */
+static inline int drm_pci_register_driver(struct pci_driver *drv)
+{
+	if (drm_firmware_drivers_only())
+		return -ENODEV;
+
+	return pci_register_driver(drv);
+}
+
+/**
+ * drm_module_pci_driver() - helper macro for registering a DRM PCI driver
+ *
+ * Helper macro for DRM PCI drivers which do not do anything special in their
+ * module init/exit and just need the DRM specific module init.
+ */
+#define drm_module_pci_driver(__pci_driver) \
+	module_driver(__pci_driver, drm_pci_register_driver, \
+		      pci_unregister_driver)
+
+/**
+ * drm_platform_driver_register - register a DRM driver for platform devices
+ * @drv: platform driver structure
+ *
+ * Returns zero on success or a negative errno code on failure.
+ */
+static inline int drm_platform_driver_register(struct platform_driver *drv)
+{
+	if (drm_firmware_drivers_only())
+		return -ENODEV;
+
+	return platform_driver_register(drv);
+}
+
+/**
+ * drm_module_platform_driver() - helper macro for registering a DRM platform driver
+ *
+ * Helper macro for DRM platform drivers which do not do anything special in their
+ * module init/exit and just need the DRM specific module init.
+ */
+#define drm_module_platform_driver(__platform_driver) \
+	module_driver(__platform_driver, drm_platform_driver_register, \
+		      platform_driver_unregister)
+
 #endif
-- 
2.33.1


  reply	other threads:[~2021-12-17  0:38 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17  0:37 [PATCH v2 00/37] drm: Make drivers to honour the nomodeset parameter Javier Martinez Canillas
2021-12-17  0:37 ` Javier Martinez Canillas [this message]
2021-12-17 14:31   ` [PATCH v2 01/37] drm: Add drm_module_{pci,platform}_driver() helper macros Thomas Zimmermann
2021-12-17  0:37 ` [PATCH v2 02/37] drm/hisilicon/hibmc: Use drm_module_pci_driver() to register the driver Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 03/37] drm/komeda: Use drm_module_platform_driver() " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 04/37] drm/arm/hdlcd: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 05/37] drm/malidp: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 06/37] drm/aspeed: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 07/37] drm/atmel-hlcdc: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 08/37] drm/fsl-dcu: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 09/37] drm/hisilicon/kirin: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 10/37] drm/imx/dcss: " Javier Martinez Canillas
2021-12-17 15:58   ` kernel test robot
2021-12-17  0:37 ` [PATCH v2 11/37] drm/kmb: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 12/37] drm/meson: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 13/37] drm: mxsfb: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 14/37] drm/shmobile: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 15/37] drm/stm: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 16/37] drm/sun4i: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 17/37] drm/tidss: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 18/37] drm/arc: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 19/37] drm/tve200: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 20/37] drm/xlnx: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 21/37] drm/armada: Add support for the nomodeset kernel parameter Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 22/37] drm/exynos: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 23/37] drm/gma500: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 24/37] drm/hyperv: " Javier Martinez Canillas
2021-12-20 17:10   ` Deepak Rawat
2021-12-17  0:37 ` [PATCH v2 25/37] drm/imx: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 26/37] drm/ingenic: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 27/37] drm/mcde: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 28/37] drm/mediatek: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 29/37] drm/msm: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 30/37] drm/omap: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 31/37] drm: rcar-du: " Javier Martinez Canillas
2022-01-28  9:13   ` Kieran Bingham
2022-01-28  9:33     ` Thomas Zimmermann
2022-01-28 10:34       ` Laurent Pinchart
2022-01-28 10:46         ` Thomas Zimmermann
2022-01-28 11:04           ` Laurent Pinchart
2022-01-28 11:26             ` Thomas Zimmermann
2022-01-28 11:36               ` Laurent Pinchart
2022-01-28 11:53                 ` Thomas Zimmermann
2022-01-28 11:09           ` Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 32/37] drm/rockchip: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 33/37] drm/sprd: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 34/37] drm/sti: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 35/37] drm/tegra: " Javier Martinez Canillas
2021-12-17  0:37 ` [PATCH v2 36/37] drm/tilcdc: " Javier Martinez Canillas
2021-12-17 13:30   ` Jyri Sarha
2021-12-17  0:37 ` [PATCH v2 37/37] drm/xen: " Javier Martinez Canillas
2022-01-27 18:29 ` [PATCH v2 00/37] drm: Make drivers to honour the nomodeset parameter Javier Martinez Canillas

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=20211217003752.3946210-2-javierm@redhat.com \
    --to=javierm@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).