Commit 889a1b3f authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Bartosz Golaszewski
Browse files

gpio: mpc8xxx: Use 'devm_gpiochip_add_data()' to simplify the code and avoid a leak



If an error occurs after a 'gpiochip_add_data()' call it must be undone by
a corresponding 'gpiochip_remove()' as already done in the remove function.

To simplify the code a fix a leak in the error handling path of the probe,
use the managed version instead (i.e. 'devm_gpiochip_add_data()')

Fixes: 698b8eea ("gpio/mpc8xxx: change irq handler from chained to normal")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 7d658893
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
	    is_acpi_node(fwnode))
		gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff);

	ret = gpiochip_add_data(gc, mpc8xxx_gc);
	ret = devm_gpiochip_add_data(&pdev->dev, gc, mpc8xxx_gc);
	if (ret) {
		dev_err(&pdev->dev,
			"GPIO chip registration failed with status %d\n", ret);
@@ -429,8 +429,6 @@ static int mpc8xxx_remove(struct platform_device *pdev)
		irq_domain_remove(mpc8xxx_gc->irq);
	}

	gpiochip_remove(&mpc8xxx_gc->gc);

	return 0;
}