* [PATCH] driver core: Clarify which counterparts to use to device_add()
@ 2019-04-18 17:41 Borislav Petkov
2019-04-18 19:32 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2019-04-18 17:41 UTC (permalink / raw)
To: LKML; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki
From: Borislav Petkov <bp@suse.de>
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>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
---
drivers/base/core.c | 5 +++++
1 file changed, 5 insertions(+)
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)
{
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] driver core: Clarify which counterparts to use to device_add()
2019-04-18 17:41 [PATCH] driver core: Clarify which counterparts to use to device_add() Borislav Petkov
@ 2019-04-18 19:32 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-04-18 19:32 UTC (permalink / raw)
To: Borislav Petkov; +Cc: LKML, Greg Kroah-Hartman, Rafael J. Wysocki
On Thu, Apr 18, 2019 at 7:42 PM Borislav Petkov <bp@alien8.de> wrote:
>
> From: Borislav Petkov <bp@suse.de>
>
> 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>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> 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)
> {
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-18 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 17:41 [PATCH] driver core: Clarify which counterparts to use to device_add() Borislav Petkov
2019-04-18 19:32 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®