linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <zonque@gmail.com>
To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: linux-input@vger.kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: Re: [PATCH 1/1] Input: rotary-encoder: Add 'stepped' irq handler
Date: Sun, 29 Sep 2013 12:40:41 +0200	[thread overview]
Message-ID: <524803A9.5090708@gmail.com> (raw)
In-Reply-To: <1380392798-23345-2-git-send-email-ezequiel@vanguardiasur.com.ar>

Hi Ezequiel,

On 28.09.2013 20:26, Ezequiel Garcia wrote:
> Some rotary-encoder devices (such as those with detents) are capable
> of producing a stable event on each step. This commit adds support
> for this case, by implementing a new interruption handler.
> 
> The handler needs only detect the direction of the turn and generate
> an event according to this detection.
> 

> +static irqreturn_t rotary_encoder_stepped_irq(int irq, void *dev_id)
> +{
> +	struct rotary_encoder *encoder = dev_id;
> +	int state, sum;
> +
> +	state = rotary_encoder_get_state(encoder->pdata);
> +
> +	/*
> +	 * We encode the previous and the current state,
> +	 * in the 'sum' variable and then use a table
> +	 * to decide the direction of the turn.
> +	 */
> +	sum = (encoder->last_stable << 2) + state;
> +	switch (sum) {
> +	case 0b1101:
> +	case 0b0100:
> +	case 0b0010:
> +	case 0b1011:

Binary constants are frowned upon, please avoid them in the kernel.
checkpatch.pl should have warned you about them as well.

> diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
> index 3f594dc..499f6f7 100644
> --- a/include/linux/rotary_encoder.h
> +++ b/include/linux/rotary_encoder.h
> @@ -11,6 +11,7 @@ struct rotary_encoder_platform_data {
>  	bool relative_axis;
>  	bool rollover;
>  	bool half_period;
> +	bool on_each_step;

Care to add a DT binding for this property as well?


Other than that, this looks good to me, but I can't test it due to the
lack of hardware.


Thanks,
Daniel


  reply	other threads:[~2013-09-29 10:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28 18:26 [RFC/PATCH 0/1] rotary-encoder: Add new interruption handler Ezequiel Garcia
2013-09-28 18:26 ` [PATCH 1/1] Input: rotary-encoder: Add 'stepped' irq handler Ezequiel Garcia
2013-09-29 10:40   ` Daniel Mack [this message]
2013-09-29 17:29     ` Ezequiel García
2013-09-29 17:39       ` Daniel Mack

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=524803A9.5090708@gmail.com \
    --to=zonque@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=linux-input@vger.kernel.org \
    /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).