Commit 103081ef authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Greg Kroah-Hartman
Browse files

usb: gadget: fsl_udc: Convert to platform remove callback returning void



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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20231120215830.71071-3-u.kleine-koenig@pengutronix.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cbd1b152
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -2532,15 +2532,18 @@ static int fsl_udc_probe(struct platform_device *pdev)
/* Driver removal function
 * Free resources and finish pending transactions
 */
static int fsl_udc_remove(struct platform_device *pdev)
static void fsl_udc_remove(struct platform_device *pdev)
{
	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev);

	DECLARE_COMPLETION_ONSTACK(done);

	if (!udc_controller)
		return -ENODEV;
	if (!udc_controller) {
		dev_err(&pdev->dev,
			"Driver still in use but removing anyhow\n");
		return;
	}

	udc_controller->done = &done;
	usb_del_gadget_udc(&udc_controller->gadget);
@@ -2568,8 +2571,6 @@ static int fsl_udc_remove(struct platform_device *pdev)
	 */
	if (pdata->exit)
		pdata->exit(pdev);

	return 0;
}

/*-----------------------------------------------------------------
@@ -2667,7 +2668,7 @@ static const struct platform_device_id fsl_udc_devtype[] = {
MODULE_DEVICE_TABLE(platform, fsl_udc_devtype);
static struct platform_driver udc_driver = {
	.probe		= fsl_udc_probe,
	.remove		= fsl_udc_remove,
	.remove_new	= fsl_udc_remove,
	.id_table	= fsl_udc_devtype,
	/* these suspend and resume are not usb suspend and resume */
	.suspend	= fsl_udc_suspend,