Skip to content

Commit

Permalink
cxl: Split afu_register_irqs() function
Browse files Browse the repository at this point in the history
Split the afu_register_irqs() function so that different parts can
be useful elsewhere.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Michael Neuling authored and Michael Ellerman committed Jun 3, 2015
1 parent a6b07d8 commit c358d84
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions drivers/misc/cxl/cxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,5 +672,6 @@ int cxl_psl_purge(struct cxl_afu *afu);
void cxl_stop_trace(struct cxl *cxl);

extern struct pci_driver cxl_pci_driver;
int afu_allocate_irqs(struct cxl_context *ctx, u32 count);

#endif
31 changes: 24 additions & 7 deletions drivers/misc/cxl/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,8 @@ void afu_irq_name_free(struct cxl_context *ctx)
}
}

int afu_register_irqs(struct cxl_context *ctx, u32 count)
int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
{
irq_hw_number_t hwirq;
int rc, r, i, j = 1;
struct cxl_irq_name *irq_name;

Expand Down Expand Up @@ -458,6 +457,18 @@ int afu_register_irqs(struct cxl_context *ctx, u32 count)
j++;
}
}
return 0;

out:
afu_irq_name_free(ctx);
return -ENOMEM;
}

void afu_register_hwirqs(struct cxl_context *ctx)
{
irq_hw_number_t hwirq;
struct cxl_irq_name *irq_name;
int r,i;

/* We've allocated all memory now, so let's do the irq allocations */
irq_name = list_first_entry(&ctx->irq_names, struct cxl_irq_name, list);
Expand All @@ -469,13 +480,19 @@ int afu_register_irqs(struct cxl_context *ctx, u32 count)
irq_name = list_next_entry(irq_name, list);
}
}
}

return 0;
int afu_register_irqs(struct cxl_context *ctx, u32 count)
{
int rc;

out:
afu_irq_name_free(ctx);
return -ENOMEM;
}
rc = afu_allocate_irqs(ctx, count);
if (rc)
return rc;

afu_register_hwirqs(ctx);
return 0;
}

void afu_release_irqs(struct cxl_context *ctx, void *cookie)
{
Expand Down

0 comments on commit c358d84

Please sign in to comment.