public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: John Stultz <john.stultz@linaro.org>
Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Lee Jones <lee.jones@linaro.org>,
	Feng Chen <puck.chen@hisilicon.com>,
	Wei Xu <xuwei5@hisilicon.com>, Guodong Xu <guodong.xu@linaro.org>
Subject: Re: [PATCH 1/4] drivers: input: powerkey for HISI 65xx SoC
Date: Wed, 22 Jun 2016 17:47:16 -0700	[thread overview]
Message-ID: <20160623004716.GA26808@dtor-ws> (raw)
In-Reply-To: <CALAqxLWeG5Lj8Gg7kSeh6x-xM-tVNRQcttPdpk_Y07+65UJMbw@mail.gmail.com>

On Tue, Jun 21, 2016 at 05:06:23PM -0700, John Stultz wrote:
> On Tue, Jun 14, 2016 at 3:43 PM, John Stultz <john.stultz@linaro.org> wrote:
> > From: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
> >
> > This driver provides a input driver for the power button on the
> > HiSi 65xx SoC for boards like HiKey.
> >
> > This driver was originally by Zhiliang Xue <xuezhiliang@huawei.com>
> > then basically rewritten by Jorge, but preserving the original
> > module author credits.
> >
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
> > Cc: Feng Chen <puck.chen@hisilicon.com>
> > Cc: Wei Xu <xuwei5@hisilicon.com>
> > Cc: Guodong Xu <guodong.xu@linaro.org>
> > Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
> > [jstultz: Reworked commit message, folded in other fixes/cleanups
> > from Jorge, implemented some larger cleanups suggested by DmitryT]
> > Signed-off-by: John Stultz <john.stultz@linaro.org>
> > ---
> > v2: Major rework integrating feedback from Dmitry.
> > v3: Dropped of_match compatible line since no longer using DT
> >     for this.
> > v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
> >     I missed in the last revision, which casued build issues w/
> >     modules.
> 
> Hey Dmitry,
>   Just wanted to ping you to see if there was anything else you were
> wanting changed with this patch. Lee has queued the mfd patches in
> -next, so I wanted to be sure to address any concerns you had that was
> keeping this from heading upstream in 4.8 (hopefully :).

Right, sorry, does the following look OK to you? 

Thanks.

-- 
Dmitry


Input: hisi_powerkey - misc changes

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/misc/hisi_powerkey.c |  101 +++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 53 deletions(-)

diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c
index e5ab5d8..675539c 100644
--- a/drivers/input/misc/hisi_powerkey.c
+++ b/drivers/input/misc/hisi_powerkey.c
@@ -26,101 +26,96 @@
 /* the held interrupt will trigger after 4 seconds */
 #define MAX_HELD_TIME	(4 * MSEC_PER_SEC)
 
-
-enum id_action { ID_PRESSED, ID_RELEASED, ID_HELD, ID_LAST };
-const char *const irq_names[ID_LAST] = {"down", "up", "hold 4s"};
-
-struct hi65xx_priv {
-	struct input_dev *input;
-};
-
 static irqreturn_t hi65xx_power_press_isr(int irq, void *q)
 {
-	struct hi65xx_priv *p = q;
+	struct input_dev *input = q;
 
-	pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
-	input_report_key(p->input, KEY_POWER, 1);
-	input_sync(p->input);
+	pm_wakeup_event(input->dev.parent, MAX_HELD_TIME);
+	input_report_key(input, KEY_POWER, 1);
+	input_sync(input);
 
 	return IRQ_HANDLED;
 }
 
 static irqreturn_t hi65xx_power_release_isr(int irq, void *q)
 {
-	struct hi65xx_priv *p = q;
+	struct input_dev *input = q;
 
-	pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
-	input_report_key(p->input, KEY_POWER, 0);
-	input_sync(p->input);
+	pm_wakeup_event(input->dev.parent, MAX_HELD_TIME);
+	input_report_key(input, KEY_POWER, 0);
+	input_sync(input);
 
 	return IRQ_HANDLED;
 }
 
 static irqreturn_t hi65xx_restart_toggle_isr(int irq, void *q)
 {
-	struct hi65xx_priv *p = q;
-	int value = test_bit(KEY_RESTART, p->input->key);
+	struct input_dev *input = q;
+	int value = test_bit(KEY_RESTART, input->key);
 
-	pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
-	input_report_key(p->input, KEY_RESTART, !value);
-	input_sync(p->input);
+	pm_wakeup_event(input->dev.parent, MAX_HELD_TIME);
+	input_report_key(input, KEY_RESTART, !value);
+	input_sync(input);
 
 	return IRQ_HANDLED;
 }
 
