Skip to content

Commit

Permalink
flex_array: export symbols to modules
Browse files Browse the repository at this point in the history
Alex said:

  I want to use flex_array to store a sparse array of ATM cell
  re-assembly buffers for my ATM over Ethernet driver.  Using the per-vcc
  user_back structure causes problems when stacked with things like
  br2684.

Add EXPORT_SYMBOL() for all publically accessible flex array functions
and move to obj-y so that modules may use this library.

Signed-off-by: David Rientjes <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Paul Mundt <[email protected]>
Reported-by: Alex Bennee <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rientjes authored and torvalds committed Jan 13, 2011
1 parent 7348257 commit 78c377d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
idr.o int_sqrt.o extable.o prio_tree.o \
sha1.o irq_regs.o reciprocal_div.o argv_split.o \
proportions.o prio_heap.o ratelimit.o show_mem.o \
is_single_threaded.o plist.o decompress.o flex_array.o
is_single_threaded.o plist.o decompress.o

lib-$(CONFIG_MMU) += ioremap.o
lib-$(CONFIG_SMP) += cpumask.o
Expand All @@ -21,7 +21,7 @@ lib-y += kobject.o kref.o klist.o

obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
string_helpers.o gcd.o lcm.o list_sort.o uuid.o
string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o

ifeq ($(CONFIG_DEBUG_KOBJECT),y)
CFLAGS_kobject.o += -DDEBUG
Expand Down
10 changes: 10 additions & 0 deletions lib/flex_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/flex_array.h>
#include <linux/slab.h>
#include <linux/stddef.h>
#include <linux/module.h>

struct flex_array_part {
char elements[FLEX_ARRAY_PART_SIZE];
Expand Down Expand Up @@ -103,6 +104,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
FLEX_ARRAY_BASE_BYTES_LEFT);
return ret;
}
EXPORT_SYMBOL(flex_array_alloc);

static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
Expand All @@ -126,12 +128,14 @@ void flex_array_free_parts(struct flex_array *fa)
for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++)
kfree(fa->parts[part_nr]);
}
EXPORT_SYMBOL(flex_array_free_parts);

void flex_array_free(struct flex_array *fa)
{
flex_array_free_parts(fa);
kfree(fa);
}
EXPORT_SYMBOL(flex_array_free);

static unsigned int index_inside_part(struct flex_array *fa,
unsigned int element_nr)
Expand Down Expand Up @@ -196,6 +200,7 @@ int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
memcpy(dst, src, fa->element_size);
return 0;
}
EXPORT_SYMBOL(flex_array_put);

/**
* flex_array_clear - clear element in array at @element_nr
Expand Down Expand Up @@ -223,6 +228,7 @@ int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
memset(dst, FLEX_ARRAY_FREE, fa->element_size);
return 0;
}
EXPORT_SYMBOL(flex_array_clear);

/**
* flex_array_prealloc - guarantee that array space exists
Expand Down Expand Up @@ -259,6 +265,7 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
}
return 0;
}
EXPORT_SYMBOL(flex_array_prealloc);

/**
* flex_array_get - pull data back out of the array
Expand Down Expand Up @@ -288,6 +295,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
}
return &part->elements[index_inside_part(fa, element_nr)];
}
EXPORT_SYMBOL(flex_array_get);

/**
* flex_array_get_ptr - pull a ptr back out of the array
Expand All @@ -308,6 +316,7 @@ void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr)

return *tmp;
}
EXPORT_SYMBOL(flex_array_get_ptr);

static int part_is_free(struct flex_array_part *part)
{
Expand Down Expand Up @@ -348,3 +357,4 @@ int flex_array_shrink(struct flex_array *fa)
}
return ret;
}
EXPORT_SYMBOL(flex_array_shrink);

0 comments on commit 78c377d

Please sign in to comment.