Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mdio-gpio: Use devm_ functions where possible

This simplifies error path and deinit/removal functions.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Guenter Roeck and committed by
David S. Miller
78cdb079 bc383ea5

+5 -14
+5 -14
drivers/net/phy/mdio-gpio.c
··· 110 110 struct mdio_gpio_info *bitbang; 111 111 int i; 112 112 113 - bitbang = kzalloc(sizeof(*bitbang), GFP_KERNEL); 113 + bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL); 114 114 if (!bitbang) 115 115 goto out; 116 116 ··· 121 121 122 122 new_bus = alloc_mdio_bitbang(&bitbang->ctrl); 123 123 if (!new_bus) 124 - goto out_free_bitbang; 124 + goto out; 125 125 126 126 new_bus->name = "GPIO Bitbanged MDIO", 127 127 ··· 138 138 139 139 snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id); 140 140 141 - if (gpio_request(bitbang->mdc, "mdc")) 141 + if (devm_gpio_request(dev, bitbang->mdc, "mdc")) 142 142 goto out_free_bus; 143 143 144 - if (gpio_request(bitbang->mdio, "mdio")) 145 - goto out_free_mdc; 144 + if (devm_gpio_request(dev, bitbang->mdio, "mdio")) 145 + goto out_free_bus; 146 146 147 147 gpio_direction_output(bitbang->mdc, 0); 148 148 ··· 150 150 151 151 return new_bus; 152 152 153 - out_free_mdc: 154 - gpio_free(bitbang->mdc); 155 153 out_free_bus: 156 154 free_mdio_bitbang(new_bus); 157 - out_free_bitbang: 158 - kfree(bitbang); 159 155 out: 160 156 return NULL; 161 157 } ··· 159 163 static void mdio_gpio_bus_deinit(struct device *dev) 160 164 { 161 165 struct mii_bus *bus = dev_get_drvdata(dev); 162 - struct mdio_gpio_info *bitbang = bus->priv; 163 166 164 - dev_set_drvdata(dev, NULL); 165 - gpio_free(bitbang->mdio); 166 - gpio_free(bitbang->mdc); 167 167 free_mdio_bitbang(bus); 168 - kfree(bitbang); 169 168 } 170 169 171 170 static void mdio_gpio_bus_destroy(struct device *dev)