From: Sean Young <sean@mess.org>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
linux-media@vger.kernel.org
Subject: Re: [PATCH] media: rc: reduce size of struct ir_raw_event
Date: Wed, 16 Mar 2016 22:28:26 +0000 [thread overview]
Message-ID: <20160316222826.GA6635@gofer.mess.org> (raw)
In-Reply-To: <56E9CDAE.2040200@gmail.com>
On Wed, Mar 16, 2016 at 10:18:38PM +0100, Heiner Kallweit wrote:
> struct ir_raw_event currently has a size of 12 bytes on most (all?)
> architectures. This can be reduced to 8 bytes whilst maintaining
> full backwards compatibility.
> This saves 2KB in size of struct ir_raw_event_ctrl (as element
> kfifo is reduced by 512 * 4 bytes) and it allows to copy the
> full struct ir_raw_event with a single 64 bit operation.
>
> Successfully tested with the Nuvoton driver and successfully
> compile-tested with the ene_ir driver (as it uses the carrier /
> duty_cycle elements).
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> include/media/rc-core.h | 26 ++++++++------------------
> 1 file changed, 8 insertions(+), 18 deletions(-)
>
> diff --git a/include/media/rc-core.h b/include/media/rc-core.h
> index 0f77b3d..b8f27c9 100644
> --- a/include/media/rc-core.h
> +++ b/include/media/rc-core.h
> @@ -214,27 +214,17 @@ enum raw_event_type {
>
> struct ir_raw_event {
> union {
> - u32 duration;
> -
> - struct {
> - u32 carrier;
> - u8 duty_cycle;
> - };
> + u32 duration;
> + u32 carrier;
> };
> -
> - unsigned pulse:1;
> - unsigned reset:1;
> - unsigned timeout:1;
> - unsigned carrier_report:1;
> + u8 duty_cycle;
Moving duty_cycle does indeed reduce the structure size from 12 to 8.
> + u8 pulse:1;
> + u8 reset:1;
> + u8 timeout:1;
> + u8 carrier_report:1;
Why are you changing the type of the bitfields?
> };
>
> -#define DEFINE_IR_RAW_EVENT(event) \
> - struct ir_raw_event event = { \
> - { .duration = 0 } , \
> - .pulse = 0, \
> - .reset = 0, \
> - .timeout = 0, \
> - .carrier_report = 0 }
> +#define DEFINE_IR_RAW_EVENT(event) struct ir_raw_event event = {}
Seems fine. I've always kinda wondered why this macro is needed.
Sean
next prev parent reply other threads:[~2016-03-16 22:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-16 21:18 [PATCH] media: rc: reduce size of struct ir_raw_event Heiner Kallweit
2016-03-16 22:28 ` Sean Young [this message]
2016-03-17 6:40 ` Heiner Kallweit
2016-03-17 10:53 ` Sean Young
2016-03-17 19:37 ` Heiner Kallweit
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=20160316222826.GA6635@gofer.mess.org \
--to=sean@mess.org \
--cc=hkallweit1@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
/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