diff options
| author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2019-02-07 18:27:56 -0500 |
|---|---|---|
| committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2019-02-08 10:57:38 -0500 |
| commit | 4d69c80e0d0fd8cf12d985841eb0fce5c29819ad (patch) | |
| tree | 163bb131a70961025f2f6ca214388583f76d8e3b /include/linux/component.h | |
| parent | 8834f5600cf3c8db365e18a3d5cac2c2780c81e5 (diff) | |
component: Add documentation
While typing these I think doing an s/component_master/aggregate/
would be useful:
- it's shorter :-)
- I think component/aggregate is much more meaningful naming than
component/puppetmaster or something like that. At least to my
English ear "aggregate" emphasizes much more the "assemble a pile of
things into something bigger" aspect, and there's not really much
of a control hierarchy between aggregate and constituing components.
But that's way more than a quick doc typing exercise ...
Thanks to Ram for commenting on an initial draft of these docs.
v2: Review from Rafael:
- git add Documenation/driver-api/component.rst
- lots of polish to the wording + spelling fixes.
v3: Review from Russell:
- s/framework/helper
- clarify the documentation for component_match_add functions.
v4: Remove a few superflous "This".
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: "C, Ramalingam" <ramalingam.c@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190207232759.14553-1-daniel.vetter@ffwll.ch
Diffstat (limited to 'include/linux/component.h')
| -rw-r--r-- | include/linux/component.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/include/linux/component.h b/include/linux/component.h index e71fbbbc74e2..83da25bdf59c 100644 --- a/include/linux/component.h +++ b/include/linux/component.h | |||
| @@ -4,11 +4,31 @@ | |||
| 4 | 4 | ||
| 5 | #include <linux/stddef.h> | 5 | #include <linux/stddef.h> |
| 6 | 6 | ||
| 7 | |||
| 7 | struct device; | 8 | struct 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 | */ | ||
| 9 | struct component_ops { | 16 | struct 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 | }; |
| @@ -21,8 +41,42 @@ void component_unbind_all(struct device *master, void *master_data); | |||
| 21 | 41 | ||
| 22 | struct master; | 42 | struct master; |
| 23 | 43 | ||
| 44 | /** | ||
| 45 | * struct component_master_ops - callback for the aggregate driver | ||
| 46 | * | ||
| 47 | * Aggregate drivers are registered with component_master_add_with_match() and | ||
| 48 | * unregistered with component_master_del(). | ||
| 49 | */ | ||
| 24 | struct component_master_ops { | 50 | struct component_master_ops { |
| 51 | /** | ||
| 52 | * @bind: | ||
| 53 | * | ||
| 54 | * Called when all components or the aggregate driver, as specified in | ||
| 55 | * the match list passed to component_master_add_with_match(), are | ||
| 56 | * ready. Usually there are 3 steps to bind an aggregate driver: | ||
| 57 | * | ||
| 58 | * 1. Allocate a structure for the aggregate driver. | ||
| 59 | * | ||
| 60 | * 2. Bind all components to the aggregate driver by calling | ||
| 61 | * component_bind_all() with the aggregate driver structure as opaque | ||
| 62 | * pointer data. | ||
| 63 | * | ||
| 64 | * 3. Register the aggregate driver with the subsystem to publish its | ||
| 65 | * interfaces. | ||
| 66 | * | ||
| 67 | * Note that the lifetime of the aggregate driver does not align with | ||
| 68 | * any of the underlying &struct device instances. Therefore devm cannot | ||
| 69 | * be used and all resources acquired or allocated in this callback must | ||
| 70 | * be explicitly released in the @unbind callback. | ||
| 71 | */ | ||
| 25 | int (*bind)(struct device *master); | 72 | int (*bind)(struct device *master); |
| 73 | /** | ||
| 74 | * @unbind: | ||
| 75 | * | ||
| 76 | * Called when either the aggregate driver, using | ||
| 77 | * component_master_del(), or one of its components, using | ||
| 78 | * component_del(), is unregistered. | ||
| 79 | */ | ||
| 26 | void (*unbind)(struct device *master); | 80 | void (*unbind)(struct device *master); |
| 27 | }; | 81 | }; |
| 28 | 82 | ||
| @@ -38,6 +92,22 @@ void component_match_add_release(struct device *master, | |||
| 38 | void (*release)(struct device *, void *), | 92 | void (*release)(struct device *, void *), |
| 39 | int (*compare)(struct device *, void *), void *compare_data); | 93 | int (*compare)(struct device *, void *), void *compare_data); |
| 40 | 94 | ||
| 95 | /** | ||
| 96 | * component_match_add - add a compent match | ||
| 97 | * @master: device with the aggregate driver | ||
| 98 | * @matchptr: pointer to the list of component matches | ||
| 99 | * @compare: compare function to match against all components | ||
| 100 | * @compare_data: opaque pointer passed to the @compare function | ||
| 101 | * | ||
| 102 | * Adds a new component match to the list stored in @matchptr, which the @master | ||
| 103 | * aggregate driver needs to function. The list of component matches pointed to | ||
| 104 | * by @matchptr must be initialized to NULL before adding the first match. | ||
| 105 | * | ||
| 106 | * The allocated match list in @matchptr is automatically released using devm | ||
| 107 | * actions. | ||
| 108 | * | ||
| 109 | * See also component_match_add_release(). | ||
| 110 | */ | ||
| 41 | static inline void component_match_add(struct device *master, | 111 | static inline void component_match_add(struct device *master, |
| 42 | struct component_match **matchptr, | 112 | struct component_match **matchptr, |
| 43 | int (*compare)(struct device *, void *), void *compare_data) | 113 | int (*compare)(struct device *, void *), void *compare_data) |
