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 161 { 162 162 int ret; 163 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 + 164 174 ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); 165 175 if (ret < 0) 166 176 goto failwlan; ··· 195 185 if (ret < 0) 196 186 goto failring; 197 187 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 188 return ret; 209 189 210 - failremap: 211 - led_classdev_unregister(&fsg_ring_led); 212 190 failring: 213 191 led_classdev_unregister(&fsg_sync_led); 214 192 failsync: ··· 208 210 failwan: 209 211 led_classdev_unregister(&fsg_wlan_led); 210 212 failwlan: 213 + iounmap(latch_address); 214 + failremap: 211 215 212 216 return ret; 213 217 } 214 218 215 219 static int fsg_led_remove(struct platform_device *pdev) 216 220 { 217 - iounmap(latch_address); 218 - 219 221 led_classdev_unregister(&fsg_wlan_led); 220 222 led_classdev_unregister(&fsg_wan_led); 221 223 led_classdev_unregister(&fsg_sata_led); 222 224 led_classdev_unregister(&fsg_usb_led); 223 225 led_classdev_unregister(&fsg_sync_led); 224 226 led_classdev_unregister(&fsg_ring_led); 227 + 228 + iounmap(latch_address); 225 229 226 230 return 0; 227 231 }