Commit 07f696c7 authored by Sven Wegener's avatar Sven Wegener Committed by Linus Torvalds

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: default avatarSven Wegener <sven.wegener@stealer.net>
Acked-by: default avatarRod Whitby <rod@whitby.id.au>
Acked-by: default avatarRichard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7fe7b2f4
...@@ -161,6 +161,16 @@ static int fsg_led_probe(struct platform_device *pdev) ...@@ -161,6 +161,16 @@ static int fsg_led_probe(struct platform_device *pdev)
{ {
int ret; int ret;
/* Map the LED chip select address space */
latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
if (!latch_address) {
ret = -ENOMEM;
goto failremap;
}
latch_value = 0xffff;
*latch_address = latch_value;
ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); ret = led_classdev_register(&pdev->dev, &fsg_wlan_led);
if (ret < 0) if (ret < 0)
goto failwlan; goto failwlan;
...@@ -185,20 +195,8 @@ static int fsg_led_probe(struct platform_device *pdev) ...@@ -185,20 +195,8 @@ static int fsg_led_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
goto failring; goto failring;
/* Map the LED chip select address space */
latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
if (!latch_address) {
ret = -ENOMEM;
goto failremap;
}
latch_value = 0xffff;
*latch_address = latch_value;
return ret; return ret;
failremap:
led_classdev_unregister(&fsg_ring_led);
failring: failring:
led_classdev_unregister(&fsg_sync_led); led_classdev_unregister(&fsg_sync_led);
failsync: failsync:
...@@ -210,14 +208,14 @@ static int fsg_led_probe(struct platform_device *pdev) ...@@ -210,14 +208,14 @@ static int fsg_led_probe(struct platform_device *pdev)
failwan: failwan:
led_classdev_unregister(&fsg_wlan_led); led_classdev_unregister(&fsg_wlan_led);
failwlan: failwlan:
iounmap(latch_address);
failremap:
return ret; return ret;
} }
static int fsg_led_remove(struct platform_device *pdev) static int fsg_led_remove(struct platform_device *pdev)
{ {
iounmap(latch_address);
led_classdev_unregister(&fsg_wlan_led); led_classdev_unregister(&fsg_wlan_led);
led_classdev_unregister(&fsg_wan_led); led_classdev_unregister(&fsg_wan_led);
led_classdev_unregister(&fsg_sata_led); led_classdev_unregister(&fsg_sata_led);
...@@ -225,6 +223,8 @@ static int fsg_led_remove(struct platform_device *pdev) ...@@ -225,6 +223,8 @@ static int fsg_led_remove(struct platform_device *pdev)
led_classdev_unregister(&fsg_sync_led); led_classdev_unregister(&fsg_sync_led);
led_classdev_unregister(&fsg_ring_led); led_classdev_unregister(&fsg_ring_led);
iounmap(latch_address);
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