Merge remote-tracking branches 'regmap/topic/irq', 'regmap/topic/le', 'regmap/topic...
authorMark Brown <broonie@linaro.org>
Mon, 2 Jun 2014 16:07:39 +0000 (17:07 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 2 Jun 2014 16:07:39 +0000 (17:07 +0100)
1  2  3  4  5 
drivers/base/regmap/regmap-mmio.c
drivers/base/regmap/regmap.c

index 902c4fb5c760b2fd589618f6d2c68a3ae54ffe4e,1e03e7f8bacb220a47d0edf29700f6a1814fc21e,1e03e7f8bacb220a47d0edf29700f6a1814fc21e,dff32c6b247441ca3af0f51302344f9fb7e70776,1e03e7f8bacb220a47d0edf29700f6a1814fc21e..04a329a377e96b585dd074e2e16340d954e908a4
@@@@@@ -61,17 -61,17 -61,17 -61,36 -61,17 +61,36 @@@@@@ static int regmap_mmio_regbits_check(si
        }
     }
     
 ----static inline void regmap_mmio_count_check(size_t count)
 ++++static inline void regmap_mmio_count_check(size_t count, u32 offset)
     {
 ----   BUG_ON(count % 2 != 0);
 ++++   BUG_ON(count <= offset);
 ++ +}
 ++ +
+++ +static inline unsigned int
+++ +regmap_mmio_get_offset(const void *reg, size_t reg_size)
+++ +{
+++ +   switch (reg_size) {
+++ +   case 1:
+++ +           return *(u8 *)reg;
+++ +   case 2:
+++ +           return *(u16 *)reg;
+++ +   case 4:
+++ +           return *(u32 *)reg;
+++ +#ifdef CONFIG_64BIT
+++ +   case 8:
+++ +           return *(u64 *)reg;
+++ +#endif
+++ +   default:
+++ +           BUG();
+++ +   }
+    }
+    
     static int regmap_mmio_gather_write(void *context,
                                    const void *reg, size_t reg_size,
                                    const void *val, size_t val_size)
     {
        struct regmap_mmio_context *ctx = context;
--- -   u32 offset;
+++ +   unsigned int offset;
        int ret;
     
        regmap_mmio_regsize_check(reg_size);
                        return ret;
        }
     
