software node: allow embedding of small arrays into property_entry
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 8 Nov 2019 04:22:21 +0000 (20:22 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 3 Dec 2019 10:46:19 +0000 (11:46 +0100)
commit996b0830f95d132e50891a5568fef9e2965e4af2
treed3e36383f0501db16b19b2f7f3eded9bd7b14d0f
parente6bff4665c595b5a4aff173848851ed49ac3bfad
software node: allow embedding of small arrays into property_entry

We should not conflate whether a property data is an array or a single
value with where it is stored (embedded into property_entry structure or
out-of-line). All single-value properties are in effect 1-element
arrays, and we can figure the amount of data stored in a property by
examining its length and the data type. And arrays can be as easily
stored in property entry instances as single values are, provided that
we have enough space (we have up to 8 bytes). We can embed:

 - up to 8 bytes from U8 arrays
 - up to 4 words
 - up to 2 double words
 - one U64 value
 - one (on 64 bit architectures) or 2 (on 32 bit) strings.

This change also has an effect of switching properties with small amount
of data to embed it instead of keeping it separate when copying such
properties.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/swnode.c
include/linux/property.h