Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 2 | #ifndef COMPONENT_H |
| 3 | #define COMPONENT_H |
| 4 | |
Russell King | ce657b1 | 2015-11-17 12:08:01 +0000 | [diff] [blame] | 5 | #include <linux/stddef.h> |
| 6 | |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 7 | struct device; |
| 8 | |
| 9 | struct component_ops { |
Russell King | ce657b1 | 2015-11-17 12:08:01 +0000 | [diff] [blame] | 10 | int (*bind)(struct device *comp, struct device *master, |
| 11 | void *master_data); |
| 12 | void (*unbind)(struct device *comp, struct device *master, |
| 13 | void *master_data); |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 14 | }; |
| 15 | |
| 16 | int component_add(struct device *, const struct component_ops *); |
| 17 | void component_del(struct device *, const struct component_ops *); |
| 18 | |
Russell King | ce657b1 | 2015-11-17 12:08:01 +0000 | [diff] [blame] | 19 | int component_bind_all(struct device *master, void *master_data); |
| 20 | void component_unbind_all(struct device *master, void *master_data); |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 21 | |
| 22 | struct master; |
| 23 | |
| 24 | struct component_master_ops { |
Russell King | ce657b1 | 2015-11-17 12:08:01 +0000 | [diff] [blame] | 25 | int (*bind)(struct device *master); |
| 26 | void (*unbind)(struct device *master); |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 29 | void component_master_del(struct device *, |
| 30 | const struct component_master_ops *); |
| 31 | |
Russell King | 6955b58 | 2014-04-19 11:18:01 +0100 | [diff] [blame] | 32 | struct component_match; |
| 33 | |
| 34 | int component_master_add_with_match(struct device *, |
| 35 | const struct component_master_ops *, struct component_match *); |
Russell King | ce657b1 | 2015-11-17 12:08:01 +0000 | [diff] [blame] | 36 | void component_match_add_release(struct device *master, |
| 37 | struct component_match **matchptr, |
| 38 | void (*release)(struct device *, void *), |
Russell King | 6955b58 | 2014-04-19 11:18:01 +0100 | [diff] [blame] | 39 | int (*compare)(struct device *, void *), void *compare_data); |
| 40 | |
Russell King | ce657b1 | 2015-11-17 12:08:01 +0000 | [diff] [blame] | 41 | static inline void component_match_add(struct device *master, |
| 42 | struct component_match **matchptr, |
| 43 | int (*compare)(struct device *, void *), void *compare_data) |
| 44 | { |
| 45 | component_match_add_release(master, matchptr, NULL, compare, |
| 46 | compare_data); |
| 47 | } |
| 48 | |
Russell King | 2a41e60 | 2014-01-10 23:23:37 +0000 | [diff] [blame] | 49 | #endif |