From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: "Chunfeng Yun (云春峰)" <Chunfeng.Yun@mediatek.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: Re: [PATCH v2] usb: mtu3: Convert to platform remove callback returning void
Date: Tue, 19 Sep 2023 10:23:27 +0200 [thread overview]
Message-ID: <20230919082327.pe32kmjuiqdkorn7@pengutronix.de> (raw)
In-Reply-To: <3cdb8de0223327b820b5344945ce53c0555f4882.camel@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]
Hello,
On Tue, Sep 19, 2023 at 07:52:04AM +0000, Chunfeng Yun (云春峰) wrote:
> On Thu, 2023-09-14 at 22:02 +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);
> > +break;
> How about changing as below:
> defualt:
> break;
> > }
I think a warning is a good idea as today that case cannot happen
(unless I missed something) and if it still happened, you'd want to know
as the handling is insufficient then. And I also think that if the enum
usb_dr_mode should ever be expanded, this code location should be
revisited, so the explicit "case USB_DR_MODE_UNKNOWN" is better in my
opinion.
As you suggest this variant you seem to have some upside in mind, didn't
put it into your message though. Would you share your thoughts?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-09-19 8:23 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 [this message]
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
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=20230919082327.pe32kmjuiqdkorn7@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=Chunfeng.Yun@mediatek.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-usb@vger.kernel.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