Skip to content

Commit b2eba39

Browse files
author
Marc Zyngier
committed
genirq/msi: Make the .prepare callback reusable
The .prepare callbacks are so far only called from msi_domain_alloc_irqs. In order to reuse that code, split that code and create a msi_domain_prepare_irqs function that the existing code can call into. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent c466595 commit b2eba39

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎include/linux/msi.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode,
279279
int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
280280
irq_write_msi_msg_t write_msi_msg);
281281
void platform_msi_domain_free_irqs(struct device *dev);
282+
283+
/* When an MSI domain is used as an intermediate domain */
284+
int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
285+
int nvec, msi_alloc_info_t *args);
282286
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
283287

284288
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN

‎kernel/irq/msi.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,20 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
252252
&msi_domain_ops, info);
253253
}
254254

255+
int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
256+
int nvec, msi_alloc_info_t *arg)
257+
{
258+
struct msi_domain_info *info = domain->host_data;
259+
struct msi_domain_ops *ops = info->ops;
260+
int ret;
261+
262+
ret = ops->msi_check(domain, info, dev);
263+
if (ret == 0)
264+
ret = ops->msi_prepare(domain, dev, nvec, arg);
265+
266+
return ret;
267+
}
268+
255269
/**
256270
* msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
257271
* @domain: The domain to allocate from
@@ -270,9 +284,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
270284
struct msi_desc *desc;
271285
int i, ret, virq = -1;
272286

273-
ret = ops->msi_check(domain, info, dev);
274-
if (ret == 0)
275-
ret = ops->msi_prepare(domain, dev, nvec, &arg);
287+
ret = msi_domain_prepare_irqs(domain, dev, nvec, &arg);
276288
if (ret)
277289
return ret;
278290

0 commit comments

Comments
 (0)