Remove the sfi 0.7 related code, and also adjust the power button
parsing code a little

Signed-off-by: Feng Tang <[email protected]>
---
 arch/x86/kernel/mrst.c |   70 +++++++++++-------------------------------------
 1 files changed, 16 insertions(+), 54 deletions(-)

diff --git a/arch/x86/kernel/mrst.c b/arch/x86/kernel/mrst.c
index feab066..86c584d 100644
--- a/arch/x86/kernel/mrst.c
+++ b/arch/x86/kernel/mrst.c
@@ -1354,7 +1354,6 @@ static struct gpio_keys_button gpio_button[] = {
        {KEY_CAMERA_FOCUS,      -1, 1, "camera_half",   EV_KEY, 0, 20},
        {SW_KEYPAD_SLIDE,       -1, 1, "MagSw1",        EV_SW,  0, 20},
        {SW_KEYPAD_SLIDE,       -1, 1, "MagSw2",        EV_SW,  0, 20},
-       {-1},/* must be ended with code = -1 */
 };
 
 static struct gpio_keys_platform_data mrst_gpio_keys = {
@@ -1371,68 +1370,31 @@ static struct platform_device pb_device = {
        },
 };
 
-static void __init pb_match(const char *name, int gpio)
+/*
+ * Shrink the non-existent buttons, register the gpio button
+ * device if there is some
+ */
+static int __init pb_keys_init(void)
 {
        struct gpio_keys_button *gb = gpio_button;
+       int i, num, good = 0;
 
-       while (gb->code != -1) {
-               if (!strcmp(name, gb->desc)) {
-                       gb->gpio = gpio;
-                       break;
-               }
-               gb++;
-       }
-}
+       num = sizeof(gpio_button) / sizeof(struct gpio_keys_button);
+       for (i = 0; i < num; i++) {
+               gb[i].gpio = get_gpio_by_name(gb[i].desc);
+               if (gb[i].gpio == -1)
+                       continue;
 
-/* shrink non-existent buttons and return total available number */
-static int __init pb_shrink(void)
-{
-       struct gpio_keys_button *gb = gpio_button;
-       struct gpio_keys_button *next = NULL;
-       int num = 0;
-
-       while (gb->code != -1) {
-               if (gb->gpio == -1) {
-                       if (!next)
-                               next = gb + 1;
-                       while (next->code != -1 && next->gpio == -1)
-                               next++;
-                       if (next->code == -1)/* end */
-                               break;
-                       *gb = *next;
-                       next->gpio = -1;
-                       next++;
-               }
-               num++;
-               gb++;
+               if (i != good)
+                       gb[good] = gb[i];
+               good++;
        }
-       return num;
-}
 
-static int __init pb_keys_init(void)
-{
-       int num;
-       /* for SFI 0.7, we have to claim static gpio buttons */
-       if (!gpio_table) {
-               pb_match("power_btn", 65);
-               pb_match("prog_btn1", 66);
-               pb_match("prog_btn2", 69);
-               pb_match("lid_switch", 101);
-       } else {/* SFI 0.8 */
-               struct gpio_keys_button *gb = gpio_button;
-
-               while (gb->code != -1) {
-                       gb->gpio = get_gpio_by_name(gb->desc);
-                       gb++;
-               }
-       }
-       num = pb_shrink();
-       if (num) {
-               mrst_gpio_keys.nbuttons = num;
+       if (good) {
+               mrst_gpio_keys.nbuttons = good;
                return platform_device_register(&pb_device);
        }
        return 0;
 }
-
 late_initcall(pb_keys_init);
 
-- 
1.7.0.4

_______________________________________________
Meego-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to