summaryrefslogtreecommitdiffstats
path: root/include/linux/component.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 17:18:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 17:18:59 -0500
commit45763bf4bc1ebdf8eb95697607e1fd042a3e1221 (patch)
treec5b26c2d5d1190247b59d6d1fe68b8a247351362 /include/linux/component.h
parentda2577fe63f865cd9dc785a42c29c0071f567a35 (diff)
parent142a0f83b216a607aebed42e54a1be620765e28c (diff)
Merge tag 'char-misc-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH: "Here is the big char/misc driver patch pull request for 5.1-rc1. The largest thing by far is the new habanalabs driver for their AI accelerator chip. For now it is in the drivers/misc directory but will probably move to a new directory soon along with other drivers of this type. Other than that, just the usual set of individual driver updates and fixes. There's an "odd" merge in here from the DRM tree that they asked me to do as the MEI driver is starting to interact with the i915 driver, and it needed some coordination. All of those patches have been properly acked by the relevant subsystem maintainers. All of these have been in linux-next with no reported issues, most for quite some time" * tag 'char-misc-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (219 commits) habanalabs: adjust Kconfig to fix build errors habanalabs: use %px instead of %p in error print habanalabs: use do_div for 64-bit divisions intel_th: gth: Fix an off-by-one in output unassigning habanalabs: fix little-endian<->cpu conversion warnings habanalabs: use NULL to initialize array of pointers habanalabs: fix little-endian<->cpu conversion warnings habanalabs: soft-reset device if context-switch fails habanalabs: print pointer using %p habanalabs: fix memory leak with CBs with unaligned size habanalabs: return correct error code on MMU mapping failure habanalabs: add comments in uapi/misc/habanalabs.h habanalabs: extend QMAN0 job timeout habanalabs: set DMA0 completion to SOB 1007 habanalabs: fix validation of WREG32 to DMA completion habanalabs: fix mmu cache registers init habanalabs: disable CPU access on timeouts habanalabs: add MMU DRAM default page mapping habanalabs: Dissociate RAZWI info from event types misc/habanalabs: adjust Kconfig to fix build errors ...
Diffstat (limited to 'include/linux/component.h')
-rw-r--r--include/linux/component.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/include/linux/component.h b/include/linux/component.h
index e71fbbbc74e2..30bcc7e590eb 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -4,16 +4,38 @@
4 4
5#include <linux/stddef.h> 5#include <linux/stddef.h>
6 6
7
7struct device; 8struct device;
8 9
10/**
11 * struct component_ops - callbacks for component drivers
12 *
13 * Components are registered with component_add() and unregistered with
14 * component_del().
15 */
9struct component_ops { 16struct component_ops {
17 /**
18 * @bind:
19 *
20 * Called through component_bind_all() when the aggregate driver is
21 * ready to bind the overall driver.
22 */
10 int (*bind)(struct device *comp, struct device *master, 23 int (*bind)(struct device *comp, struct device *master,
11 void *master_data); 24 void *master_data);
25 /**
26 * @unbind:
27 *
28 * Called through component_unbind_all() when the aggregate driver is
29 * ready to bind the overall driver, or when component_bind_all() fails
30 * part-ways through and needs to unbind some already bound components.
31 */
12 void (*unbind)(struct device *comp, struct device *master, 32 void (*unbind)(struct device *comp, struct device *master,
13 void *master_data); 33 void *master_data);
14}; 34};
15 35
16int component_add(struct device *, const struct component_ops *); 36int component_add(struct device *, const struct component_ops *);
37int component_add_typed(struct device *dev, const struct component_ops *ops,
38 int subcomponent);
17void component_del(struct device *, const struct component_ops *); 39void component_del(struct device *, const struct component_ops *);
18 40
19int component_bind_all(struct device *master, void *master_data); 41int component_bind_all(struct device *master, void *master_data);
@@ -21,8 +43,42 @@ void component_unbind_all(struct device *master, void *master_data);
21 43
22struct master; 44struct master;
23 45
46/**
47 * struct component_master_ops - callback for the aggregate driver
48 *
49 * Aggregate drivers are registered with component_master_add_with_match() and
50 * unregistered with component_master_del().
51 */
24struct component_master_ops { 52struct component_master_ops {
53 /**
54 * @bind:
55 *
56 * Called when all components or the aggregate driver, as specified in
57 * the match list passed to component_master_add_with_match(), are
58 * ready. Usually there are 3 steps to bind an aggregate driver:
59 *
60 * 1. Allocate a structure for the aggregate driver.
61 *
62 * 2. Bind all components to the aggregate driver by calling
63 * component_bind_all() with the aggregate driver structure as opaque
64 * pointer data.
65 *
66 * 3. Register the aggregate driver with the subsystem to publish its
67 * interfaces.
68 *
69 * Note that the lifetime of the aggregate driver does not align with
70 * any of the underlying &struct device instances. Therefore devm cannot
71 * be used and all resources acquired or allocated in this callback must
72 * be explicitly released in the @unbind callback.
73 */
25 int (*bind)(struct device *master); 74 int (*bind)(struct device *master);
75 /**
76 * @unbind:
77 *
78 * Called when either the aggregate driver, using
79 * component_master_del(), or one of its components, using
80 * component_del(), is unregistered.
81 */
26 void (*unbind)(struct device *master); 82 void (*unbind)(struct device *master);
27}; 83};
28 84
@@ -37,7 +93,27 @@ void component_match_add_release(struct device *master,
37 struct component_match **matchptr, 93 struct component_match **matchptr,
38 void (*release)(struct device *, void *), 94 void (*release)(struct device *, void *),
39 int (*compare)(struct device *, void *), void *compare_data); 95 int (*compare)(struct device *, void *), void *compare_data);
96void component_match_add_typed(struct device *master,
97 struct component_match **matchptr,
98 int (*compare_typed)(struct device *, int, void *), void *compare_data);
40 99
100/**
101 * component_match_add - add a compent match
102 * @master: device with the aggregate driver
103 * @matchptr: pointer to the list of component matches
104 * @compare: compare function to match against all components
105 * @compare_data: opaque pointer passed to the @compare function
106 *
107 * Adds a new component match to the list stored in @matchptr, which the @master
108 * aggregate driver needs to function. The list of component matches pointed to
109 * by @matchptr must be initialized to NULL before adding the first match. This
110 * only matches against components added with component_add().
111 *
112 * The allocated match list in @matchptr is automatically released using devm
113 * actions.
114 *
115 * See also component_match_add_release() and component_match_add_typed().
116 */
41static inline void component_match_add(struct device *master, 117static inline void component_match_add(struct device *master,
42 struct component_match **matchptr, 118 struct component_match **matchptr,
43 int (*compare)(struct device *, void *), void *compare_data) 119 int (*compare)(struct device *, void *), void *compare_data)