From: Johan Hovold <johan@kernel.org>
To: "Uwe Kleine-König" <uwe@kleine-koenig.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] USB: serial: Drop if with an always false condition
Date: Mon, 8 Feb 2021 16:28:54 +0100 [thread overview]
Message-ID: <YCFYtv/yC124CTaR@hovoldconsulting.com> (raw)
In-Reply-To: <20210208143149.963644-1-uwe@kleine-koenig.org>
On Mon, Feb 08, 2021 at 03:31:48PM +0100, Uwe Kleine-König wrote:
> 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.)
Right, this check was just broken. I don't think it was even intended to
catch a NULL struct device pointer. Note that there's two more in
match() and probe() that I'll remove in a follow up.
> 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
Both patches now applied, thanks.
Johan
prev parent reply other threads:[~2021-02-08 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Johan Hovold [this message]
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=YCFYtv/yC124CTaR@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=uwe@kleine-koenig.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 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).