* [PATCH] Input: wm831x-ts - Remove use of ternery operator
@ 2011-01-31 12:01 Mark Brown
2011-01-31 17:20 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2011-01-31 12:01 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, patches, Mark Brown
While being applied the driver was modified to add use of the ternery
operator. Write the conditionals out longhand as I find it terribly
unhelpful for legibility.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
This is a bit of a preference issue but as I'm most likely to be
updating the code it would be very helpful if you could apply it.
drivers/input/touchscreen/wm831x-ts.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c
index a6121bd..1022f71 100644
--- a/drivers/input/touchscreen/wm831x-ts.c
+++ b/drivers/input/touchscreen/wm831x-ts.c
@@ -76,9 +76,14 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data)
struct wm831x *wm831x = wm831x_ts->wm831x;
static int data_types[] = { ABS_X, ABS_Y, ABS_PRESSURE };
u16 data[3];
- int count = wm831x_ts->pressure ? 3 : 2;
+ int count;
int i, ret;
+ if (wm831x_ts->pressure)
+ count = 3;
+ else
+ count = 2;
+
wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1,
WM831X_TCHDATA_EINT, WM831X_TCHDATA_EINT);
@@ -134,10 +139,11 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data)
{
struct wm831x_ts *wm831x_ts = irq_data;
struct wm831x *wm831x = wm831x_ts->wm831x;
- int ena;
+ int ena = 0;
/* Start collecting data */
- ena = wm831x_ts->pressure ? WM831X_TCH_Z_ENA : 0;
+ if (wm831x_ts->pressure)
+ ena |= WM831X_TCH_Z_ENA;
wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA,
@@ -188,11 +194,13 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev)
struct wm831x_ts *wm831x_ts;
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent);
- struct wm831x_touch_pdata *pdata =
- core_pdata ? core_pdata->touch : NULL;
+ struct wm831x_touch_pdata *pdata = NULL;
struct input_dev *input_dev;
int error;
+ if (core_pdata)
+ pdata = core_pdata->touch;
+
wm831x_ts = kzalloc(sizeof(struct wm831x_ts), GFP_KERNEL);
input_dev = input_allocate_device();
if (!wm831x_ts || !input_dev) {
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: wm831x-ts - Remove use of ternery operator
2011-01-31 12:01 [PATCH] Input: wm831x-ts - Remove use of ternery operator Mark Brown
@ 2011-01-31 17:20 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2011-01-31 17:20 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-input, patches
On Mon, Jan 31, 2011 at 12:01:55PM +0000, Mark Brown wrote:
> While being applied the driver was modified to add use of the ternery
> operator. Write the conditionals out longhand as I find it terribly
> unhelpful for legibility.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>
> This is a bit of a preference issue but as I'm most likely to be
> updating the code it would be very helpful if you could apply it.
>
> drivers/input/touchscreen/wm831x-ts.c | 18 +++++++++++++-----
> 1 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c
> index a6121bd..1022f71 100644
> --- a/drivers/input/touchscreen/wm831x-ts.c
> +++ b/drivers/input/touchscreen/wm831x-ts.c
> @@ -76,9 +76,14 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data)
> struct wm831x *wm831x = wm831x_ts->wm831x;
> static int data_types[] = { ABS_X, ABS_Y, ABS_PRESSURE };
> u16 data[3];
> - int count = wm831x_ts->pressure ? 3 : 2;
> + int count;
> int i, ret;
>
> + if (wm831x_ts->pressure)
> + count = 3;
> + else
> + count = 2;
> +
Hm, OK, although I really wish we did not use 4 lines for something as
simple as this.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-31 17:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-31 12:01 [PATCH] Input: wm831x-ts - Remove use of ternery operator Mark Brown
2011-01-31 17:20 ` Dmitry Torokhov
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).