Re: [PATCH 1/9] input: goodix: fix alignment issues

From: Joe Perches
Date: Fri Jun 05 2015 - 13:18:08 EST


On Fri, 2015-06-05 at 09:49 -0700, Dmitry Torokhov wrote:
> Hi Irina,
>
> On Thu, May 28, 2015 at 03:47:37PM +0300, Irina Tirdea wrote:
> > Fix alignment to match open parenthesis detected by
> > running checkpatch.pl --strict.
>
> Mixed bag of changes here, but that's checkpatch for you.

Yup,

checkpatch output is definitely a mix of automated
semi-competence and brain-deadness.

> > diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
[]
> > @@ -112,7 +112,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
> > data += 1 + GOODIX_CONTACT_SIZE;
> > error = goodix_i2c_read(ts->client,
> > GOODIX_READ_COOR_ADDR +
> > - 1 + GOODIX_CONTACT_SIZE,
> > + 1 + GOODIX_CONTACT_SIZE,
>
> Bad - makes 1 + GOODIX_CONTACT_SIZE look like extra argument, not
> continuation of expression.

<shrug> There's no great way to do this.

Parentheses around the longer expression work.

error = goodix_i2c_read(ts->client,
(GOODIX_READ_COOR_ADDR +
1 + GOODIX_CONTACT_SIZE),

Exceeding 80 columns may be better.
Leaving it alone would be OK too.

Maybe starting with 1 to be more similar
to the below would be better.

> > @@ -157,7 +157,8 @@ static void goodix_process_events(struct goodix_ts_data *ts)
> >
> > for (i = 0; i < touch_num; i++)
> > goodix_ts_report_touch(ts,
> > - &point_data[1 + GOODIX_CONTACT_SIZE * i]);
> > + &point_data[1 +
> > + GOODIX_CONTACT_SIZE * i]);
>
> No, this is plain ugly.

Sometimes it's better to exceed 80 columns or
maybe use temporaries. Something like:

u8 *tmp = point_data + 1;
...

for (i = 0; i < touch_num; i++, tmp += GOODIX_CONTACT_SIZE)
goodix_ts_report_touch(ts, tmp);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/