Commit c17e3178 authored by Jisheng Zhang's avatar Jisheng Zhang Committed by David S. Miller

net: mdio-mux-gpio: use devm_gpiod_get_array()

Use devm_gpiod_get_array() to simplify the error handling and exit
code path.
Signed-off-by: default avatarJisheng Zhang <Jisheng.Zhang@synaptics.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 71d4364a
...@@ -42,25 +42,21 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) ...@@ -42,25 +42,21 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev)
struct gpio_descs *gpios; struct gpio_descs *gpios;
int r; int r;
gpios = gpiod_get_array(&pdev->dev, NULL, GPIOD_OUT_LOW); gpios = devm_gpiod_get_array(&pdev->dev, NULL, GPIOD_OUT_LOW);
if (IS_ERR(gpios)) if (IS_ERR(gpios))
return PTR_ERR(gpios); return PTR_ERR(gpios);
s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL); s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL);
if (!s) { if (!s)
gpiod_put_array(gpios);
return -ENOMEM; return -ENOMEM;
}
s->gpios = gpios; s->gpios = gpios;
r = mdio_mux_init(&pdev->dev, pdev->dev.of_node, r = mdio_mux_init(&pdev->dev, pdev->dev.of_node,
mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL); mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL);
if (r != 0) { if (r != 0)
gpiod_put_array(s->gpios);
return r; return r;
}
pdev->dev.platform_data = s; pdev->dev.platform_data = s;
return 0; return 0;
...@@ -70,7 +66,6 @@ static int mdio_mux_gpio_remove(struct platform_device *pdev) ...@@ -70,7 +66,6 @@ static int mdio_mux_gpio_remove(struct platform_device *pdev)
{ {
struct mdio_mux_gpio_state *s = dev_get_platdata(&pdev->dev); struct mdio_mux_gpio_state *s = dev_get_platdata(&pdev->dev);
mdio_mux_uninit(s->mux_handle); mdio_mux_uninit(s->mux_handle);
gpiod_put_array(s->gpios);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment