mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antonios Motakis <a.motakis@virtualopensystems.com>
To: kvmarm@lists.cs.columbia.edu, iommu@lists.linux-foundation.org,
	alex.williamson@redhat.com
Cc: tech@virtualopensystems.com, christoffer.dall@linaro.org,
	eric.auger@linaro.org, kim.phillips@freescale.com,
	Antonios Motakis <a.motakis@virtualopensystems.com>,
	kvm@vger.kernel.org (open list:VFIO DRIVER),
	linux-kernel@vger.kernel.org (open list)
Subject: [RFC PATCH v2 3/4] vfio: platform: devtree: access property as a list of strings
Date: Thu, 16 Oct 2014 17:54:35 +0200	[thread overview]
Message-ID: <1413474876-28544-4-git-send-email-a.motakis@virtualopensystems.com> (raw)
In-Reply-To: <1413474876-28544-1-git-send-email-a.motakis@virtualopensystems.com>

Certain device tree properties (e.g. the device node name, the compatible
string), are available as a list of strings (separated by the null
terminating character). Let the VFIO user query this type of properties.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
---
 drivers/vfio/platform/devtree.c | 43 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/platform/devtree.c b/drivers/vfio/platform/devtree.c
index 032ee16..6d25f97 100644
--- a/drivers/vfio/platform/devtree.c
+++ b/drivers/vfio/platform/devtree.c
@@ -45,11 +45,52 @@ static int devtree_get_prop_list(struct device_node *np, unsigned *lenp,
 	return ret;
 }
 
+static int devtree_get_full_name(struct device_node *np, unsigned *lenp,
+				 void __user *datap, unsigned long datasz)
+{
+	int len = strlen(np->full_name) + 1;
+
+	if (lenp)
+		*lenp = len;
+
+	if (len > datasz)
+		return -EAGAIN;
+
+	if (copy_to_user(datap, np->full_name, len))
+		return -EFAULT;
+
+	return 0;
+}
+
 static int devtree_get_strings(struct device_node *np,
 			       char *name, unsigned *lenp,
 			       void __user *datap, unsigned long datasz)
 {
-	return -EINVAL;
+	struct property *prop;
+	int len;
+
+	prop = of_find_property(np, name, &len);
+
+	if (!prop) {
+		/* special case full_name as a property that is not on the fdt,
+		 * but we wish to return to the user as it includes the full
+		 * path of the device */
+		if (!strcmp(name, "full_name"))
+			return devtree_get_full_name(np, lenp, datap, datasz);
+		else
+			return -EINVAL;
+	}
+
+	if (lenp)
+		*lenp = len;
+
+	if (len > datasz)
+		return -EAGAIN;
+
+	if (copy_to_user(datap, prop->value, len))
+		return -EFAULT;
+
+	return 0;
 }
 
 static int devtree_get_uint(struct device_node *np, char *name,
-- 
2.1.1


  parent reply	other threads:[~2014-10-16 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1413474876-28544-1-git-send-email-a.motakis@virtualopensystems.com>
2014-10-16 15:54 ` [RFC PATCH v2 1/4] vfio: platform: add device tree info API and skeleton Antonios Motakis
2014-10-16 15:54 ` [RFC PATCH v2 2/4] vfio: platform: devtree: return available property names Antonios Motakis
2014-10-16 15:54 ` Antonios Motakis [this message]
2014-10-16 15:54 ` [RFC PATCH v2 4/4] vfio: platform: devtree: return arrays of u32, u16, or u8 data Antonios Motakis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413474876-28544-4-git-send-email-a.motakis@virtualopensystems.com \
    --to=a.motakis@virtualopensystems.com \
    --cc=alex.williamson@redhat.com \
    --cc=christoffer.dall@linaro.org \
    --cc=eric.auger@linaro.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kim.phillips@freescale.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tech@virtualopensystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®