leds-fsg: change order of initialization and deinitialization

On initialization, we first do the ioremap and then register the led devices.
On deinitialization, we do it in reverse order. This prevents someone calling
into the brightness_set functions with an invalid latch_address.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Acked-by: Rod Whitby <rod@whitby.id.au>
Acked-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Sven Wegener and committed by Linus Torvalds 07f696c7 7fe7b2f4

+14 -14
+14 -14
drivers/leds/leds-fsg.c
··· 161 { 162 int ret; 163 164 ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); 165 if (ret < 0) 166 goto failwlan; ··· 195 if (ret < 0) 196 goto failring; 197 198 - /* Map the LED chip select address space */ 199 - latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512); 200 - if (!latch_address) { 201 - ret = -ENOMEM; 202 - goto failremap; 203 - } 204 - 205 - latch_value = 0xffff; 206 - *latch_address = latch_value; 207 - 208 return ret; 209 210 - failremap: 211 - led_classdev_unregister(&fsg_ring_led); 212 failring: 213 led_classdev_unregister(&fsg_sync_led); 214 failsync: ··· 208 failwan: 209 led_classdev_unregister(&fsg_wlan_led); 210 failwlan: 211 212 return ret; 213 } 214 215 static int fsg_led_remove(struct platform_device *pdev) 216 { 217 - iounmap(latch_address); 218 - 219 led_classdev_unregister(&fsg_wlan_led); 220 led_classdev_unregister(&fsg_wan_led); 221 led_classdev_unregister(&fsg_sata_led); 222 led_classdev_unregister(&fsg_usb_led); 223 led_classdev_unregister(&fsg_sync_led); 224 led_classdev_unregister(&fsg_ring_led); 225 226 return 0; 227 }
··· 161 { 162 int ret; 163 164 + /* Map the LED chip select address space */ 165 + latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512); 166 + if (!latch_address) { 167 + ret = -ENOMEM; 168 + goto failremap; 169 + } 170 + 171 + latch_value = 0xffff; 172 + *latch_address = latch_value; 173 + 174 ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); 175 if (ret < 0) 176 goto failwlan; ··· 185 if (ret < 0) 186 goto failring; 187 188 return ret; 189 190 failring: 191 led_classdev_unregister(&fsg_sync_led); 192 failsync: ··· 210 failwan: 211 led_classdev_unregister(&fsg_wlan_led); 212 failwlan: 213 + iounmap(latch_address); 214 + failremap: 215 216 return ret; 217 } 218 219 static int fsg_led_remove(struct platform_device *pdev) 220 { 221 led_classdev_unregister(&fsg_wlan_led); 222 led_classdev_unregister(&fsg_wan_led); 223 led_classdev_unregister(&fsg_sata_led); 224 led_classdev_unregister(&fsg_usb_led); 225 led_classdev_unregister(&fsg_sync_led); 226 led_classdev_unregister(&fsg_ring_led); 227 + 228 + iounmap(latch_address); 229 230 return 0; 231 }