blob: e71fbbbc74e2b44cc7b39ddbc9f5cd70bbd29397 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Russell King2a41e602014-01-10 23:23:37 +00002#ifndef COMPONENT_H
3#define COMPONENT_H
4
Russell Kingce657b12015-11-17 12:08:01 +00005#include <linux/stddef.h>
6
Russell King2a41e602014-01-10 23:23:37 +00007struct device;
8
9struct component_ops {
Russell Kingce657b12015-11-17 12:08:01 +000010 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 King2a41e602014-01-10 23:23:37 +000014};
15
16int component_add(struct device *, const struct component_ops *);
17void component_del(struct device *, const struct component_ops *);
18
Russell Kingce657b12015-11-17 12:08:01 +000019int component_bind_all(struct device *master, void *master_data);
20void component_unbind_all(struct device *master, void *master_data);
Russell King2a41e602014-01-10 23:23:37 +000021
22struct master;
23
24struct component_master_ops {
Russell Kingce657b12015-11-17 12:08:01 +000025 int (*bind)(struct device *master);
26 void (*unbind)(struct device *master);
Russell King2a41e602014-01-10 23:23:37 +000027};
28
Russell King2a41e602014-01-10 23:23:37 +000029void component_master_del(struct device *,
30 const struct component_master_ops *);
31
Russell King6955b582014-04-19 11:18:01 +010032struct component_match;
33
34int component_master_add_with_match(struct device *,
35 const struct component_master_ops *, struct component_match *);
Russell Kingce657b12015-11-17 12:08:01 +000036void component_match_add_release(struct device *master,
37 struct component_match **matchptr,
38 void (*release)(struct device *, void *),
Russell King6955b582014-04-19 11:18:01 +010039 int (*compare)(struct device *, void *), void *compare_data);
40
Russell Kingce657b12015-11-17 12:08:01 +000041static 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 King2a41e602014-01-10 23:23:37 +000049#endif