lkml.org 
[lkml]   [2015]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v8 5/9] PCI: Add pci_iomap_wc() variants
On Thu, Jun 25, 2015 at 8:09 AM, Borislav Petkov <bp@suse.de> wrote:
>> +void __iomem *pci_iomap_wc_range(struct pci_dev *dev,
>> + int bar,
>> + unsigned long offset,
>> + unsigned long maxlen)
>> +{
>> + resource_size_t start = pci_resource_start(dev, bar);
>> + resource_size_t len = pci_resource_len(dev, bar);
>> + unsigned long flags = pci_resource_flags(dev, bar);
>> +
>> + if (len <= offset || !start)
>> + return NULL;
>> + len -= offset;
>> + start += offset;
>> + if (maxlen && len > maxlen)
>> + len = maxlen;
>> + if (flags & IORESOURCE_IO)
>> + return NULL;
>
> I've moved this check at the beginning of the function so that we bail
> out before doing the computations above it.

That indeed looks like a good optimization.

Luis


\
 
 \ /
  Last update: 2015-06-25 18:21    [W:0.212 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site