All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Wolfram Sang <wsa@kernel.org>
Cc: linux-i2c@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kernel@pengutronix.de
Subject: [PATCH 2/2] i2c: remove check that can never be true
Date: Thu, 26 Nov 2020 08:23:31 +0100	[thread overview]
Message-ID: <20201126072331.1737632-2-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20201126072331.1737632-1-u.kleine-koenig@pengutronix.de>

A driver remove callback is only called if the device was bound before.
So it's sure that both dev and dev->driver are valid and dev is an i2c
device. If the check fails something louder than "return 0" might be
appropriate because the problem is grave (something like memory
corruption), otherwise the check is useless.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/i2c/i2c-core-base.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 86e43016ff85..be995a95c4ac 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -549,12 +549,9 @@ static int i2c_device_probe(struct device *dev)
 
 static int i2c_device_remove(struct device *dev)
 {
-	struct i2c_client	*client = i2c_verify_client(dev);
+	struct i2c_client	*client = to_i2c_client(dev);
 	struct i2c_driver	*driver;
 
-	if (!client || !dev->driver)
-		return 0;
-
 	driver = to_i2c_driver(dev->driver);
 	if (driver->remove) {
 		int status = 0;
-- 
2.29.2


  reply	other threads:[~2020-11-26  7:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26  7:23 [PATCH 1/2] i2c: Warn when device removing fails Uwe Kleine-König
2020-11-26  7:23 ` Uwe Kleine-König [this message]
2020-12-11 14:44   ` [PATCH 2/2] i2c: remove check that can never be true Wolfram Sang
2020-12-10 20:10 ` [PATCH 1/2] i2c: Warn when device removing fails Wolfram Sang
2020-12-11 10:43   ` Uwe Kleine-König
2020-12-11 14:00     ` Wolfram Sang
2020-12-11 14:44 ` Wolfram Sang

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=20201126072331.1737632-2-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=wsa@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.