diff --git a/drivers/gpu/drm/sysfb/drm_sysfb.c b/drivers/gpu/drm/sysfb/drm_sysfb.c
index c083d21fd9cab..97547ea5e2131 100644
--- a/drivers/gpu/drm/sysfb/drm_sysfb.c
+++ b/drivers/gpu/drm/sysfb/drm_sysfb.c
@@ -1,8 +1,35 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include <linux/export.h>
+#include <linux/limits.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 
+#include <drm/drm_print.h>
+
 #include "drm_sysfb_helper.h"
 
 MODULE_DESCRIPTION("Helpers for DRM sysfb drivers");
 MODULE_LICENSE("GPL");
+
+int drm_sysfb_get_validated_int(struct drm_device *dev, const char *name,
+				u64 value, u32 max)
+{
+	if (value > min(max, INT_MAX)) {
+		drm_warn(dev, "%s of %llu exceeds maximum of %u\n", name, value, max);
+		return -EINVAL;
+	}
+	return value;
+}
+EXPORT_SYMBOL(drm_sysfb_get_validated_int);
+
+int drm_sysfb_get_validated_int0(struct drm_device *dev, const char *name,
+				 u64 value, u32 max)
+{
+	if (!value) {
+		drm_warn(dev, "%s of 0 not allowed\n", name);
+		return -EINVAL;
+	}
+	return drm_sysfb_get_validated_int(dev, name, value, max);
+}
+EXPORT_SYMBOL(drm_sysfb_get_validated_int0);
diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h
index ee94d6199b601..1697cf7ace973 100644
--- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h
+++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h
@@ -13,6 +13,15 @@
 struct drm_format_info;
 struct drm_scanout_buffer;
 
+/*
+ * Input parsing
+ */
+
+int drm_sysfb_get_validated_int(struct drm_device *dev, const char *name,
+				u64 value, u32 max);
+int drm_sysfb_get_validated_int0(struct drm_device *dev, const char *name,
+				 u64 value, u32 max);
+
 /*
  * Display modes
  */
diff --git a/drivers/gpu/drm/sysfb/efidrm.c b/drivers/gpu/drm/sysfb/efidrm.c
index af90064a4c04f..a77ea5285cc1d 100644
--- a/drivers/gpu/drm/sysfb/efidrm.c
+++ b/drivers/gpu/drm/sysfb/efidrm.c
@@ -33,28 +33,6 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
-static int efidrm_get_validated_int(struct drm_device *dev, const char *name,
-				    u64 value, u32 max)
-{
-	if (max > INT_MAX)
-		max = INT_MAX;
-	if (value > max) {
-		drm_err(dev, "%s of %llu exceeds maximum of %u\n", name, value, max);
-		return -EINVAL;
-	}
-	return value;
-}
-
-static int efidrm_get_validated_int0(struct drm_device *dev, const char *name,
-				     u64 value, u32 max)
-{
-	if (!value) {
-		drm_err(dev, "%s of 0 not allowed\n", name);
-		return -EINVAL;
-	}
-	return efidrm_get_validated_int(dev, name, value, max);
-}
-
 static s64 efidrm_get_validated_size0(struct drm_device *dev, const char *name,
 				      u64 value, u64 max)
 {
@@ -70,12 +48,12 @@ static s64 efidrm_get_validated_size0(struct drm_device *dev, const char *name,
 
 static int efidrm_get_width_si(struct drm_device *dev, const struct screen_info *si)
 {
-	return efidrm_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
+	return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
 }
 
 static int efidrm_get_height_si(struct drm_device *dev, const struct screen_info *si)
 {
-	return efidrm_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
+	return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
 }
 
 static struct resource *efidrm_get_memory_si(struct drm_device *dev,
@@ -102,7 +80,8 @@ static int efidrm_get_stride_si(struct drm_device *dev, const struct screen_info
 	if (!lfb_linelength)
 		lfb_linelength = drm_format_info_min_pitch(format, 0, width);
 
-	return efidrm_get_validated_int0(dev, "stride", lfb_linelength, div64_u64(size, height));
+	return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength,
+					    div64_u64(size, height));
 }
 
 static u64 efidrm_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c
index 86c1a0c80ceb3..fddfe8bea9f7f 100644
--- a/drivers/gpu/drm/sysfb/ofdrm.c
+++ b/drivers/gpu/drm/sysfb/ofdrm.c
@@ -78,20 +78,12 @@ enum ofdrm_model {
 
 static int display_get_validated_int(struct drm_device *dev, const char *name, uint32_t value)
 {
-	if (value > INT_MAX) {
-		drm_err(dev, "invalid framebuffer %s of %u\n", name, value);
-		return -EINVAL;
-	}
-	return (int)value;
+	return drm_sysfb_get_validated_int(dev, name, value, INT_MAX);
 }
 
 static int display_get_validated_int0(struct drm_device *dev, const char *name, uint32_t value)
 {
-	if (!value) {
-		drm_err(dev, "invalid framebuffer %s of %u\n", name, value);
-		return -EINVAL;
-	}
-	return display_get_validated_int(dev, name, value);
+	return drm_sysfb_get_validated_int0(dev, name, value, INT_MAX);
 }
 
 static const struct drm_format_info *display_get_validated_format(struct drm_device *dev,
diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c
index f37b1994de71f..a1c3119330def 100644
--- a/drivers/gpu/drm/sysfb/simpledrm.c
+++ b/drivers/gpu/drm/sysfb/simpledrm.c
@@ -42,24 +42,14 @@ static int
 simplefb_get_validated_int(struct drm_device *dev, const char *name,
 			   uint32_t value)
 {
-	if (value > INT_MAX) {
-		drm_err(dev, "simplefb: invalid framebuffer %s of %u\n",
-			name, value);
-		return -EINVAL;
-	}
-	return (int)value;
+	return drm_sysfb_get_validated_int(dev, name, value, INT_MAX);
 }
 
 static int
 simplefb_get_validated_int0(struct drm_device *dev, const char *name,
 			    uint32_t value)
 {
-	if (!value) {
-		drm_err(dev, "simplefb: invalid framebuffer %s of %u\n",
-			name, value);
-		return -EINVAL;
-	}
-	return simplefb_get_validated_int(dev, name, value);
+	return drm_sysfb_get_validated_int0(dev, name, value, INT_MAX);
 }
 
 static const struct drm_format_info *
diff --git a/drivers/gpu/drm/sysfb/vesadrm.c b/drivers/gpu/drm/sysfb/vesadrm.c
index 9cc50e3072ead..d87ff77be20de 100644
--- a/drivers/gpu/drm/sysfb/vesadrm.c
+++ b/drivers/gpu/drm/sysfb/vesadrm.c
@@ -36,28 +36,6 @@
 
 #define VESADRM_GAMMA_LUT_SIZE 256
 
-static int vesadrm_get_validated_int(struct drm_device *dev, const char *name,
-				     u64 value, u32 max)
-{
-	if (max > INT_MAX)
-		max = INT_MAX;
-	if (value > max) {
-		drm_err(dev, "%s of %llu exceeds maximum of %u\n", name, value, max);
-		return -EINVAL;
-	}
-	return value;
-}
-
-static int vesadrm_get_validated_int0(struct drm_device *dev, const char *name,
-				      u64 value, u32 max)
-{
-	if (!value) {
-		drm_err(dev, "%s of 0 not allowed\n", name);
-		return -EINVAL;
-	}
-	return vesadrm_get_validated_int(dev, name, value, max);
-}
-
 static s64 vesadrm_get_validated_size0(struct drm_device *dev, const char *name,
 				       u64 value, u64 max)
 {
@@ -73,12 +51,12 @@ static s64 vesadrm_get_validated_size0(struct drm_device *dev, const char *name,
 
 static int vesadrm_get_width_si(struct drm_device *dev, const struct screen_info *si)
 {
-	return vesadrm_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
+	return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
 }
 
 static int vesadrm_get_height_si(struct drm_device *dev, const struct screen_info *si)
 {
-	return vesadrm_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
+	return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
 }
 
 static struct resource *vesadrm_get_memory_si(struct drm_device *dev,
@@ -105,7 +83,8 @@ static int vesadrm_get_stride_si(struct drm_device *dev, const struct screen_inf
 	if (!lfb_linelength)
 		lfb_linelength = drm_format_info_min_pitch(format, 0, width);
 
-	return vesadrm_get_validated_int0(dev, "stride", lfb_linelength, div64_u64(size, height));
+	return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength,
+					    div64_u64(size, height));
 }
 
 static u64 vesadrm_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
