public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "jeffrey.lin" <yajohn@gmail.com>,
	dmitry.torokhov@gmail.com, rydberg@euromail.se,
	grant.likely@linaro.org, robh+dt@kernel.org, jeesw@melfas.com,
	bleung@chromium.org, scott.liu@emc.com.tw
Cc: jeffrey.lin@rad-ic.com, roger.yang@rad-ic.com, KP.li@rad-ic.com,
	albert.shieh@rad-ic.com, linux-kernel@vger.kernel.org,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver
Date: Wed, 02 Mar 2016 18:44:10 -0800	[thread overview]
Message-ID: <1456973050.4044.81.camel@perches.com> (raw)
In-Reply-To: <1456972150-32303-1-git-send-email-jeffrey.lin@rad-ic.com>

On Thu, 2016-03-03 at 10:29 +0800, jeffrey.lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

trivial comments:

> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
[]
> +static int raydium_i2c_send(struct i2c_client *client,
> +	u8 addr, u8 *data, size_t len)
> +{
> +	u8 buf[MAX_PACKET_SIZE + 1];
> +	int i, tries = 0;
> +
> +	if (len > MAX_PACKET_SIZE)
> +		return -EINVAL;
> +
> +	buf[0] = addr & 0xff;

Seems pointless to use & 0xff when both
buf and addr are u8

> +	for (i = 0; i < len; i++)
> +		buf[i + 1] = *data++;

memcpy.  Maybe:

	buf[0] = addr;
	memcpy(&buf[1], data, len);

> +static int raydium_i2c_send_message(struct i2c_client *client,
> +	size_t len, void *data)
> +{
> +	int error;
> +	u8 buf[HEADER_SIZE], ii;
> +
> +	for (ii = 0; ii < HEADER_SIZE; ii++)
> +		buf[ii] = ((u8 *)data)[3 - ii];
> +	/*set data bank*/
> +	error = raydium_i2c_send(client, CMD_BANK_SWITCH,
> +		(u8 *)buf, HEADER_SIZE);
> +
> +	/*send messange*/

typo, message

> +	if (!error)
> +		error = raydium_i2c_send(client, buf[ADDR_INDEX], buf, len);
> +
> +	return error;
> +}
> +
> +static int raydium_i2c_sw_reset(struct i2c_client *client)
> +{
> +	const u8 soft_rst_cmd[] = { 0x01, 0x04, 0x00, 0x00, 0x40};

static

> +	int error;
> +
> +	error = raydium_i2c_send_message(client,
> +			1, (void *)soft_rst_cmd);

could be better on a single line

> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> +	const u8 boot_cmd[] = { 0x20, 0x06, 0x00, 0x50 };
> +	u8 buf[HEADER_SIZE];
> +	int error;
> +
> +	error = raydium_i2c_read_message(client,
> +		get_unaligned_be32(boot_cmd),
> +		sizeof(boot_cmd),
> +		buf);
> +
> +	if (error) {
> +		dev_err(&client->dev, "boot failed: %d\n", error);
> +		return error;
> +	} else if (buf[0] == RM_BOOT_BLDR) {

unnecessary else

> +		dev_dbg(&client->dev, "boot in fastboot mode\n");
> +		return -EINVAL;
> +	}
> +
> +	dev_dbg(&client->dev, "boot success -- 0x%x\n", client->addr);
> +	return 0;
> +}
> +
> +static int raydium_i2c_initialize(struct raydium_data *ts)
> +{
> +	struct i2c_client *client = ts->client;
> +	int error, retry_cnt;
> +	const u8 recov_packet[] = { 0x04, 0x81 };

static and etc...

generally, it'd be nice to align to open parenthesis and
to more maximally fill lines to 80 chars instead of using
relatively short line lengths and multiple line statements.

  reply	other threads:[~2016-03-03  2:44 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03  2:29 [PATCH] driver: input :touchscreen : add Raydium I2C touch driver jeffrey.lin
2016-03-03  2:44 ` Joe Perches [this message]
2016-03-03  3:14   ` Jeffrey Lin (林義章)
2016-03-03  3:55     ` Joe Perches
  -- strict thread matches above, loose matches on Subject: below --
2016-05-24  9:05 jeffrey.lin
2016-05-17 15:34 jeffrey.lin
2016-05-11 13:51 jeffrey.lin
2016-04-29  9:45 jeffrey.lin
2016-05-04 22:58 ` Dmitry Torokhov
2016-05-06  8:24 ` jeffrey.lin
2016-05-11 16:04 ` jeffrey.lin
2016-05-13  4:18 ` Dmitry Torokhov
2016-05-13 17:08   ` jeffrey.lin
2016-05-16 15:46   ` jeffrey.lin
2016-05-16 16:41     ` Dmitry Torokhov
2016-05-16 16:43       ` Dmitry Torokhov
2016-05-16 15:57   ` jeffrey.lin
2016-05-17 16:07   ` jeffrey.lin
2016-05-21 18:18     ` Dmitry Torokhov
2016-05-22  9:32   ` jeffrey.lin
2016-05-22 22:37     ` Dmitry Torokhov
2016-05-22  9:35   ` jeffrey.lin
2016-05-23 14:43   ` jeffrey.lin
2016-05-23 16:27     ` Dmitry Torokhov
2016-05-24  9:31   ` jeffrey.lin
2016-05-27 16:34     ` Dmitry Torokhov
2016-04-22 10:01 dan.huang
2016-04-22 22:50 ` Dmitry Torokhov
2016-03-25  5:21 jeffrey.lin
2016-04-11  8:24 ` Dmitry Torokhov
2016-04-11  9:57   ` Jeffrey Lin (林義章)
2016-04-14  9:28   ` Jeffrey Lin (林義章)
2016-03-22  6:23 jeffrey.lin
2016-03-15  8:44 jeffrey.lin
2016-03-18 21:04 ` Rob Herring
2016-03-03  6:42 jeffrey.lin
2016-03-10 18:47 ` Dmitry Torokhov
2016-03-11  2:10   ` Jeffrey Lin (林義章)
2016-02-23  8:11 jeffrey.lin
2016-01-21  4:02 Jeffrey Lin
2016-01-21  9:37 ` Dmitry Torokhov
2016-01-15  3:30 Jeffrey Lin
2016-01-13  7:49 Jeffrey Lin
2016-01-13  8:31 ` Dmitry Torokhov
2016-01-13 19:14 ` Dmitry Torokhov
2016-01-13  6:23 Jeffrey Lin
2016-01-13  6:44 ` Dmitry Torokhov
2016-01-08 15:17 Jeffrey Lin
2016-01-09 19:20 ` Dmitry Torokhov
2015-01-06  9:25 jeffrey.lin
2015-01-06 19:43 ` Jeremiah Mahler
2015-01-07  0:40   ` Dmitry Torokhov
2014-12-08  3:42 jeffrey.lin
2014-12-05  8:15 jeffrey.lin
2014-12-05 15:04 ` Dmitry Torokhov
2014-11-14  7:19 jeffrey.lin
2014-11-14 17:43 ` Benson Leung
2014-11-14 18:00 ` Dmitry Torokhov

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=1456973050.4044.81.camel@perches.com \
    --to=joe@perches.com \
    --cc=KP.li@rad-ic.com \
    --cc=albert.shieh@rad-ic.com \
    --cc=bleung@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=jeesw@melfas.com \
    --cc=jeffrey.lin@rad-ic.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=roger.yang@rad-ic.com \
    --cc=rydberg@euromail.se \
    --cc=scott.liu@emc.com.tw \
    --cc=yajohn@gmail.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