-irqreturn_t (*irq_handlers[ID_LAST])(int irq, void *q) = {
-	hi65xx_power_press_isr,
-	hi65xx_power_release_isr,
-	hi65xx_restart_toggle_isr,
+static const struct {
+	const char *name;
+	irqreturn_t (*handler)(int irq, void *q);
+} hi65xx_irq_info[] = {
+	{ "down", hi65xx_power_press_isr },
+	{ "up", hi65xx_power_release_isr },
+	{ "hold 4s", hi65xx_restart_toggle_isr },
 };
 
 static int hi65xx_powerkey_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct hi65xx_priv *priv;
-	int irq, i, ret;
-
-	priv = devm_kzalloc(dev, sizeof(struct hi65xx_priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	struct input_dev *input;
+	int irq, i, error;
 
-	priv->input = devm_input_allocate_device(&pdev->dev);
-	if (!priv->input) {
+	input = devm_input_allocate_device(&pdev->dev);
+	if (!input) {
 		dev_err(&pdev->dev, "failed to allocate input device\n");
 		return -ENOMEM;
 	}
 
-	priv->input->phys = "hisi_on/input0";
-	priv->input->name = "HISI 65xx PowerOn Key";
+	input->phys = "hisi_on/input0";
+	input->name = "HISI 65xx PowerOn Key";
 
-	input_set_capability(priv->input, EV_KEY, KEY_POWER);
-	input_set_capability(priv->input, EV_KEY, KEY_RESTART);
+	input_set_capability(input, EV_KEY, KEY_POWER);
+	input_set_capability(input, EV_KEY, KEY_RESTART);
 
-	for (i = 0; i < ID_LAST; i++) {
+	for (i = 0; i < ARRAY_SIZE(hi65xx_irq_info); i++) {
 
-		irq = platform_get_irq_byname(pdev, irq_names[i]);
+		irq = platform_get_irq_byname(pdev, hi65xx_irq_info[i].name);
 		if (irq < 0) {
-			dev_err(dev, "couldn't get irq %s\n", irq_names[i]);
-			return irq;
+			error = irq;
+			dev_err(dev, "couldn't get irq %s: %d\n",
+				hi65xx_irq_info[i].name, error);
+			return error;
 		}
 
-		ret = devm_request_any_context_irq(dev, irq,
-					irq_handlers[i], IRQF_ONESHOT,
-					irq_names[i], priv);
-		if (ret < 0) {
-			dev_err(dev, "couldn't get irq %s\n", irq_names[i]);
-			return ret;
+		error = devm_request_any_context_irq(dev, irq,
+						     hi65xx_irq_info[i].handler,
+						     IRQF_ONESHOT,
+						     hi65xx_irq_info[i].name,
+						     input);
+		if (error < 0) {
+			dev_err(dev, "couldn't request irq %s: %d\n",
+				hi65xx_irq_info[i].name, error);
+			return error;
 		}
 	}
 
-	ret = input_register_device(priv->input);
-	if (ret) {
+	error = input_register_device(input);
+	if (error) {
 		dev_err(&pdev->dev, "failed to register input device: %d\n",
-			ret);
-		return ret;
+			error);
+		return error;
 	}
 
-	platform_set_drvdata(pdev, priv);
 	device_init_wakeup(&pdev->dev, 1);
 
 	return 0;
@@ -129,6 +124,7 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev)
 static int hi65xx_powerkey_remove(struct platform_device *pdev)
 {
 	device_init_wakeup(&pdev->dev, 0);
+
 	return 0;
 }
 
@@ -139,7 +135,6 @@ static struct platform_driver hi65xx_powerkey_driver = {
 	.probe = hi65xx_powerkey_probe,
 	.remove  = hi65xx_powerkey_remove,
 };
-
 module_platform_driver(hi65xx_powerkey_driver);
 
 MODULE_AUTHOR("Zhiliang Xue <xuezhiliang@huawei.com");

  reply	other threads:[~2016-06-23  0:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 22:43 [PATCH 0/4] Hi655x powerkey support for HiKey (v4) John Stultz
2016-06-14 22:43 ` [PATCH 1/4] drivers: input: powerkey for HISI 65xx SoC John Stultz
2016-06-22  0:06   ` John Stultz
2016-06-23  0:47     ` Dmitry Torokhov [this message]
2016-06-23 20:31       ` John Stultz
2016-06-23 20:40         ` Dmitry Torokhov
2016-06-23 20:47           ` Dmitry Torokhov
2016-06-23 20:54             ` John Stultz
2016-06-23 21:03               ` Dmitry Torokhov
2016-06-14 22:43 ` [PATCH 2/4] mfd: hi655x-pmic: Fixup issue with un-acked interrupts John Stultz
2016-06-15 12:54   ` Lee Jones
2016-06-14 22:43 ` [PATCH 3/4] mfd: hi655x-pmic: Rename some interrupt macro names John Stultz
2016-06-15 12:54   ` Lee Jones
2016-06-14 22:43 ` [PATCH 4/4] mfd: hi655x-pmic: Add powerkey device to hi655x PMIC driver John Stultz
2016-06-15 12:54   ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160623004716.GA26808@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=guodong.xu@linaro.org \
    --cc=john.stultz@linaro.org \
    --cc=jorge.ramirez-ortiz@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=puck.chen@hisilicon.com \
    --cc=robh+dt@kernel.org \
    --cc=xuwei5@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox