Input: psmouse - move sliced command implementation to libps2
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 2 Jan 2018 20:03:02 +0000 (12:03 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 3 Feb 2018 00:50:24 +0000 (16:50 -0800)
In preparation to adding some debugging statements to PS/2 control
sequences let's move psmouse_sliced_command() into libps2 and rename it
to ps2_sliced_command().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/mouse/elantech.c
drivers/input/mouse/logips2pp.c
drivers/input/mouse/psmouse-base.c
drivers/input/mouse/psmouse.h
drivers/input/mouse/synaptics.c
drivers/input/serio/libps2.c
include/linux/libps2.h

index af7fc17c14d965abc66becb6c9441da08d56e6f4..db47a5e1d114dcaee65f63df4ee7a51fb0b6aa07 100644 (file)
@@ -35,7 +35,7 @@
 static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
                                unsigned char *param)
 {
-       if (psmouse_sliced_command(psmouse, c) ||
+       if (ps2_sliced_command(&psmouse->ps2dev, c) ||
            ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
                psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c);
                return -1;
@@ -107,8 +107,8 @@ static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg,
 
        switch (etd->hw_version) {
        case 1:
-               if (psmouse_sliced_command(psmouse, ETP_REGISTER_READ) ||
-                   psmouse_sliced_command(psmouse, reg) ||
+               if (ps2_sliced_command(&psmouse->ps2dev, ETP_REGISTER_READ) ||
+                   ps2_sliced_command(&psmouse->ps2dev, reg) ||
                    ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
                        rc = -1;
                }
@@ -162,9 +162,9 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
 
        switch (etd->hw_version) {
        case 1:
-               if (psmouse_sliced_command(psmouse, ETP_REGISTER_WRITE) ||
-                   psmouse_sliced_command(psmouse, reg) ||
-                   psmouse_sliced_command(psmouse, val) ||
+               if (ps2_sliced_command(&psmouse->ps2dev, ETP_REGISTER_WRITE) ||
+                   ps2_sliced_command(&psmouse->ps2dev, reg) ||
+                   ps2_sliced_command(&psmouse->ps2dev, val) ||
                    ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11)) {
                        rc = -1;
                }
index 3c8d7051ef5e0ae8a6289bb074e4364755b09382..3d5637e6fa5fac579c3f067245f2a62926309427 100644 (file)
@@ -117,7 +117,7 @@ static int ps2pp_cmd(struct psmouse *psmouse, u8 *param, u8 command)
 {
        int error;
 
-       error = psmouse_sliced_command(psmouse, command);
+       error = ps2_sliced_command(&psmouse->ps2dev, command);
        if (error)
                return error;
 
index f0b16eb4a32ab377c1ae56657a3abd0003a9bfc6..4f9f438e26533e6bbd032f9001104179181487e1 100644 (file)
@@ -431,32 +431,6 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
        return IRQ_HANDLED;
 }
 
-/*
- * psmouse_sliced_command() sends an extended PS/2 command to the mouse
- * using sliced syntax, understood by advanced devices, such as Logitech
- * or Synaptics touchpads. The command is encoded as:
- * 0xE6 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu
- * is the command.
- */
-int psmouse_sliced_command(struct psmouse *psmouse, u8 command)
-{
-       int i;
-       int error;
-
-       error = ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
-       if (error)
-               return error;
-
-       for (i = 6; i >= 0; i -= 2) {
-               u8 d = (command >> i) & 3;
-               error = ps2_command(&psmouse->ps2dev, &d, PSMOUSE_CMD_SETRES);
-               if (error)
-                       return error;
-       }
-
-       return 0;
-}
-
 /*
  * psmouse_reset() resets the mouse into power-on state.
  */
index 8bc99691494e94d6158b502c1306d10eee8826ec..71ac50082c8b41a1ceb032779402ef79324828b7 100644 (file)
@@ -131,7 +131,6 @@ struct psmouse {
 
 void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
                unsigned long delay);
-int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
 int psmouse_reset(struct psmouse *psmouse);
 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
index cd9f61cb3fc67fd3f5f8fe7a55fb1094d5bf1672..89ab77a211b51e575b6ca9682eb2e20c49d47c72 100644 (file)
@@ -84,7 +84,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode)
        u8 param[1];
        int error;
 
-       error = psmouse_sliced_command(psmouse, mode);
+       error = ps2_sliced_command(&psmouse->ps2dev, mode);
        if (error)
                return error;
 
@@ -190,7 +190,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param)
 {
        int error;
 
-       error = psmouse_sliced_command(psmouse, cmd);
+       error = ps2_sliced_command(&psmouse->ps2dev, cmd);
        if (error)
                return error;
 
@@ -547,7 +547,7 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
        static u8 param = 0xc8;
        int error;
 
-       error = psmouse_sliced_command(psmouse, SYN_QUE_MODEL);
+       error = ps2_sliced_command(&psmouse->ps2dev, SYN_QUE_MODEL);
        if (error)
                return error;
 
@@ -614,7 +614,7 @@ static int synaptics_pt_write(struct serio *serio, u8 c)
        u8 rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */
        int error;
 
-       error = psmouse_sliced_command(parent, c);
+       error = ps2_sliced_command(&parent->ps2dev, c);
        if (error)
                return error;
 
index c3712f0a47b50dc33080eb082956f43d483e18b1..e96ae477f0b5654798241e124f3ea9b850405021 100644 (file)
@@ -269,6 +269,38 @@ int ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
 }
 EXPORT_SYMBOL(ps2_command);
 
+/*
+ * ps2_sliced_command() sends an extended PS/2 command to the mouse
+ * using sliced syntax, understood by advanced devices, such as Logitech
+ * or Synaptics touchpads. The command is encoded as:
+ * 0xE6 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu
+ * is the command.
+ */
+
+int ps2_sliced_command(struct ps2dev *ps2dev, u8 command)
+{
+       int i;
+       int retval;
+
+       ps2_begin_command(ps2dev);
+
+       retval = __ps2_command(ps2dev, NULL, PS2_CMD_SETSCALE11);
+       if (retval)
+               goto out;
+
+       for (i = 6; i >= 0; i -= 2) {
+               u8 d = (command >> i) & 3;
+               retval = __ps2_command(ps2dev, &d, PS2_CMD_SETRES);
+               if (retval)
+                       break;
+       }
+
+out:
+       ps2_end_command(ps2dev);
+       return retval;
+}
+EXPORT_SYMBOL(ps2_sliced_command);
+
 /*
  * ps2_init() initializes ps2dev structure
  */
index 646b581fea5647d0499e1f6db89048f173f7593f..3c69cd796f48b4e85479ce43ae5fa39d08eb80a1 100644 (file)
@@ -15,6 +15,8 @@
 #include <linux/types.h>
 #include <linux/wait.h>
 
+#define PS2_CMD_SETSCALE11     0x00e6
+#define PS2_CMD_SETRES         0x10e8
 #define PS2_CMD_GETID          0x02f2
 #define PS2_CMD_RESET_BAT      0x02ff
 
@@ -52,6 +54,7 @@ void ps2_begin_command(struct ps2dev *ps2dev);
 void ps2_end_command(struct ps2dev *ps2dev);
 int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command);
 int ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command);
+int ps2_sliced_command(struct ps2dev *ps2dev, u8 command);
 bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data);
 bool ps2_handle_response(struct ps2dev *ps2dev, u8 data);
 void ps2_cmd_aborted(struct ps2dev *ps2dev);