MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / linux / transport_class.h
blob1d6cc22e5f42a49ab4e42a3db982c8b4a9107f04
1 /*
2 * transport_class.h - a generic container for all transport classes
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
6 * This file is licensed under GPLv2
7 */
9 #ifndef _TRANSPORT_CLASS_H_
10 #define _TRANSPORT_CLASS_H_
12 #include <linux/device.h>
13 #include <linux/attribute_container.h>
15 struct transport_container;
17 struct transport_class {
18 struct class class;
19 int (*setup)(struct transport_container *, struct device *,
20 struct class_device *);
21 int (*configure)(struct transport_container *, struct device *,
22 struct class_device *);
23 int (*remove)(struct transport_container *, struct device *,
24 struct class_device *);
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, \
38 struct anon_transport_class {
39 struct transport_class tclass;
40 struct attribute_container container;
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 }, \
53 #define class_to_transport_class(x) \
54 container_of(x, struct transport_class, class)
56 struct transport_container {
57 struct attribute_container ac;
58 struct attribute_group *statistics;
61 #define attribute_container_to_transport_container(x) \
62 container_of(x, struct transport_container, ac)
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 *);
70 static inline void
71 transport_register_device(struct device *dev)
73 transport_setup_device(dev);
74 transport_add_device(dev);
77 static inline void
78 transport_unregister_device(struct device *dev)
80 transport_remove_device(dev);
81 transport_destroy_device(dev);
84 static inline int transport_container_register(struct transport_container *tc)
86 return attribute_container_register(&tc->ac);
89 static inline int transport_container_unregister(struct transport_container *tc)
91 return attribute_container_unregister(&tc->ac);
94 int transport_class_register(struct transport_class *);
95 int anon_transport_class_register(struct anon_transport_class *);
96 void transport_class_unregister(struct transport_class *);
97 void anon_transport_class_unregister(struct anon_transport_class *);
100 #endif