* [PATCH] USB: serial: drop bogus to_usb_serial_port() checks
@ 2021-02-08 15:48 Johan Hovold
2021-02-08 16:43 ` Greg Kroah-Hartman
2021-02-08 17:06 ` Uwe Kleine-König
0 siblings, 2 replies; 4+ messages in thread
From: Johan Hovold @ 2021-02-08 15:48 UTC (permalink / raw)
To: linux-usb
Cc: Uwe Kleine-König, Greg Kroah-Hartman, linux-kernel, Johan Hovold
The to_usb_serial_port() macro is implemented using container_of() so
there's no need to check for NULL.
Note that neither bus match() or probe() is ever called with a NULL
struct device pointer so the checks weren't just misplaced.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/bus.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 1a8c7821d00a..7133818a58b9 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -16,19 +16,13 @@
static int usb_serial_device_match(struct device *dev,
struct device_driver *drv)
{
- struct usb_serial_driver *driver;
- const struct usb_serial_port *port;
+ const struct usb_serial_port *port = to_usb_serial_port(dev);
+ struct usb_serial_driver *driver = to_usb_serial_driver(drv);
/*
* drivers are already assigned to ports in serial_probe so it's
* a simple check here.
*/
- port = to_usb_serial_port(dev);
- if (!port)
- return 0;
-
- driver = to_usb_serial_driver(drv);
-
if (driver == port->serial->type)
return 1;
@@ -37,16 +31,12 @@ static int usb_serial_device_match(struct device *dev,
static int usb_serial_device_probe(struct device *dev)
{
+ struct usb_serial_port *port = to_usb_serial_port(dev);
struct usb_serial_driver *driver;
- struct usb_serial_port *port;
struct device *tty_dev;
int retval = 0;
int minor;
- port = to_usb_serial_port(dev);
- if (!port)
- return -ENODEV;
-
/* make sure suspend/resume doesn't race against port_probe */
retval = usb_autopm_get_interface(port->serial->interface);
if (retval)
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] USB: serial: drop bogus to_usb_serial_port() checks
2021-02-08 15:48 [PATCH] USB: serial: drop bogus to_usb_serial_port() checks Johan Hovold
@ 2021-02-08 16:43 ` Greg Kroah-Hartman
2021-02-08 17:06 ` Uwe Kleine-König
1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-02-08 16:43 UTC (permalink / raw)
To: Johan Hovold; +Cc: linux-usb, Uwe Kleine-König, linux-kernel
On Mon, Feb 08, 2021 at 04:48:06PM +0100, Johan Hovold wrote:
> The to_usb_serial_port() macro is implemented using container_of() so
> there's no need to check for NULL.
>
> Note that neither bus match() or probe() is ever called with a NULL
> struct device pointer so the checks weren't just misplaced.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] USB: serial: drop bogus to_usb_serial_port() checks
2021-02-08 15:48 [PATCH] USB: serial: drop bogus to_usb_serial_port() checks Johan Hovold
2021-02-08 16:43 ` Greg Kroah-Hartman
@ 2021-02-08 17:06 ` Uwe Kleine-König
2021-02-09 12:16 ` Johan Hovold
1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2021-02-08 17:06 UTC (permalink / raw)
To: Johan Hovold, linux-usb; +Cc: Greg Kroah-Hartman, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 420 bytes --]
On 2/8/21 4:48 PM, Johan Hovold wrote:
> The to_usb_serial_port() macro is implemented using container_of() so
> there's no need to check for NULL.
>
> Note that neither bus match() or probe() is ever called with a NULL
> struct device pointer so the checks weren't just misplaced.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Thanks
Uwe
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-09 12:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 15:48 [PATCH] USB: serial: drop bogus to_usb_serial_port() checks Johan Hovold
2021-02-08 16:43 ` Greg Kroah-Hartman
2021-02-08 17:06 ` Uwe Kleine-König
2021-02-09 12:16 ` 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).