]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/edid: Use unsigned int in drm_add_modes_noedid()
authorLyude Paul <lyude@redhat.com>
Mon, 31 Mar 2025 22:23:54 +0000 (18:23 -0400)
committerLyude Paul <lyude@redhat.com>
Wed, 2 Apr 2025 21:19:54 +0000 (17:19 -0400)
A negative resolution doesn't really make any sense, so let's make these
parameters unsigned. In C this doesn't make much of a difference, but Rust
is stricter about signed/unsigned casts and additionally can check for
arithmetic over/underflows if CONFIG_RUST_OVERFLOW_CHECKS is enabled.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20250331222556.454334-2-lyude@redhat.com
drivers/gpu/drm/drm_edid.c
include/drm/drm_edid.h

index 13bc4c290b17d556d654b7cdd8c48c24a32aba9c..1e69326283dceb8c4ed84f604e1fbe65402098ee 100644 (file)
@@ -7099,18 +7099,12 @@ EXPORT_SYMBOL(drm_add_edid_modes);
  * Return: The number of modes added or 0 if we couldn't find any.
  */
 int drm_add_modes_noedid(struct drm_connector *connector,
-                       int hdisplay, int vdisplay)
+                        unsigned int hdisplay, unsigned int vdisplay)
 {
-       int i, count, num_modes = 0;
+       int i, count = ARRAY_SIZE(drm_dmt_modes), num_modes = 0;
        struct drm_display_mode *mode;
        struct drm_device *dev = connector->dev;
 
-       count = ARRAY_SIZE(drm_dmt_modes);
-       if (hdisplay < 0)
-               hdisplay = 0;
-       if (vdisplay < 0)
-               vdisplay = 0;
-
        for (i = 0; i < count; i++) {
                const struct drm_display_mode *ptr = &drm_dmt_modes[i];
 
index eaac5e665892a0ca8f774c8b6bb23b810545bd9d..b38409670868d8c7240988338d6ea8e7969c5b43 100644 (file)
@@ -437,7 +437,7 @@ bool drm_detect_monitor_audio(const struct edid *edid);
 enum hdmi_quantization_range
 drm_default_rgb_quant_range(const struct drm_display_mode *mode);
 int drm_add_modes_noedid(struct drm_connector *connector,
-                        int hdisplay, int vdisplay);
+                        unsigned int hdisplay, unsigned int vdisplay);
 
 int drm_edid_header_is_valid(const void *edid);
 bool drm_edid_is_valid(struct edid *edid);