Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
ee959b00 | 2 | * attribute_container.h - a generic container for all classes |
1da177e4 LT |
3 | * |
4 | * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> | |
5 | * | |
6 | * This file is licensed under GPLv2 | |
7 | */ | |
8 | ||
9 | #ifndef _ATTRIBUTE_CONTAINER_H_ | |
10 | #define _ATTRIBUTE_CONTAINER_H_ | |
11 | ||
1da177e4 | 12 | #include <linux/list.h> |
53c165e0 | 13 | #include <linux/klist.h> |
1da177e4 | 14 | |
313162d0 PG |
15 | struct device; |
16 | ||
1da177e4 LT |
17 | struct attribute_container { |
18 | struct list_head node; | |
53c165e0 | 19 | struct klist containers; |
1da177e4 | 20 | struct class *class; |
a4dbd674 | 21 | const struct attribute_group *grp; |
ee959b00 | 22 | struct device_attribute **attrs; |
1da177e4 LT |
23 | int (*match)(struct attribute_container *, struct device *); |
24 | #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 | |
25 | unsigned long flags; | |
26 | }; | |
27 | ||
28 | static inline int | |
29 | attribute_container_no_classdevs(struct attribute_container *atc) | |
30 | { | |
31 | return atc->flags & ATTRIBUTE_CONTAINER_NO_CLASSDEVS; | |
32 | } | |
33 | ||
34 | static inline void | |
35 | attribute_container_set_no_classdevs(struct attribute_container *atc) | |
36 | { | |
37 | atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS; | |
38 | } | |
39 | ||
40 | int attribute_container_register(struct attribute_container *cont); | |
2f3edc69 | 41 | int __must_check attribute_container_unregister(struct attribute_container *cont); |
1da177e4 LT |
42 | void attribute_container_create_device(struct device *dev, |
43 | int (*fn)(struct attribute_container *, | |
44 | struct device *, | |
ee959b00 | 45 | struct device *)); |
1da177e4 LT |
46 | void attribute_container_add_device(struct device *dev, |
47 | int (*fn)(struct attribute_container *, | |
48 | struct device *, | |
ee959b00 | 49 | struct device *)); |
1da177e4 LT |
50 | void attribute_container_remove_device(struct device *dev, |
51 | void (*fn)(struct attribute_container *, | |
52 | struct device *, | |
ee959b00 | 53 | struct device *)); |
1da177e4 LT |
54 | void attribute_container_device_trigger(struct device *dev, |
55 | int (*fn)(struct attribute_container *, | |
56 | struct device *, | |
ee959b00 | 57 | struct device *)); |
1da177e4 LT |
58 | void attribute_container_trigger(struct device *dev, |
59 | int (*fn)(struct attribute_container *, | |
60 | struct device *)); | |
ee959b00 TJ |
61 | int attribute_container_add_attrs(struct device *classdev); |
62 | int attribute_container_add_class_device(struct device *classdev); | |
1da177e4 LT |
63 | int attribute_container_add_class_device_adapter(struct attribute_container *cont, |
64 | struct device *dev, | |
ee959b00 TJ |
65 | struct device *classdev); |
66 | void attribute_container_remove_attrs(struct device *classdev); | |
67 | void attribute_container_class_device_del(struct device *classdev); | |
68 | struct attribute_container *attribute_container_classdev_to_container(struct device *); | |
69 | struct device *attribute_container_find_class_device(struct attribute_container *, struct device *); | |
70 | struct device_attribute **attribute_container_classdev_to_attrs(const struct device *classdev); | |
1da177e4 LT |
71 | |
72 | #endif |