diff options
author | Ohad Ben-Cohen <ohad@wizery.com> | 2012-07-02 04:41:16 -0400 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2012-07-05 17:53:25 -0400 |
commit | c6b5a27628faf6657b741d828a1462d832d0dbc5 (patch) | |
tree | 3f5bcb10c6d2b1e395330536476d471415632832 /Documentation | |
parent | 7183a2a799b81490354973117ecd810c23cdc668 (diff) |
remoteproc: simplify unregister/free interfaces
Simplify the unregister/free interfaces, and make them easier
to understand and use, by moving to a symmetric and consistent
alloc() -> register() -> unregister() -> free() flow.
To create and register an rproc instance, one needed to invoke
rproc_alloc() followed by rproc_register().
To unregister and free an rproc instance, one now needs to invoke
rproc_unregister() followed by rproc_free().
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/remoteproc.txt | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/Documentation/remoteproc.txt b/Documentation/remoteproc.txt index 70a048cd3fa3..ad6ded4bca5c 100644 --- a/Documentation/remoteproc.txt +++ b/Documentation/remoteproc.txt | |||
@@ -120,14 +120,14 @@ int dummy_rproc_example(struct rproc *my_rproc) | |||
120 | On success, the new rproc is returned, and on failure, NULL. | 120 | On success, the new rproc is returned, and on failure, NULL. |
121 | 121 | ||
122 | Note: _never_ directly deallocate @rproc, even if it was not registered | 122 | Note: _never_ directly deallocate @rproc, even if it was not registered |
123 | yet. Instead, if you just need to unroll rproc_alloc(), use rproc_free(). | 123 | yet. Instead, when you need to unroll rproc_alloc(), use rproc_free(). |
124 | 124 | ||
125 | void rproc_free(struct rproc *rproc) | 125 | void rproc_free(struct rproc *rproc) |
126 | - Free an rproc handle that was allocated by rproc_alloc. | 126 | - Free an rproc handle that was allocated by rproc_alloc. |
127 | This function should _only_ be used if @rproc was only allocated, | 127 | This function essentially unrolls rproc_alloc(), by decrementing the |
128 | but not registered yet. | 128 | rproc's refcount. It doesn't directly free rproc; that would happen |
129 | If @rproc was already successfully registered (by calling | 129 | only if there are no other references to rproc and its refcount now |
130 | rproc_register()), then use rproc_unregister() instead. | 130 | dropped to zero. |
131 | 131 | ||
132 | int rproc_register(struct rproc *rproc) | 132 | int rproc_register(struct rproc *rproc) |
133 | - Register @rproc with the remoteproc framework, after it has been | 133 | - Register @rproc with the remoteproc framework, after it has been |
@@ -143,19 +143,14 @@ int dummy_rproc_example(struct rproc *my_rproc) | |||
143 | probed. | 143 | probed. |
144 | 144 | ||
145 | int rproc_unregister(struct rproc *rproc) | 145 | int rproc_unregister(struct rproc *rproc) |
146 | - Unregister a remote processor, and decrement its refcount. | 146 | - Unroll rproc_register(). |
147 | If its refcount drops to zero, then @rproc will be freed. If not, | ||
148 | it will be freed later once the last reference is dropped. | ||
149 | |||
150 | This function should be called when the platform specific rproc | 147 | This function should be called when the platform specific rproc |
151 | implementation decides to remove the rproc device. it should | 148 | implementation decides to remove the rproc device. it should |
152 | _only_ be called if a previous invocation of rproc_register() | 149 | _only_ be called if a previous invocation of rproc_register() |
153 | has completed successfully. | 150 | has completed successfully. |
154 | 151 | ||
155 | After rproc_unregister() returns, @rproc is _not_ valid anymore and | 152 | After rproc_unregister() returns, @rproc is still valid, and its |
156 | it shouldn't be used. More specifically, don't call rproc_free() | 153 | last refcount should be decremented by calling rproc_free(). |
157 | or try to directly free @rproc after rproc_unregister() returns; | ||
158 | none of these are needed, and calling them is a bug. | ||
159 | 154 | ||
160 | Returns 0 on success and -EINVAL if @rproc isn't valid. | 155 | Returns 0 on success and -EINVAL if @rproc isn't valid. |
161 | 156 | ||