Merge branch 'torvalds/master'
[firefly-linux-kernel-4.4.55.git] / drivers / input / keyboard / imx_keypad.c
index 03c8cc5cb6c144433c2883f12ca8685ba4bc7c26..2165f3dd328babc2285a0e98e5bcf06fc423b983 100644 (file)
@@ -5,15 +5,12 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
- *
- * <<Power management needs to be implemented>>.
  */
 
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -416,7 +413,7 @@ open_err:
 }
 
 #ifdef CONFIG_OF
-static struct of_device_id imx_keypad_of_match[] = {
+static const struct of_device_id imx_keypad_of_match[] = {
        { .compatible = "fsl,imx21-kpp", },
        { /* sentinel */ }
 };
@@ -425,7 +422,8 @@ MODULE_DEVICE_TABLE(of, imx_keypad_of_match);
 
 static int imx_keypad_probe(struct platform_device *pdev)
 {
-       const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
+       const struct matrix_keymap_data *keymap_data =
+                       dev_get_platdata(&pdev->dev);
        struct imx_keypad *keypad;
        struct input_dev *input_dev;
        struct resource *res;
@@ -439,13 +437,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "no irq defined in platform data\n");
-               return -EINVAL;
-       }
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (res == NULL) {
-               dev_err(&pdev->dev, "no I/O memory defined in platform data\n");
-               return -EINVAL;
+               return irq;
        }
 
        input_dev = devm_input_allocate_device(&pdev->dev);
@@ -454,8 +446,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       keypad = devm_kzalloc(&pdev->dev, sizeof(struct imx_keypad),
-                            GFP_KERNEL);
+       keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL);
        if (!keypad) {
                dev_err(&pdev->dev, "not enough memory for driver data\n");
                return -ENOMEM;
@@ -468,6 +459,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
        setup_timer(&keypad->check_matrix_timer,
                    imx_keypad_check_for_events, (unsigned long) keypad);
 
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(keypad->mmio_base))
                return PTR_ERR(keypad->mmio_base);
@@ -512,7 +504,9 @@ static int imx_keypad_probe(struct platform_device *pdev)
        input_set_drvdata(input_dev, keypad);
 
        /* Ensure that the keypad will stay dormant until opened */
-       clk_prepare_enable(keypad->clk);
+       error = clk_prepare_enable(keypad->clk);
+       if (error)
+               return error;
        imx_keypad_inhibit(keypad);
        clk_disable_unprepare(keypad->clk);
 
@@ -536,8 +530,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int imx_kbd_suspend(struct device *dev)
+static int __maybe_unused imx_kbd_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct imx_keypad *kbd = platform_get_drvdata(pdev);
@@ -557,7 +550,7 @@ static int imx_kbd_suspend(struct device *dev)
        return 0;
 }
 
-static int imx_kbd_resume(struct device *dev)
+static int __maybe_unused imx_kbd_resume(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct imx_keypad *kbd = platform_get_drvdata(pdev);
@@ -580,14 +573,12 @@ err_clk:
 
        return ret;
 }
-#endif
 
 static SIMPLE_DEV_PM_OPS(imx_kbd_pm_ops, imx_kbd_suspend, imx_kbd_resume);
 
 static struct platform_driver imx_keypad_driver = {
        .driver         = {
                .name   = "imx-keypad",
-               .owner  = THIS_MODULE,
                .pm     = &imx_kbd_pm_ops,
                .of_match_table = of_match_ptr(imx_keypad_of_match),
        },