73 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * attribute_container.h - a generic container for all classes4 *5 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>6 */7 8#ifndef _ATTRIBUTE_CONTAINER_H_9#define _ATTRIBUTE_CONTAINER_H_10 11#include <linux/list.h>12#include <linux/klist.h>13 14struct device;15 16struct attribute_container {17 struct list_head node;18 struct klist containers;19 struct class *class;20 const struct attribute_group *grp;21 struct device_attribute **attrs;22 int (*match)(struct attribute_container *, struct device *);23#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x0124 unsigned long flags;25};26 27static inline int28attribute_container_no_classdevs(struct attribute_container *atc)29{30 return atc->flags & ATTRIBUTE_CONTAINER_NO_CLASSDEVS;31}32 33static inline void34attribute_container_set_no_classdevs(struct attribute_container *atc)35{36 atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS;37}38 39int attribute_container_register(struct attribute_container *cont) HWJS_SUSPENDS;40int __must_check attribute_container_unregister(struct attribute_container *cont) HWJS_SUSPENDS;41void attribute_container_create_device(struct device *dev,42 int (*fn)(struct attribute_container *,43 struct device *,44 struct device *));45void attribute_container_add_device(struct device *dev,46 int (*fn)(struct attribute_container *,47 struct device *,48 struct device *)) HWJS_SUSPENDS;49void attribute_container_remove_device(struct device *dev,50 void (*fn)(struct attribute_container *,51 struct device *,52 struct device *)) HWJS_SUSPENDS;53void attribute_container_device_trigger(struct device *dev, 54 int (*fn)(struct attribute_container *,55 struct device *,56 struct device *)) HWJS_SUSPENDS;57int attribute_container_device_trigger_safe(struct device *dev,58 int (*fn)(struct attribute_container *,59 struct device *,60 struct device *),61 int (*undo)(struct attribute_container *,62 struct device *,63 struct device *)) HWJS_SUSPENDS;64int attribute_container_add_attrs(struct device *classdev);65int attribute_container_add_class_device(struct device *classdev) HWJS_SUSPENDS;66void attribute_container_remove_attrs(struct device *classdev);67void attribute_container_class_device_del(struct device *classdev) HWJS_SUSPENDS;68struct attribute_container *attribute_container_classdev_to_container(struct device *);69struct device *attribute_container_find_class_device(struct attribute_container *, struct device *) HWJS_SUSPENDS;70struct device_attribute **attribute_container_classdev_to_attrs(const struct device *classdev);71 72#endif73