Skip to content

Commit

Permalink
leds-fsg: change order of initialization and deinitialization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sven Wegener authored and Linus Torvalds committed Oct 4, 2008
1 parent 7fe7b2f commit 07f696c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions drivers/leds/leds-fsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ static int fsg_led_probe(struct platform_device *pdev)
{
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);
if (ret < 0)
goto failwlan;
Expand All @@ -185,20 +195,8 @@ static int fsg_led_probe(struct platform_device *pdev)
if (ret < 0)
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;

failremap:
led_classdev_unregister(&fsg_ring_led);
failring:
led_classdev_unregister(&fsg_sync_led);
failsync:
Expand All @@ -210,21 +208,23 @@ static int fsg_led_probe(struct platform_device *pdev)
failwan:
led_classdev_unregister(&fsg_wlan_led);
failwlan:
iounmap(latch_address);
failremap:

return ret;
}

static int fsg_led_remove(struct platform_device *pdev)
{
iounmap(latch_address);

led_classdev_unregister(&fsg_wlan_led);
led_classdev_unregister(&fsg_wan_led);
led_classdev_unregister(&fsg_sata_led);
led_classdev_unregister(&fsg_usb_led);
led_classdev_unregister(&fsg_sync_led);
led_classdev_unregister(&fsg_ring_led);

iounmap(latch_address);

return 0;
}

Expand Down

0 comments on commit 07f696c

Please sign in to comment.