From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
sameo@linux.intel.com, jic23@cam.ac.uk, balbi@ti.com
Subject: Re: [PATCH 3/5] input/ti_am335x_tsc: fold regbit_map() and simplfy
Date: Tue, 4 Jun 2013 09:53:11 -0700 [thread overview]
Message-ID: <20130604165311.GG26400@core.coreip.homeip.net> (raw)
In-Reply-To: <1369847397-27451-4-git-send-email-bigeasy@linutronix.de>
On Wed, May 29, 2013 at 07:09:54PM +0200, Sebastian Andrzej Siewior wrote:
> If we put the values which are looked up by regbit_map() directly in the
> config array then we can remove the function.
> And now when I look at it I don't understand why the array has to have
> two dimensions. One does it, too. And while at it, the description says
> that AIN0 … AIN7 can be used so allow this.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/input/touchscreen/ti_am335x_tsc.c | 76 ++++++++---------------------
> 1 file changed, 19 insertions(+), 57 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index 7c97fc7..63cee57 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -37,15 +37,11 @@
> #define TSCADC_DELTA_X 15
> #define TSCADC_DELTA_Y 15
>
> -/*
> - * Refer to function regbit_map() to
> - * map the values in the matrix.
> - */
> -static int config[4][4] = {
> - {1, 0, 1, 0},
> - {2, 3, 2, 3},
> - {4, 5, 4, 5},
> - {0, 6, 0, 6}
> +static const int config_pins[] = {
> + XPP,
> + XNN,
> + YPP,
> + YNN,
> };
>
> struct titsc {
> @@ -79,45 +75,11 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg,
> regmap_write(tsc->mfd_tscadc->regmap_tscadc, reg, val);
> }
>
> -/*
> - * Each of the analog lines are mapped
> - * with one or two register bits,
> - * which can be either pulled high/low
> - * depending on the value to be read.
> - */
> -static int regbit_map(int val)
> -{
> - int map_bits = 0;
> -
> - switch (val) {
> - case 1:
> - map_bits = XPP;
> - break;
> - case 2:
> - map_bits = XNP;
> - break;
> - case 3:
> - map_bits = XNN;
> - break;
> - case 4:
> - map_bits = YPP;
> - break;
> - case 5:
> - map_bits = YPN;
> - break;
> - case 6:
> - map_bits = YNN;
> - break;
> - }
> -
> - return map_bits;
> -}
> -
> static int titsc_config_wires(struct titsc *ts_dev)
> {
> u32 analog_line[4];
> u32 wire_order[4];
> - int i, temp_bits;
> + int i, bit_cfg;
>
> for (i = 0; i < 4; i++) {
> /*
> @@ -126,9 +88,9 @@ static int titsc_config_wires(struct titsc *ts_dev)
> */
> analog_line[i] = (ts_dev->config_inp[i] & 0xF0) >> 4;
> wire_order[i] = ts_dev->config_inp[i] & 0x0F;
> - if (WARN_ON(analog_line[i] > 4))
> + if (WARN_ON(analog_line[i] > 7))
> return -EINVAL;
> - if (WARN_ON(wire_order[i] > 4))
> + if (WARN_ON(wire_order[i] > ARRAY_SIZE(config_pins)))
> return -EINVAL;
> }
>
> @@ -138,27 +100,27 @@ static int titsc_config_wires(struct titsc *ts_dev)
>
> an_line = analog_line[i];
> wi_order = wire_order[i];
> - temp_bits = config[an_line][wi_order];
> - if (temp_bits == 0)
> + bit_cfg = config_pins[wi_order];
> + if (bit_cfg == 0)
> return -EINVAL;
> - switch (wire_order[i]) {
> + switch (wi_order) {
> case 0:
> - ts_dev->bit_xp = regbit_map(temp_bits);
> - ts_dev->inp_xp = analog_line[i];
> + ts_dev->bit_xp = bit_cfg;
> + ts_dev->inp_xp = an_line;
> break;
>
> case 1:
> - ts_dev->bit_xn = regbit_map(temp_bits);
> - ts_dev->inp_xn = analog_line[i];
> + ts_dev->bit_xn = bit_cfg;
> + ts_dev->inp_xn = an_line;
> break;
>
> case 2:
> - ts_dev->bit_yp = regbit_map(temp_bits);
> - ts_dev->inp_yp = analog_line[i];
> + ts_dev->bit_yp = bit_cfg;
> + ts_dev->inp_yp = an_line;
> break;
> case 3:
> - ts_dev->bit_yn = regbit_map(temp_bits);
> - ts_dev->inp_yn = analog_line[i];
> + ts_dev->bit_yn = bit_cfg;
> + ts_dev->inp_yn = an_line;
> break;
> }
> }
> --
> 1.7.10.4
>
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-06-04 16:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-29 17:09 am335x adc & tsc, second batch Sebastian Andrzej Siewior
2013-05-29 17:09 ` [PATCH 1/5] drivers/iio: am335x_adc: cleanup on missing DT nodes Sebastian Andrzej Siewior
[not found] ` <1369847397-27451-2-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-02 17:56 ` Jonathan Cameron
[not found] ` <51AB8758.5010705-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-04 10:38 ` Sebastian Andrzej Siewior
2013-05-29 17:09 ` [PATCH 3/5] input/ti_am335x_tsc: fold regbit_map() and simplfy Sebastian Andrzej Siewior
2013-06-04 16:53 ` Dmitry Torokhov [this message]
2013-05-29 17:09 ` [PATCH 4/5] iio/ti_am335x_adc: Allow to specify input line Sebastian Andrzej Siewior
[not found] ` <1369847397-27451-5-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-02 18:02 ` Jonathan Cameron
[not found] ` <51AB88BE.6040109-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-04 10:39 ` Sebastian Andrzej Siewior
[not found] ` <1369847397-27451-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-05-29 17:09 ` [PATCH 2/5] input/ti_am335x_adc: use only FIFO0 and clean up a little Sebastian Andrzej Siewior
2013-06-04 16:52 ` Dmitry Torokhov
2013-05-29 17:09 ` [PATCH 5/5] iio/ti_am335x_adc: check if we found the value Sebastian Andrzej Siewior
[not found] ` <1369847397-27451-6-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-02 18:03 ` Jonathan Cameron
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=20130604165311.GG26400@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=balbi@ti.com \
--cc=bigeasy@linutronix.de \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=sameo@linux.intel.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).