Linux Power Management development
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
To: Colin King <colin.king@canonical.com>
Cc: Milo Kim <milo.kim@ti.com>,
	linux-pm@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: supply: lp8788: Make several arrays static const * const
Date: Sat, 12 Aug 2017 14:03:56 -0400	[thread overview]
Message-ID: <20170812180356.fth4xnltlccnyiyz@earth> (raw)
In-Reply-To: <20170811215212.9985-1-colin.king@canonical.com>

[-- Attachment #1: Type: text/plain, Size: 2506 bytes --]

Hi,

On Fri, Aug 11, 2017 at 10:52:12PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate various read only arrays on the stack but make them
> static const, making the object code smaller and saves 148 bytes
> overall:
> 
> Before:
>    text    data     bss     dec     hex filename
>   11940    4496      64   16500    4074 lp8788-charger.o
> 
> After:
>    text    data     bss     dec     hex filename
>   11472    4816      64   16352    3fe0 lp8788-charger.o
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks, queued.

-- Sebastian

> ---
>  drivers/power/supply/lp8788-charger.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
> index 677f7c40b25a..0f3432795f3c 100644
> --- a/drivers/power/supply/lp8788-charger.c
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -626,7 +626,7 @@ static ssize_t lp8788_show_charger_status(struct device *dev,
>  {
>  	struct lp8788_charger *pchg = dev_get_drvdata(dev);
>  	enum lp8788_charging_state state;
> -	char *desc[LP8788_MAX_CHG_STATE] = {
> +	static const char * const desc[LP8788_MAX_CHG_STATE] = {
>  		[LP8788_OFF] = "CHARGER OFF",
>  		[LP8788_WARM_UP] = "WARM UP",
>  		[LP8788_LOW_INPUT] = "LOW INPUT STATE",
> @@ -650,8 +650,10 @@ static ssize_t lp8788_show_eoc_time(struct device *dev,
>  				struct device_attribute *attr, char *buf)
>  {
>  	struct lp8788_charger *pchg = dev_get_drvdata(dev);
> -	char *stime[] = { "400ms", "5min", "10min", "15min",
> -			"20min", "25min", "30min", "No timeout" };
> +	static const char * const stime[] = {
> +		"400ms", "5min", "10min", "15min",
> +		"20min", "25min", "30min", "No timeout"
> +	};
>  	u8 val;
>  
>  	lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val);
> @@ -665,9 +667,13 @@ static ssize_t lp8788_show_eoc_level(struct device *dev,
>  				struct device_attribute *attr, char *buf)
>  {
>  	struct lp8788_charger *pchg = dev_get_drvdata(dev);
> -	char *abs_level[] = { "25mA", "49mA", "75mA", "98mA" };
> -	char *relative_level[] = { "5%", "10%", "15%", "20%" };
> -	char *level;
> +	static const char * const abs_level[] = {
> +			"25mA", "49mA", "75mA", "98mA"
> +	};
> +	static const char * const relative_level[] = {
> +			"5%", "10%", "15%", "20%"
> +	};
> +	const char *level;
>  	u8 val;
>  	u8 mode;
>  
> -- 
> 2.11.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2017-08-12 18:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 21:52 [PATCH] power: supply: lp8788: Make several arrays static const * const Colin King
2017-08-12 18:03 ` Sebastian Reichel [this message]

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=20170812180356.fth4xnltlccnyiyz@earth \
    --to=sebastian.reichel@collabora.co.uk \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=milo.kim@ti.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