]> git.baikalelectronics.ru Git - kernel.git/commit
of: Add array read functions with min/max size limits
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Mon, 12 Sep 2016 13:01:29 +0000 (14:01 +0100)
committerRob Herring <robh@kernel.org>
Thu, 15 Sep 2016 13:33:01 +0000 (08:33 -0500)
commitc5f460bf6fed3a5b5615626351d8cde8c564dc9c
tree0e6b3da989b014b7eece1b4222f189de76c43bae
parente01419817df514b409d5d87d5a9163fefdff8a9c
of: Add array read functions with min/max size limits

Add a new set of array reading functions that take a minimum and
maximum size limit and will fail if the property size is not within
the size limits. This makes it more convenient for drivers that
use variable-size DT arrays which must be bounded at both ends -
data must be at least N entries but must not overflow the array
it is being copied into. It is also more efficient than making this
functionality out of existing public functions and avoids duplication.

The existing array functions have been left in the API, since there
are a very large number of clients of those functions and their
existing functionality is still useful. This avoids turning a small
API improvement into a major kernel rework.

The old functions have been turned into mininmal static inlines calling
the new functions. The old functions had no upper limit on the actual
size of the dts entry, to preserve this functionality rather than keeping
two near-identical implementations, if the new function is called with
max=0 there is no limit on the size of the dts entry but only the min
number of elements are read.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/base.c
include/linux/of.h