ARM: dts: Cygnus: Update PCIe PHY node unit name(s)
[linux-2.6-microblaze.git] / lib / stackdepot.c
index 09485dc..b437ae7 100644 (file)
@@ -213,6 +213,49 @@ static inline struct stack_record *find_stack(struct stack_record *bucket,
        return NULL;
 }
 
+/**
+ * stack_depot_snprint - print stack entries from a depot into a buffer
+ *
+ * @handle:    Stack depot handle which was returned from
+ *             stack_depot_save().
+ * @buf:       Pointer to the print buffer
+ *
+ * @size:      Size of the print buffer
+ *
+ * @spaces:    Number of leading spaces to print
+ *
+ * Return:     Number of bytes printed.
+ */
+int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
+                      int spaces)
+{
+       unsigned long *entries;
+       unsigned int nr_entries;
+
+       nr_entries = stack_depot_fetch(handle, &entries);
+       return nr_entries ? stack_trace_snprint(buf, size, entries, nr_entries,
+                                               spaces) : 0;
+}
+EXPORT_SYMBOL_GPL(stack_depot_snprint);
+
+/**
+ * stack_depot_print - print stack entries from a depot
+ *
+ * @stack:             Stack depot handle which was returned from
+ *                     stack_depot_save().
+ *
+ */
+void stack_depot_print(depot_stack_handle_t stack)
+{
+       unsigned long *entries;
+       unsigned int nr_entries;
+
+       nr_entries = stack_depot_fetch(stack, &entries);
+       if (nr_entries > 0)
+               stack_trace_print(entries, nr_entries, 0);
+}
+EXPORT_SYMBOL_GPL(stack_depot_print);
+
 /**
  * stack_depot_fetch - Fetch stack entries from a depot
  *
@@ -231,6 +274,9 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle,
        struct stack_record *stack;
 
        *entries = NULL;
+       if (!handle)
+               return 0;
+
        if (parts.slabindex > depot_index) {
                WARN(1, "slab index %d out of bounds (%d) for stack id %08x\n",
                        parts.slabindex, depot_index, handle);