Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * attribute_container.h - a generic container for all classes
0004  *
0005  * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
0006  */
0007 
0008 #ifndef _ATTRIBUTE_CONTAINER_H_
0009 #define _ATTRIBUTE_CONTAINER_H_
0010 
0011 #include <linux/list.h>
0012 #include <linux/klist.h>
0013 
0014 struct device;
0015 
0016 struct attribute_container {
0017     struct list_head    node;
0018     struct klist        containers;
0019     struct class        *class;
0020     const struct attribute_group *grp;
0021     struct device_attribute **attrs;
0022     int (*match)(struct attribute_container *, struct device *);
0023 #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS    0x01
0024     unsigned long       flags;
0025 };
0026 
0027 static inline int
0028 attribute_container_no_classdevs(struct attribute_container *atc)
0029 {
0030     return atc->flags & ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
0031 }
0032 
0033 static inline void
0034 attribute_container_set_no_classdevs(struct attribute_container *atc)
0035 {
0036     atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
0037 }
0038 
0039 int attribute_container_register(struct attribute_container *cont);
0040 int __must_check attribute_container_unregister(struct attribute_container *cont);
0041 void attribute_container_create_device(struct device *dev,
0042                        int (*fn)(struct attribute_container *,
0043                          struct device *,
0044                          struct device *));
0045 void attribute_container_add_device(struct device *dev,
0046                     int (*fn)(struct attribute_container *,
0047                           struct device *,
0048                           struct device *));
0049 void attribute_container_remove_device(struct device *dev,
0050                        void (*fn)(struct attribute_container *,
0051                           struct device *,
0052                           struct device *));
0053 void attribute_container_device_trigger(struct device *dev, 
0054                     int (*fn)(struct attribute_container *,
0055                           struct device *,
0056                           struct device *));
0057 int attribute_container_device_trigger_safe(struct device *dev,
0058                         int (*fn)(struct attribute_container *,
0059                               struct device *,
0060                               struct device *),
0061                         int (*undo)(struct attribute_container *,
0062                             struct device *,
0063                             struct device *));
0064 void attribute_container_trigger(struct device *dev, 
0065                  int (*fn)(struct attribute_container *,
0066                        struct device *));
0067 int attribute_container_add_attrs(struct device *classdev);
0068 int attribute_container_add_class_device(struct device *classdev);
0069 int attribute_container_add_class_device_adapter(struct attribute_container *cont,
0070                          struct device *dev,
0071                          struct device *classdev);
0072 void attribute_container_remove_attrs(struct device *classdev);
0073 void attribute_container_class_device_del(struct device *classdev);
0074 struct attribute_container *attribute_container_classdev_to_container(struct device *);
0075 struct device *attribute_container_find_class_device(struct attribute_container *, struct device *);
0076 struct device_attribute **attribute_container_classdev_to_attrs(const struct device *classdev);
0077 
0078 #endif