linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Lee Jones <lee.jones@linaro.org>, Wei Xu <xuwei5@hisilicon.com>,
	Guodong Xu <guodong.xu@linaro.org>
Subject: Re: [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC
Date: Thu, 2 Jun 2016 15:47:28 -0700	[thread overview]
Message-ID: <20160602224728.GA34193@dtor-ws> (raw)
In-Reply-To: <CALAqxLXE83Up24Lfb3sk6NPAzp4QW6ppdcsWHyT027Sbpb9NZg@mail.gmail.com>

On Thu, Jun 02, 2016 at 03:10:33PM -0700, John Stultz wrote:
> On Wed, Jun 1, 2016 at 7:10 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > Hi John,
> >
> > On Wed, Jun 01, 2016 at 02:27:39PM -0700, John Stultz 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: Pawel Moll <pawel.moll@arm.com>
> >> Cc: Mark Rutland <mark.rutland@arm.com>
> >> Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
> >> Cc: Kumar Gala <galak@codeaurora.org>
> >> Cc: Lee Jones <lee.jones@linaro.org>
> >> Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
> >> 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, and made a few small fixes and cleanups of my own]
> >> Signed-off-by: John Stultz <john.stultz@linaro.org>
> >> ---
> >>  drivers/input/misc/Kconfig         |   8 ++
> >>  drivers/input/misc/Makefile        |   1 +
> >>  drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
> >>  3 files changed, 237 insertions(+)
> >>  create mode 100644 drivers/input/misc/hisi_powerkey.c
> >>
> >> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> >> index 1f2337a..2e57bbd 100644
> >> --- a/drivers/input/misc/Kconfig
> >> +++ b/drivers/input/misc/Kconfig
> >> @@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
> >>         To compile this driver as a module, choose M here: the
> >>         module will be called drv2667-haptics.
> >>
> >> +config HISI_POWERKEY
> >> +     tristate "Hisilicon PMIC ONKEY support"
> >
> > Any depends on? Something MACH_XX || COMPILE_TEST?
> 
> Hey Dmitry!
> 
> Thanks so much for the review! I've got almost all your suggestions
> integrated (and it greatly simplifies things) and will resend
> tomorrow.

Actually, I was thinking about it some more and I wonder if it would not
be even simpler if we had 3 separate interrupt handlers, one for key
press, one fore key release, and another for toggling. Then you woudl
not need to iterate through IRQ numbers to figure out the action and
interrupt handlers would be really tiny:

static irqreturn_t hi65xx_power_press_isr(int irq, void *q)
{
	struct hi65xx_priv *p = q;

	pm_wakeup_event(&p->dev, MAX_HELD_TIME);
	input_report_key(p->input, KEY_POWER, 1);
	input_sync(p->input);
}

static irqreturn_t hi65xx_power_release_isr(int irq, void *q)
{
	struct hi65xx_priv *p = q;

	pm_wakeup_event(&p->dev, MAX_HELD_TIME); // Needed ?
	input_report_key(p->input, KEY_POWER, 0);
	input_sync(p->input);
}

static irqreturn_t hi65xx_restart_toggle_isr(int irq, void *q)
{
	struct hi65xx_priv *p = q;
	int value = test_bit(KEY_RESTART, p->input->keys);

	pm_wakeup_event(&p->dev, MAX_HELD_TIME);
	input_report_key(p->input, KEY_RESTART, !value);
	input_sync(p->input);
}

static struct hi65xx_isr_info {
	const char *name;
	irqreturn_t (*handler)(int irq, void *q);
} hi65xx_isr_info[] = {
	{ .name = "down", .handler = hi65xx_power_press_isr },
	{ .name = "up", .handler = hi65xx_power_release_isr },
	{ .name = "hold 4s", .handler = hi65xx_restart_toggle_isr },
};

> 
> One comment on your question below...
> 
> >> +             ret = devm_request_threaded_irq(dev, irq, NULL,
> >> +                                     irq_info[i].handler, IRQF_ONESHOT,
> >> +                                     irq_info[i].name, priv);
> >
> > Why threaded irq? Seems wasteful to have 3 threads for this.
> 
> As this is a nested interrupt, devm_request_irq was failing unless it
> was threaded.
> Any ideas for something better?

Ahh, that is unfortunate, but I guess we'll have to live with it. Please
use devm_request_any_context_irq() then to show that the driver itself
does not need threaded interrupt but platform may provide it.

Thanks.

-- 
Dmitry

  reply	other threads:[~2016-06-02 22:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-01 21:27 [RFC][PATCH 0/5] Hi655x powerkey support for HiKey John Stultz
2016-06-01 21:27 ` [RFC][PATCH 1/5] dts: bindings: Add binding documentation for hisilicon,hi6552-powerkey John Stultz
2016-06-01 21:27 ` [RFC][PATCH 2/5] hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt John Stultz
2016-06-08 14:31   ` Lee Jones
2016-06-08 17:22     ` John Stultz
2016-06-09 14:43       ` Lee Jones
2016-06-01 21:27 ` [RFC][PATCH 3/5] hi655x-pmic: Fixup issue with un-acked interrupts John Stultz
2016-06-08 14:32   ` Lee Jones
2016-06-01 21:27 ` [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC John Stultz
2016-06-02  2:10   ` Dmitry Torokhov
2016-06-02 22:10     ` John Stultz
2016-06-02 22:47       ` Dmitry Torokhov [this message]
2016-06-02 23:15         ` John Stultz
2016-06-02 23:33           ` Dmitry Torokhov
2016-06-01 21:27 ` [RFC][PATCH 5/5] arm64: dts: Add powerkey info to pmic for hi6220-hikey John Stultz
2016-06-01 21:48   ` Rob Herring

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=20160602224728.GA34193@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=guodong.xu@linaro.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=john.stultz@linaro.org \
    --cc=jorge.ramirez-ortiz@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.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;
as well as URLs for NNTP newsgroup(s).