aboutsummaryrefslogtreecommitdiff
path: root/lib/flex_array.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-03-06 17:44:28 +0800
committerMark Brown <broonie@linaro.org>2014-03-06 17:44:28 +0800
commitd083f580e5b940834a93ab741cdf064f0324dc0f (patch)
treed034075e47d68179d2f8bf7220d26bef0ba740d3 /lib/flex_array.c
parent931f27c6e892fdfe98896055e0df7962e21969d9 (diff)
parent13ff50c85846338bb9820abd3933227b678dc086 (diff)
Merge tag 'parse-val' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into asoc-core
regmap: Add parse_val() API This is useful for generic code built on top of regmap dealing with blocks of data.
Diffstat (limited to 'lib/flex_array.c')
-rw-r--r--lib/flex_array.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/flex_array.c b/lib/flex_array.c
index 6948a6692fc4..2eed22fa507c 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -90,8 +90,8 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
{
struct flex_array *ret;
int elems_per_part = 0;
- int reciprocal_elems = 0;
int max_size = 0;
+ struct reciprocal_value reciprocal_elems = { 0 };
if (element_size) {
elems_per_part = FLEX_ARRAY_ELEMENTS_PER_PART(element_size);
@@ -119,6 +119,11 @@ EXPORT_SYMBOL(flex_array_alloc);
static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
{
+ /*
+ * if element_size == 0 we don't get here, so we never touch
+ * the zeroed fa->reciprocal_elems, which would yield invalid
+ * results
+ */
return reciprocal_divide(element_nr, fa->reciprocal_elems);
}