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 v2] usb: mtu3: Convert to platform remove callback returning void
Date: Thu, 5 Oct 2023 09:13:18 +0200 [thread overview]
Message-ID: <2023100530-degree-overlap-6aff@gregkh> (raw)
In-Reply-To: <20231002214158.wvhals4ywezftepo@pengutronix.de>
On Mon, Oct 02, 2023 at 11:41:58PM +0200, Uwe Kleine-König wrote:
> Hello Greg,
>
> On Mon, Oct 02, 2023 at 04:53:05PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, Oct 02, 2023 at 04:49:59PM +0200, Uwe Kleine-König wrote:
> > > On Mon, Oct 02, 2023 at 04:39:47PM +0200, Greg Kroah-Hartman wrote:
> > > > On Thu, Sep 14, 2023 at 10:02:51PM +0200, Uwe Kleine-König wrote:
> > > > > @@ -469,8 +469,17 @@ static int mtu3_remove(struct platform_device *pdev)
> > > > > ssusb_gadget_exit(ssusb);
> > > > > ssusb_host_exit(ssusb);
> > > > > break;
> > > > > - default:
> > > > > - return -EINVAL;
> > > > > + case USB_DR_MODE_UNKNOWN:
> > > > > + /*
> > > > > + * This cannot happen because with dr_mode ==
> > > > > + * USB_DR_MODE_UNKNOWN, .probe() doesn't succeed and so
> > > > > + * .remove() wouldn't be called at all. However (little
> > > > > + * surprising) the compiler isn't smart enough to see that, so
> > > > > + * we explicitly have this case item to not make the compiler
> > > > > + * wail about an unhandled enumeration value.
> > > > > + */
> > > > > + WARN_ON(1);
> > > >
> > > > Please don't add new WARN_ON() calls to the kernel, print out a big
> > > > error message and return, don't reboot the machine.
> > >
> > > Huh, printing out an loud error message was my intention. It's news to
> > > me that WARN_ON() reboots the machine?! I thought BUG_ON() was the one
> > > with the effects you describe that I shouldn't use.
> >
> > panic-on-warn is set for zillions[1] of Linux systems out there, so systems
> > will reboot.
>
> The people enabling panic-on-warn *ask* for a reboot if something
> strange happens, right? If ssusb->dr_mode is USB_DR_MODE_UNKNOWN in
> .remove() but wasn't in .probe(), that's strange, right? If I don't
> enable panic-on-warn, my system just emits a warning and then the driver
> copes with what it has, right? Sounds to me as if WARN_ON does exactly
> what is the right thing here.
I really don't want to add more WARN_ON() to the kernel if at all
possible.
If this "can not happen" then just don't even add code for it, why have
this at all? The compiler warning can be handled a different way,
right?
thanks,
greg k-h
next prev parent reply other threads:[~2023-10-05 7:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 20:02 [PATCH v2] usb: mtu3: Convert to platform remove callback returning void Uwe Kleine-König
2023-09-19 7:52 ` Chunfeng Yun (云春峰)
2023-09-19 8:23 ` Uwe Kleine-König
2023-10-02 14:39 ` Greg Kroah-Hartman
2023-10-02 14:49 ` Uwe Kleine-König
2023-10-02 14:53 ` Greg Kroah-Hartman
2023-10-02 21:41 ` Uwe Kleine-König
2023-10-05 7:13 ` Greg Kroah-Hartman [this message]
2023-10-20 9:53 ` Uwe Kleine-König
2023-10-20 14:33 ` Greg Kroah-Hartman
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=2023100530-degree-overlap-6aff@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;
as well as URLs for NNTP newsgroup(s).