d/psmv: More verbose error handling

This commit is contained in:
Jakob Bornecrantz 2019-11-06 19:47:23 +00:00
parent e5a9cbb2f9
commit c60b9881e2

View file

@ -1176,10 +1176,13 @@ psmv_get_calibration_zcm1(struct psmv_device *psmv)
ret = os_hid_get_feature(psmv->hid, 0x10, src, sizeof(part)); ret = os_hid_get_feature(psmv->hid, 0x10, src, sizeof(part));
if (ret < 0) { if (ret < 0) {
PSMV_ERROR(psmv, "os_hid_get_feature returned %i", ret);
return ret; return ret;
} }
if (ret != (int)sizeof(part)) { if (ret != (int)sizeof(part)) {
PSMV_ERROR(psmv, "Size wrong: %i != %i", ret,
(int)sizeof(part));
return -1; return -1;
} }
@ -1196,7 +1199,9 @@ psmv_get_calibration_zcm1(struct psmv_device *psmv)
src_offset = 2; src_offset = 2;
dst_offset = sizeof(part) * 2 - 2; dst_offset = sizeof(part) * 2 - 2;
break; break;
default: return -1; default:
PSMV_ERROR(psmv, "Unexpected part id! %i", part.which);
return -1;
} }
memcpy(dst + dst_offset, src + src_offset, memcpy(dst + dst_offset, src + src_offset,
@ -1402,10 +1407,13 @@ psmv_get_calibration_zcm2(struct psmv_device *psmv)
ret = os_hid_get_feature(psmv->hid, 0x10, src, sizeof(part)); ret = os_hid_get_feature(psmv->hid, 0x10, src, sizeof(part));
if (ret < 0) { if (ret < 0) {
PSMV_ERROR(psmv, "os_hid_get_feature returned %i", ret);
return ret; return ret;
} }
if (ret != (int)sizeof(part)) { if (ret != (int)sizeof(part)) {
PSMV_ERROR(psmv, "Size wrong: %i != %i", ret,
(int)sizeof(*part));
return -1; return -1;
} }
@ -1418,7 +1426,9 @@ psmv_get_calibration_zcm2(struct psmv_device *psmv)
src_offset = 2; src_offset = 2;
dst_offset = sizeof(part); dst_offset = sizeof(part);
break; break;
default: return -1; default:
PSMV_ERROR(psmv, "Unexpected part id! %i", part->which);
return -1;
} }
memcpy(dst + dst_offset, src + src_offset, memcpy(dst + dst_offset, src + src_offset,