All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 3/3] spi: Warn when a driver's remove callback returns an error
Date: Thu, 19 Nov 2020 16:20:59 +0100	[thread overview]
Message-ID: <20201119152059.2631650-3-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20201119152059.2631650-1-u.kleine-koenig@pengutronix.de>

The driver core ignores the return value of struct device_driver::remove
(because in general there is nothing that can be done about that). So
add a warning when an spi driver returns an error.

This simplifies the quest to make struct device_driver::remove return void.
A consequent change would be to make struct spi_driver::remove return void,
but I'm keeping this quest for later (or someone else).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/spi/spi.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index e8c0a000ee19..6b7c19bf7715 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -408,13 +408,20 @@ static int spi_probe(struct device *dev)
 static int spi_remove(struct device *dev)
 {
 	const struct spi_driver		*sdrv = to_spi_driver(dev->driver);
-	int ret = 0;
 
-	if (sdrv->remove)
+	if (sdrv->remove) {
+		int ret;
+
 		ret = sdrv->remove(to_spi_device(dev));
+		if (ret)
+			dev_warn(dev,
+				 "Failed to unbind driver (%pe), ignoring\n",
+				 ERR_PTR(ret));
+	}
+
 	dev_pm_domain_detach(dev, true);
 
-	return ret;
+	return 0;
 }
 
 static void spi_shutdown(struct device *dev)
-- 
2.28.0


  parent reply	other threads:[~2020-11-19 15:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 15:20 [PATCH 1/3] spi: fix resource leak for drivers without .remove callback Uwe Kleine-König
2020-11-19 15:20 ` [PATCH 2/3] spi: Use bus_type functions for probe, remove and shutdown Uwe Kleine-König
2020-11-19 15:20 ` Uwe Kleine-König [this message]
2020-11-19 15:24 ` [PATCH 1/3] spi: fix resource leak for drivers without .remove callback Mark Brown
2020-11-19 15:35   ` Uwe Kleine-König
2020-11-19 15:41     ` Mark Brown
2020-11-19 16:04       ` Uwe Kleine-König
2020-11-19 16:09         ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201119152059.2631650-3-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.