LCOV - code coverage report
Current view: top level - drivers/base/regmap - regcache-flat.c (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 0 19 0.0 %
Date: 2020-09-30 20:25:40 Functions: 0 4 0.0 %
Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: GPL-2.0
       2                 :            : //
       3                 :            : // Register cache access API - flat caching support
       4                 :            : //
       5                 :            : // Copyright 2012 Wolfson Microelectronics plc
       6                 :            : //
       7                 :            : // Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
       8                 :            : 
       9                 :            : #include <linux/device.h>
      10                 :            : #include <linux/seq_file.h>
      11                 :            : #include <linux/slab.h>
      12                 :            : 
      13                 :            : #include "internal.h"
      14                 :            : 
      15                 :            : static inline unsigned int regcache_flat_get_index(const struct regmap *map,
      16                 :            :                                                    unsigned int reg)
      17                 :            : {
      18                 :            :         return regcache_get_index_by_order(map, reg);
      19                 :            : }
      20                 :            : 
      21                 :          0 : static int regcache_flat_init(struct regmap *map)
      22                 :            : {
      23                 :            :         int i;
      24                 :            :         unsigned int *cache;
      25                 :            : 
      26   [ #  #  #  #  :          0 :         if (!map || map->reg_stride_order < 0 || !map->max_register)
                   #  # ]
      27                 :            :                 return -EINVAL;
      28                 :            : 
      29                 :          0 :         map->cache = kcalloc(regcache_flat_get_index(map, map->max_register)
      30                 :            :                              + 1, sizeof(unsigned int), GFP_KERNEL);
      31         [ #  # ]:          0 :         if (!map->cache)
      32                 :            :                 return -ENOMEM;
      33                 :            : 
      34                 :            :         cache = map->cache;
      35                 :            : 
      36         [ #  # ]:          0 :         for (i = 0; i < map->num_reg_defaults; i++) {
      37                 :          0 :                 unsigned int reg = map->reg_defaults[i].reg;
      38                 :            :                 unsigned int index = regcache_flat_get_index(map, reg);
      39                 :            : 
      40                 :          0 :                 cache[index] = map->reg_defaults[i].def;
      41                 :            :         }
      42                 :            : 
      43                 :            :         return 0;
      44                 :            : }
      45                 :            : 
      46                 :          0 : static int regcache_flat_exit(struct regmap *map)
      47                 :            : {
      48                 :          0 :         kfree(map->cache);
      49                 :          0 :         map->cache = NULL;
      50                 :            : 
      51                 :          0 :         return 0;
      52                 :            : }
      53                 :            : 
      54                 :          0 : static int regcache_flat_read(struct regmap *map,
      55                 :            :                               unsigned int reg, unsigned int *value)
      56                 :            : {
      57                 :          0 :         unsigned int *cache = map->cache;
      58                 :            :         unsigned int index = regcache_flat_get_index(map, reg);
      59                 :            : 
      60                 :          0 :         *value = cache[index];
      61                 :            : 
      62                 :          0 :         return 0;
      63                 :            : }
      64                 :            : 
      65                 :          0 : static int regcache_flat_write(struct regmap *map, unsigned int reg,
      66                 :            :                                unsigned int value)
      67                 :            : {
      68                 :          0 :         unsigned int *cache = map->cache;
      69                 :            :         unsigned int index = regcache_flat_get_index(map, reg);
      70                 :            : 
      71                 :          0 :         cache[index] = value;
      72                 :            : 
      73                 :          0 :         return 0;
      74                 :            : }
      75                 :            : 
      76                 :            : struct regcache_ops regcache_flat_ops = {
      77                 :            :         .type = REGCACHE_FLAT,
      78                 :            :         .name = "flat",
      79                 :            :         .init = regcache_flat_init,
      80                 :            :         .exit = regcache_flat_exit,
      81                 :            :         .read = regcache_flat_read,
      82                 :            :         .write = regcache_flat_write,
      83                 :            : };

Generated by: LCOV version 1.14