[kernel/2.6.38] fix gcc-4.6 set but unused warnings
[openwrt.git] / target / linux / omap24xx / patches-3.1 / 350-n8x0-gpioswitch-input.patch
1 ---
2 arch/arm/mach-omap2/board-n8x0.c | 73 +++++++++++++++++++++++++++++++++++++++
3 1 file changed, 73 insertions(+)
4
5 --- a/arch/arm/mach-omap2/board-n8x0.c
6 +++ b/arch/arm/mach-omap2/board-n8x0.c
7 @@ -316,6 +316,77 @@ void __init n8x0_bt_init(void)
8 BUG();
9 }
10
11 +struct gpio_switch_input_dev {
12 + struct input_dev *idev;
13 + unsigned int swcode;
14 +};
15 +
16 +static struct gpio_switch_input_dev *slide_input;
17 +static struct gpio_switch_input_dev *kblock_input;
18 +
19 +static void n8x0_gpio_switch_input_notify(struct gpio_switch_input_dev *gdev,
20 + int state)
21 +{
22 + if (gdev) {
23 + input_report_switch(gdev->idev, gdev->swcode, state);
24 + input_sync(gdev->idev);
25 + }
26 +}
27 +
28 +static void n8x0_slide_notify(void *data, int state)
29 +{
30 + n8x0_gpio_switch_input_notify(slide_input, state);
31 +}
32 +
33 +static void n8x0_kb_lock_notify(void *data, int state)
34 +{
35 + n8x0_gpio_switch_input_notify(kblock_input, state);
36 +}
37 +
38 +static struct gpio_switch_input_dev * __init gpioswitch_input_init(
39 + const char *name,
40 + unsigned int swcode)
41 +{
42 + struct gpio_switch_input_dev *gdev;
43 + int err;
44 +
45 + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
46 + if (!gdev)
47 + goto error;
48 + gdev->swcode = swcode;
49 +
50 + gdev->idev = input_allocate_device();
51 + if (!gdev->idev)
52 + goto err_free;
53 +
54 + gdev->idev->evbit[0] = BIT_MASK(EV_SW);
55 + gdev->idev->swbit[BIT_WORD(swcode)] = BIT_MASK(swcode);
56 + gdev->idev->name = name;
57 +
58 + err = input_register_device(gdev->idev);
59 + if (err)
60 + goto err_free_idev;
61 +
62 + return gdev;
63 +
64 +err_free_idev:
65 + input_free_device(gdev->idev);
66 +err_free:
67 + kfree(gdev);
68 +error:
69 + return NULL;
70 +}
71 +
72 +static int __init n8x0_gpio_switches_input_init(void)
73 +{
74 + slide_input = gpioswitch_input_init("slide", SW_KEYPAD_SLIDE);
75 + kblock_input = gpioswitch_input_init("kb_lock", SW_LID);
76 + if (WARN_ON(!slide_input || !kblock_input))
77 + return -ENODEV;
78 + return 0;
79 +}
80 +late_initcall(n8x0_gpio_switches_input_init);
81 +
82 static struct omap_gpio_switch n8x0_gpio_switches[] __initdata = {
83 {
84 .name = "headphone",
85 @@ -337,11 +408,13 @@ static struct omap_gpio_switch n8x0_gpio
86 .gpio = -1,
87 .debounce_rising = 200,
88 .debounce_falling = 200,
89 + .notify = n8x0_slide_notify,
90 }, {
91 .name = "kb_lock",
92 .gpio = -1,
93 .debounce_rising = 200,
94 .debounce_falling = 200,
95 + .notify = n8x0_kb_lock_notify,
96 },
97 };
98
This page took 0.051821 seconds and 5 git commands to generate.