Input: synaptics-rmi4 - fix endianness issue in SMBus transport
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 24 Mar 2017 19:34:20 +0000 (12:34 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 3 Apr 2017 23:23:59 +0000 (16:23 -0700)
The mapping table holds address in LE form, so we should convert it
to CPU when comparing it.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/rmi4/rmi_smbus.c

index 7675255..6bb67ba 100644 (file)
@@ -89,17 +89,17 @@ 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];
+
+               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;