From: Jack Leigh <jack.leigh@collabora.com>
Date: Wed, 2 Jul 2014 15:43:30 +0100
Subject: Move simple_dname into drm_drv.c

---
 drivers/gpu/drm/drm_stub.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 869295e..8d0732f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -489,8 +489,29 @@ EXPORT_SYMBOL(drm_unplug_dev);
 static int drm_fs_cnt;
 static struct vfsmount *drm_fs_mnt;
 
+static int prepend(char **buffer, int *buflen, const char *str, int namelen)
+{
+	*buflen -= namelen;
+	if (*buflen < 0)
+		return -ENAMETOOLONG;
+	*buffer -= namelen;
+	memcpy(*buffer, str, namelen);
+	return 0;
+}
+
+static char *backport_dname(struct dentry *dentry, char *buffer, int buflen)
+{
+	char *end = buffer + buflen;
+	/* these dentries are never renamed, so d_lock is not needed */
+	if (prepend(&end, &buflen, " (deleted)", 11) ||
+	    prepend(&end, &buflen, dentry->d_name.name, dentry->d_name.len) ||
+	    prepend(&end, &buflen, "/", 1))
+		end = ERR_PTR(-ENAMETOOLONG);
+	return end;
+}
+
 static const struct dentry_operations drm_fs_dops = {
-	.d_dname	= simple_dname,
+	.d_dname	= backport_dname,
 };
 
 static const struct super_operations drm_fs_sops = {
