USB: serial: usb_debug: add new USB device id
[linux-2.6-block.git] / mm / memblock.c
index 91205780e6b151f8239574c5f97b8d5ebc89b59f..46aacdfa4f4d70711fefc6191e57bd7b6f1e45d3 100644 (file)
@@ -533,7 +533,7 @@ repeat:
        base = obase;
        nr_new = 0;
 
-       for_each_memblock_type(type, rgn) {
+       for_each_memblock_type(idx, type, rgn) {
                phys_addr_t rbase = rgn->base;
                phys_addr_t rend = rbase + rgn->size;
 
@@ -637,7 +637,7 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type,
                if (memblock_double_array(type, base, size) < 0)
                        return -ENOMEM;
 
-       for_each_memblock_type(type, rgn) {
+       for_each_memblock_type(idx, type, rgn) {
                phys_addr_t rbase = rgn->base;
                phys_addr_t rend = rbase + rgn->size;
 
@@ -1327,7 +1327,6 @@ again:
        return NULL;
 done:
        ptr = phys_to_virt(alloc);
-       memset(ptr, 0, size);
 
        /*
         * The min_count is set to 0 so that bootmem allocated blocks
@@ -1340,6 +1339,45 @@ done:
        return ptr;
 }
 
+/**
+ * memblock_virt_alloc_try_nid_raw - allocate boot memory block without zeroing
+ * memory and without panicking
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @min_addr: the lower bound of the memory region from where the allocation
+ *       is preferred (phys address)
+ * @max_addr: the upper bound of the memory region from where the allocation
+ *           is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to
+ *           allocate only from memory limited by memblock.current_limit value
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
+ *
+ * Public function, provides additional debug information (including caller
+ * info), if enabled. Does not zero allocated memory, does not panic if request
+ * cannot be satisfied.
+ *
+ * RETURNS:
+ * Virtual address of allocated memory block on success, NULL on failure.
+ */
+void * __init memblock_virt_alloc_try_nid_raw(
+                       phys_addr_t size, phys_addr_t align,
+                       phys_addr_t min_addr, phys_addr_t max_addr,
+                       int nid)
+{
+       void *ptr;
+
+       memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx %pF\n",
+                    __func__, (u64)size, (u64)align, nid, (u64)min_addr,
+                    (u64)max_addr, (void *)_RET_IP_);
+
+       ptr = memblock_virt_alloc_internal(size, align,
+                                          min_addr, max_addr, nid);
+#ifdef CONFIG_DEBUG_VM
+       if (ptr && size > 0)
+               memset(ptr, 0xff, size);
+#endif
+       return ptr;
+}
+
 /**
  * memblock_virt_alloc_try_nid_nopanic - allocate boot memory block
  * @size: size of memory block to be allocated in bytes
@@ -1351,8 +1389,8 @@ done:
  *           allocate only from memory limited by memblock.current_limit value
  * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
  *
- * Public version of _memblock_virt_alloc_try_nid_nopanic() which provides
- * additional debug information (including caller info), if enabled.
+ * Public function, provides additional debug information (including caller
+ * info), if enabled. This function zeroes the allocated memory.
  *
  * RETURNS:
  * Virtual address of allocated memory block on success, NULL on failure.
@@ -1362,11 +1400,17 @@ void * __init memblock_virt_alloc_try_nid_nopanic(
                                phys_addr_t min_addr, phys_addr_t max_addr,
                                int nid)
 {
+       void *ptr;
+
        memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx %pF\n",
                     __func__, (u64)size, (u64)align, nid, (u64)min_addr,
                     (u64)max_addr, (void *)_RET_IP_);
-       return memblock_virt_alloc_internal(size, align, min_addr,
-                                            max_addr, nid);
+
+       ptr = memblock_virt_alloc_internal(size, align,
+                                          min_addr, max_addr, nid);
+       if (ptr)
+               memset(ptr, 0, size);
+       return ptr;
 }
 
 /**
@@ -1380,7 +1424,7 @@ void * __init memblock_virt_alloc_try_nid_nopanic(
  *           allocate only from memory limited by memblock.current_limit value
  * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
  *
- * Public panicking version of _memblock_virt_alloc_try_nid_nopanic()
+ * Public panicking version of memblock_virt_alloc_try_nid_nopanic()
  * which provides debug information (including caller info), if enabled,
  * and panics if the request can not be satisfied.
  *
@@ -1399,8 +1443,10 @@ void * __init memblock_virt_alloc_try_nid(
                     (u64)max_addr, (void *)_RET_IP_);
        ptr = memblock_virt_alloc_internal(size, align,
                                           min_addr, max_addr, nid);
-       if (ptr)
+       if (ptr) {
+               memset(ptr, 0, size);
                return ptr;
+       }
 
        panic("%s: Failed to allocate %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx\n",
              __func__, (u64)size, (u64)align, nid, (u64)min_addr,
@@ -1715,7 +1761,7 @@ static void __init_memblock memblock_dump(struct memblock_type *type)
 
        pr_info(" %s.cnt  = 0x%lx\n", type->name, type->cnt);
 
-       for_each_memblock_type(type, rgn) {
+       for_each_memblock_type(idx, type, rgn) {
                char nid_buf[32] = "";
 
                base = rgn->base;
@@ -1739,7 +1785,7 @@ memblock_reserved_memory_within(phys_addr_t start_addr, phys_addr_t end_addr)
        unsigned long size = 0;
        int idx;
 
-       for_each_memblock_type((&memblock.reserved), rgn) {
+       for_each_memblock_type(idx, (&memblock.reserved), rgn) {
                phys_addr_t start, end;
 
                if (rgn->base + rgn->size < start_addr)