EXPORT_SYMBOL(iomem_resource);
-static rwlock_t resource_lock = RW_LOCK_UNLOCKED;
+static DEFINE_RWLOCK(resource_lock);
#ifdef CONFIG_PROC_FS
}
static void *r_start(struct seq_file *m, loff_t *pos)
+ __acquires(resource_lock)
{
struct resource *p = m->private;
loff_t l = 0;
}
static void r_stop(struct seq_file *m, void *v)
+ __releases(resource_lock)
{
read_unlock(&resource_lock);
}
return 0;
}
-struct seq_operations resource_op = {
+static struct seq_operations resource_op = {
.start = r_start,
.next = r_next,
.stop = r_stop,
new->start = min;
if (new->end > max)
new->end = max;
- new->start = (new->start + align - 1) & ~(align - 1);
+ new->start = ALIGN(new->start, align);
if (alignf)
alignf(alignf_data, new, size, align);
- if (new->start < new->end && new->end - new->start + 1 >= size) {
+ if (new->start < new->end && new->end - new->start >= size - 1) {
new->end = new->start + size - 1;
return 0;
}
*/
int insert_resource(struct resource *parent, struct resource *new)
{
- int result = 0;
+ int result;
struct resource *first, *next;
write_lock(&resource_lock);
begin:
+ result = 0;
first = __request_resource(parent, new);
if (!first)
goto out;
if (first == parent)
goto out;
- for (next = first; next->sibling; next = next->sibling)
+ /* Resource fully contained by the clashing resource? Recurse into it */
+ if (first->start <= new->start && first->end >= new->end) {
+ parent = first;
+ goto begin;
+ }
+
+ for (next = first; ; next = next->sibling) {
+ /* Partial overlap? Bad, and unfixable */
+ if (next->start < new->start || next->end > new->end)
+ goto out;
+ if (!next->sibling)
+ break;
if (next->sibling->start > new->end)
break;
-
- /* existing resource includes new resource */
- if (next->end >= new->end) {
- parent = next;
- result = 0;
- goto begin;
}
result = 0;
*/
struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name)
{
- struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL);
+ struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
if (res) {
- memset(res, 0, sizeof(*res));
res->name = name;
res->start = start;
res->end = start + n - 1;
EXPORT_SYMBOL(__request_region);
-int __deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n)
+int __check_region(struct resource *parent, unsigned long start, unsigned long n)
{
struct resource * res;