Skip to content

Commit

Permalink
driver core: Clarify which counterparts to use to device_add()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Borislav Petkov authored and Greg Kroah-Hartman committed Apr 25, 2019
1 parent 9abb249 commit affada7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit affada7

Please sign in to comment.