Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * class_container.h - a generic container for all classes |
| 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 | |
| 12 | #include <linux/device.h> |
| 13 | #include <linux/list.h> |
James Bottomley | 53c165e | 2005-08-22 10:06:19 -0500 | [diff] [blame] | 14 | #include <linux/klist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | struct attribute_container { |
| 17 | struct list_head node; |
James Bottomley | 53c165e | 2005-08-22 10:06:19 -0500 | [diff] [blame] | 18 | struct klist containers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | struct class *class; |
James Bottomley | fd11097 | 2008-01-02 18:48:47 -0600 | [diff] [blame] | 20 | struct attribute_group *grp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | struct class_device_attribute **attrs; |
| 22 | int (*match)(struct attribute_container *, struct device *); |
| 23 | #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 |
| 24 | unsigned long flags; |
| 25 | }; |
| 26 | |
| 27 | static inline int |
| 28 | attribute_container_no_classdevs(struct attribute_container *atc) |
| 29 | { |
| 30 | return atc->flags & ATTRIBUTE_CONTAINER_NO_CLASSDEVS; |
| 31 | } |
| 32 | |
| 33 | static inline void |
| 34 | attribute_container_set_no_classdevs(struct attribute_container *atc) |
| 35 | { |
| 36 | atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS; |
| 37 | } |
| 38 | |
| 39 | int attribute_container_register(struct attribute_container *cont); |
| 40 | int attribute_container_unregister(struct attribute_container *cont); |
| 41 | void attribute_container_create_device(struct device *dev, |
| 42 | int (*fn)(struct attribute_container *, |
| 43 | struct device *, |
| 44 | struct class_device *)); |
| 45 | void attribute_container_add_device(struct device *dev, |
| 46 | int (*fn)(struct attribute_container *, |
| 47 | struct device *, |
| 48 | struct class_device *)); |
| 49 | void attribute_container_remove_device(struct device *dev, |
| 50 | void (*fn)(struct attribute_container *, |
| 51 | struct device *, |
| 52 | struct class_device *)); |
| 53 | void attribute_container_device_trigger(struct device *dev, |
| 54 | int (*fn)(struct attribute_container *, |
| 55 | struct device *, |
| 56 | struct class_device *)); |
| 57 | void attribute_container_trigger(struct device *dev, |
| 58 | int (*fn)(struct attribute_container *, |
| 59 | struct device *)); |
| 60 | int attribute_container_add_attrs(struct class_device *classdev); |
| 61 | int attribute_container_add_class_device(struct class_device *classdev); |
| 62 | int attribute_container_add_class_device_adapter(struct attribute_container *cont, |
| 63 | struct device *dev, |
| 64 | struct class_device *classdev); |
| 65 | void attribute_container_remove_attrs(struct class_device *classdev); |
| 66 | void attribute_container_class_device_del(struct class_device *classdev); |
James Bottomley | caca177 | 2005-08-16 17:26:10 -0500 | [diff] [blame] | 67 | struct attribute_container *attribute_container_classdev_to_container(struct class_device *); |
James Bottomley | d0a7e57 | 2005-08-14 17:09:01 -0500 | [diff] [blame] | 68 | struct class_device *attribute_container_find_class_device(struct attribute_container *, struct device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | struct class_device_attribute **attribute_container_classdev_to_attrs(const struct class_device *classdev); |
| 70 | |
| 71 | #endif |