/* Set a field value. The report this field belongs to has to be created and transferred to the device, to set this value in the device.  */
int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
/* Set a field value. The report this field belongs to has to be created and transferred to the device, to set this value in the device.  */
int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
{
	unsigned size = field->report_size;
	hid_dump_input(field->report->device, field->usage + offset, value);
	if (offset >= field->report_count) {
		dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
		return -1;
	}
	if (field->logical_minimum < 0) {
		if (value != snto32(s32ton(value, size), size)) {
			dbg_hid("value %d is out of range\n", value);
			return -1;
		}
	}
	field->value[offset] = value;
	return 0;
}