@@ -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;
+}
@@ -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;
}
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@redhat.com> --- virt/kvm/arm/vgic-v2.c | 44 +++++++++++++++++++++++++++++++------------- virt/kvm/arm/vgic-v3.c | 37 ++++++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 26 deletions(-)