History

genirq/msi: Provide msi_device_populate/destroy_sysfs()

Add new allocation functions which can be activated by domain info flags. They store the groups pointer in struct msi_device_data.

Thomas Gleixner committed 4 years ago

Commit bf6e0541 parent 686073e2 files · +44 −2Browse files

Showing the changes to kernel (1 of 2 files). Show all

Unified · Split

kernel/irq/msi.c+40−2
@@ -199,6 +199,20 @@ error_attrs: · 198 unmodified lines
199 return ERR_PTR(ret);199 return ERR_PTR(ret);
200}200}
201 201
202/**
203 * msi_device_populate_sysfs - Populate msi_irqs sysfs entries for a device
204 * @dev: The device (PCI, platform etc) which will get sysfs entries
205 */
206int msi_device_populate_sysfs(struct device *dev)
207{
208 const struct attribute_group **group = msi_populate_sysfs(dev);
209
210 if (IS_ERR(group))
211 return PTR_ERR(group);
212 dev->msi.data->attrs = group;
213 return 0;
214}
215
202/**216/**
203 * msi_destroy_sysfs - Destroy msi_irqs sysfs entries for devices217 * msi_destroy_sysfs - Destroy msi_irqs sysfs entries for devices
204 * @dev: The device(PCI, platform etc) who will remove sysfs entries218 * @dev: The device(PCI, platform etc) who will remove sysfs entries
@@ -225,6 +239,17 @@ void msi_destroy_sysfs(struct device *dev, const struct attribute_group **msi_ir · 20 unmodified lines
225 kfree(msi_irq_groups);239 kfree(msi_irq_groups);
226 }240 }
227}241}
242
243/**
244 * msi_device_destroy_sysfs - Destroy msi_irqs sysfs entries for a device
245 * @dev: The device (PCI, platform etc) for which to remove
246 * sysfs entries
247 */
248void msi_device_destroy_sysfs(struct device *dev)
249{
250 msi_destroy_sysfs(dev, dev->msi.data->attrs);
251 dev->msi.data->attrs = NULL;
252}
228#endif253#endif
229 254
230#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN255#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
@@ -672,8 +697,19 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 441 unmodified lines
672{697{
673 struct msi_domain_info *info = domain->host_data;698 struct msi_domain_info *info = domain->host_data;
674 struct msi_domain_ops *ops = info->ops;699 struct msi_domain_ops *ops = info->ops;
700 int ret;
701
702 ret = ops->domain_alloc_irqs(domain, dev, nvec);
703 if (ret)
704 return ret;
705
706 if (!(info->flags & MSI_FLAG_DEV_SYSFS))
707 return 0;
675 708
676 return ops->domain_alloc_irqs(domain, dev, nvec);709 ret = msi_device_populate_sysfs(dev);
710 if (ret)
711 msi_domain_free_irqs(domain, dev);
712 return ret;
677}713}
678 714
679void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)715void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)
@@ -712,7 +748,9 @@ void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) · 32 unmodified lines
712 struct msi_domain_info *info = domain->host_data;748 struct msi_domain_info *info = domain->host_data;
713 struct msi_domain_ops *ops = info->ops;749 struct msi_domain_ops *ops = info->ops;
714 750
715 return ops->domain_free_irqs(domain, dev);751 if (info->flags & MSI_FLAG_DEV_SYSFS)
752 msi_device_destroy_sysfs(dev);
753 ops->domain_free_irqs(domain, dev);
716}754}
717 755
718/**756/**