]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'regmap/fix/raw' into regmap-linus
authorMark Brown <broonie@kernel.org>
Sat, 5 Mar 2016 12:30:22 +0000 (21:30 +0900)
committerMark Brown <broonie@kernel.org>
Sat, 5 Mar 2016 12:30:22 +0000 (21:30 +0900)
1  2 
drivers/base/regmap/regcache.c

index 348be3a354108eb2533587dabed9495e9c324b5a,45ae91eb6be9cda1af96554f65a8e4020cffcf0c..5c5090b68939f842bce9ba58b9c42e3b960d2172
@@@ -57,7 -57,7 +57,7 @@@ static int regcache_hw_init(struct regm
                bool cache_bypass = map->cache_bypass;
                dev_warn(map->dev, "No cache defaults, reading back from HW\n");
  
-               /* Bypass the cache access till data read from HW*/
+               /* Bypass the cache access till data read from HW */
                map->cache_bypass = true;
                tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL);
                if (!tmp_buf) {
@@@ -65,7 -65,7 +65,7 @@@
                        goto err_free;
                }
                ret = regmap_raw_read(map, 0, tmp_buf,
-                                     map->num_reg_defaults_raw);
+                                     map->cache_size_raw);
                map->cache_bypass = cache_bypass;
                if (ret < 0)
                        goto err_cache_free;
@@@ -100,25 -100,15 +100,25 @@@ int regcache_init(struct regmap *map, c
        int i;
        void *tmp_buf;
  
 -      for (i = 0; i < config->num_reg_defaults; i++)
 -              if (config->reg_defaults[i].reg % map->reg_stride)
 -                      return -EINVAL;
 -
        if (map->cache_type == REGCACHE_NONE) {
 +              if (config->reg_defaults || config->num_reg_defaults_raw)
 +                      dev_warn(map->dev,
 +                               "No cache used with register defaults set!\n");
 +
                map->cache_bypass = true;
                return 0;
        }
  
 +      if (config->reg_defaults && !config->num_reg_defaults) {
 +              dev_err(map->dev,
 +                       "Register defaults are set without the number!\n");
 +              return -EINVAL;
 +      }
 +
 +      for (i = 0; i < config->num_reg_defaults; i++)
 +              if (config->reg_defaults[i].reg % map->reg_stride)
 +                      return -EINVAL;
 +
        for (i = 0; i < ARRAY_SIZE(cache_types); i++)
                if (cache_types[i]->type == map->cache_type)
                        break;
         * a copy of it.
         */
        if (config->reg_defaults) {
 -              if (!map->num_reg_defaults)
 -                      return -EINVAL;
                tmp_buf = kmemdup(config->reg_defaults, map->num_reg_defaults *
                                  sizeof(struct reg_default), GFP_KERNEL);
                if (!tmp_buf)
@@@ -543,30 -535,19 +543,30 @@@ bool regcache_set_val(struct regmap *ma
        switch (map->cache_word_size) {
        case 1: {
                u8 *cache = base;
 +
                cache[idx] = val;
                break;
        }
        case 2: {
                u16 *cache = base;
 +
                cache[idx] = val;
                break;
        }
        case 4: {
                u32 *cache = base;
 +
 +              cache[idx] = val;
 +              break;
 +      }
 +#ifdef CONFIG_64BIT
 +      case 8: {
 +              u64 *cache = base;
 +
                cache[idx] = val;
                break;
        }
 +#endif
        default:
                BUG();
        }
@@@ -587,26 -568,16 +587,26 @@@ unsigned int regcache_get_val(struct re
        switch (map->cache_word_size) {
        case 1: {
                const u8 *cache = base;
 +
                return cache[idx];
        }
        case 2: {
                const u16 *cache = base;
 +
                return cache[idx];
        }
        case 4: {
                const u32 *cache = base;
 +
 +              return cache[idx];
 +      }
 +#ifdef CONFIG_64BIT
 +      case 8: {
 +              const u64 *cache = base;
 +
                return cache[idx];
        }
 +#endif
        default:
                BUG();
        }