LCOV - code coverage report
Current view: top level - include/linux - transport_class.h (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 0 9 0.0 %
Date: 2020-09-30 20:25:40 Functions: 0 1 0.0 %
Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0-only */
       2                 :            : /*
       3                 :            :  * transport_class.h - a generic container for all transport classes
       4                 :            :  *
       5                 :            :  * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
       6                 :            :  */
       7                 :            : 
       8                 :            : #ifndef _TRANSPORT_CLASS_H_
       9                 :            : #define _TRANSPORT_CLASS_H_
      10                 :            : 
      11                 :            : #include <linux/device.h>
      12                 :            : #include <linux/bug.h>
      13                 :            : #include <linux/attribute_container.h>
      14                 :            : 
      15                 :            : struct transport_container;
      16                 :            : 
      17                 :            : struct transport_class {
      18                 :            :         struct class class;
      19                 :            :         int (*setup)(struct transport_container *, struct device *,
      20                 :            :                      struct device *);
      21                 :            :         int (*configure)(struct transport_container *, struct device *,
      22                 :            :                          struct device *);
      23                 :            :         int (*remove)(struct transport_container *, struct device *,
      24                 :            :                       struct device *);
      25                 :            : };
      26                 :            : 
      27                 :            : #define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg)                   \
      28                 :            : struct transport_class cls = {                                          \
      29                 :            :         .class = {                                                      \
      30                 :            :                 .name = nm,                                             \
      31                 :            :         },                                                              \
      32                 :            :         .setup = su,                                                    \
      33                 :            :         .remove = rm,                                                   \
      34                 :            :         .configure = cfg,                                               \
      35                 :            : }
      36                 :            : 
      37                 :            : 
      38                 :            : struct anon_transport_class {
      39                 :            :         struct transport_class tclass;
      40                 :            :         struct attribute_container container;
      41                 :            : };
      42                 :            : 
      43                 :            : #define DECLARE_ANON_TRANSPORT_CLASS(cls, mtch, cfg)            \
      44                 :            : struct anon_transport_class cls = {                             \
      45                 :            :         .tclass = {                                             \
      46                 :            :                 .configure = cfg,                               \
      47                 :            :         },                                                      \
      48                 :            :         . container = {                                         \
      49                 :            :                 .match = mtch,                                  \
      50                 :            :         },                                                      \
      51                 :            : }
      52                 :            : 
      53                 :            : #define class_to_transport_class(x) \
      54                 :            :         container_of(x, struct transport_class, class)
      55                 :            : 
      56                 :            : struct transport_container {
      57                 :            :         struct attribute_container ac;
      58                 :            :         const struct attribute_group *statistics;
      59                 :            : };
      60                 :            : 
      61                 :            : #define attribute_container_to_transport_container(x) \
      62                 :            :         container_of(x, struct transport_container, ac)
      63                 :            : 
      64                 :            : void transport_remove_device(struct device *);
      65                 :            : void transport_add_device(struct device *);
      66                 :            : void transport_setup_device(struct device *);
      67                 :            : void transport_configure_device(struct device *);
      68                 :            : void transport_destroy_device(struct device *);
      69                 :            : 
      70                 :            : static inline void
      71                 :            : transport_register_device(struct device *dev)
      72                 :            : {
      73                 :          0 :         transport_setup_device(dev);
      74                 :          0 :         transport_add_device(dev);
      75                 :            : }
      76                 :            : 
      77                 :            : static inline void
      78                 :            : transport_unregister_device(struct device *dev)
      79                 :            : {
      80                 :          0 :         transport_remove_device(dev);
      81                 :          0 :         transport_destroy_device(dev);
      82                 :            : }
      83                 :            : 
      84                 :            : static inline int transport_container_register(struct transport_container *tc)
      85                 :            : {
      86                 :          0 :         return attribute_container_register(&tc->ac);
      87                 :            : }
      88                 :            : 
      89                 :          0 : static inline void transport_container_unregister(struct transport_container *tc)
      90                 :            : {
      91         [ #  # ]:          0 :         if (unlikely(attribute_container_unregister(&tc->ac)))
      92                 :          0 :                 BUG();
      93                 :          0 : }
      94                 :            : 
      95                 :            : int transport_class_register(struct transport_class *);
      96                 :            : int anon_transport_class_register(struct anon_transport_class *);
      97                 :            : void transport_class_unregister(struct transport_class *);
      98                 :            : void anon_transport_class_unregister(struct anon_transport_class *);
      99                 :            : 
     100                 :            : 
     101                 :            : #endif

Generated by: LCOV version 1.14