Use standard validation function

This commit is contained in:
Jeff Epler 2022-11-08 17:08:53 -06:00
parent 6be0a425c7
commit 530e5a1df2
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
1 changed files with 1 additions and 3 deletions

View File

@ -344,9 +344,7 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p
int32_t in_start = args[ARG_in_start].u_int;
const int32_t in_end = args[ARG_in_end].u_int;
normalize_buffer_bounds(&in_start, in_end, &in_length);
if (in_length == 0) {
mp_raise_ValueError_varg(translate("%q length must be >= %d"), MP_QSTR_out_buffer, 1);
}
mp_arg_validate_length_min(in_length, 1, MP_QSTR_out_buffer);
uint8_t status = common_hal_busio_i2c_write_read(self, args[ARG_address].u_int,
((uint8_t *)out_bufinfo.buf) + out_start, out_length,((uint8_t *)in_bufinfo.buf) + in_start, in_length);