Patchwork Re: [PATCH 1/3] input: pm8xxx_keypad: Qualcomm PMIC8XXX keypad controller driver

login
register
mail settings
Submitter Dmitry Torokhov
Date April 6, 2011, 10:20 p.m.
Message ID <20110406222022.GB11611@core.coreip.homeip.net>
Download mbox | patch
Permalink /patch/90097/
State New
Headers show

Comments

Dmitry Torokhov - April 6, 2011, 10:20 p.m.
Hi Anirudh,

On Sat, Mar 26, 2011 at 10:22:23PM +0530, Anirudh Ghayal wrote:
> +
> +#include <linux/mfd/pm8xxx/core.h>

I do not have this file so I won't be able to merge the driver. You will
have to merge it (with my Ack) with the rest of MFD patches.

Generally speaking the driver looks pretty clean, it would be great if
you could fold the patch below into it before merging.

Thanks.

Patch

diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 4adf817..949a738 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -106,7 +106,7 @@  struct pmic8xxx_kp {
 	u16 keystate[PM8XXX_MAX_ROWS];
 	u16 stuckstate[PM8XXX_MAX_ROWS];
 
-	u8			ctrl_reg;
+	u8 ctrl_reg;
 };
 
 static int pmic8xxx_kp_write_u8(struct pmic8xxx_kp *kp,
@@ -195,13 +195,13 @@  static int pmic8xxx_kp_read_data(struct pmic8xxx_kp *kp, u16 *state,
 	u8 new_data[PM8XXX_MAX_ROWS];
 
 	rc = pmic8xxx_kp_read(kp, new_data, data_reg, read_rows);
+	if (rc)
+		return rc;
 
-	if (!rc) {
-		for (row = 0; row < kp->pdata->num_rows; row++) {
-			dev_dbg(kp->dev, "new_data[%d] = %d\n", row,
-						new_data[row]);
-			state[row] = pmic8xxx_col_state(kp, new_data[row]);
-		}
+	for (row = 0; row < kp->pdata->num_rows; row++) {
+		dev_dbg(kp->dev, "new_data[%d] = %d\n", row,
+					new_data[row]);
+		state[row] = pmic8xxx_col_state(kp, new_data[row]);
 	}
 
 	return rc;
@@ -266,6 +266,7 @@  static void __pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
 					"pressed" : "released");
 
 			code = MATRIX_SCAN_CODE(row, col, PM8XXX_ROW_SHIFT);
+
 			input_event(kp->input, EV_MSC, MSC_SCAN, code);
 			input_report_key(kp->input,
 					kp->keycodes[code],
@@ -498,31 +499,33 @@  static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
 	u8 ctrl_val;
 
 	if (!pdata || !pdata->num_cols || !pdata->num_rows ||
-		pdata->num_cols > PM8XXX_MAX_COLS ||
-		pdata->num_rows > PM8XXX_MAX_ROWS ||
-		pdata->num_cols < PM8XXX_MIN_COLS) {
+	    pdata->num_cols > PM8XXX_MAX_COLS ||
+	    pdata->num_rows > PM8XXX_MAX_ROWS ||
+	    pdata->num_cols < PM8XXX_MIN_COLS) {
 		dev_err(&pdev->dev, "invalid platform data\n");
 		return -EINVAL;
 	}
 
-	if (!pdata->scan_delay_ms || pdata->scan_delay_ms > MAX_SCAN_DELAY
-		|| pdata->scan_delay_ms < MIN_SCAN_DELAY ||
-		!is_power_of_2(pdata->scan_delay_ms)) {
+	if (!pdata->scan_delay_ms ||
+            pdata->scan_delay_ms > MAX_SCAN_DELAY ||
+	    pdata->scan_delay_ms < MIN_SCAN_DELAY ||
+	    !is_power_of_2(pdata->scan_delay_ms)) {
 		dev_err(&pdev->dev, "invalid keypad scan time supplied\n");
 		return -EINVAL;
 	}
 
-	if (!pdata->row_hold_ns || pdata->row_hold_ns > MAX_ROW_HOLD_DELAY ||
-		pdata->row_hold_ns < MIN_ROW_HOLD_DELAY ||
-		((pdata->row_hold_ns % MIN_ROW_HOLD_DELAY) != 0)) {
+	if (!pdata->row_hold_ns ||
+	    pdata->row_hold_ns > MAX_ROW_HOLD_DELAY ||
+	    pdata->row_hold_ns < MIN_ROW_HOLD_DELAY ||
+	    ((pdata->row_hold_ns % MIN_ROW_HOLD_DELAY) != 0)) {
 		dev_err(&pdev->dev, "invalid keypad row hold time supplied\n");
 		return -EINVAL;
 	}
 
 	if (!pdata->debounce_ms ||
-		((pdata->debounce_ms % 5) != 0) ||
-		pdata->debounce_ms > MAX_DEBOUNCE_TIME ||
-		pdata->debounce_ms < MIN_DEBOUNCE_TIME) {
+	    ((pdata->debounce_ms % 5) != 0) ||
+	    pdata->debounce_ms > MAX_DEBOUNCE_TIME ||
+	    pdata->debounce_ms < MIN_DEBOUNCE_TIME) {
 		dev_err(&pdev->dev, "invalid debounce time supplied\n");
 		return -EINVAL;
 	}
@@ -655,16 +658,17 @@  static int __devexit pmic8xxx_kp_remove(struct platform_device *pdev)
 	free_irq(kp->key_stuck_irq, NULL);
 	free_irq(kp->key_sense_irq, NULL);
 	input_unregister_device(kp->input);
-	platform_set_drvdata(pdev, NULL);
 	kfree(kp);
 
+	platform_set_drvdata(pdev, NULL);
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int pmic8xxx_kp_suspend(struct device *dev)
 {
-	struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
+	struct platform_device *pdev = to_platform_device(dev);
+	struct pmic8xxx_kp *kp = platform_get_drvdata(dev);
 	struct input_dev *input_dev = kp->input;
 
 	if (device_may_wakeup(dev)) {
@@ -683,7 +687,8 @@  static int pmic8xxx_kp_suspend(struct device *dev)
 
 static int pmic8xxx_kp_resume(struct device *dev)
 {
-	struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
+	struct platform_device *pdev = to_platform_device(dev);
+	struct pmic8xxx_kp *kp = platform_get_drvdata(dev);
 	struct input_dev *input_dev = kp->input;
 
 	if (device_may_wakeup(dev)) {
@@ -699,22 +704,18 @@  static int pmic8xxx_kp_resume(struct device *dev)
 
 	return 0;
 }
-
-static const struct dev_pm_ops pm8xxx_kp_pm_ops = {
-	.suspend	= pmic8xxx_kp_suspend,
-	.resume		= pmic8xxx_kp_resume,
-};
 #endif
 
+static SIMPLE_DEV_PM_OPS(pm8xxx_kp_pm_ops,
+			 pmic8xxx_kp_suspend, pmic8xxx_kp_resume);
+
 static struct platform_driver pmic8xxx_kp_driver = {
 	.probe		= pmic8xxx_kp_probe,
 	.remove		= __devexit_p(pmic8xxx_kp_remove),
 	.driver		= {
 		.name = PM8XXX_KEYPAD_DEV_NAME,
 		.owner = THIS_MODULE,
-#ifdef CONFIG_PM
 		.pm = &pm8xxx_kp_pm_ops,
-#endif
 	},
 };