Changeset c657bd7 in mainline for uspace/drv/hid/ps2mouse/ps2mouse.c
- Timestamp:
- 2017-11-20T10:06:59Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19ea61d
- Parents:
- 5d50c419
- git-author:
- Jiri Svoboda <jiri@…> (2017-11-19 22:05:26)
- git-committer:
- Jiri Svoboda <jiri@…> (2017-11-20 10:06:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/hid/ps2mouse/ps2mouse.c
r5d50c419 rc657bd7 212 212 } 213 213 214 /** Read fixed-size mouse packet. 215 * 216 * Continue reading until entire packet is received. 217 * 218 * @param mouse Mouse device 219 * @param pbuf Buffer for storing packet 220 * @param psize Packet size 221 * 222 * @return EOK on success or non-zero error code 223 */ 224 static int ps2_mouse_read_packet(ps2_mouse_t *mouse, void *pbuf, size_t psize) 225 { 226 int rc; 227 size_t pos; 228 size_t nread; 229 230 pos = 0; 231 while (pos < psize) { 232 rc = chardev_read(mouse->chardev, pbuf + pos, psize - pos, 233 &nread); 234 if (rc != EOK) { 235 ddf_msg(LVL_WARN, "Error reading packet."); 236 return rc; 237 } 238 239 pos += nread; 240 } 241 242 return EOK; 243 } 244 214 245 /** Get data and parse ps2 protocol packets. 215 246 * @param arg Pointer to ps2_mouse_t structure. … … 219 250 { 220 251 ps2_mouse_t *mouse = (ps2_mouse_t *) arg; 221 size_t nread;222 252 int rc; 223 253 … … 225 255 while (1) { 226 256 uint8_t packet[PS2_BUFSIZE] = {}; 227 rc = chardev_read(mouse->chardev, packet, PS2_BUFSIZE, &nread); 228 if (rc != EOK || nread != PS2_BUFSIZE) { 229 ddf_msg(LVL_WARN, "Incorrect packet size: %zd.", nread); 257 rc = ps2_mouse_read_packet(mouse, packet, PS2_BUFSIZE); 258 if (rc != EOK) 230 259 continue; 231 }232 260 233 261 ddf_msg(LVL_DEBUG2, "Got packet: %hhx:%hhx:%hhx.", … … 274 302 { 275 303 ps2_mouse_t *mouse = (ps2_mouse_t *) arg; 276 size_t nread;277 304 int rc; 278 305 … … 280 307 while (1) { 281 308 uint8_t packet[INTELLIMOUSE_BUFSIZE] = {}; 282 rc = chardev_read(mouse->chardev, packet, INTELLIMOUSE_BUFSIZE, 283 &nread); 284 if (rc != EOK || nread != INTELLIMOUSE_BUFSIZE) { 285 ddf_msg(LVL_WARN, "Incorrect packet size: %zd.", nread); 309 rc = ps2_mouse_read_packet(mouse, packet, INTELLIMOUSE_BUFSIZE); 310 if (rc != EOK) 286 311 continue; 287 } 312 288 313 ddf_msg(LVL_DEBUG2, "Got packet: %hhx:%hhx:%hhx:%hhx.", 289 314 packet[0], packet[1], packet[2], packet[3]);
Note:
See TracChangeset
for help on using the changeset viewer.