All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	ian.campbell@citrix.com, tim@xen.org,
	Julien Grall <julien.grall@linaro.org>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	stefano.stabellini@citrix.com
Subject: [PATCH v5 p2 14/19] tools/libxl: Check if fdt_{first, next}_subnode are present in libfdt
Date: Thu, 9 Apr 2015 16:09:40 +0100	[thread overview]
Message-ID: <1428592185-18581-15-git-send-email-julien.grall@citrix.com> (raw)
In-Reply-To: <1428592185-18581-1-git-send-email-julien.grall@citrix.com>

From: Julien Grall <julien.grall@linaro.org>

The functions fdt_{fisrt,next}_subnode may not be available because:
    * It has been introduced in 2013 => Doesn't work on Wheezy
    * The prototype exists but the functions are not exposed. Don't ask
    why...

The later has been fixed recently in the dtc repo [1]

When the functions are not available, implement our own in order to use
them in a following patch.

[1] git://git.kernel.org/pub/scm/utils/dtc/dtc.git
    commit a4b093f7366fdb429ca1781144d3985fa50d0fbb

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>

---
    tools/configure needs to be regenerate as this patch is modifying
    tools/configure.ac

    Changes in v5:
        - Add Ian's Signed-off-by for the license part and update the
        license
        - Rename libxl_fdt to libxl_libfdt_compat.c

    Changes in v4:
        - Patch added
---
 tools/config.h.in                 |  6 +++
 tools/configure.ac                |  5 +++
 tools/libxl/Makefile              |  2 +-
 tools/libxl/libxl_libfdt_compat.c | 92 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_libfdt_compat.c

diff --git a/tools/config.h.in b/tools/config.h.in
index 2a0ae48..06f8b6c 100644
--- a/tools/config.h.in
+++ b/tools/config.h.in
@@ -3,6 +3,12 @@
 /* Blktap2 enabled */
 #undef HAVE_BLKTAP2
 
+/* Define to 1 if you have the `fdt_first_subnode' function. */
+#undef HAVE_FDT_FIRST_SUBNODE
+
+/* Define to 1 if you have the `fdt_next_subnode' function. */
+#undef HAVE_FDT_NEXT_SUBNODE
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
diff --git a/tools/configure.ac b/tools/configure.ac
index d31c2f3..cc13336 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -355,6 +355,11 @@ AC_SUBST(libiconv)
 case "$host_cpu" in
 arm*|aarch64)
 AC_CHECK_LIB([fdt], [fdt_create], [], [AC_MSG_ERROR([Could not find libfdt])])
+
+# The functions fdt_{first,next}_subnode may not be available because:
+#   * It has been introduced in 2013 => Doesn't work on Wheezy
+#   * The prototype exists but the functions are not exposed. Don't ask why...
+AC_CHECK_FUNCS([fdt_first_subnode fdt_next_subnode])
 esac
 
 # Checks for header files.
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 1b16598..2afb146 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -59,7 +59,7 @@ endif
 LIBXL_OBJS-y += libxl_remus_device.o libxl_remus_disk_drbd.o
 
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
-LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o
+LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
 
 ifeq ($(CONFIG_NetBSD),y)
 LIBXL_OBJS-y += libxl_netbsd.o
