Commit b26b2d49 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Jesse Barnes

resource/PCI: align functions now return start of resource

As suggested by Linus, align functions should return the start
of a resource, not void. An update of "res->start" is no longer
necessary.

Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 93da6202
...@@ -126,7 +126,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final); ...@@ -126,7 +126,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final);
#define MB (1024*KB) #define MB (1024*KB)
#define GB (1024*MB) #define GB (1024*MB)
void resource_size_t
pcibios_align_resource(void *data, struct resource *res, pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
...@@ -184,7 +184,7 @@ pcibios_align_resource(void *data, struct resource *res, ...@@ -184,7 +184,7 @@ pcibios_align_resource(void *data, struct resource *res,
} }
} }
res->start = start; return start;
} }
#undef KB #undef KB
#undef MB #undef MB
......
...@@ -616,15 +616,17 @@ char * __init pcibios_setup(char *str) ...@@ -616,15 +616,17 @@ char * __init pcibios_setup(char *str)
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might be mirrored at 0x0100-0x03ff.. * which might be mirrored at 0x0100-0x03ff..
*/ */
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
resource_size_t start = res->start; resource_size_t start = res->start;
if (res->flags & IORESOURCE_IO && start & 0x300) if (res->flags & IORESOURCE_IO && start & 0x300)
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = (start + align - 1) & ~(align - 1); start = (start + align - 1) & ~(align - 1);
return start;
} }
/** /**
......
...@@ -41,18 +41,16 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, ...@@ -41,18 +41,16 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
return 0; return 0;
} }
void resource_size_t
pcibios_align_resource(void *data, struct resource *res, pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
if (res->flags & IORESOURCE_IO) { resource_size_t start = res->start;
resource_size_t start = res->start;
if (start & 0x300) { if ((res->flags & IORESOURCE_IO) && (start & 0x300))
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = start;
} return start
}
} }
int pcibios_enable_resources(struct pci_dev *dev, int mask) int pcibios_enable_resources(struct pci_dev *dev, int mask)
......
...@@ -32,18 +32,16 @@ ...@@ -32,18 +32,16 @@
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might have be mirrored at 0x0100-0x03ff.. * which might have be mirrored at 0x0100-0x03ff..
*/ */
void resource_size_t
pcibios_align_resource(void *data, struct resource *res, pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
if (res->flags & IORESOURCE_IO) { resource_size_t start = res->start;
resource_size_t start = res->start;
if (start & 0x300) { if ((res->flags & IORESOURCE_IO) && (start & 0x300))
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = start;
} return start
}
} }
......
...@@ -547,10 +547,11 @@ pcibios_disable_device (struct pci_dev *dev) ...@@ -547,10 +547,11 @@ pcibios_disable_device (struct pci_dev *dev)
acpi_pci_irq_disable(dev); acpi_pci_irq_disable(dev);
} }
void resource_size_t
pcibios_align_resource (void *data, struct resource *res, pcibios_align_resource (void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
return res->start;
} }
/* /*
......
...@@ -49,7 +49,7 @@ static int pci_initialized; ...@@ -49,7 +49,7 @@ static int pci_initialized;
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might have be mirrored at 0x0100-0x03ff.. * which might have be mirrored at 0x0100-0x03ff..
*/ */
void resource_size_t
pcibios_align_resource(void *data, struct resource *res, pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
...@@ -73,7 +73,7 @@ pcibios_align_resource(void *data, struct resource *res, ...@@ -73,7 +73,7 @@ pcibios_align_resource(void *data, struct resource *res,
start = PCIBIOS_MIN_MEM + hose->mem_resource->start; start = PCIBIOS_MIN_MEM + hose->mem_resource->start;
} }
res->start = start; return start;
} }
static void __devinit pcibios_scanbus(struct pci_controller *hose) static void __devinit pcibios_scanbus(struct pci_controller *hose)
......
...@@ -345,14 +345,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) ...@@ -345,14 +345,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
return pcibios_enable_resources(dev); return pcibios_enable_resources(dev);
} }
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
struct pci_dev *dev = data; struct pci_dev *dev = data;
resource_size_t start = res->start;
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
resource_size_t start = res->start;
/* We need to avoid collisions with `mirrored' VGA ports /* We need to avoid collisions with `mirrored' VGA ports
and other strange ISA hardware, so we always want the and other strange ISA hardware, so we always want the
addresses kilobyte aligned. */ addresses kilobyte aligned. */
...@@ -363,8 +362,9 @@ void pcibios_align_resource(void *data, struct resource *res, ...@@ -363,8 +362,9 @@ void pcibios_align_resource(void *data, struct resource *res,
} }
start = (start + 1024 - 1) & ~(1024 - 1); start = (start + 1024 - 1) & ~(1024 - 1);
res->start = start;
} }
return start;
} }
struct pci_ops titan_pci_ops = { struct pci_ops titan_pci_ops = {
......
...@@ -31,9 +31,11 @@ ...@@ -31,9 +31,11 @@
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might have be mirrored at 0x0100-0x03ff.. * which might have be mirrored at 0x0100-0x03ff..
*/ */
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
resource_size_t start = res->start;
#if 0 #if 0
struct pci_dev *dev = data; struct pci_dev *dev = data;
...@@ -47,14 +49,10 @@ void pcibios_align_resource(void *data, struct resource *res, ...@@ -47,14 +49,10 @@ void pcibios_align_resource(void *data, struct resource *res,
); );
#endif #endif
if (res->flags & IORESOURCE_IO) { if ((res->flags & IORESOURCE_IO) && (start & 0x300))
unsigned long start = res->start; start = (start + 0x3ff) & ~0x3ff;
if (start & 0x300) { return start;
start = (start + 0x3ff) & ~0x3ff;
res->start = start;
}
}
} }
......
...@@ -254,10 +254,10 @@ EXPORT_SYMBOL(pcibios_bus_to_resource); ...@@ -254,10 +254,10 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
* Since we are just checking candidates, don't use any fields other * Since we are just checking candidates, don't use any fields other
* than res->start. * than res->start.
*/ */
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t alignment) resource_size_t size, resource_size_t alignment)
{ {
resource_size_t mask, align; resource_size_t mask, align, start = res->start;
DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n", DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n",
pci_name(((struct pci_dev *) data)), pci_name(((struct pci_dev *) data)),
...@@ -269,10 +269,10 @@ void pcibios_align_resource(void *data, struct resource *res, ...@@ -269,10 +269,10 @@ void pcibios_align_resource(void *data, struct resource *res,
/* Align to largest of MIN or input size */ /* Align to largest of MIN or input size */
mask = max(alignment, align) - 1; mask = max(alignment, align) - 1;
res->start += mask; start += mask;
res->start &= ~mask; start &= ~mask;
/* The caller updates the end field, we don't. */ return start;
} }
......
...@@ -1181,21 +1181,20 @@ static int skip_isa_ioresource_align(struct pci_dev *dev) ...@@ -1181,21 +1181,20 @@ static int skip_isa_ioresource_align(struct pci_dev *dev)
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might have be mirrored at 0x0100-0x03ff.. * which might have be mirrored at 0x0100-0x03ff..
*/ */
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
struct pci_dev *dev = data; struct pci_dev *dev = data;
resource_size_t start = res->start;
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
resource_size_t start = res->start;
if (skip_isa_ioresource_align(dev)) if (skip_isa_ioresource_align(dev))
return; return start;
if (start & 0x300) { if (start & 0x300)
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = start;
}
} }
return start;
} }
EXPORT_SYMBOL(pcibios_align_resource); EXPORT_SYMBOL(pcibios_align_resource);
......
...@@ -148,8 +148,8 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus) ...@@ -148,8 +148,8 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
* addresses to be allocated in the 0x000-0x0ff region * addresses to be allocated in the 0x000-0x0ff region
* modulo 0x400. * modulo 0x400.
*/ */
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
struct pci_dev *dev = data; struct pci_dev *dev = data;
struct pci_channel *chan = dev->sysdata; struct pci_channel *chan = dev->sysdata;
...@@ -171,7 +171,7 @@ void pcibios_align_resource(void *data, struct resource *res, ...@@ -171,7 +171,7 @@ void pcibios_align_resource(void *data, struct resource *res,
start = PCIBIOS_MIN_MEM + chan->mem_resource->start; start = PCIBIOS_MIN_MEM + chan->mem_resource->start;
} }
res->start = start; return start;
} }
void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
......
...@@ -722,9 +722,10 @@ void pcibios_update_irq(struct pci_dev *pdev, int irq) ...@@ -722,9 +722,10 @@ void pcibios_update_irq(struct pci_dev *pdev, int irq)
{ {
} }
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
return res->start;
} }
int pcibios_enable_device(struct pci_dev *dev, int mask) int pcibios_enable_device(struct pci_dev *dev, int mask)
......
...@@ -768,9 +768,10 @@ char * __devinit pcibios_setup(char *str) ...@@ -768,9 +768,10 @@ char * __devinit pcibios_setup(char *str)
return str; return str;
} }
void pcibios_align_resource(void *data, struct resource *res, resource_size_t pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
return res->start;
} }
int pcibios_enable_device(struct pci_dev *pdev, int mask) int pcibios_enable_device(struct pci_dev *pdev, int mask)
......
...@@ -60,22 +60,20 @@ skip_isa_ioresource_align(struct pci_dev *dev) { ...@@ -60,22 +60,20 @@ skip_isa_ioresource_align(struct pci_dev *dev) {
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might have be mirrored at 0x0100-0x03ff.. * which might have be mirrored at 0x0100-0x03ff..
*/ */
void resource_size_t
pcibios_align_resource(void *data, struct resource *res, pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
struct pci_dev *dev = data; struct pci_dev *dev = data;
resource_size_t start = res->start;
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
resource_size_t start = res->start;
if (skip_isa_ioresource_align(dev)) if (skip_isa_ioresource_align(dev))
return; return start;
if (start & 0x300) { if (start & 0x300)
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = start;
}
} }
return start;
} }
EXPORT_SYMBOL(pcibios_align_resource); EXPORT_SYMBOL(pcibios_align_resource);
......
...@@ -69,26 +69,25 @@ static int pci_bus_count; ...@@ -69,26 +69,25 @@ static int pci_bus_count;
* but we want to try to avoid allocating at 0x2900-0x2bff * but we want to try to avoid allocating at 0x2900-0x2bff
* which might have be mirrored at 0x0100-0x03ff.. * which might have be mirrored at 0x0100-0x03ff..
*/ */
void resource_size_t
pcibios_align_resource(void *data, struct resource *res, resource_size_t size, pcibios_align_resource(void *data, struct resource *res, resource_size_t size,
resource_size_t align) resource_size_t align)
{ {
struct pci_dev *dev = data; struct pci_dev *dev = data;
resource_size_t start = res->start;
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
resource_size_t start = res->start;
if (size > 0x100) { if (size > 0x100) {
printk(KERN_ERR "PCI: I/O Region %s/%d too large" printk(KERN_ERR "PCI: I/O Region %s/%d too large"
" (%ld bytes)\n", pci_name(dev), " (%ld bytes)\n", pci_name(dev),
dev->resource - res, size); dev->resource - res, size);
} }
if (start & 0x300) { if (start & 0x300)
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = start;
}
} }
return start;
} }
int int
......
...@@ -36,8 +36,10 @@ int ...@@ -36,8 +36,10 @@ int
pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
resource_size_t size, resource_size_t align, resource_size_t size, resource_size_t align,
resource_size_t min, unsigned int type_mask, resource_size_t min, unsigned int type_mask,
void (*alignf)(void *, struct resource *, resource_size_t, resource_size_t (*alignf)(void *,
resource_size_t), struct resource *,
resource_size_t,
resource_size_t),
void *alignf_data) void *alignf_data)
{ {
int i, ret = -ENOMEM; int i, ret = -ENOMEM;
......
...@@ -114,22 +114,20 @@ struct pcmcia_align_data { ...@@ -114,22 +114,20 @@ struct pcmcia_align_data {
unsigned long offset; unsigned long offset;
}; };
static void pcmcia_align(void *align_data, struct resource *res, static resource_size_t pcmcia_align(void *align_data, struct resource *res,
unsigned long size, unsigned long align) resource_size_t size, resource_size_t align)
{ {
struct pcmcia_align_data *data = align_data; struct pcmcia_align_data *data = align_data;
unsigned long start; resource_size_t start;
start = (res->start & ~data->mask) + data->offset; start = (res->start & ~data->mask) + data->offset;
if (start < res->start) if (start < res->start)
start += data->mask + 1; start += data->mask + 1;
res->start = start;
#ifdef CONFIG_X86 #ifdef CONFIG_X86
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
if (start & 0x300) { if (start & 0x300) {
start = (start + 0x3ff) & ~0x3ff; start = (start + 0x3ff) & ~0x3ff;
res->start = start;
} }
} }
#endif #endif
...@@ -137,9 +135,11 @@ static void pcmcia_align(void *align_data, struct resource *res, ...@@ -137,9 +135,11 @@ static void pcmcia_align(void *align_data, struct resource *res,
#ifdef CONFIG_M68K #ifdef CONFIG_M68K
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
if ((res->start + size - 1) >= 1024) if ((res->start + size - 1) >= 1024)
res->start = res->end; start = res->end;
} }
#endif #endif
return start;
} }
......
...@@ -533,7 +533,7 @@ struct pcmcia_align_data { ...@@ -533,7 +533,7 @@ struct pcmcia_align_data {
struct resource_map *map; struct resource_map *map;
}; };
static void static resource_size_t
pcmcia_common_align(void *align_data, struct resource *res, pcmcia_common_align(void *align_data, struct resource *res,
resource_size_t size, resource_size_t align) resource_size_t size, resource_size_t align)
{ {
...@@ -545,17 +545,18 @@ pcmcia_common_align(void *align_data, struct resource *res, ...@@ -545,17 +545,18 @@ pcmcia_common_align(void *align_data, struct resource *res,
start = (res->start & ~data->mask) + data->offset; start = (res->start & ~data->mask) + data->offset;
if (start < res->start) if (start < res->start)
start += data->mask + 1; start += data->mask + 1;
res->start = start; return start;
} }
static void static resource_size_t
pcmcia_align(void *align_data, struct resource *res, resource_size_t size, pcmcia_align(void *align_data, struct resource *res, resource_size_t size,
resource_size_t align) resource_size_t align)
{ {
struct pcmcia_align_data *data = align_data; struct pcmcia_align_data *data = align_data;
struct resource_map *m; struct resource_map *m;
resource_size_t start;
pcmcia_common_align(data, res, size, align); start = pcmcia_common_align(data, res, size, align);
for (m = data->map->next; m != data->map; m = m->next) { for (m = data->map->next; m != data->map; m = m->next) {
unsigned long start = m->base; unsigned long start = m->base;
...@@ -567,8 +568,7 @@ pcmcia_align(void *align_data, struct resource *res, resource_size_t size, ...@@ -567,8 +568,7 @@ pcmcia_align(void *align_data, struct resource *res, resource_size_t size,
* fit here. * fit here.
*/ */
if (res->start < start) { if (res->start < start) {
res->start = start; start = pcmcia_common_align(data, res, size, align);
pcmcia_common_align(data, res, size, align);
} }
/* /*
...@@ -586,7 +586,9 @@ pcmcia_align(void *align_data, struct resource *res, resource_size_t size, ...@@ -586,7 +586,9 @@ pcmcia_align(void *align_data, struct resource *res, resource_size_t size,
* If we failed to find something suitable, ensure we fail. * If we failed to find something suitable, ensure we fail.
*/ */
if (m == data->map) if (m == data->map)
res->start = res->end; start = res->end;
return start;
} }
/* /*
......
...@@ -120,8 +120,10 @@ extern void insert_resource_expand_to_fit(struct resource *root, struct resource ...@@ -120,8 +120,10 @@ extern void insert_resource_expand_to_fit(struct resource *root, struct resource
extern int allocate_resource(struct resource *root, struct resource *new, extern int allocate_resource(struct resource *root, struct resource *new,
resource_size_t size, resource_size_t min, resource_size_t size, resource_size_t min,
resource_size_t max, resource_size_t align, resource_size_t max, resource_size_t align,
void (*alignf)(void *, struct resource *, resource_size_t (*alignf)(void *,
resource_size_t, resource_size_t), struct resource *,
resource_size_t,
resource_size_t),
void *alignf_data); void *alignf_data);
int adjust_resource(struct resource *res, resource_size_t start, int adjust_resource(struct resource *res, resource_size_t start,
resource_size_t size); resource_size_t size);
......
...@@ -592,7 +592,8 @@ int __must_check pcibios_enable_device(struct pci_dev *, int mask); ...@@ -592,7 +592,8 @@ int __must_check pcibios_enable_device(struct pci_dev *, int mask);
char *pcibios_setup(char *str); char *pcibios_setup(char *str);
/* Used only when drivers/pci/setup.c is used */ /* Used only when drivers/pci/setup.c is used */
void pcibios_align_resource(void *, struct resource *, resource_size_t, resource_size_t pcibios_align_resource(void *, struct resource *,
resource_size_t,
resource_size_t); resource_size_t);
void pcibios_update_irq(struct pci_dev *, int irq); void pcibios_update_irq(struct pci_dev *, int irq);
...@@ -827,8 +828,9 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus, ...@@ -827,8 +828,9 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
struct resource *res, resource_size_t size, struct resource *res, resource_size_t size,
resource_size_t align, resource_size_t min, resource_size_t align, resource_size_t min,
unsigned int type_mask, unsigned int type_mask,
void (*alignf)(void *, struct resource *, resource_size_t (*alignf)(void *, struct resource *,
resource_size_t, resource_size_t), resource_size_t,
resource_size_t),
void *alignf_data); void *alignf_data);
void pci_enable_bridges(struct pci_bus *bus); void pci_enable_bridges(struct pci_bus *bus);
......
...@@ -303,8 +303,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, ...@@ -303,8 +303,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
static int find_resource(struct resource *root, struct resource *new, static int find_resource(struct resource *root, struct resource *new,
resource_size_t size, resource_size_t min, resource_size_t size, resource_size_t min,
resource_size_t max, resource_size_t align, resource_size_t max, resource_size_t align,
void (*alignf)(void *, struct resource *, resource_size_t (*alignf)(void *,
resource_size_t, resource_size_t), struct resource *,
resource_size_t,
resource_size_t),
void *alignf_data) void *alignf_data)
{ {
struct resource *this = root->child; struct resource *this = root->child;
...@@ -330,7 +332,7 @@ static int find_resource(struct resource *root, struct resource *new, ...@@ -330,7 +332,7 @@ static int find_resource(struct resource *root, struct resource *new,
tmp.end = max; tmp.end = max;
tmp.start = ALIGN(tmp.start, align); tmp.start = ALIGN(tmp.start, align);
if (alignf) if (alignf)
alignf(alignf_data, &tmp, size, align); tmp.start = alignf(alignf_data, &tmp, size, align);
if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) { if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) {
new->start = tmp.start; new->start = tmp.start;
new->end = tmp.start + size - 1; new->end = tmp.start + size - 1;
...@@ -358,8 +360,10 @@ static int find_resource(struct resource *root, struct resource *new, ...@@ -358,8 +360,10 @@ static int find_resource(struct resource *root, struct resource *new,
int allocate_resource(struct resource *root, struct resource *new, int allocate_resource(struct resource *root, struct resource *new,
resource_size_t size, resource_size_t min, resource_size_t size, resource_size_t min,
resource_size_t max, resource_size_t align, resource_size_t max, resource_size_t align,
void (*alignf)(void *, struct resource *, resource_size_t (*alignf)(void *,
resource_size_t, resource_size_t), struct resource *,
resource_size_t,
resource_size_t),
void *alignf_data) void *alignf_data)
{ {
int err; int err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment