Re: [PATCH v14 17/25] virt: gunyah: Translate gh_rm_hyp_resource into gunyah_resource

From: Bjorn Andersson
Date: Sat Aug 05 2023 - 14:13:05 EST


On Tue, Jun 13, 2023 at 10:20:45AM -0700, Elliot Berman wrote:
> diff --git a/drivers/virt/gunyah/rsc_mgr.c b/drivers/virt/gunyah/rsc_mgr.c
[..]
> +struct gh_resource *gh_rm_alloc_resource(struct gh_rm *rm, struct gh_rm_hyp_resource *hyp_resource)
> +{
> + struct gh_resource *ghrsc;
> + int ret;
> +
> + ghrsc = kzalloc(sizeof(*ghrsc), GFP_KERNEL);
> + if (!ghrsc)
> + return NULL;
> +
> + ghrsc->type = hyp_resource->type;
> + ghrsc->capid = le64_to_cpu(hyp_resource->cap_id);
> + ghrsc->irq = IRQ_NOTCONNECTED;
> + ghrsc->rm_label = le32_to_cpu(hyp_resource->resource_label);
> + if (hyp_resource->virq) {
> + struct gh_irq_chip_data irq_data = {
> + .gh_virq = le32_to_cpu(hyp_resource->virq),
> + };
> +
> + ret = irq_domain_alloc_irqs(rm->irq_domain, 1, NUMA_NO_NODE, &irq_data);
> + if (ret < 0) {
> + dev_err(rm->dev,
> + "Failed to allocate interrupt for resource %d label: %d: %d\n",
> + ghrsc->type, ghrsc->rm_label, ret);
> + kfree(ghrsc);
> + return NULL;
> + } else {

No need for the else here, the failure case has already returned.

> + ghrsc->irq = ret;
> + }
> + }
> +
> + return ghrsc;
> +}
[..]
> diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h
> index 982e27d10d57f..4b398b59c2c5a 100644
> --- a/include/linux/gunyah.h
> +++ b/include/linux/gunyah.h
> @@ -27,6 +27,9 @@ struct gh_resource {
> enum gh_resource_type type;
> u64 capid;
> unsigned int irq;
> +
> + struct list_head list;

This is unused.

Regards,
Bjorn