From: Trilok Soni <soni.trilok@gmail.com>
To: Manuel Lauss <mano@roarinelk.homelinux.net>
Cc: Kwangwoo Lee <kwlee@mtekvision.com>,
linux-kernel@vger.kernel.org,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Subject: Re: [PATCH] TSC2007: private data for platform callbacks.
Date: Thu, 14 May 2009 15:58:19 +0530 [thread overview]
Message-ID: <5d5443650905140328v319e673o2f7b865e21619486@mail.gmail.com> (raw)
In-Reply-To: <20090514100909.GA23626@roarinelk.homelinux.net>
Hi Manuel,
CCing linux-input mailing list, so not deleting any code from this
e-mail while replying.
On Thu, May 14, 2009 at 3:39 PM, Manuel Lauss
<mano@roarinelk.homelinux.net> wrote:
> Add a private data field to the tsc2007 platform data and pass this
> to the callbacks.
I hope that you have created this patch on top of two recently posted
patches by Kwangwoo Lee
to merge changes from Thierry.
>
> Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
> ---
> drivers/input/touchscreen/tsc2007.c | 52 +++++++++++++++++++++++-----------
> include/linux/i2c/tsc2007.h | 10 ++++---
> 2 files changed, 41 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 948e167..5c4242d 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -83,10 +83,35 @@ struct tsc2007 {
> unsigned pendown;
> int irq;
>
> - int (*get_pendown_state)(void);
> - void (*clear_penirq)(void);
> + struct tsc2007_platform_data *pd;
> };
>
> +/* ask platform for pendown state */
> +static inline int ts_get_pendown_state(struct tsc2007 *ts)
> +{
> + return ts->pd->get_pendown_state(ts->pd->priv);
So, we don't need check here, like this:
if (ts->pd->get_pendown_state)
ret = ts->pd->get_pendown_state(ts->pd->priv);
> +}
> +
> +/* ask platform to clear pendown irq if available */
> +static inline void ts_clear_penirq(struct tsc2007 *ts)
> +{
> + if (ts->pd->clear_penirq)
> + ts->pd->clear_penirq(ts->pd->priv);
> +}
> +
> +static inline void ts_init_platform_hw(struct tsc2007 *ts)
> +{
> + if (ts->pd->init_platform_hw)
> + ts->pd->init_platform_hw(ts->pd->priv);
> +}
> +
> +static inline void ts_exit_platform_hw(struct tsc2007 *ts)
> +{
> + if (ts->pd->exit_platform_hw)
> + ts->pd->exit_platform_hw(ts->pd->priv);
> +}
> +
> +
> static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
> {
> s32 data;
> @@ -129,7 +154,7 @@ static void tsc2007_send_event(void *tsc)
> rt = z2;
> rt -= z1;
> rt *= x;
> - rt *= ts->x_plate_ohms;
> + rt *= ts->pd->x_plate_ohms;
> rt /= z1;
> rt = (rt + 2047) >> 12;
> } else
> @@ -204,7 +229,7 @@ static enum hrtimer_restart tsc2007_timer(struct hrtimer *handle)
>
> spin_lock_irqsave(&ts->lock, flags);
>
> - if (unlikely(!ts->get_pendown_state() && ts->pendown)) {
> + if (unlikely(!ts_get_pendown_state(ts) && ts->pendown)) {
> struct input_dev *input = ts->input;
>
> dev_dbg(&ts->client->dev, "UP\n");
> @@ -235,14 +260,13 @@ static irqreturn_t tsc2007_irq(int irq, void *handle)
>
> spin_lock_irqsave(&ts->lock, flags);
>
> - if (likely(ts->get_pendown_state())) {
> + if (likely(ts_get_pendown_state(ts))) {
> disable_irq_nosync(ts->irq);
> hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY),
> HRTIMER_MODE_REL);
> }
>
> - if (ts->clear_penirq)
> - ts->clear_penirq();
> + ts_clear_penirq(ts);
>
> spin_unlock_irqrestore(&ts->lock, flags);
>
> @@ -253,7 +277,7 @@ static int tsc2007_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> struct tsc2007 *ts;
> - struct tsc2007_platform_data *pdata = pdata = client->dev.platform_data;
> + struct tsc2007_platform_data *pdata = client->dev.platform_data;
This change shows that you need to rebase based on two patches
submitted by Lee recently.
> struct input_dev *input_dev;
> int err;
>
> @@ -283,12 +307,8 @@ static int tsc2007_probe(struct i2c_client *client,
>
> spin_lock_init(&ts->lock);
>
> - ts->model = pdata->model;
> - ts->x_plate_ohms = pdata->x_plate_ohms;
> - ts->get_pendown_state = pdata->get_pendown_state;
> - ts->clear_penirq = pdata->clear_penirq;
> -
> - pdata->init_platform_hw();
> + ts->pd = pdata;
> + ts_init_platform_hw(ts);
>
> snprintf(ts->phys, sizeof(ts->phys),
> "%s/input0", dev_name(&client->dev));
> @@ -335,10 +355,8 @@ static int tsc2007_probe(struct i2c_client *client,
> static int tsc2007_remove(struct i2c_client *client)
> {
> struct tsc2007 *ts = i2c_get_clientdata(client);
> - struct tsc2007_platform_data *pdata;
>
> - pdata = client->dev.platform_data;
> - pdata->exit_platform_hw();
> + ts_exit_platform_hw(ts);
>
> free_irq(ts->irq, ts);
> hrtimer_cancel(&ts->timer);
> diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
> index c6361fb..45582b3 100644
> --- a/include/linux/i2c/tsc2007.h
> +++ b/include/linux/i2c/tsc2007.h
> @@ -7,11 +7,13 @@ struct tsc2007_platform_data {
> u16 model; /* 2007. */
> u16 x_plate_ohms;
>
> - int (*get_pendown_state)(void);
> - void (*clear_penirq)(void); /* If needed, clear 2nd level
> + int (*get_pendown_state)(void *priv);
> + void (*clear_penirq)(void *priv); /* If needed, clear 2nd level
> interrupt source */
> - int (*init_platform_hw)(void);
> - void (*exit_platform_hw)(void);
> + int (*init_platform_hw)(void *priv);
> + void (*exit_platform_hw)(void *priv);
> +
> + void *priv; /* passed to callbacks */
> };
>
> #endif
> --
> 1.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
--
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 parent reply other threads:[~2009-05-14 10:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090514100909.GA23626@roarinelk.homelinux.net>
2009-05-14 10:28 ` Trilok Soni [this message]
2009-05-14 10:37 ` [PATCH] TSC2007: private data for platform callbacks Manuel Lauss
2009-05-15 4:32 ` Kwangwoo Lee
2009-05-15 4:25 ` Kwangwoo Lee
2009-05-15 6:10 ` Manuel Lauss
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=5d5443650905140328v319e673o2f7b865e21619486@mail.gmail.com \
--to=soni.trilok@gmail.com \
--cc=kwlee@mtekvision.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mano@roarinelk.homelinux.net \
/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).