Re: [RESEND RFC PATCH 1/5] platform: x86: add driver for UP Board I/O CPLD
From: Bryan O'Donoghue
Date: Fri Jul 08 2016 - 13:05:59 EST
On Mon, 2016-07-04 at 17:07 +0100, Dan O'Donovan wrote:
> + cpld->pinctrl_pdev =
> + platform_device_register_data(dev, "up-board-
> pinctrl",
> + ÂÂÂÂÂÂPLATFORM_DEVID_NONE,
> + ÂÂÂÂÂÂ&up_board_pinctrl_pdat
> a,
> + ÂÂÂÂÂÂsizeof(up_board_pinctr
> l_pdata));
> + if (IS_ERR(cpld->pinctrl_pdev)) {
> + ret = PTR_ERR(cpld->pinctrl_pdev);
> + goto fail_register_pinctrl_pdev;
> + }
> +
> + cpld->gpio_pdev =
> + platform_device_register_data(dev, "up-board-gpio",
> + ÂÂÂÂÂÂPLATFORM_DEVID_NONE,
> + ÂÂÂÂÂÂ&up_board_gpio_pdata,
> + ÂÂÂÂÂÂsizeof(up_board_gpio_p
> data));
> + if (IS_ERR(cpld->gpio_pdev)) {
> + ret = PTR_ERR(cpld->gpio_pdev);
> + goto fail_register_gpio_pdev;
> + }
> +
> + cpld->leds_pdev =
> + platform_device_register_data(dev, "up-board-leds",
> + ÂÂÂÂÂÂPLATFORM_DEVID_NONE,
> + ÂÂÂÂÂÂ&up_board_leds_pdata,
> + ÂÂÂÂÂÂsizeof(up_board_leds_p
> data));
> + if (IS_ERR(cpld->leds_pdev)) {
> + ret = PTR_ERR(cpld->leds_pdev);
> + goto fail_register_leds_pdev;
> + }
> +
> + return 0;
> +
> +fail_register_leds_pdev:
> + platform_device_unregister(cpld->gpio_pdev);
> +fail_register_gpio_pdev:
> + platform_device_unregister(cpld->pinctrl_pdev);
> +fail_register_pinctrl_pdev:
Because the subordinate drivers don't have remove routines if any of
these error paths are triggered you'll leak resources. Recommend adding
cleanup exit routines to the subordinate drivers which should then be
triggered on the failure jumps here.
---
bod