[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 01/15] xen: Clean up asm-generic/device.h
There's some pretense this header may be used without CONFIG_HAS_DEVICE_TREE, but that's just wishful thinking. Only x86 lacks that option, and it fully overrides this header, typedeffing struct pci_dev to be device_t. Furthermore there's an include for xen/device_tree.h halfway through the header, but that header already includes asm/device.h, creating a cycle. Clean up the header removing ifdef guards, merging the typedef onto the struct definition for device_t and removing the spurious include. The only affected file is aplic.c, in riscv, which is forced now to include device_tree.h directly. Not a functional change. Signed-off-by: Alejandro Vallejo <agarciav@xxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- v2: * Add new comment and ifdef guard with #error --- xen/arch/riscv/aplic.c | 3 ++- xen/include/asm-generic/device.h | 26 ++++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index 10ae81f7ac..dd7a274c52 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -9,13 +9,14 @@ * Copyright (c) 2024-2025 Vates */ +#include <xen/device_tree.h> #include <xen/errno.h> #include <xen/init.h> +#include <xen/lib.h> #include <xen/irq.h> #include <xen/sections.h> #include <xen/types.h> -#include <asm/device.h> #include <asm/intc.h> static struct intc_info __ro_after_init aplic_info = { diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/device.h index 1acd1ba1d8..631dab046a 100644 --- a/xen/include/asm-generic/device.h +++ b/xen/include/asm-generic/device.h @@ -1,14 +1,20 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +/* + * This header helps DTB-based architectures abstract away where a particular + * device came from, be it the DTB itself or enumerated on a PCI bus. + */ #ifndef __ASM_GENERIC_DEVICE_H__ #define __ASM_GENERIC_DEVICE_H__ +#ifndef CONFIG_HAS_DEVICE_TREE +#error "Header for exclusive use of DTB-based architectures" +#endif + #include <xen/stdbool.h> enum device_type { -#ifdef CONFIG_HAS_DEVICE_TREE DEV_DT, -#endif DEV_PCI }; @@ -23,23 +29,15 @@ enum device_class }; /* struct device - The basic device structure */ -struct device +typedef struct device { enum device_type type; -#ifdef CONFIG_HAS_DEVICE_TREE struct dt_device_node *of_node; /* Used by drivers imported from Linux */ -#endif #ifdef CONFIG_HAS_PASSTHROUGH void *iommu; /* IOMMU private data */; struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */ #endif -}; - -typedef struct device device_t; - -#ifdef CONFIG_HAS_DEVICE_TREE - -#include <xen/device_tree.h> +} device_t; #define dev_is_dt(dev) ((dev)->type == DEV_DT) @@ -87,10 +85,6 @@ struct device_desc { int (*init)(struct dt_device_node *dev, const void *data); }; -#else /* !CONFIG_HAS_DEVICE_TREE */ -#define dev_is_dt(dev) ((void)(dev), false) -#endif /* CONFIG_HAS_DEVICE_TREE */ - #define dev_is_pci(dev) ((dev)->type == DEV_PCI) #ifdef CONFIG_ACPI -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |