Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Borislav Petkov and committed by
Greg Kroah-Hartman
affada72 9abb2499

+5
+5
drivers/base/core.c
··· 1999 1999 * NOTE: _Never_ directly free @dev after calling this function, even 2000 2000 * if it returned an error! Always use put_device() to give up your 2001 2001 * reference instead. 2002 + * 2003 + * Rule of thumb is: if device_add() succeeds, you should call 2004 + * device_del() when you want to get rid of it. If device_add() has 2005 + * *not* succeeded, use *only* put_device() to drop the reference 2006 + * count. 2002 2007 */ 2003 2008 int device_add(struct device *dev) 2004 2009 {