lkml.org 
[lkml]   [2021]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 2/5] regmap: Altered regmap_X_X_write functions to account for padding bits
    Date
    From: Christopher Tyerman <c.tyerman@firebladeautomationsystems.co.uk>

    modified: drivers/base/regmap/regmap.c

    Signed-off-by: Christopher Tyerman <c.tyerman@firebladeautomationsystems.co.uk>
    ---
    drivers/base/regmap/regmap.c | 22 ++++++++++++++++------
    1 file changed, 16 insertions(+), 6 deletions(-)

    diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
    index 05c104659381..07d6d804c4b9 100644
    --- a/drivers/base/regmap/regmap.c
    +++ b/drivers/base/regmap/regmap.c
    @@ -232,42 +232,52 @@ static void regmap_format_2_6_write(struct regmap *map,
    unsigned int reg, unsigned int val)
    {
    u8 *out = map->work_buf;
    + u8 shift = map->reg_shift;

    - *out = (reg << 6) | val;
    + *out = (reg << (6 + shift) | val);
    }

    static void regmap_format_4_12_write(struct regmap *map,
    unsigned int reg, unsigned int val)
    {
    + u8 shift = map->reg_shift;
    __be16 *out = map->work_buf;
    - *out = cpu_to_be16((reg << 12) | val);
    +
    + *out = cpu_to_be16((reg << (12 + shift)) | val);
    }

    static void regmap_format_7_9_write(struct regmap *map,
    unsigned int reg, unsigned int val)
    {
    + u8 shift = map->reg_shift;
    __be16 *out = map->work_buf;
    - *out = cpu_to_be16((reg << 9) | val);
    +
    + *out = cpu_to_be16((reg << (9 + shift)) | val);
    }

    static void regmap_format_7_17_write(struct regmap *map,
    unsigned int reg, unsigned int val)
    {
    + u8 shift = map->reg_shift;
    u8 *out = map->work_buf;

    out[2] = val;
    out[1] = val >> 8;
    - out[0] = (val >> 16) | (reg << 1);
    + out[0] = (val >> 16) | (reg << (1 + shift));
    }

    static void regmap_format_10_14_write(struct regmap *map,
    unsigned int reg, unsigned int val)
    {
    + u8 shift = map->reg_shift;
    u8 *out = map->work_buf;

    out[2] = val;
    - out[1] = (val >> 8) | (reg << 6);
    - out[0] = reg >> 2;
    + out[1] = (val >> 8) | (reg << (6 + shift));
    + if (shift <= 2)
    + out[0] = reg >> (2 - shift);
    + else
    + out[0] = reg << shift;
    }

    static void regmap_format_8(void *buf, unsigned int val, unsigned int shift)
    --
    2.25.1
    \
     
     \ /
      Last update: 2021-12-17 23:43    [W:3.115 / U:0.416 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site