Root/target/linux/ar71xx/files/drivers/leds/leds-wndr3700-usb.c

1/*
2 * USB LED driver for the NETGEAR WNDR3700
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11#include <linux/leds.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14
15#include <asm/mach-ar71xx/ar71xx.h>
16
17#define DRIVER_NAME "wndr3700-led-usb"
18
19static void wndr3700_usb_led_set(struct led_classdev *cdev,
20                 enum led_brightness brightness)
21{
22    if (brightness)
23        ar71xx_device_start(RESET_MODULE_GE1_PHY);
24    else
25        ar71xx_device_stop(RESET_MODULE_GE1_PHY);
26}
27
28static enum led_brightness wndr3700_usb_led_get(struct led_classdev *cdev)
29{
30    return ar71xx_device_stopped(RESET_MODULE_GE1_PHY) ? LED_OFF : LED_FULL;
31}
32
33static struct led_classdev wndr3700_usb_led = {
34    .name = "wndr3700:green:usb",
35    .brightness_set = wndr3700_usb_led_set,
36    .brightness_get = wndr3700_usb_led_get,
37};
38
39static int __devinit wndr3700_usb_led_probe(struct platform_device *pdev)
40{
41    return led_classdev_register(&pdev->dev, &wndr3700_usb_led);
42}
43
44static int __devexit wndr3700_usb_led_remove(struct platform_device *pdev)
45{
46    led_classdev_unregister(&wndr3700_usb_led);
47    return 0;
48}
49
50static struct platform_driver wndr3700_usb_led_driver = {
51    .probe = wndr3700_usb_led_probe,
52    .remove = __devexit_p(wndr3700_usb_led_remove),
53    .driver = {
54        .name = DRIVER_NAME,
55        .owner = THIS_MODULE,
56    },
57};
58
59static int __init wndr3700_usb_led_init(void)
60{
61    return platform_driver_register(&wndr3700_usb_led_driver);
62}
63
64static void __exit wndr3700_usb_led_exit(void)
65{
66    platform_driver_unregister(&wndr3700_usb_led_driver);
67}
68
69module_init(wndr3700_usb_led_init);
70module_exit(wndr3700_usb_led_exit);
71
72MODULE_DESCRIPTION("USB LED driver for the NETGEAR WNDR3700");
73MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
74MODULE_LICENSE("GPL v2");
75MODULE_ALIAS("platform:" DRIVER_NAME);
76

Archive Download this file



interactive