From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>,
linux-usb@vger.kernel.org, linux-mediatek@lists.infradead.org,
kernel@pengutronix.de
Subject: Re: [PATCH] usb: mtu3: Convert to platform remove callback returning void
Date: Tue, 25 Jul 2023 18:15:14 +0200 [thread overview]
Message-ID: <2023072550-blot-moonlit-0b91@gregkh> (raw)
In-Reply-To: <20230709163335.3458886-1-u.kleine-koenig@pengutronix.de>
On Sun, Jul 09, 2023 at 06:33:35PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
>
> The function mtu3_remove() can only return a non-zero value if
> ssusb->dr_mode is neiter USB_DR_MODE_PERIPHERAL nor USB_DR_MODE_HOST nor
> USB_DR_MODE_OTG. In this case however the probe callback doesn't succeed
> and so the remove callback isn't called at all. So the code branch
> resulting in this error path can just be dropped and then mtu3_remove()
> be converted to return void trivially.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/usb/mtu3/mtu3_plat.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
This patch causes the following build error:
drivers/usb/mtu3/mtu3_plat.c: In function ‘mtu3_remove’:
drivers/usb/mtu3/mtu3_plat.c:460:9: error: enumeration value ‘USB_DR_MODE_UNKNOWN’ not handled in switch [-Werror=switch]
460 | switch (ssusb->dr_mode) {
| ^~~~~~
cc1: all warnings being treated as errors
prev parent reply other threads:[~2023-07-25 16:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-09 16:33 [PATCH] usb: mtu3: Convert to platform remove callback returning void Uwe Kleine-König
2023-07-25 16:15 ` Greg Kroah-Hartman [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=2023072550-blot-moonlit-0b91@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=chunfeng.yun@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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