linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@caiaq.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org,
	H Hartley Sweeten <hsweeten@visionengravers.com>
Subject: Re: [PATCH] generic driver for rotary encoders on GPIOs
Date: Wed, 4 Mar 2009 10:50:53 +0100	[thread overview]
Message-ID: <20090304095053.GA6098@buzzloop.caiaq.de> (raw)
In-Reply-To: <20090304084851.GB7394@dtor-d630.eng.vmware.com>

On Wed, Mar 04, 2009 at 12:48:52AM -0800, Dmitry Torokhov wrote:
> On Tue, Mar 03, 2009 at 10:59:27AM +0100, Daniel Mack wrote:
> > This patch adds a generic driver for rotary encoders connected to GPIO
> > pins of a system. It relies on gpiolib and generic hardware irqs. The
> > documentation that also comes with this patch explains the concept and
> > how to use the driver.
> > 
> > Signed-off-by: Daniel Mack <daniel@caiaq.de>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> > ---
> >  New version with Dmitry's change requests included:
> > 
> >   * calling input_free_device() in case input_register_device() fails
> >   * calling input_unregister_device() in all other cases
> >   * made the axis information part of the platform data
> > 
> 
> I fiddled with the driver a little bit more changing formatting, please
> take a look and if you are still OK with it I will apply to 'next'.

Ok for me, except for one thing ...

> +	case 0x0:
> +		if (encoder->armed) {
> +			if (encoder->dir) {
> +				/* turning counter-clockwise */
> +				encoder->pos += pdata->steps;
> +				encoder->pos--;
> +				encoder->pos %= pdata->steps;
> +			} else {
> +				/* turning clockwise */
> +				encoder->pos++;
> +				encoder->pos %= pdata->steps;
> +			}
> +			input_report_abs(encoder->input,
> +					 pdata->axis, encoder->pos);
> +			input_sync(encoder->input);
> +			encoder->armed = 0;
> +		}

I really prefer early exits ("if (!encoder->armed) break;") as it saves
one indentation level and makes the code more readable.

Thanks,
Daniel


  reply	other threads:[~2009-03-04  9:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26 18:00 [PATCH] generic driver for rotary encoders on GPIOs Daniel Mack
2009-02-26 18:42 ` Daniel Mack
2009-02-27  3:18   ` hartleys
2009-02-27  6:43     ` Daniel Mack
2009-02-27  8:48       ` Daniel Mack
2009-02-27 17:13       ` hartleys
2009-02-27 17:17         ` Daniel Mack
2009-02-27 18:00       ` Daniel Mack
2009-02-27 18:30         ` hartleys
2009-02-27 18:34           ` Daniel Mack
2009-02-27 20:15             ` hartleys
2009-03-02 14:43               ` Daniel Mack
2009-03-03  8:52                 ` Dmitry Torokhov
2009-03-03  9:03                   ` Dmitry Torokhov
2009-03-03  9:59                     ` Daniel Mack
2009-03-04  8:48                       ` Dmitry Torokhov
2009-03-04  9:50                         ` Daniel Mack [this message]
2009-03-04 17:02                           ` hartleys
2009-03-04 17:20                             ` Daniel Mack
2009-03-07 17:06                               ` Daniel Mack
2009-04-13 23:06                                 ` [PATCH] add REL_* axes support to the rotary encoder driver H Hartley Sweeten
2009-04-14  5:50                                   ` Daniel Mack
2009-04-14 15:33                                     ` H Hartley Sweeten
2009-04-16  2:08                                   ` Dmitry Torokhov
2009-04-16  2:24                                     ` H Hartley Sweeten
2009-04-16  2:33                                       ` Dmitry Torokhov
2009-04-16  3:11                                         ` H Hartley Sweeten
2009-04-16  6:35                                           ` Daniel Mack
2009-04-16  8:05                                           ` Daniel Mack
2009-04-16 16:48                                             ` H Hartley Sweeten
2009-04-16  8:39                                           ` Daniel Mack
2009-04-16 17:09                                             ` H Hartley Sweeten

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=20090304095053.GA6098@buzzloop.caiaq.de \
    --to=daniel@caiaq.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hsweeten@visionengravers.com \
    --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).