Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 1d51b370a0f8f642f4fc84c795fbedac0fcdbbd2 108 lines 2.7 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * transport_class.h - a generic container for all transport classes 4 * 5 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> 6 */ 7 8#ifndef _TRANSPORT_CLASS_H_ 9#define _TRANSPORT_CLASS_H_ 10 11#include <linux/device.h> 12#include <linux/bug.h> 13#include <linux/attribute_container.h> 14 15struct transport_container; 16 17struct transport_class { 18 struct class class; 19 int (*setup)(struct transport_container *, struct device *, 20 struct device *); 21 int (*configure)(struct transport_container *, struct device *, 22 struct device *); 23 int (*remove)(struct transport_container *, struct device *, 24 struct device *); 25}; 26 27#define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \ 28struct transport_class cls = { \ 29 .class = { \ 30 .name = nm, \ 31 }, \ 32 .setup = su, \ 33 .remove = rm, \ 34 .configure = cfg, \ 35} 36 37 38struct anon_transport_class { 39 struct transport_class tclass; 40 struct attribute_container container; 41}; 42 43#define DECLARE_ANON_TRANSPORT_CLASS(cls, mtch, cfg) \ 44struct anon_transport_class cls = { \ 45 .tclass = { \ 46 .configure = cfg, \ 47 }, \ 48 . container = { \ 49 .match = mtch, \ 50 }, \ 51} 52 53#define class_to_transport_class(x) \ 54 container_of(x, struct transport_class, class) 55 56struct transport_container { 57 struct attribute_container ac; 58 const struct attribute_group *statistics; 59 const struct attribute_group *encryption; 60}; 61 62#define attribute_container_to_transport_container(x) \ 63 container_of(x, struct transport_container, ac) 64 65void transport_remove_device(struct device *); 66int transport_add_device(struct device *); 67void transport_setup_device(struct device *); 68void transport_configure_device(struct device *); 69void transport_destroy_device(struct device *); 70 71static inline int 72transport_register_device(struct device *dev) 73{ 74 int ret; 75 76 transport_setup_device(dev); 77 ret = transport_add_device(dev); 78 if (ret) 79 transport_destroy_device(dev); 80 81 return ret; 82} 83 84static inline void 85transport_unregister_device(struct device *dev) 86{ 87 transport_remove_device(dev); 88 transport_destroy_device(dev); 89} 90 91static inline void transport_container_register(struct transport_container *tc) 92{ 93 attribute_container_register(&tc->ac); 94} 95 96static inline void transport_container_unregister(struct transport_container *tc) 97{ 98 if (unlikely(attribute_container_unregister(&tc->ac))) 99 BUG(); 100} 101 102int transport_class_register(struct transport_class *); 103void anon_transport_class_register(struct anon_transport_class *); 104void transport_class_unregister(struct transport_class *); 105void anon_transport_class_unregister(struct anon_transport_class *); 106 107 108#endif