mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alessio Belle <alessio.belle@imgtec.com>
To: Luigi Santivetti <luigi.santivetti@imgtec.com>,
	Brajesh Gupta <brajesh.gupta@imgtec.com>,
	Alexandru Dadu <alexandru.dadu@imgtec.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: <linux-kernel@vger.kernel.org>,
	<imagination@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>,
	Alessio Belle <alessio.belle@imgtec.com>
Subject: [PATCH 1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h
Date: Wed, 29 Jul 2026 15:57:06 +0100	[thread overview]
Message-ID: <20260729-fwif-checks-updates-v1-1-af65e9606a7e@imgtec.com> (raw)
In-Reply-To: <20260729-fwif-checks-updates-v1-0-af65e9606a7e@imgtec.com>

From: Alexandru Dadu <alexandru.dadu@imgtec.com>

The same macros are redefined in three places, so move them to a common
file to reduce duplication and make it easier to reuse them.

Signed-off-by: Alexandru Dadu <alexandru.dadu@imgtec.com>
Co-developed-by: Alessio Belle <alessio.belle@imgtec.com>
Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
---
 drivers/gpu/drm/imagination/pvr_check.h            | 36 ++++++++++++++++++++++
 drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h | 26 +---------------
 .../drm/imagination/pvr_rogue_fwif_client_check.h  |  9 +-----
 .../drm/imagination/pvr_rogue_fwif_shared_check.h  |  9 +-----
 4 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_check.h b/drivers/gpu/drm/imagination/pvr_check.h
new file mode 100644
index 000000000000..94764ce9bbd1
--- /dev/null
+++ b/drivers/gpu/drm/imagination/pvr_check.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
+/* Copyright (c) 2026 Imagination Technologies Ltd. */
+
+#ifndef PVR_CHECK_H
+#define PVR_CHECK_H
+
+#include <linux/build_bug.h>
+#include <linux/overflow.h>
+#include <linux/stddef.h>
+
+#define OFFSET_CHECK(type, member, offset) \
+	static_assert(offsetof(type, member) == (offset), \
+	"offsetof(" #type ", " #member ") incorrect")
+
+#define SIZE_CHECK(type, size) \
+	static_assert(sizeof(type) == (size), #type " is incorrect size")
+
+#define ALIGN_CHECK(type, align) \
+	static_assert(__alignof__(type) <= (align), #type " has incorrect alignment")
+
+/*
+ * Where the last member of a struct is a flexible array member, using
+ * SIZE_CHECK() is pointless. If the structure is not already padded to
+ * alignment without the flexible array member, sizeof() will not match the
+ * offset of the flexible array member and the "correct" sizeof() value is
+ * completely meaningless.
+ *
+ * In those instances, use FLEX_ARRAY_CHECK() instead to assert that the final
+ * field is a flexible array member and that it behaves as expected.
+ */
+#define FLEX_ARRAY_CHECK(type, member)                               \
+	static_assert(flex_array_size((type *)NULL, member, 1) ==    \
+				      sizeof_field(type, member[0]), \
+		      #type "->" #member " is incorrect size")
+
+#endif /* PVR_CHECK_H */
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
index e72f4064af18..5048866359b9 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
@@ -4,31 +4,7 @@
 #ifndef PVR_ROGUE_FWIF_CHECK_H
 #define PVR_ROGUE_FWIF_CHECK_H
 
-#include <linux/build_bug.h>
-#include <linux/overflow.h>
-#include <linux/stddef.h>
-
-#define OFFSET_CHECK(type, member, offset) \
-	static_assert(offsetof(type, member) == (offset), \
-		      "offsetof(" #type ", " #member ") incorrect")
-
-#define SIZE_CHECK(type, size) \
-	static_assert(sizeof(type) == (size), #type " is incorrect size")
-
-/*
- * Where the last member of a struct is a flexible array member, using
- * SIZE_CHECK() is pointless. If the structure is not already padded to
- * alignment without the flexible array member, sizeof() will not match the
- * offset of the flexible array member and the "correct" sizeof() value is
- * completely meaningless.
- *
- * In those instances, use FLEX_ARRAY_CHECK() instead to assert that the final
- * field is a flexible array member and that it behaves as expected.
- */
-#define FLEX_ARRAY_CHECK(type, member)                            \
-	static_assert(flex_array_size((type *)NULL, member, 1) == \
-			      sizeof_field(type, member[0]),      \
-		      #type "->" #member " is incorrect size")
+#include "pvr_check.h"
 
 OFFSET_CHECK(struct rogue_fwif_file_info_buf, path, 0);
 OFFSET_CHECK(struct rogue_fwif_file_info_buf, info, 200);
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h
index 54aa4474163e..467d1d2073a1 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h
@@ -4,14 +4,7 @@
 #ifndef PVR_ROGUE_FWIF_CLIENT_CHECK_H
 #define PVR_ROGUE_FWIF_CLIENT_CHECK_H
 
-#include <linux/build_bug.h>
-
-#define OFFSET_CHECK(type, member, offset) \
-	static_assert(offsetof(type, member) == (offset), \
-		      "offsetof(" #type ", " #member ") incorrect")
-
-#define SIZE_CHECK(type, size) \
-	static_assert(sizeof(type) == (size), #type " is incorrect size")
+#include "pvr_check.h"
 
 OFFSET_CHECK(struct rogue_fwif_geom_regs, vdm_ctrl_stream_base, 0);
 OFFSET_CHECK(struct rogue_fwif_geom_regs, tpu_border_colour_table, 8);
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h
index 597ed54bbd3a..59ef0a9aa395 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h
@@ -4,14 +4,7 @@
 #ifndef PVR_ROGUE_FWIF_SHARED_CHECK_H
 #define PVR_ROGUE_FWIF_SHARED_CHECK_H
 
-#include <linux/build_bug.h>
-
-#define OFFSET_CHECK(type, member, offset) \
-	static_assert(offsetof(type, member) == (offset), \
-		      "offsetof(" #type ", " #member ") incorrect")
-
-#define SIZE_CHECK(type, size) \
-	static_assert(sizeof(type) == (size), #type " is incorrect size")
+#include "pvr_check.h"
 
 OFFSET_CHECK(struct rogue_fwif_dma_addr, dev_addr, 0);
 OFFSET_CHECK(struct rogue_fwif_dma_addr, fw_addr, 8);

-- 
2.43.0


  reply	other threads:[~2026-07-29 15:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 14:57 [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Alessio Belle
2026-07-29 14:57 ` Alessio Belle [this message]
2026-07-29 14:57 ` [PATCH 2/2] drm/imagination: Reuse layout check macros for MIPS FW structures Alessio Belle
2026-08-03  6:41 ` [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Brajesh Gupta
2026-08-03 10:29 ` Alessio Belle

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=20260729-fwif-checks-updates-v1-1-af65e9606a7e@imgtec.com \
    --to=alessio.belle@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=alexandru.dadu@imgtec.com \
    --cc=brajesh.gupta@imgtec.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imagination@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luigi.santivetti@imgtec.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --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

all inboxes | Powered by JetHome®