--- -   offset = *(u32 *)reg;
+++ +   offset = regmap_mmio_get_offset(reg, reg_size);
     
        while (val_size) {
                switch (ctx->val_bytes) {
     static int regmap_mmio_write(void *context, const void *data, size_t count)
     {
        struct regmap_mmio_context *ctx = context;
--- -   u32 offset = ctx->reg_bytes + ctx->pad_bytes;
+++ +   unsigned int offset = ctx->reg_bytes + ctx->pad_bytes;
     
 ----   regmap_mmio_count_check(count);
 ++++   regmap_mmio_count_check(count, offset);
     
        return regmap_mmio_gather_write(context, data, ctx->reg_bytes,
                                        data + offset, count - offset);
@@@@@@ -131,7 -131,7 -131,7 -150,7 -131,7 +150,7 @@@@@@ static int regmap_mmio_read(void *conte
                            void *val, size_t val_size)
     {
        struct regmap_mmio_context *ctx = context;
--- -   u32 offset;
+++ +   unsigned int offset;
        int ret;
     
        regmap_mmio_regsize_check(reg_size);
                        return ret;
        }
     
--- -   offset = *(u32 *)reg;
+++ +   offset = regmap_mmio_get_offset(reg, reg_size);
     
        while (val_size) {
                switch (ctx->val_bytes) {
index 35869755d46491cee13a6e4d3da7806388a8f485,63e30ef096e2be5e16a1e989bba22dd3b6c69f8d,a1beffb4b066c260f14a53091f893edc9cde38c6,63e30ef096e2be5e16a1e989bba22dd3b6c69f8d,63e30ef096e2be5e16a1e989bba22dd3b6c69f8d..2615cc180d35401961304eb94d60144241efa147
@@@@@@ -192,6 -192,6 -192,13 -192,6 -192,6 +192,13 @@@@@@ static void regmap_format_16_be(void *b
        b[0] = cpu_to_be16(val << shift);
     }
     
++ ++static void regmap_format_16_le(void *buf, unsigned int val, unsigned int shift)
++ ++{
++ ++   __le16 *b = buf;
++ ++
++ ++   b[0] = cpu_to_le16(val << shift);
++ ++}
++ ++
     static void regmap_format_16_native(void *buf, unsigned int val,
                                    unsigned int shift)
     {
@@@@@@ -216,6 -216,6 -223,13 -216,6 -216,6 +223,13 @@@@@@ static void regmap_format_32_be(void *b
        b[0] = cpu_to_be32(val << shift);
     }
     
++ ++static void regmap_format_32_le(void *buf, unsigned int val, unsigned int shift)
++ ++{
++ ++   __le32 *b = buf;
++ ++
++ ++   b[0] = cpu_to_le32(val << shift);
++ ++}
++ ++
     static void regmap_format_32_native(void *buf, unsigned int val,
                                    unsigned int shift)
     {
@@@@@@ -240,6 -240,6 -254,13 -240,6 -240,6 +254,13 @@@@@@ static unsigned int regmap_parse_16_be(
        return be16_to_cpu(b[0]);
     }
     
++ ++static unsigned int regmap_parse_16_le(const void *buf)
++ ++{
++ ++   const __le16 *b = buf;
++ ++
++ ++   return le16_to_cpu(b[0]);
++ ++}
++ ++
     static void regmap_parse_16_be_inplace(void *buf)
     {
        __be16 *b = buf;
        b[0] = be16_to_cpu(b[0]);
     }
     
++ ++static void regmap_parse_16_le_inplace(void *buf)
++ ++{
++ ++   __le16 *b = buf;
++ ++
++ ++   b[0] = le16_to_cpu(b[0]);
++ ++}
++ ++
     static unsigned int regmap_parse_16_native(const void *buf)
     {
        return *(u16 *)buf;
@@@@@@ -269,6 -269,6 -297,13 -269,6 -269,6 +297,13 @@@@@@ static unsigned int regmap_parse_32_be(
        return be32_to_cpu(b[0]);
     }
     
++ ++static unsigned int regmap_parse_32_le(const void *buf)
++ ++{
++ ++   const __le32 *b = buf;
++ ++
++ ++   return le32_to_cpu(b[0]);
++ ++}
++ ++
     static void regmap_parse_32_be_inplace(void *buf)
     {
        __be32 *b = buf;
        b[0] = be32_to_cpu(b[0]);
     }
     
++ ++static void regmap_parse_32_le_inplace(void *buf)
++ ++{
++ ++   __le32 *b = buf;
++ ++
++ ++   b[0] = le32_to_cpu(b[0]);
++ ++}
++ ++
     static unsigned int regmap_parse_32_native(const void *buf)
     {
        return *(u32 *)buf;
@@@@@@ -608,6 -608,6 -650,11 -608,6 -608,6 +650,11 @@@@@@ struct regmap *regmap_init(struct devic
                        map->format.parse_val = regmap_parse_16_be;
                        map->format.parse_inplace = regmap_parse_16_be_inplace;
                        break;
++ ++           case REGMAP_ENDIAN_LITTLE:
++ ++                   map->format.format_val = regmap_format_16_le;
++ ++                   map->format.parse_val = regmap_parse_16_le;
++ ++                   map->format.parse_inplace = regmap_parse_16_le_inplace;
++ ++                   break;
                case REGMAP_ENDIAN_NATIVE:
                        map->format.format_val = regmap_format_16_native;
                        map->format.parse_val = regmap_parse_16_native;
                        map->format.parse_val = regmap_parse_32_be;
                        map->format.parse_inplace = regmap_parse_32_be_inplace;
                        break;
++ ++           case REGMAP_ENDIAN_LITTLE:
++ ++                   map->format.format_val = regmap_format_32_le;
++ ++                   map->format.parse_val = regmap_parse_32_le;
++ ++                   map->format.parse_inplace = regmap_parse_32_le_inplace;
++ ++                   break;
                case REGMAP_ENDIAN_NATIVE:
                        map->format.format_val = regmap_format_32_native;
                        map->format.parse_val = regmap_parse_32_native;
@@@@@@ -1615,9 -1615,6 -1667,6 -1615,6 -1615,6 +1667,9 @@@@@@ static int _regmap_raw_multi_reg_write(
        size_t pair_size = reg_bytes + pad_bytes + val_bytes;
        size_t len = pair_size * num_regs;
     
 ++++   if (!len)
 ++++           return -EINVAL;
 ++++
        buf = kzalloc(len, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
@@@@@@ -1665,7 -1662,7 -1714,7 -1662,7 -1662,7 +1717,7 @@@@@@ static int _regmap_range_multi_paged_re
        int ret;
        int i, n;
        struct reg_default *base;
 ----   unsigned int this_page;
 ++++   unsigned int this_page = 0;
        /*
         * the set of registers are not neccessarily in order, but
         * since the order of write must be preserved this algorithm