lkml.org 
[lkml]   [2019]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v5 11/14] software node: move small properties inline when copying
    Date
    When copying/duplicating set of properties, move smaller properties that
    were stored separately directly inside property entry structures. We can
    move:

    - up to 8 bytes from U8 arrays
    - up to 4 words
    - up to 2 double words
    - one U64 value
    - one or 2 strings.

    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    ---
    drivers/base/swnode.c | 10 ++++++++++
    1 file changed, 10 insertions(+)

    diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
    index ae4b24ee2a54..546fc1b20095 100644
    --- a/drivers/base/swnode.c
    +++ b/drivers/base/swnode.c
    @@ -277,6 +277,16 @@ static int property_entry_copy_data(struct property_entry *dst,
    dst->value = src->value;
    }

    + if (!dst->is_inline && dst->length <= sizeof(dst->value)) {
    + /* We have an opportunity to move the data inline */
    + const void *tmp = dst->pointer;
    +
    + memcpy(&dst->value, tmp, dst->length);
    + dst->is_inline = true;
    +
    + kfree(tmp);
    + }
    +
    dst->length = src->length;
    dst->type = src->type;
    dst->name = kstrdup(src->name, GFP_KERNEL);
    --
    2.23.0.700.g56cf767bdb-goog
    \
     
     \ /
      Last update: 2019-10-12 01:08    [W:4.379 / U:0.204 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site