LCOV - code coverage report
Current view: top level - drivers/clk - clk-devres.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 20 0.0 %
Date: 2014-02-18 Functions: 0 4 0.0 %
Branches: 0 16 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * This program is free software; you can redistribute it and/or modify
       3                 :            :  * it under the terms of the GNU General Public License version 2 as
       4                 :            :  * published by the Free Software Foundation.
       5                 :            :  */
       6                 :            : 
       7                 :            : #include <linux/clk.h>
       8                 :            : #include <linux/device.h>
       9                 :            : #include <linux/export.h>
      10                 :            : #include <linux/gfp.h>
      11                 :            : 
      12                 :          0 : static void devm_clk_release(struct device *dev, void *res)
      13                 :            : {
      14                 :          0 :         clk_put(*(struct clk **)res);
      15                 :          0 : }
      16                 :            : 
      17                 :          0 : struct clk *devm_clk_get(struct device *dev, const char *id)
      18                 :            : {
      19                 :            :         struct clk **ptr, *clk;
      20                 :            : 
      21                 :          0 :         ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
      22         [ #  # ]:          0 :         if (!ptr)
      23                 :            :                 return ERR_PTR(-ENOMEM);
      24                 :            : 
      25                 :          0 :         clk = clk_get(dev, id);
      26         [ #  # ]:          0 :         if (!IS_ERR(clk)) {
      27                 :          0 :                 *ptr = clk;
      28                 :          0 :                 devres_add(dev, ptr);
      29                 :            :         } else {
      30                 :          0 :                 devres_free(ptr);
      31                 :            :         }
      32                 :            : 
      33                 :          0 :         return clk;
      34                 :            : }
      35                 :            : EXPORT_SYMBOL(devm_clk_get);
      36                 :            : 
      37                 :          0 : static int devm_clk_match(struct device *dev, void *res, void *data)
      38                 :            : {
      39                 :            :         struct clk **c = res;
      40 [ #  # ][ #  # ]:          0 :         if (!c || !*c) {
      41 [ #  # ][ #  # ]:          0 :                 WARN_ON(!c || !*c);
                 [ #  # ]
      42                 :            :                 return 0;
      43                 :            :         }
      44                 :          0 :         return *c == data;
      45                 :            : }
      46                 :            : 
      47                 :          0 : void devm_clk_put(struct device *dev, struct clk *clk)
      48                 :            : {
      49                 :            :         int ret;
      50                 :            : 
      51                 :          0 :         ret = devres_release(dev, devm_clk_release, devm_clk_match, clk);
      52                 :            : 
      53         [ #  # ]:          0 :         WARN_ON(ret);
      54                 :          0 : }
      55                 :            : EXPORT_SYMBOL(devm_clk_put);

Generated by: LCOV version 1.9