mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-05 09:36:45 +07:00
ce657b1cdd
The component helper treats the void match data pointer as an opaque object which needs no further management. When device nodes being passed, this is not true: the caller should pass its refcount to the component helper, and there should be a way to drop the refcount when the matching information is destroyed. This patch provides a per-match release method in addition to the match method to solve this issue. Rather than using component_match_add(), users should use component_match_add_release() which takes an additional function pointer for releasing this reference. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
#ifndef COMPONENT_H
|
|
#define COMPONENT_H
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
struct device;
|
|
|
|
struct component_ops {
|
|
int (*bind)(struct device *comp, struct device *master,
|
|
void *master_data);
|
|
void (*unbind)(struct device *comp, struct device *master,
|
|
void *master_data);
|
|
};
|
|
|
|
int component_add(struct device *, const struct component_ops *);
|
|
void component_del(struct device *, const struct component_ops *);
|
|
|
|
int component_bind_all(struct device *master, void *master_data);
|
|
void component_unbind_all(struct device *master, void *master_data);
|
|
|
|
struct master;
|
|
|
|
struct component_master_ops {
|
|
int (*bind)(struct device *master);
|
|
void (*unbind)(struct device *master);
|
|
};
|
|
|
|
void component_master_del(struct device *,
|
|
const struct component_master_ops *);
|
|
|
|
struct component_match;
|
|
|
|
int component_master_add_with_match(struct device *,
|
|
const struct component_master_ops *, struct component_match *);
|
|
void component_match_add_release(struct device *master,
|
|
struct component_match **matchptr,
|
|
void (*release)(struct device *, void *),
|
|
int (*compare)(struct device *, void *), void *compare_data);
|
|
|
|
static inline void component_match_add(struct device *master,
|
|
struct component_match **matchptr,
|
|
int (*compare)(struct device *, void *), void *compare_data)
|
|
{
|
|
component_match_add_release(master, matchptr, NULL, compare,
|
|
compare_data);
|
|
}
|
|
|
|
#endif
|