linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] USB: serial: Drop if with an always false condition
@ 2021-02-08 14:31 Uwe Kleine-König
  2021-02-08 14:31 ` [PATCH v1 2/2] USB: serial: Make remove callback return void Uwe Kleine-König
  2021-02-08 15:28 ` [PATCH v1 1/2] USB: serial: Drop if with an always false condition Johan Hovold
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-02-08 14:31 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

In a bus remove function the passed device is always valid, so there is
no need to check for it being NULL.

(Side note: The check for port being non-NULL is broken anyhow, because
to_usb_serial_port() is a wrapper around container_of() for a member that is
not the first one. So port can hardly become NULL.)

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 drivers/usb/serial/bus.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index eb0195cf37dd..d862ed656414 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -87,15 +87,11 @@ static int usb_serial_device_probe(struct device *dev)
 static int usb_serial_device_remove(struct device *dev)
 {
 	struct usb_serial_driver *driver;
-	struct usb_serial_port *port;
+	struct usb_serial_port *port = to_usb_serial_port(dev);
 	int retval = 0;
 	int minor;
 	int autopm_err;
 
-	port = to_usb_serial_port(dev);
-	if (!port)
-		return -ENODEV;
-
 	/*
 	 * Make sure suspend/resume doesn't race against port_remove.
 	 *

base-commit: 5c8fe583cce542aa0b84adc939ce85293de36e5e
-- 
2.29.2


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

end of thread, other threads:[~2021-02-08 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 14:31 [PATCH v1 1/2] USB: serial: Drop if with an always false condition Uwe Kleine-König
2021-02-08 14:31 ` [PATCH v1 2/2] USB: serial: Make remove callback return void Uwe Kleine-König
2021-02-08 15:28 ` [PATCH v1 1/2] USB: serial: Drop if with an always false condition Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).