devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "jeffrey.lin" <yajohn@gmail.com>
Cc: rydberg@euromail.se, grant.likely@linaro.org, robh+dt@kernel.org,
	jeesw@melfas.com, bleung@chromium.org, 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, 4 May 2016 15:58:46 -0700	[thread overview]
Message-ID: <20160504225846.GA17403@dtor-ws> (raw)
In-Reply-To: <1461923113-426-1-git-send-email-jeffrey.lin@rad-ic.com>

Hi Jeffrey,

On Fri, Apr 29, 2016 at 05:45:13PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 

In my previous e-mail I requested you to enumerate changes that are made
to the driver, compared to the previous version(s). There were also a
few questions that I did not get answer for.

Also:

> +static int raydium_i2c_query_ts_info(struct raydium_data *ts)
> +{
> +	struct i2c_client *client = ts->client;
> +	int error, retry_cnt;
> +
> +	for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
> +		error = raydium_i2c_read(client, CMD_DATA_BANK,
> +			sizeof(ts->obj), (void *)&ts->obj);
> +			ts->obj.data_bank_addr =
> +				get_unaligned_le32(&ts->obj.data_bank_addr);
> +
> +		if (!error) {
> +			error = raydium_i2c_read(client, CMD_QUERY_BANK,
> +				sizeof(ts->query_bank_info),
> +				(void *)&ts->query_bank_info);
> +			if (!error) {
> +				error = raydium_i2c_read_message(client,
> +					ts->query_bank_info, sizeof(ts->info),
> +					(void *)&ts->info);
> +
> +				ts->info.hw_ver =
> +					get_unaligned_le32(&ts->info.hw_ver);
> +				ts->info.ft_ver =
> +					get_unaligned_le16(&ts->info.ft_ver);
> +				ts->info.x_max =
> +					get_unaligned_le16(&ts->info.x_max);
> +				ts->info.y_max =
> +					get_unaligned_le16(&ts->info.y_max);
> +				return 0;
> +			}
> +		}
> +	}
> +	dev_err(&client->dev, "Get touch data failed: %d\n", error);
> +
> +	return -EINVAL;
> +}
> +
> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> +	static const u8 boot_cmd[] = { 0x50, 0x00, 0x06, 0x20 };
> +	u8 buf[HEADER_SIZE];
> +	int error;
> +
> +	error = raydium_i2c_read_message(client,
> +		get_unaligned_be32(boot_cmd),
> +		sizeof(boot_cmd), buf);

I still can't figure out the logic in read/write mesage handling. Here
we see that device is supposedly reporting data_bank_addr as LE integer,
but query_bank_info is returned in native CPU endianness. With fastboot
command we assume that we are dealing with BE-encoded data and convert
it to CPU-endianness before using it.

However in raydium_i2c_read_message() we convert from CPU endianness to
BE and this comfuses me (does the device really return data in one
endianness but accepts in another endianness?

By the way, why do you have raydium_i2c_read_message() handle reads
above MAX_PKG_SIZE? There are no callers that want it.

Thanks.

-- 
Dmitry

  reply	other threads:[~2016-05-04 22:58 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29  9:45 [PATCH] driver: input :touchscreen : add Raydium I2C touch driver jeffrey.lin
2016-05-04 22:58 ` Dmitry Torokhov [this message]
2016-05-05 10:23   ` Jeffrey Lin (林義章)
2016-05-05 10:25   ` Jeffrey Lin (林義章)
2016-05-06  8:24 ` jeffrey.lin
2016-05-11 16:04 ` jeffrey.lin
     [not found] ` <1461923113-426-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-13  4:18   ` Dmitry Torokhov
2016-05-13 17:08     ` jeffrey.lin
2016-05-16 15:46     ` jeffrey.lin
     [not found]       ` <1463413611-367-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
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
     [not found]       ` <1463501223-20723-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
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
     [not found]       ` <1464014633-20829-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-23 16:27         ` Dmitry Torokhov
2016-05-24  9:31     ` jeffrey.lin
     [not found]       ` <1464082301-11539-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-27 16:34         ` Dmitry Torokhov
  -- 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-22 10:01 dan.huang
     [not found] ` <1461319268-362-1-git-send-email-dan.huang-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-04-22 22:50   ` Dmitry Torokhov
2016-04-25  2:48     ` yajohn lin
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-03-03  2:29 jeffrey.lin
2016-03-03  2:44 ` Joe Perches
2016-03-03  3:14   ` Jeffrey Lin (林義章)
2016-03-03  3:55     ` Joe Perches
2016-02-23  8:11 jeffrey.lin

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=20160504225846.GA17403@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=KP.li@rad-ic.com \
    --cc=albert.shieh@rad-ic.com \
    --cc=bleung@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --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=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;
as well as URLs for NNTP newsgroup(s).