Re: [PATCH v1 11/12] usb: gadget: Add configfs attribuite for controling match_existing_only

From: Krzysztof Opasiak
Date: Mon Dec 03 2018 - 04:53:37 EST




On 03.12.2018 04:45, Yu Chen wrote:
> Currently the "match_existing_only" of usb_gadget_driver in configfs is
> set to one which is not flexible.
> Dwc3 udc will be removed when usb core switch to host mode. This causes
> failure of writing name of dwc3 udc to configfs's UDC attribuite.
> To fix this we need to add a way to change the config of
> "match_existing_only".
> This patch adds a configfs attribuite for controling match_existing_only
> which allow user to config "match_existing_only".
>

To be honest I strongly disagree with that patch.
This attribute was intended for build-in gadgets to allow user to decide
whether probe should fail or gadget should wait for UDC (used when
gadget is built-in). For ConfigFS we expect the UDC to always exist
prior to binding a gadget to it. If UDC goes away from what ever reason
gadget should be unbound.

So what this patch does in my opinion is abusing the attribute and
hacking the kernel instead of creating a simple udev rule that whenever
dwc3 appears and it gadget should be enabled write its name to UDC
attribute.

Best regards,
--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics