You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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>
This commit is contained in:
@@ -120,14 +120,14 @@ int dummy_rproc_example(struct rproc *my_rproc)
|
||||
On success, the new rproc is returned, and on failure, NULL.
|
||||
|
||||
Note: _never_ directly deallocate @rproc, even if it was not registered
|
||||
yet. Instead, if you just need to unroll rproc_alloc(), use rproc_free().
|
||||
yet. Instead, when you need to unroll rproc_alloc(), use rproc_free().
|
||||
|
||||
void rproc_free(struct rproc *rproc)
|
||||
- Free an rproc handle that was allocated by rproc_alloc.
|
||||
This function should _only_ be used if @rproc was only allocated,
|
||||
but not registered yet.
|
||||
If @rproc was already successfully registered (by calling
|
||||
rproc_register()), then use rproc_unregister() instead.
|
||||
This function essentially unrolls rproc_alloc(), by decrementing the
|
||||
rproc's refcount. It doesn't directly free rproc; that would happen
|
||||
only if there are no other references to rproc and its refcount now
|
||||
dropped to zero.
|
||||
|
||||
int rproc_register(struct rproc *rproc)
|
||||
- Register @rproc with the remoteproc framework, after it has been
|
||||
@@ -143,19 +143,14 @@ int dummy_rproc_example(struct rproc *my_rproc)
|
||||
probed.
|
||||
|
||||
int rproc_unregister(struct rproc *rproc)
|
||||
- Unregister a remote processor, and decrement its refcount.
|
||||
If its refcount drops to zero, then @rproc will be freed. If not,
|
||||
it will be freed later once the last reference is dropped.
|
||||
|
||||
- Unroll rproc_register().
|
||||
This function should be called when the platform specific rproc
|
||||
implementation decides to remove the rproc device. it should
|
||||
_only_ be called if a previous invocation of rproc_register()
|
||||
has completed successfully.
|
||||
|
||||
After rproc_unregister() returns, @rproc is _not_ valid anymore and
|
||||
it shouldn't be used. More specifically, don't call rproc_free()
|
||||
or try to directly free @rproc after rproc_unregister() returns;
|
||||
none of these are needed, and calling them is a bug.
|
||||
After rproc_unregister() returns, @rproc is still valid, and its
|
||||
last refcount should be decremented by calling rproc_free().
|
||||
|
||||
Returns 0 on success and -EINVAL if @rproc isn't valid.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user