~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/transport_class.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 int 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 int
 71 transport_register_device(struct device *dev)
 72 {
 73         int ret;
 74 
 75         transport_setup_device(dev);
 76         ret = transport_add_device(dev);
 77         if (ret)
 78                 transport_destroy_device(dev);
 79 
 80         return ret;
 81 }
 82 
 83 static inline void
 84 transport_unregister_device(struct device *dev)
 85 {
 86         transport_remove_device(dev);
 87         transport_destroy_device(dev);
 88 }
 89 
 90 static inline int transport_container_register(struct transport_container *tc)
 91 {
 92         return attribute_container_register(&tc->ac);
 93 }
 94 
 95 static inline void transport_container_unregister(struct transport_container *tc)
 96 {
 97         if (unlikely(attribute_container_unregister(&tc->ac)))
 98                 BUG();
 99 }
100 
101 int transport_class_register(struct transport_class *);
102 int anon_transport_class_register(struct anon_transport_class *);
103 void transport_class_unregister(struct transport_class *);
104 void anon_transport_class_unregister(struct anon_transport_class *);
105 
106 
107 #endif
108 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php