/********************************************************************* * * Filename: irias_object.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Thu Oct 1 22:49:50 1998 * Modified at: Wed Dec 15 11:20:57 1999 * Modified by: Dag Brattli * * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Neither Dag Brattli nor University of Tromsø admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #ifndef LM_IAS_OBJECT_H #define LM_IAS_OBJECT_H #include #include /* LM-IAS Attribute types */ #define IAS_MISSING 0 #define IAS_INTEGER 1 #define IAS_OCT_SEQ 2 #define IAS_STRING 3 /* Object ownership of attributes (user or kernel) */ #define IAS_KERNEL_ATTR 0 #define IAS_USER_ATTR 1 /* * LM-IAS Object */ struct ias_object { irda_queue_t q; /* Must be first! */ magic_t magic; char *name; int id; hashbin_t *attribs; }; /* * Values used by LM-IAS attributes */ struct ias_value { __u8 type; /* Value description */ __u8 owner; /* Managed from user/kernel space */ int charset; /* Only used by string type */ int len; /* Value */ union { int integer; char *string; __u8 *oct_seq; } t; }; /* * Attributes used by LM-IAS objects */ struct ias_attrib { irda_queue_t q; /* Must be first! */ int magic; char *name; /* Attribute name */ struct ias_value *value; /* Attribute value */ }; struct ias_object *irias_new_object(char *name, int id); void irias_insert_object(struct ias_object *obj); int irias_delete_object(struct ias_object *obj); int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib, int cleanobject); void __irias_delete_object(struct ias_object *obj); void irias_add_integer_attrib(struct ias_object *obj, char *name, int value, int user); void irias_add_string_attrib(struct ias_object *obj, char *name, char *value, int user); void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets, int len, int user); int irias_object_change_attribute(char *obj_name, char *attrib_name, struct ias_value *new_value); struct ias_object *irias_find_object(char *name); struct ias_attrib *irias_find_attrib(struct ias_object *obj, char *name); struct ias_value *irias_new_string_value(char *string); struct ias_value *irias_new_integer_value(int integer); struct ias_value *irias_new_octseq_value(__u8 *octseq , int len); struct ias_value *irias_new_missing_value(void); void irias_delete_value(struct ias_value *value); extern struct ias_value irias_missing; extern hashbin_t *irias_objects; #endif '5'>5space:mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2016-10-27 16:49:20 -0700
committerJiri Kosina <jkosina@suse.cz>2016-11-03 12:08:43 -0600
commit5459ada2b3cd69e6bf1b0c034feb810975d0072b (patch)
treed82ff47c3888186313d96eff7e5fc4f8b2b8b2eb /net
parent4973ca9a01e2354b159acedec1b9b8eb8de02ab7 (diff)
HID: sensor-hub: Fix packing of result buffer for feature report
When report count is more than one and report size is not 4 bytes, then we need some packing into result buffer from the caller of function sensor_hub_get_feature. By default the value extracted from a field is 4 bytes from hid core (using hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT)), even if report size if less than 4 byte. So when we copy data to user buffer in sensor_hub_get_feature, we need to only copy report size bytes even when report count is more than 1. This is not an issue for most of the sensor hub fields as report count will be 1 where we already copy only report size bytes, but some string fields like description, it is a problem as the report count will be more than 1. For example: Field(6) Physical(Sensor.OtherCustom) Application(Sensor.Sensor) Usage(11) Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Sensor.0306 Report Size(16) Report Count(11) Here since the report size is 2 bytes, we will have 2 additional bytes of 0s copied into user buffer, if we directly copy to user buffer from report->field[]->value This change will copy report size bytes into the buffer of caller for each usage report->field[]->value. So for example without this change, the data displayed for a custom sensor field "sensor-model": 76 00 101 00 110 00 111 00 118 00 111 (truncated to report count of 11) With change 76 101 110 111 118 111 32 89 111 103 97 ("Lenovo Yoga" in ASCII ) Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'net')