From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Lukasz Majewski <lukma@denx.de>
Cc: Lee Jones <lee.jones@linaro.org>,
linux-kernel@vger.kernel.org,
Sascha Hauer <s.hauer@pengutronix.de>,
Enrico Weigelt <info@metux.net>,
Thomas Gleixner <tglx@linutronix.de>,
Kate Stewart <kstewart@linuxfoundation.org>,
linux-input@vger.kernel.org
Subject: Re: [PATCH v2 3/3] input: touchscreen mc13xxx: Add mc34708 support
Date: Mon, 15 Jul 2019 00:07:02 -0700 [thread overview]
Message-ID: <20190715070702.GA153485@dtor-ws> (raw)
In-Reply-To: <20190711222346.5245-4-lukma@denx.de>
Hi Lukasz,
On Fri, Jul 12, 2019 at 12:23:46AM +0200, Lukasz Majewski wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> The mc34708 has a different bit to enable pen detection. This
> adds the driver data and devtype necessary to probe the device
> and to distinguish between the mc13783 and the mc34708.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>
> ---
> Changes for v2:
> - Change nested if statements to a single one (with cr0 > ...)
> - Replace hardcoded max resistance value (4080) with a generic driver data
> value.
> - Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
> defines
> - Define as driver data mask and value for accessing mc13xxx registers
>
> Changes from the original patch:
> - Simplify the mcXXXXX_set_pen_detection functions
> - Fix checkpatch warnings
> ---
> drivers/input/touchscreen/mc13783_ts.c | 59 +++++++++++++++++++++++++++++++---
> 1 file changed, 55 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
> index edd49e44e0c9..8fd3d0e47f57 100644
> --- a/drivers/input/touchscreen/mc13783_ts.c
> +++ b/drivers/input/touchscreen/mc13783_ts.c
> @@ -10,6 +10,7 @@
> */
> #include <linux/platform_device.h>
> #include <linux/mfd/mc13783.h>
> +#include <linux/mfd/mc34708.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/input.h>
> @@ -30,6 +31,8 @@ MODULE_PARM_DESC(sample_tolerance,
> "is supposed to be wrong and is discarded. Set to 0 to "
> "disable this check.");
>
> +struct mc13xxx_driver_data;
Why don't you define the structure here instead of sing forward
declaration? The structure is also commonly called as xxx_chip, so
struct mc13xxx_chip {
...
};
> +
> struct mc13783_ts_priv {
> struct input_dev *idev;
> struct mc13xxx *mc13xxx;
> @@ -37,6 +40,33 @@ struct mc13783_ts_priv {
> unsigned int sample[4];
> u8 ato;
> bool atox;
> + struct mc13xxx_driver_data *drvdata;
const struct mc13xxx_chip *chip;
> +};
> +
> +enum mc13xxx_type {
> + MC13XXX_TYPE_MC13783,
> + MC13XXX_TYPE_MC34708,
> +};
> +
> +struct mc13xxx_driver_data {
> + enum mc13xxx_type type;
> + int max_resistance;
> + u32 reg_mask;
> + u32 reg_value;
> +};
> +
> +static struct mc13xxx_driver_data mc13783_driver_data = {
> + .type = MC13XXX_TYPE_MC13783,
> .max_resistance = 4096,
> + .reg_mask = MC13XXX_ADC0_TSMOD_MASK,
> + .reg_value = MC13XXX_ADC0_TSMOD0,
> +};
> +
> +static struct mc13xxx_driver_data mc34708_driver_data = {
> + .type = MC13XXX_TYPE_MC34708,
> + .max_resistance = 4080,
> + .reg_mask = MC34708_ADC0_TSMASK,
> + .reg_value = MC34708_ADC0_TSPENDETEN,
> };
Have these 2 closer to the ID table.
>
> static irqreturn_t mc13783_ts_handler(int irq, void *data)
> @@ -93,6 +123,10 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
>
> cr0 = (cr0 + cr1) / 2;
>
> + if (priv->drvdata->type == MC13XXX_TYPE_MC34708 &&
> + cr0 > priv->drvdata->max_resistance)
> + cr0 = 0;
I would like to avoid the type comparisons. Given that both cr0 and cr1
can't be more than 4095 (because we limit them when parsing sampling
data) I think we can simply say
if (cr0 > priv->chip->max_resistance)
cr0 = 0;
Thanks.
--
Dmitry
next prev parent reply other threads:[~2019-07-15 7:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 22:23 [PATCH v2 0/3] mfd: mc13xxx: Fixes and enhancements for NXP's mc34708 Lukasz Majewski
2019-07-11 22:23 ` [PATCH v2 1/3] mfd: mc13xxx: Add mc34708 adc support Lukasz Majewski
2019-07-11 22:23 ` [PATCH v2 2/3] input: touchscreen mc13xxx: Make platform data optional Lukasz Majewski
2019-07-15 7:10 ` Dmitry Torokhov
2019-07-15 8:43 ` Lukasz Majewski
2019-07-15 18:27 ` Dmitry Torokhov
2019-07-16 7:02 ` Lukasz Majewski
2019-07-11 22:23 ` [PATCH v2 3/3] input: touchscreen mc13xxx: Add mc34708 support Lukasz Majewski
2019-07-15 7:07 ` Dmitry Torokhov [this message]
2019-07-15 9:13 ` Lukasz Majewski
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=20190715070702.GA153485@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=info@metux.net \
--cc=kstewart@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukma@denx.de \
--cc=s.hauer@pengutronix.de \
--cc=tglx@linutronix.de \
/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).