public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Andrew Duggan <aduggan@synaptics.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Nick Dyer <nick@shmanahar.org>
Subject: Re: [PATCH 2/4] Input: synaptics-rmi4 - fix endianness issue in SMBus transport
Date: Fri, 31 Mar 2017 11:15:05 +0200	[thread overview]
Message-ID: <20170331091505.GH22683@mail.corp.redhat.com> (raw)
In-Reply-To: <20170325060050.39867-2-dmitry.torokhov@gmail.com>

On Mar 24 2017 or thereabouts, Dmitry Torokhov wrote:
> The mapping table holds address in LE form, so we should convert it
> to CPU when comparing it.

Are you sure about that?

>From what I can read:
rmiaddr is set by rmi_smb_get_command_code(), and it's forwarded
directly from the caller to the table. When we write the data to the
device, we use cpu_to_le16() so rmiaddr is used as le16, but always
stored as CPU type.

> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/rmi4/rmi_smbus.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
> index 76752555d809..c8bf49686460 100644
> --- a/drivers/input/rmi4/rmi_smbus.c
> +++ b/drivers/input/rmi4/rmi_smbus.c
> @@ -89,17 +89,16 @@ static int rmi_smb_get_command_code(struct rmi_transport_dev *xport,
>  
>  	mutex_lock(&rmi_smb->mappingtable_mutex);
>  	for (i = 0; i < RMI_SMB2_MAP_SIZE; i++) {
> -		if (rmi_smb->mapping_table[i].rmiaddr == rmiaddr) {
> +		struct mapping_table_entry *entry = &rmi_smb->mapping_table[i];

In case you want to keep the temporary variable here, I believe
checkpatch would complain about a missing empty line here (just
nitpicking).

Cheers,
Benjamin

> +		if (le16_to_cpu(entry->rmiaddr) == rmiaddr) {
>  			if (isread) {
> -				if (rmi_smb->mapping_table[i].readcount
> -							== bytecount) {
> +				if (entry->readcount == bytecount) {
>  					*commandcode = i;
>  					retval = 0;
>  					goto exit;
>  				}
>  			} else {
> -				if (rmi_smb->mapping_table[i].flags &
> -							RMI_SMB2_MAP_FLAGS_WE) {
> +				if (entry->flags & RMI_SMB2_MAP_FLAGS_WE) {
>  					*commandcode = i;
>  					retval = 0;
>  					goto exit;
> -- 
> 2.12.1.578.ge9c3154ca4-goog
> 

  reply	other threads:[~2017-03-31  9:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-25  6:00 [PATCH 1/4] Input: synaptics-rmi4 - fix handling failures from rmi_enable_sensor Dmitry Torokhov
2017-03-25  6:00 ` [PATCH 2/4] Input: synaptics-rmi4 - fix endianness issue in SMBus transport Dmitry Torokhov
2017-03-31  9:15   ` Benjamin Tissoires [this message]
2017-03-25  6:00 ` [PATCH 3/4] Input: synaptics-rmi4 - cleanup SMbus mapping handling Dmitry Torokhov
2017-03-31  9:21   ` Benjamin Tissoires
2017-03-25  6:00 ` [PATCH 4/4] Input: synaptics-rmi4 - when registering sensors do not call them "drivers" Dmitry Torokhov
2017-03-31  9:28   ` Benjamin Tissoires
2017-03-31  9:15 ` [PATCH 1/4] Input: synaptics-rmi4 - fix handling failures from rmi_enable_sensor Benjamin Tissoires

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=20170331091505.GH22683@mail.corp.redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=aduggan@synaptics.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick@shmanahar.org \
    /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