On Thu, Aug 20, 2020 at 09:37:12AM -0400, Jim Quinlan wrote: > On Tue, Aug 18, 2020 at 4:14 AM Andy Shevchenko > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote: > > On Mon, Aug 17, 2020 at 05:53:09PM -0400, Jim Quinlan wrote: ... > > > +static inline u64 dma_offset_from_dma_addr(struct device *dev, dma_addr_t dma_addr) > > > +{ > > > + const struct bus_dma_region *m = dev->dma_range_map; > > > + > > > + if (!m) > > > + return 0; > > > + for (; m->size; m++) > > > + if (dma_addr >= m->dma_start && dma_addr - m->dma_start < m->size) > > > + return m->offset; > > > + return 0; > > > +} > > > + > > > +static inline u64 dma_offset_from_phys_addr(struct device *dev, phys_addr_t paddr) > > > +{ > > > + const struct bus_dma_region *m = dev->dma_range_map; > > > + > > > + if (!m) > > > + return 0; > > > + for (; m->size; m++) > > > + if (paddr >= m->cpu_start && paddr - m->cpu_start < m->size) > > > + return m->offset; > > > + return 0; > > > +} > > > > Perhaps for these the form with one return 0 is easier to read > > > > if (m) { > > for (; m->size; m++) > > if (paddr >= m->cpu_start && paddr - m->cpu_start < m->size) > > return m->offset; > > } > > return 0; > > > > ? > I see what you are saying but I don't think there is enough difference > between the two to justify changing it. The difference is that you have return 0 / non-0 cases one each. I think it's slightly easier to read and understand, but it's up to you. -- With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel