OSDN Git Service

drm/edid: split drm_add_edid_modes() to two
authorJani Nikula <jani.nikula@intel.com>
Mon, 28 Mar 2022 14:34:33 +0000 (17:34 +0300)
committerJani Nikula <jani.nikula@intel.com>
Tue, 29 Mar 2022 11:51:30 +0000 (14:51 +0300)
Reduce the size of the function that actually modifies the EDID.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/437c3c79f68d1144444fb2dd18a678f3aa97272c.1648477901.git.jani.nikula@intel.com
drivers/gpu/drm/drm_edid.c

index 2bdc0ee..359c52e 100644 (file)
@@ -5556,18 +5556,8 @@ static int add_displayid_detailed_modes(struct drm_connector *connector,
        return num_modes;
 }
 
-/**
- * drm_add_edid_modes - add modes from EDID data, if available
- * @connector: connector we're probing
- * @edid: EDID data
- *
- * Add the specified modes to the connector's mode list. Also fills out the
- * &drm_display_info structure and ELD in @connector with any information which
- * can be derived from the edid.
- *
- * Return: The number of modes added or 0 if we couldn't find any.
- */
-int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
+static int drm_edid_connector_update(struct drm_connector *connector,
+                                    const struct edid *edid)
 {
        int num_modes = 0;
        u32 quirks;
@@ -5576,12 +5566,6 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
                clear_eld(connector);
                return 0;
        }
-       if (!drm_edid_is_valid(edid)) {
-               clear_eld(connector);
-               drm_warn(connector->dev, "%s: EDID invalid.\n",
-                        connector->name);
-               return 0;
-       }
 
        drm_edid_to_eld(connector, edid);
 
@@ -5633,6 +5617,28 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 
        return num_modes;
 }
+
+/**
+ * drm_add_edid_modes - add modes from EDID data, if available
+ * @connector: connector we're probing
+ * @edid: EDID data
+ *
+ * Add the specified modes to the connector's mode list. Also fills out the
+ * &drm_display_info structure and ELD in @connector with any information which
+ * can be derived from the edid.
+ *
+ * Return: The number of modes added or 0 if we couldn't find any.
+ */
+int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
+{
+       if (edid && !drm_edid_is_valid(edid)) {
+               drm_warn(connector->dev, "%s: EDID invalid.\n",
+                        connector->name);
+               edid = NULL;
+       }
+
+       return drm_edid_connector_update(connector, edid);
+}
 EXPORT_SYMBOL(drm_add_edid_modes);
 
 /**