>>> On 19.11.14 at 02:26, <tiejun.c...@intel.com> wrote: >> > So without lookuping devices[i], how can we call func() for each sbdf as >>> you mentioned? >> >> You've got both rmrr and bdf in the body of for_each_rmrr_device(). >> After all - as I said - you just open-coded it. >> > > Yeah, so change this again, > > int intel_iommu_get_reserved_device_memory(iommu_grdm_t *func, void *ctxt) > { > struct acpi_rmrr_unit *rmrr; > int rc = 0; > unsigned int i; > u16 bdf; > > for_each_rmrr_device ( rmrr, bdf, i ) > { > rc = func(PFN_DOWN(rmrr->base_address), > PFN_UP(rmrr->end_address) - > PFN_DOWN(rmrr->base_address), > PCI_SBDF(rmrr->segment, bdf), > ctxt); > /* Hit this entry so just go next. */ > if ( rc == 1 ) > i = rmrr->scope.devices_cnt; > else if ( rc < 0 ) > return rc; > } > > return rc; > }
Better. Another improvement would be make it not depend on the internal workings of for_each_rmrr_device()... And in any case you should not special case 1 - just return when rc is negative and skip the rest of the current RMRR when it's positive. And of course make the function's final return value predictable. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel