leds: convert led platform drivers to module_platform_driver
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / leds / leds-hp6xx.c
CommitLineData
d39a7a63
KE
1/*
2 * LED Triggers Core
3 * For the HP Jornada 620/660/680/690 handhelds
4 *
5 * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
6 * this driver is based on leds-spitz.c by Richard Purdie.
7 *
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.
11 */
12
86383b55 13#include <linux/module.h>
d39a7a63
KE
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/leds.h>
18#include <asm/hd64461.h>
7639a454 19#include <mach/hp6xx.h>
d39a7a63 20
4d404fd5
NM
21static void hp6xxled_green_set(struct led_classdev *led_cdev,
22 enum led_brightness value)
d39a7a63
KE
23{
24 u8 v8;
25
26 v8 = inb(PKDR);
27 if (value)
28 outb(v8 & (~PKDR_LED_GREEN), PKDR);
29 else
30 outb(v8 | PKDR_LED_GREEN, PKDR);
31}
32
4d404fd5
NM
33static void hp6xxled_red_set(struct led_classdev *led_cdev,
34 enum led_brightness value)
d39a7a63
KE
35{
36 u16 v16;
37
38 v16 = inw(HD64461_GPBDR);
39 if (value)
40 outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
41 else
42 outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
43}
44
45static struct led_classdev hp6xx_red_led = {
46 .name = "hp6xx:red",
47 .default_trigger = "hp6xx-charge",
48 .brightness_set = hp6xxled_red_set,
859cb7f2 49 .flags = LED_CORE_SUSPENDRESUME,
d39a7a63
KE
50};
51
52static struct led_classdev hp6xx_green_led = {
53 .name = "hp6xx:green",
54 .default_trigger = "ide-disk",
55 .brightness_set = hp6xxled_green_set,
859cb7f2 56 .flags = LED_CORE_SUSPENDRESUME,
d39a7a63
KE
57};
58
d39a7a63
KE
59static int hp6xxled_probe(struct platform_device *pdev)
60{
61 int ret;
62
63 ret = led_classdev_register(&pdev->dev, &hp6xx_red_led);
64 if (ret < 0)
65 return ret;
66
67 ret = led_classdev_register(&pdev->dev, &hp6xx_green_led);
68 if (ret < 0)
69 led_classdev_unregister(&hp6xx_red_led);
70
71 return ret;
72}
73
74static int hp6xxled_remove(struct platform_device *pdev)
75{
76 led_classdev_unregister(&hp6xx_red_led);
77 led_classdev_unregister(&hp6xx_green_led);
78
79 return 0;
80}
81
82static struct platform_driver hp6xxled_driver = {
83 .probe = hp6xxled_probe,
84 .remove = hp6xxled_remove,
d39a7a63
KE
85 .driver = {
86 .name = "hp6xx-led",
3c4ded97 87 .owner = THIS_MODULE,
d39a7a63
KE
88 },
89};
90
892a8843 91module_platform_driver(hp6xxled_driver);
d39a7a63
KE
92
93MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
94MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
95MODULE_LICENSE("GPL");
892a8843 96MODULE_ALIAS("platform:hp6xx-led");