All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] driver core: platform: Respect return code of platform_device_register_full()
@ 2018-12-03 18:21 Andy Shevchenko
  2018-12-06 12:58 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2018-12-03 18:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel,
	Pierre-Louis Bossart
  Cc: Andy Shevchenko

The platform_device_register_full() might return an error pointer. If we
instantiate platform device which is optional we may simplify the routine at
removal stage by simply calling platform_device_unregister(). For now it
requires to check parameter for being an error pointer in each caller.

To make users' life easier, check for an error pointer inside driver core.

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
- rebase on top of linux-next since the conflicting patch has been applied there

 drivers/base/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 0fb5f140f1b0..2c36bf490944 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -234,7 +234,7 @@ struct platform_object {
  */
 void platform_device_put(struct platform_device *pdev)
 {
-	if (pdev)
+	if (!IS_ERR_OR_NULL(pdev))
 		put_device(&pdev->dev);
 }
 EXPORT_SYMBOL_GPL(platform_device_put);
@@ -447,7 +447,7 @@ void platform_device_del(struct platform_device *pdev)
 {
 	int i;
 
-	if (pdev) {
+	if (!IS_ERR_OR_NULL(pdev)) {
 		device_del(&pdev->dev);
 
 		if (pdev->id_auto) {
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] driver core: platform: Respect return code of platform_device_register_full()
  2018-12-03 18:21 [PATCH v2] driver core: platform: Respect return code of platform_device_register_full() Andy Shevchenko
@ 2018-12-06 12:58 ` Greg Kroah-Hartman
  2018-12-06 13:24   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-12-06 12:58 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Rafael J. Wysocki, linux-kernel, Pierre-Louis Bossart

On Mon, Dec 03, 2018 at 08:21:41PM +0200, Andy Shevchenko wrote:
> The platform_device_register_full() might return an error pointer. If we
> instantiate platform device which is optional we may simplify the routine at
> removal stage by simply calling platform_device_unregister(). For now it
> requires to check parameter for being an error pointer in each caller.
> 
> To make users' life easier, check for an error pointer inside driver core.
> 
> Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> - rebase on top of linux-next since the conflicting patch has been applied there

What conflicting patch?  This now doesn't apply to my tree.

Let me fix it up by hand...


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] driver core: platform: Respect return code of platform_device_register_full()
  2018-12-06 12:58 ` Greg Kroah-Hartman
@ 2018-12-06 13:24   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-12-06 13:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Andy Shevchenko, Rafael J. Wysocki, Linux Kernel Mailing List,
	Pierre-Louis Bossart

On Thu, Dec 6, 2018 at 2:59 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Mon, Dec 03, 2018 at 08:21:41PM +0200, Andy Shevchenko wrote:
> > The platform_device_register_full() might return an error pointer. If we
> > instantiate platform device which is optional we may simplify the routine at
> > removal stage by simply calling platform_device_unregister(). For now it
> > requires to check parameter for being an error pointer in each caller.
> >
> > To make users' life easier, check for an error pointer inside driver core.
> >
> > Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > - rebase on top of linux-next since the conflicting patch has been applied there
>
> What conflicting patch?  This now doesn't apply to my tree.

One patch from Heikki had been applied earlier, I rebased and sent v2
at the same day as this one.

>
> Let me fix it up by hand...
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-06 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 18:21 [PATCH v2] driver core: platform: Respect return code of platform_device_register_full() Andy Shevchenko
2018-12-06 12:58 ` Greg Kroah-Hartman
2018-12-06 13:24   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.