diff --git a/tools/libxl/libxl_libfdt_compat.c b/tools/libxl/libxl_libfdt_compat.c
new file mode 100644
index 0000000..d0519f9
--- /dev/null
+++ b/tools/libxl/libxl_libfdt_compat.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * This file is part of libxl, and was originally taken from libfdt.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Additionally, this particular file is dual licensed.  That is,
+ * alternatively, at your option:
+ *
+ *      Redistribution and use in source and binary forms, with or
+ *      without modification, are permitted provided that the following
+ *      conditions are met:
+ *
+ *      1. Redistributions of source code must retain the above
+ *         copyright notice, this list of conditions and the following
+ *         disclaimer.
+ *      2. Redistributions in binary form must reproduce the above
+ *         copyright notice, this list of conditions and the following
+ *         disclaimer in the documentation and/or other materials
+ *         provided with the distribution.
+ *
+ *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ *      CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ *      INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *      MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ *      DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ *      CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *      NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ *      HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ *      OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ *      EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Note that this applies only to this file, and other files with a
+ * similar notice.  Also, note that when the same code is distributed
+ * along with the rest of libxl, you must comply with the terms of the
+ * LGPLv2.1 for the whole of libxl including this file.
+ *
+ * The intent is to permit, in particular, upstream libfdt to
+ * incorporate improvements to this file within upstream libfdt.  At
+ * the time of writing, upstream libfdt is dual licensed: 2-clause BSD
+ * (as above) and GPLv2-or-later.  The 2-clause BSD licence is
+ * compatible with both GPLv2-or-later and LGPLv2.1-only; this permits
+ * copying in both directions, and the optional licence upgrade to a
+ * copyleft licence by libdft upstream or the Xen Project,
+ * respectively.
+ */
+
+#include <libfdt.h>
+
+#ifndef HAVE_FDT_FIRST_SUBNODE
+int fdt_first_subnode(const void *fdt, int offset)
+{
+	int depth = 0;
+
+	offset = fdt_next_node(fdt, offset, &depth);
+	if (offset < 0 || depth != 1)
+		return -FDT_ERR_NOTFOUND;
+
+	return offset;
+}
+#endif
+
+#ifndef HAVE_FDT_NEXT_SUBNODE
+int fdt_next_subnode(const void *fdt, int offset)
+{
+	int depth = 1;
+
+	/*
+	 * With respect to the parent, the depth of the next subnode will be
+	 * the same as the last.
+	 */
+	do {
+		offset = fdt_next_node(fdt, offset, &depth);
+		if (offset < 0 || depth < 1)
+			return -FDT_ERR_NOTFOUND;
+	} while (depth > 1);
+
+	return offset;
+}
+#endif
-- 
2.1.4

  parent reply	other threads:[~2015-04-09 15:21 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 15:09 [PATCH v5 p2 00/19] xen/arm Add support for non-PCI passthrough Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 01/19] xen/arm: Let the toolstack configure the number of SPIs Julien Grall
2015-04-16 14:39   ` Ian Campbell
2015-04-16 15:10     ` Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 02/19] xen/arm: vgic: Add spi_to_pending Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 03/19] xen/arm: Release IRQ routed to a domain when it's destroying Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 04/19] xen/arm: Implement hypercall DOMCTL_{, un}bind_pt_pirq Julien Grall
2015-04-16 14:55   ` Ian Campbell
2015-04-16 15:20     ` Julien Grall
2015-04-16 15:40       ` Ian Campbell
2015-04-17  6:02         ` Julien Grall
2015-04-17  9:47           ` Ian Campbell
2015-04-17 23:05     ` Daniel De Graaf
2015-04-09 15:09 ` [PATCH v5 p2 05/19] xen: guestcopy: Provide an helper to safely copy string from guest Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 06/19] xen/dts: Provide an helper to get a DT node from a path provided by a guest Julien Grall
2015-04-16 14:57   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 07/19] xen/passthrough: Introduce iommu_construct Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 08/19] xen/passthrough: arm: release the DT devices assigned to a guest earlier Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 09/19] xen/passthrough: iommu_deassign_device_dt: By default reassign device to nobody Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 10/19] xen/iommu: arm: Wire iommu DOMCTL for ARM Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 11/19] xen/xsm: Add helpers to check permission for device tree passthrough Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 12/19] xen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device Julien Grall
2015-04-16 15:11   ` Ian Campbell
2015-04-16 15:21     ` Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 13/19] tools/libxl: Create a per-arch function to map IRQ to a domain Julien Grall
2015-04-16 15:12   ` Ian Campbell
2015-04-16 15:26     ` Julien Grall
2015-04-16 15:42       ` Ian Campbell
2015-04-09 15:09 ` Julien Grall [this message]
2015-04-16 15:13   ` [PATCH v5 p2 14/19] tools/libxl: Check if fdt_{first, next}_subnode are present in libfdt Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 15/19] tools/(lib)xl: Add partial device tree support for ARM Julien Grall
2015-04-09 16:13   ` Ian Jackson
2015-04-28 13:30     ` Julien Grall
2015-04-16 15:17   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 16/19] tools/libxl: arm: Use an higher value for the GIC phandle Julien Grall
2015-04-09 16:17   ` Ian Jackson
2015-04-09 16:33     ` Julien Grall
2015-04-09 16:52       ` Ian Jackson
2015-04-09 17:00         ` Julien Grall
2015-04-09 17:02           ` Julien Grall
2015-04-09 17:04           ` Ian Jackson
2015-04-13 12:07             ` Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 17/19] libxl: Add support for Device Tree passthrough Julien Grall
2015-04-09 16:14   ` Ian Jackson
2015-04-16 15:19   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 18/19] xl: Add new option dtdev Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 19/19] docs/misc: arm: Add documentation about Device Tree passthrough Julien Grall
2015-04-16 15:20   ` Ian Campbell

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=1428592185-18581-15-git-send-email-julien.grall@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.