diff options
Diffstat (limited to 'drivers/iommu/iommu.c')
-rw-r--r-- | drivers/iommu/iommu.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index b59826aa5531..ed8b04867b1f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
@@ -799,18 +799,26 @@ static int iommu_bus_notifier(struct notifier_block *nb, | |||
799 | return 0; | 799 | return 0; |
800 | } | 800 | } |
801 | 801 | ||
802 | static struct notifier_block iommu_bus_nb = { | 802 | static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops) |
803 | .notifier_call = iommu_bus_notifier, | ||
804 | }; | ||
805 | |||
806 | static void iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops) | ||
807 | { | 803 | { |
804 | int err; | ||
805 | struct notifier_block *nb; | ||
808 | struct iommu_callback_data cb = { | 806 | struct iommu_callback_data cb = { |
809 | .ops = ops, | 807 | .ops = ops, |
810 | }; | 808 | }; |
811 | 809 | ||
812 | bus_register_notifier(bus, &iommu_bus_nb); | 810 | nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL); |
813 | bus_for_each_dev(bus, NULL, &cb, add_iommu_group); | 811 | if (!nb) |
812 | return -ENOMEM; | ||
813 | |||
814 | nb->notifier_call = iommu_bus_notifier; | ||
815 | |||
816 | err = bus_register_notifier(bus, nb); | ||
817 | if (err) { | ||
818 | kfree(nb); | ||
819 | return err; | ||
820 | } | ||
821 | return bus_for_each_dev(bus, NULL, &cb, add_iommu_group); | ||
814 | } | 822 | } |
815 | 823 | ||
816 | /** | 824 | /** |
@@ -834,9 +842,7 @@ int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops) | |||
834 | bus->iommu_ops = ops; | 842 | bus->iommu_ops = ops; |
835 | 843 | ||
836 | /* Do IOMMU specific setup for this bus-type */ | 844 | /* Do IOMMU specific setup for this bus-type */ |
837 | iommu_bus_init(bus, ops); | 845 | return iommu_bus_init(bus, ops); |
838 | |||
839 | return 0; | ||
840 | } | 846 | } |
841 | EXPORT_SYMBOL_GPL(bus_set_iommu); | 847 | EXPORT_SYMBOL_GPL(bus_set_iommu); |
842 | 848 | ||