diff options
author | Borislav Petkov <bp@suse.de> | 2019-04-18 19:41:56 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-25 19:34:54 +0200 |
commit | affada726cad2402804ec29fc000276c7dc23b95 (patch) | |
tree | 56630f15d0ec8ae72767bb465102aa323b9eeb53 /drivers/base | |
parent | 9abb24990a2bfa3d9dd35a6b3b93ff54d9cc7908 (diff) |
driver core: Clarify which counterparts to use to device_add()
It is not absolutely clear from the docs how the cleanup path after
device_add() should look like so spell it out explicitly.
No functional changes, just documentation.
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 4aeaa0c92bda..fd7511e04e62 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1999,6 +1999,11 @@ static int device_private_init(struct device *dev) * NOTE: _Never_ directly free @dev after calling this function, even * if it returned an error! Always use put_device() to give up your * reference instead. + * + * Rule of thumb is: if device_add() succeeds, you should call + * device_del() when you want to get rid of it. If device_add() has + * *not* succeeded, use *only* put_device() to drop the reference + * count. */ int device_add(struct device *dev) { |