Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e8cc7c2 authored by Alexander Shiyan's avatar Alexander Shiyan Committed by Greg Kroah-Hartman
Browse files

serial: max310x: Using resource-managed function for GPIO



Use resource managed functions devm_gpiochip_add_data() to make
error & exit path a bit simpler.

Signed-off-by: default avatarAlexander Shiyan <shc_work@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5bdb48b5
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -1193,9 +1193,11 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
	s->gpio.base		= -1;
	s->gpio.base		= -1;
	s->gpio.ngpio		= devtype->nr * 4;
	s->gpio.ngpio		= devtype->nr * 4;
	s->gpio.can_sleep	= 1;
	s->gpio.can_sleep	= 1;
	ret = gpiochip_add_data(&s->gpio, s);
	ret = devm_gpiochip_add_data(dev, &s->gpio, s);
	if (ret)
	if (ret) {
		goto out_uart;
		uart_unregister_driver(&s->uart);
		goto out_clk;
	}
#endif
#endif


	mutex_init(&s->mutex);
	mutex_init(&s->mutex);
@@ -1244,11 +1246,6 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,


	mutex_destroy(&s->mutex);
	mutex_destroy(&s->mutex);


#ifdef CONFIG_GPIOLIB
	gpiochip_remove(&s->gpio);

out_uart:
#endif
	uart_unregister_driver(&s->uart);
	uart_unregister_driver(&s->uart);


out_clk:
out_clk:
@@ -1262,10 +1259,6 @@ static int max310x_remove(struct device *dev)
	struct max310x_port *s = dev_get_drvdata(dev);
	struct max310x_port *s = dev_get_drvdata(dev);
	int i;
	int i;


#ifdef CONFIG_GPIOLIB
	gpiochip_remove(&s->gpio);
#endif

	for (i = 0; i < s->uart.nr; i++) {
	for (i = 0; i < s->uart.nr; i++) {
		cancel_work_sync(&s->p[i].tx_work);
		cancel_work_sync(&s->p[i].tx_work);
		cancel_work_sync(&s->p[i].md_work);
		cancel_work_sync(&s->p[i].md_work);