[PATCH] Have x86_64 use add_active_range() and free_area_init_nodes
[linux-2.6/mini2440.git] / drivers / leds / leds-net48xx.c
blob713c4a8aa77dc347af774edc6ddf2f11fe58176b
1 /*
2 * LEDs driver for Soekris net48xx
4 * Copyright (C) 2006 Chris Boot <bootc@bootc.net>
6 * Based on leds-ams-delta.c
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <linux/err.h>
18 #include <asm/io.h>
19 #include <linux/scx200_gpio.h>
21 #define DRVNAME "net48xx-led"
22 #define NET48XX_ERROR_LED_GPIO 20
24 static struct platform_device *pdev;
26 static void net48xx_error_led_set(struct led_classdev *led_cdev,
27 enum led_brightness value)
29 if (value)
30 scx200_gpio_set_high(NET48XX_ERROR_LED_GPIO);
31 else
32 scx200_gpio_set_low(NET48XX_ERROR_LED_GPIO);
35 static struct led_classdev net48xx_error_led = {
36 .name = "net48xx:error",
37 .brightness_set = net48xx_error_led_set,
40 #ifdef CONFIG_PM
41 static int net48xx_led_suspend(struct platform_device *dev,
42 pm_message_t state)
44 led_classdev_suspend(&net48xx_error_led);
45 return 0;
48 static int net48xx_led_resume(struct platform_device *dev)
50 led_classdev_resume(&net48xx_error_led);
51 return 0;
53 #else
54 #define net48xx_led_suspend NULL
55 #define net48xx_led_resume NULL
56 #endif
58 static int net48xx_led_probe(struct platform_device *pdev)
60 return led_classdev_register(&pdev->dev, &net48xx_error_led);
63 static int net48xx_led_remove(struct platform_device *pdev)
65 led_classdev_unregister(&net48xx_error_led);
66 return 0;
69 static struct platform_driver net48xx_led_driver = {
70 .probe = net48xx_led_probe,
71 .remove = net48xx_led_remove,
72 .suspend = net48xx_led_suspend,
73 .resume = net48xx_led_resume,
74 .driver = {
75 .name = DRVNAME,
76 .owner = THIS_MODULE,
80 static int __init net48xx_led_init(void)
82 int ret;
84 if (!scx200_gpio_present()) {
85 ret = -ENODEV;
86 goto out;
89 ret = platform_driver_register(&net48xx_led_driver);
90 if (ret < 0)
91 goto out;
93 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
94 if (IS_ERR(pdev)) {
95 ret = PTR_ERR(pdev);
96 platform_driver_unregister(&net48xx_led_driver);
97 goto out;
100 out:
101 return ret;
104 static void __exit net48xx_led_exit(void)
106 platform_device_unregister(pdev);
107 platform_driver_unregister(&net48xx_led_driver);
110 module_init(net48xx_led_init);
111 module_exit(net48xx_led_exit);
113 MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
114 MODULE_DESCRIPTION("Soekris net48xx LED driver");
115 MODULE_LICENSE("GPL");