diff mbox series

[2/2] i2c: remove check that can never be true

Message ID 20201126072331.1737632-2-u.kleine-koenig@pengutronix.de
State Accepted
Headers show
Series [1/2] i2c: Warn when device removing fails | expand

Commit Message

Uwe Kleine-König Nov. 26, 2020, 7:23 a.m. UTC
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(-)

Comments

Wolfram Sang Dec. 11, 2020, 2:44 p.m. UTC | #1
On Thu, Nov 26, 2020 at 08:23:31AM +0100, Uwe Kleine-König wrote:
> 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>

Applied to for-next, thanks!
diff mbox series

Patch

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;