ia64: add checks for the return value of memblock_alloc*()
[sfrench/cifs-2.6.git] / arch / ia64 / kernel / mca.c
index 370bc349619a36bdd40f14a07e5eae2d615fcb5a..5cabb3fd159ffecd62b71d501338b635f332199c 100644 (file)
@@ -359,11 +359,6 @@ typedef struct ia64_state_log_s
 
 static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
 
-#define IA64_LOG_ALLOCATE(it, size) \
-       {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \
-               (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES); \
-       ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \
-               (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES);}
 #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock)
 #define IA64_LOG_LOCK(it)      spin_lock_irqsave(&ia64_state_log[it].isl_lock, s)
 #define IA64_LOG_UNLOCK(it)    spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s)
@@ -378,6 +373,19 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
 #define IA64_LOG_CURR_BUFFER(it)   (void *)((ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)]))
 #define IA64_LOG_COUNT(it)         ia64_state_log[it].isl_count
 
+static inline void ia64_log_allocate(int it, u64 size)
+{
+       ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] =
+               (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES);
+       if (!ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)])
+               panic("%s: Failed to allocate %llu bytes\n", __func__, size);
+
+       ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] =
+               (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES);
+       if (!ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)])
+               panic("%s: Failed to allocate %llu bytes\n", __func__, size);
+}
+
 /*
  * ia64_log_init
  *     Reset the OS ia64 log buffer
@@ -399,7 +407,7 @@ ia64_log_init(int sal_info_type)
                return;
 
        // set up OS data structures to hold error info
-       IA64_LOG_ALLOCATE(sal_info_type, max_size);
+       ia64_log_allocate(sal_info_type, max_size);
 }
 
 /*