[PATCH V1 3/7] KVM: GIC: Create a common probe function for GIC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch creates common functions for both GICv2 and GICv3. The
existing functions are renamed to new names specifically for DT.

Signed-off-by: Wei Huang <wei@xxxxxxxxxx>
---
 virt/kvm/arm/vgic-v2.c | 44 +++++++++++++++++++++++++++++++-------------
 virt/kvm/arm/vgic-v3.c | 37 ++++++++++++++++++++++++-------------
 2 files changed, 55 insertions(+), 26 deletions(-)

diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
index 6540a6d..7dd5fb3 100644
--- a/virt/kvm/arm/vgic-v2.c
+++ b/virt/kvm/arm/vgic-v2.c
@@ -182,23 +182,16 @@ static const struct of_device_id vgic_v2_ids[] = {
 	{},
 };
 
-/**
- * vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT
- * @ops: 	address of a pointer to the GICv2 operations
- * @params:	address of a pointer to HW-specific parameters
- *
- * Returns 0 if a GICv2 has been found, with the low level operations
- * in *ops and the HW parameters in *params. Returns an error code
- * otherwise.
+/*
+ * Returns 0 if a GICv2 can be found in DT and the details of GICv2
+ * configuration are stored in *vgic. Otherwise returns an error code.
  */
-int vgic_v2_probe(const struct vgic_ops **ops,
-		  const struct vgic_params **params)
+static int vgic_v2_dt_probe(struct vgic_params *vgic)
 {
 	int ret;
 	struct resource vctrl_res;
 	struct resource vcpu_res;
 	struct device_node *vgic_node;
-	struct vgic_params *vgic = &vgic_v2_params;
 
 	vgic_node = of_find_matching_node(NULL, vgic_v2_ids);
 	if (!vgic_node) {
@@ -269,8 +262,6 @@ int vgic_v2_probe(const struct vgic_ops **ops,
 
 	vgic->type = VGIC_V2;
 	vgic->max_gic_vcpus = VGIC_V2_MAX_CPUS;
-	*ops = &vgic_v2_ops;
-	*params = vgic;
 	goto out;
 
 out_unmap:
@@ -279,3 +270,30 @@ out:
 	of_node_put(vgic_node);
 	return ret;
 }
+
+/**
+ * vgic_v2_probe - probe for a GICv2 compatible interrupt controller
+ * @ops:	address of a pointer to the GICv2 operations
+ * @params:	address of a pointer to HW-specific parameters
+ *
+ * Returns 0 if a GICv2 has been found, with the low level operations
+ * in *ops and the HW parameters in *params. Returns an error code
+ * otherwise.
+ */
+int vgic_v2_probe(const struct vgic_ops **ops,
+		  const struct vgic_params **params)
+{
+	int ret;
+	struct vgic_params *vgic = &vgic_v2_params;
+
+	ret = vgic_v2_dt_probe(vgic);
+	if (ret)
+		goto err_out;
+
+	*ops = &vgic_v2_ops;
+	*params = vgic;
+
+	return 0;
+err_out:
+	return ret;
+}
diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
index 33a5fdf..b036134 100644
--- a/virt/kvm/arm/vgic-v3.c
+++ b/virt/kvm/arm/vgic-v3.c
@@ -220,23 +220,16 @@ static const struct of_device_id vgic_v3_ids[] = {
 	{},
 };
 
-/**
- * vgic_v3_probe - probe for a GICv3 compatible interrupt controller in DT
- * @ops: 	address of a pointer to the GICv3 operations
- * @params:	address of a pointer to HW-specific parameters
- *
- * Returns 0 if a GICv3 has been found, with the low level operations
- * in *ops and the HW parameters in *params. Returns an error code
- * otherwise.
+/*
+ * Returns 0 if a GICv3 can be found in DT and the details of GICv3
+ * configuration are stored in *vgic. Otherwise returns an error code.
  */
-int vgic_v3_probe(const struct vgic_ops **ops,
-		  const struct vgic_params **params)
+static int vgic_v3_dt_probe(struct vgic_params *vgic)
 {
 	int ret = 0;
 	u32 gicv_idx;
 	struct resource vcpu_res;
 	struct device_node *vgic_node;
-	struct vgic_params *vgic = &vgic_v3_params;
 
 	vgic_node = of_find_matching_node(NULL, vgic_v3_ids);
 	if (!vgic_node) {
@@ -292,11 +285,29 @@ int vgic_v3_probe(const struct vgic_ops **ops,
 
 	kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
 		 vcpu_res.start, vgic->maint_irq);
+out:
+	of_node_put(vgic_node);
+	return ret;
+}
+/**
+ * vgic_v3_probe - probe for a GICv3 compatible interrupt controller
+ * @ops:	address of a pointer to the GICv3 operations
+ * @params:	address of a pointer to HW-specific parameters
+ *
+ * Returns 0 if a GICv3 has been found, with the low level operations
+ * in *ops and the HW parameters in *params. Returns an error code
+ * otherwise.
+ */
+int vgic_v3_probe(const struct vgic_ops **ops,
+		  const struct vgic_params **params)
+{
+	int ret = 0;
+	struct vgic_params *vgic = &vgic_v3_params;
+
+	ret = vgic_v3_dt_probe(vgic);
 
 	*ops = &vgic_v3_ops;
 	*params = vgic;
 
-out:
-	of_node_put(vgic_node);
 	return ret;
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux