2 * attribute_container.h - a generic container for all classes
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
6 * This file is licensed under GPLv2
9 #ifndef _ATTRIBUTE_CONTAINER_H_
10 #define _ATTRIBUTE_CONTAINER_H_
12 #include <linux/device.h>
13 #include <linux/list.h>
14 #include <linux/klist.h>
16 struct attribute_container
{
17 struct list_head node
;
18 struct klist containers
;
20 struct attribute_group
*grp
;
21 struct device_attribute
**attrs
;
22 int (*match
)(struct attribute_container
*, struct device
*);
23 #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
28 attribute_container_no_classdevs(struct attribute_container
*atc
)
30 return atc
->flags
& ATTRIBUTE_CONTAINER_NO_CLASSDEVS
;
34 attribute_container_set_no_classdevs(struct attribute_container
*atc
)
36 atc
->flags
|= ATTRIBUTE_CONTAINER_NO_CLASSDEVS
;
39 int attribute_container_register(struct attribute_container
*cont
);
40 int __must_check
attribute_container_unregister(struct attribute_container
*cont
);
41 void attribute_container_create_device(struct device
*dev
,
42 int (*fn
)(struct attribute_container
*,
45 void attribute_container_add_device(struct device
*dev
,
46 int (*fn
)(struct attribute_container
*,
49 void attribute_container_remove_device(struct device
*dev
,
50 void (*fn
)(struct attribute_container
*,
53 void attribute_container_device_trigger(struct device
*dev
,
54 int (*fn
)(struct attribute_container
*,
57 void attribute_container_trigger(struct device
*dev
,
58 int (*fn
)(struct attribute_container
*,
60 int attribute_container_add_attrs(struct device
*classdev
);
61 int attribute_container_add_class_device(struct device
*classdev
);
62 int attribute_container_add_class_device_adapter(struct attribute_container
*cont
,
64 struct device
*classdev
);
65 void attribute_container_remove_attrs(struct device
*classdev
);
66 void attribute_container_class_device_del(struct device
*classdev
);
67 struct attribute_container
*attribute_container_classdev_to_container(struct device
*);
68 struct device
*attribute_container_find_class_device(struct attribute_container
*, struct device
*);
69 struct device_attribute
**attribute_container_classdev_to_attrs(const struct device
*classdev
);