mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] HID: Reorder fields in 'struct hid_field'
Date: Mon, 19 Jun 2023 20:20:08 +0200	[thread overview]
Message-ID: <ba1a74ba-e91a-bf12-2d4e-7157e4519478@wanadoo.fr> (raw)
In-Reply-To: <d6026b7f-dc07-4d0c-9805-cc61d6b9a4b8@kadam.mountain>

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

  reply	other threads:[~2023-06-19 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-18  8:08 Christophe JAILLET
2023-06-19  5:18 ` Dan Carpenter
2023-06-19 18:20   ` Christophe JAILLET [this message]
2023-06-20  5:09     ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba1a74ba-e91a-bf12-2d4e-7157e4519478@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dan.carpenter@linaro.org \
    --cc=jikos@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®