From patchwork Mon Feb 8 15:48:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 378904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56BC0C433DB for ; Mon, 8 Feb 2021 15:49:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 060D964E60 for ; Mon, 8 Feb 2021 15:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233983AbhBHPtG (ORCPT ); Mon, 8 Feb 2021 10:49:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:42910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbhBHPsq (ORCPT ); Mon, 8 Feb 2021 10:48:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD09464E60; Mon, 8 Feb 2021 15:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612799281; bh=PItUJHlIhnMJGEXKGysuzUkGG/a3tdRmx1rjVzOOgPY=; h=From:To:Cc:Subject:Date:From; b=UffVNtKu6GgAHOxqgXXxlkscrglVfRMDORXpafN1W+CVZ0JwEAlrQQJ9vfjM+XOxZ QHv/EihI25tpRpywMngSqaDuS0Q3QjIfu8TT1cAunk+8MqbiTEwXkPmfLHfVdv71n3 RvYgIYdOd0sLfvP6RlThy7wNMtgYZ4hmaZ56ATjonf6DOUcOQYNAXylGdskZWKQH8M 7rjLEdaS14mOMdJrt8yK5FhQz/gYNEaAP3V5iGOD1eC9V0iO2A1e/LWRYzO4NEIV/5 nhQfm2bolyJMxSYvCHAV/RiT58yAHFtptTgpbL7c8lOkYpTRFgEKkwC63v0/Y3/UcK IS7WB9z1HbiBQ== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l98lt-0005R4-U1; Mon, 08 Feb 2021 16:48:17 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH] USB: serial: drop bogus to_usb_serial_port() checks Date: Mon, 8 Feb 2021 16:48:06 +0100 Message-Id: <20210208154806.20853-1-johan@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 Reviewed-by: Uwe Kleine-König --- 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)