* Arbitrary resource management.
*/
+#include <linux/config.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/errno.h>
struct resource ioport_resource = {
.name = "PCI IO",
- .start = 0,
+ .start = 0x0000,
.end = IO_SPACE_LIMIT,
.flags = IORESOURCE_IO,
};
+
EXPORT_SYMBOL(ioport_resource);
struct resource iomem_resource = {
.name = "PCI mem",
- .start = 0,
- .end = -1,
+ .start = 0UL,
+ .end = ~0UL,
.flags = IORESOURCE_MEM,
};
+
EXPORT_SYMBOL(iomem_resource);
static DEFINE_RWLOCK(resource_lock);
for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
if (p->parent == root)
break;
- seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
+ seq_printf(m, "%*s%0*lx-%0*lx : %s\n",
depth * 2, "",
- width, (unsigned long long) r->start,
- width, (unsigned long long) r->end,
+ width, r->start,
+ width, r->end,
r->name ? r->name : "<BAD>");
return 0;
}
/* Return the conflict entry if you can't request it */
static struct resource * __request_resource(struct resource *root, struct resource *new)
{
- resource_size_t start = new->start;
- resource_size_t end = new->end;
+ unsigned long start = new->start;
+ unsigned long end = new->end;
struct resource *tmp, **p;
if (end < start)
EXPORT_SYMBOL(release_resource);
-#ifdef CONFIG_MEMORY_HOTPLUG
-/*
- * Finds the lowest memory reosurce exists within [res->start.res->end)
- * the caller must specify res->start, res->end, res->flags.
- * If found, returns 0, res is overwritten, if not found, returns -1.
- */
-int find_next_system_ram(struct resource *res)
-{
- resource_size_t start, end;
- struct resource *p;
-
- BUG_ON(!res);
-
- start = res->start;
- end = res->end;
- BUG_ON(start >= end);
-
- read_lock(&resource_lock);
- for (p = iomem_resource.child; p ; p = p->sibling) {
- /* system ram is just marked as IORESOURCE_MEM */
- if (p->flags != res->flags)
- continue;
- if (p->start > end) {
- p = NULL;
- break;
- }
- if ((p->end >= start) && (p->start < end))
- break;
- }
- read_unlock(&resource_lock);
- if (!p)
- return -1;
- /* copy data */
- if (res->start < p->start)
- res->start = p->start;
- if (res->end > p->end)
- res->end = p->end;
- return 0;
-}
-#endif
-
/*
* Find empty slot in the resource tree given range and alignment.
*/
static int find_resource(struct resource *root, struct resource *new,
- resource_size_t size, resource_size_t min,
- resource_size_t max, resource_size_t align,
+ unsigned long size,
+ unsigned long min, unsigned long max,
+ unsigned long align,
void (*alignf)(void *, struct resource *,
- resource_size_t, resource_size_t),
+ unsigned long, unsigned long),
void *alignf_data)
{
struct resource *this = root->child;
* Allocate empty slot in the resource tree given range and alignment.
*/
int allocate_resource(struct resource *root, struct resource *new,
- resource_size_t size, resource_size_t min,
- resource_size_t max, resource_size_t align,
+ unsigned long size,
+ unsigned long min, unsigned long max,
+ unsigned long align,
void (*alignf)(void *, struct resource *,
- resource_size_t, resource_size_t),
+ unsigned long, unsigned long),
void *alignf_data)
{
int err;
return result;
}
+EXPORT_SYMBOL(insert_resource);
+
/*
* Given an existing resource, change its start and size to match the
* arguments. Returns -EBUSY if it can't fit. Existing children of
* the resource are assumed to be immutable.
*/
-int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size)
+int adjust_resource(struct resource *res, unsigned long start, unsigned long size)
{
struct resource *tmp, *parent = res->parent;
- resource_size_t end = start + size - 1;
+ unsigned long end = start + size - 1;
int result = -EBUSY;
write_lock(&resource_lock);
*
* Release-region releases a matching busy region.
*/
-struct resource * __request_region(struct resource *parent,
- resource_size_t start, resource_size_t n,
- const char *name)
+struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name)
{
struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
EXPORT_SYMBOL(__request_region);
-int __check_region(struct resource *parent, resource_size_t start,
- resource_size_t n)
+int __check_region(struct resource *parent, unsigned long start, unsigned long n)
{
struct resource * res;
EXPORT_SYMBOL(__check_region);
-void __release_region(struct resource *parent, resource_size_t start,
- resource_size_t n)
+void __release_region(struct resource *parent, unsigned long start, unsigned long n)
{
struct resource **p;
- resource_size_t end;
+ unsigned long end;
p = &parent->child;
end = start + n - 1;
write_unlock(&resource_lock);
- printk(KERN_WARNING "Trying to free nonexistent resource "
- "<%016llx-%016llx>\n", (unsigned long long)start,
- (unsigned long long)end);
+ printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end);
}
EXPORT_SYMBOL(__release_region);