lkml.org 
[lkml]   [2023]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] HID: Reorder fields in 'struct hid_field'
From
Le 19/06/2023 à 07:18, Dan Carpenter a écrit :
> On Sun, Jun 18, 2023 at 10:08:07AM +0200, Christophe JAILLET wrote:
>> diff --git a/include/linux/hid.h b/include/linux/hid.h
>> index 39e21e3815ad..5be5e671c263 100644
>> --- a/include/linux/hid.h
>> +++ b/include/linux/hid.h
>> @@ -480,9 +480,9 @@ struct hid_field {
>> __s32 physical_maximum;
>> __s32 unit_exponent;
>> unsigned unit;
>> - bool ignored; /* this field is ignored in this event */
>> struct hid_report *report; /* associated report */
>> unsigned index; /* index into report->field[] */
>> + bool ignored; /* this field is ignored in this event */
>> /* hidinput data */
>> struct hid_input *hidinput; /* associated input structure */
>> __u16 dpad; /* dpad input code */
>
> You could move the dpad next to the ignored to save another 4 bytes.
> I think it is still grouped logically that way but I don't really know
> what dpad is so I might be wrong.
>
> struct hid_report *report; /* associated report */
> unsigned index; /* index into report->field[] */
> bool ignored; /* this field is ignored in this event */
> /* hidinput data */
> __u16 dpad; /* dpad input code */
> struct hid_input *hidinput; /* associated input structure */
>
> regards,
> dan carpenter
>
>

In fact, not really,
It would fill a hole better, but would generate some padding at the end
of the struct:

bool ignored; /* 108 1 */

/* XXX 1 byte hole, try to pack */

__u16 dpad; /* 110 2 */
struct hid_input * hidinput; /* 112 8 */
unsigned int slot_idx; /* 120 4 */

/* size: 128, cachelines: 2, members: 25 */
/* sum members: 119, holes: 2, sum holes: 5 */
/* padding: 4 */
};

CJ

\
 
 \ /
  Last update: 2023-06-19 20:21    [W:0.046 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site