diff mbox

[1/3] drm/edid: add drm_edid_duplicate

Message ID 1380283709-30572-1-git-send-email-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula Sept. 27, 2013, 12:08 p.m. UTC
We have some code duplication related to EDID duplication. Add a helper.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_edid.c |   12 ++++++++++++
 include/drm/drm_crtc.h     |    1 +
 2 files changed, 13 insertions(+)

Comments

Chris Wilson Sept. 27, 2013, 12:24 p.m. UTC | #1
On Fri, Sep 27, 2013 at 03:08:27PM +0300, Jani Nikula wrote:
> We have some code duplication related to EDID duplication. Add a helper.

Lgtm, debated the merits of assuming GFP_KERNEL and inlining, then thought
better of it.

All 3, Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Lespiau, Damien Sept. 27, 2013, 12:42 p.m. UTC | #2
On Fri, Sep 27, 2013 at 03:08:27PM +0300, Jani Nikula wrote:
> We have some code duplication related to EDID duplication. Add a helper.

git grep kmemdup.*edid drivers/gpu/drm/ also returns 3 hits in nouveau
here, should anyone be bored.
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c24af1d..412b80f 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1264,6 +1264,18 @@  struct edid *drm_get_edid(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_get_edid);
 
+/**
+ * drm_edid_duplicate - duplicate an EDID and the extensions
+ * @edid: EDID to duplicate
+ *
+ * Return duplicate edid or NULL on allocation failure.
+ */
+struct edid *drm_edid_duplicate(const struct edid *edid)
+{
+	return kmemdup(edid, (edid->extensions + 1) * EDID_LENGTH, GFP_KERNEL);
+}
+EXPORT_SYMBOL(drm_edid_duplicate);
+
 /*** EDID parsing ***/
 
 /**
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b2d08ca..8ab633a 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -980,6 +980,7 @@  extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_m
 extern bool drm_probe_ddc(struct i2c_adapter *adapter);
 extern struct edid *drm_get_edid(struct drm_connector *connector,
 				 struct i2c_adapter *adapter);
+extern struct edid *drm_edid_duplicate(const struct edid *edid);
 extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
 extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);