cgroup_freezer: prepare freezer_change_state() for full hierarchy support
[linux-2.6/libata-dev.git] / drivers / leds / leds-net48xx.c
blobf117f7326c5b632a356b37661775dc1e96f6a101
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/nsc_gpio.h>
20 #include <linux/scx200_gpio.h>
21 #include <linux/module.h>
23 #define DRVNAME "net48xx-led"
24 #define NET48XX_ERROR_LED_GPIO 20
26 static struct platform_device *pdev;
28 static void net48xx_error_led_set(struct led_classdev *led_cdev,
29 enum led_brightness value)
31 scx200_gpio_ops.gpio_set(NET48XX_ERROR_LED_GPIO, value ? 1 : 0);
34 static struct led_classdev net48xx_error_led = {
35 .name = "net48xx::error",
36 .brightness_set = net48xx_error_led_set,
37 .flags = LED_CORE_SUSPENDRESUME,
40 static int net48xx_led_probe(struct platform_device *pdev)
42 return led_classdev_register(&pdev->dev, &net48xx_error_led);
45 static int net48xx_led_remove(struct platform_device *pdev)
47 led_classdev_unregister(&net48xx_error_led);
48 return 0;
51 static struct platform_driver net48xx_led_driver = {
52 .probe = net48xx_led_probe,
53 .remove = net48xx_led_remove,
54 .driver = {
55 .name = DRVNAME,
56 .owner = THIS_MODULE,
60 static int __init net48xx_led_init(void)
62 int ret;
64 /* small hack, but scx200_gpio doesn't set .dev if the probe fails */
65 if (!scx200_gpio_ops.dev) {
66 ret = -ENODEV;
67 goto out;
70 ret = platform_driver_register(&net48xx_led_driver);
71 if (ret < 0)
72 goto out;
74 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
75 if (IS_ERR(pdev)) {
76 ret = PTR_ERR(pdev);
77 platform_driver_unregister(&net48xx_led_driver);
78 goto out;
81 out:
82 return ret;
85 static void __exit net48xx_led_exit(void)
87 platform_device_unregister(pdev);
88 platform_driver_unregister(&net48xx_led_driver);
91 module_init(net48xx_led_init);
92 module_exit(net48xx_led_exit);
94 MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
95 MODULE_DESCRIPTION("Soekris net48xx LED driver");
96 MODULE_LICENSE("GPL");