public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: linux-kernel@vger.kernel.org, Richard Purdie <rpurdie@rpsys.net>,
	"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH] leds: Fix warnings when PM is disabled for BD2802
Date: Fri, 21 Jan 2011 14:14:02 -0800	[thread overview]
Message-ID: <20110121141402.30aac149.akpm@linux-foundation.org> (raw)
In-Reply-To: <1295631217-19591-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On Fri, 21 Jan 2011 17:33:37 +0000
Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:

> The suspend and resume functions will only be referenced when PM is
> enabled so they generate warnings due to being unreferenced and
> unexported.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> 
> This is the more usual idiom for fixing this than the patch you added.
> 
>  drivers/leds/leds-bd2802.c |   30 ++++++++++++++++--------------
>  1 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
> index 22152a2..ef0b868 100644
> --- a/drivers/leds/leds-bd2802.c
> +++ b/drivers/leds/leds-bd2802.c
> @@ -319,20 +319,6 @@ static void bd2802_turn_off(struct bd2802_led *led, enum led_ids id,
>  	bd2802_update_state(led, id, color, BD2802_OFF);
>  }
>  
> -static void bd2802_restore_state(struct bd2802_led *led)
> -{
> -	int i;
> -
> -	for (i = 0; i < LED_NUM; i++) {
> -		if (led->led[i].r)
> -			bd2802_turn_on(led, i, RED, led->led[i].r);
> -		if (led->led[i].g)
> -			bd2802_turn_on(led, i, GREEN, led->led[i].g);
> -		if (led->led[i].b)
> -			bd2802_turn_on(led, i, BLUE, led->led[i].b);
> -	}
> -}
> -
>  #define BD2802_SET_REGISTER(reg_addr, reg_name)				\
>  static ssize_t bd2802_store_reg##reg_addr(struct device *dev,		\
>  	struct device_attribute *attr, const char *buf, size_t count)	\
> @@ -761,6 +747,7 @@ static int __exit bd2802_remove(struct i2c_client *client)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
>  static int bd2802_suspend(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
> @@ -771,6 +758,20 @@ static int bd2802_suspend(struct device *dev)
>  	return 0;
>  }
>  
> +static void bd2802_restore_state(struct bd2802_led *led)
> +{
> +	int i;
> +
> +	for (i = 0; i < LED_NUM; i++) {
> +		if (led->led[i].r)
> +			bd2802_turn_on(led, i, RED, led->led[i].r);
> +		if (led->led[i].g)
> +			bd2802_turn_on(led, i, GREEN, led->led[i].g);
> +		if (led->led[i].b)
> +			bd2802_turn_on(led, i, BLUE, led->led[i].b);
> +	}
> +}
> +
>  static int bd2802_resume(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
> @@ -783,6 +784,7 @@ static int bd2802_resume(struct device *dev)
>  
>  	return 0;
>  }
> +#endif
>  

That rather sucks.  It leaves an all-zeroes instance of dev_pm_ops
uselessly bloating the driver.  And it leaves
bd2802_i2c_driver.driver.pm pointing at that all-zeroes instance of
dev_pm_ops, which is rather dangerous.

If CONFIG_PM_SLEEP=n, the .driver.pm field shouldn't exist at all.

<looks at Rafael>

  reply	other threads:[~2011-01-21 22:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21 17:33 [PATCH] leds: Fix warnings when PM is disabled for BD2802 Mark Brown
2011-01-21 22:14 ` Andrew Morton [this message]
2011-01-21 23:38   ` Dmitry Torokhov
2011-01-21 23:47     ` Mark Brown
2011-01-22 10:21       ` Rafael J. Wysocki
2011-01-22  0:23     ` Andrew Morton

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=20110121141402.30aac149.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=rpurdie@rpsys.net \
    /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