Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: synaptics - use u8 instead of unsigned char

The rest of the kernel uses u8, u16, etc for data coming form hardware,
let's switch ti using u8 here as well.

Also turn pkt_type into an enum.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+42 -40
+30 -30
drivers/input/mouse/synaptics.c
··· 79 79 /* 80 80 * Set the synaptics touchpad mode byte by special commands 81 81 */ 82 - static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) 82 + static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode) 83 83 { 84 - unsigned char param[1]; 84 + u8 param[1]; 85 85 int error; 86 86 87 87 error = psmouse_sliced_command(psmouse, mode); ··· 99 99 int synaptics_detect(struct psmouse *psmouse, bool set_properties) 100 100 { 101 101 struct ps2dev *ps2dev = &psmouse->ps2dev; 102 - unsigned char param[4]; 102 + u8 param[4]; 103 103 104 104 param[0] = 0; 105 105 ··· 179 179 /* 180 180 * Send a command to the synpatics touchpad by special commands 181 181 */ 182 - static int synaptics_send_cmd(struct psmouse *psmouse, 183 - unsigned char c, unsigned char *param) 182 + static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param) 184 183 { 185 184 int error; 186 185 187 - error = psmouse_sliced_command(psmouse, c); 186 + error = psmouse_sliced_command(psmouse, cmd); 188 187 if (error) 189 188 return error; 190 189 ··· 253 254 static int synaptics_query_modes(struct psmouse *psmouse, 254 255 struct synaptics_device_info *info) 255 256 { 256 - unsigned char bid[3]; 257 + u8 bid[3]; 257 258 int error; 258 259 259 260 /* firmwares prior 7.5 have no board_id encoded */ ··· 337 338 static int synaptics_resolution(struct psmouse *psmouse, 338 339 struct synaptics_device_info *info) 339 340 { 340 - unsigned char resp[3]; 341 + u8 resp[3]; 341 342 int error; 342 343 343 344 if (SYN_ID_MAJOR(info->identity) < 4) ··· 536 537 537 538 static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) 538 539 { 539 - static unsigned char param = 0xc8; 540 + static u8 param = 0xc8; 540 541 struct synaptics_data *priv = psmouse->private; 541 542 int error; 542 543 ··· 608 609 /***************************************************************************** 609 610 * Synaptics pass-through PS/2 port support 610 611 ****************************************************************************/ 611 - static int synaptics_pt_write(struct serio *serio, unsigned char c) 612 + static int synaptics_pt_write(struct serio *serio, u8 c) 612 613 { 613 614 struct psmouse *parent = serio_get_drvdata(serio->parent); 614 615 u8 rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ ··· 647 648 serio_continue_rx(parent->ps2dev.serio); 648 649 } 649 650 650 - static int synaptics_is_pt_packet(unsigned char *buf) 651 + static int synaptics_is_pt_packet(u8 *buf) 651 652 { 652 653 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; 653 654 } 654 655 655 - static void synaptics_pass_pt_packet(struct serio *ptport, 656 - unsigned char *packet) 656 + static void synaptics_pass_pt_packet(struct serio *ptport, u8 *packet) 657 657 { 658 658 struct psmouse *child = serio_get_drvdata(ptport); 659 659 ··· 715 717 * Functions to interpret the absolute mode packets 716 718 ****************************************************************************/ 717 719 718 - static void synaptics_parse_agm(const unsigned char buf[], 720 + static void synaptics_parse_agm(const u8 buf[], 719 721 struct synaptics_data *priv, 720 722 struct synaptics_hw_state *hw) 721 723 { ··· 742 744 } 743 745 } 744 746 745 - static void synaptics_parse_ext_buttons(const unsigned char buf[], 747 + static void synaptics_parse_ext_buttons(const u8 buf[], 746 748 struct synaptics_data *priv, 747 749 struct synaptics_hw_state *hw) 748 750 { ··· 754 756 hw->ext_buttons |= (buf[5] & ext_mask) << ext_bits; 755 757 } 756 758 757 - static int synaptics_parse_hw_state(const unsigned char buf[], 759 + static int synaptics_parse_hw_state(const u8 buf[], 758 760 struct synaptics_data *priv, 759 761 struct synaptics_hw_state *hw) 760 762 { ··· 830 832 } else if (SYN_CAP_MIDDLE_BUTTON(priv->info.capabilities)) { 831 833 hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0; 832 834 if (hw->w == 2) 833 - hw->scroll = (signed char)(buf[1]); 835 + hw->scroll = (s8)buf[1]; 834 836 } 835 837 836 838 if (SYN_CAP_FOUR_BUTTON(priv->info.capabilities)) { ··· 1132 1134 input_sync(dev); 1133 1135 } 1134 1136 1135 - static int synaptics_validate_byte(struct psmouse *psmouse, 1136 - int idx, unsigned char pkt_type) 1137 + static bool synaptics_validate_byte(struct psmouse *psmouse, 1138 + int idx, enum synaptics_pkt_type pkt_type) 1137 1139 { 1138 - static const unsigned char newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 }; 1139 - static const unsigned char newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 }; 1140 - static const unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 }; 1141 - static const unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 }; 1142 - static const unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 }; 1143 - const char *packet = psmouse->packet; 1140 + static const u8 newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 }; 1141 + static const u8 newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 }; 1142 + static const u8 newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 }; 1143 + static const u8 oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 }; 1144 + static const u8 oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 }; 1145 + const u8 *packet = psmouse->packet; 1144 1146 1145 1147 if (idx < 0 || idx > 4) 1146 - return 0; 1148 + return false; 1147 1149 1148 1150 switch (pkt_type) { 1149 1151 ··· 1159 1161 1160 1162 default: 1161 1163 psmouse_err(psmouse, "unknown packet type %d\n", pkt_type); 1162 - return 0; 1164 + return false; 1163 1165 } 1164 1166 } 1165 1167 1166 - static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse) 1168 + static enum synaptics_pkt_type 1169 + synaptics_detect_pkt_type(struct psmouse *psmouse) 1167 1170 { 1168 1171 int i; 1169 1172 1170 - for (i = 0; i < 5; i++) 1173 + for (i = 0; i < 5; i++) { 1171 1174 if (!synaptics_validate_byte(psmouse, i, SYN_NEWABS_STRICT)) { 1172 1175 psmouse_info(psmouse, "using relaxed packet validation\n"); 1173 1176 return SYN_NEWABS_RELAXED; 1174 1177 } 1178 + } 1175 1179 1176 1180 return SYN_NEWABS_STRICT; 1177 1181 } ··· 1378 1378 { 1379 1379 struct synaptics_data *priv = psmouse->private; 1380 1380 struct synaptics_device_info info; 1381 - unsigned char param[2]; 1381 + u8 param[2]; 1382 1382 int retry = 0; 1383 1383 int error; 1384 1384
+12 -10
drivers/input/mouse/synaptics.h
··· 137 137 #define SYN_PS_SET_MODE2 0x14 138 138 #define SYN_PS_CLIENT_CMD 0x28 139 139 140 - /* synaptics packet types */ 141 - #define SYN_NEWABS 0 142 - #define SYN_NEWABS_STRICT 1 143 - #define SYN_NEWABS_RELAXED 2 144 - #define SYN_OLDABS 3 145 - 146 140 /* amount to fuzz position data when touchpad reports reduced filtering */ 147 141 #define SYN_REDUCED_FILTER_FUZZ 8 142 + 143 + /* synaptics packet types */ 144 + enum synaptics_pkt_type { 145 + SYN_NEWABS, 146 + SYN_NEWABS_STRICT, 147 + SYN_NEWABS_RELAXED, 148 + SYN_OLDABS, 149 + }; 148 150 149 151 /* 150 152 * A structure to describe the state of the touchpad hardware (buttons and pad) ··· 161 159 unsigned int middle:1; 162 160 unsigned int up:1; 163 161 unsigned int down:1; 164 - unsigned char ext_buttons; 165 - signed char scroll; 162 + u8 ext_buttons; 163 + s8 scroll; 166 164 }; 167 165 168 166 /* Data read from the touchpad */ ··· 183 181 struct synaptics_data { 184 182 struct synaptics_device_info info; 185 183 186 - unsigned char pkt_type; /* packet type - old, new, etc */ 187 - unsigned char mode; /* current mode byte */ 184 + enum synaptics_pkt_type pkt_type; /* packet type - old, new, etc */ 185 + u8 mode; /* current mode byte */ 188 186 int scroll; 189 187 190 188 bool absolute_mode; /* run in Absolute mode */