leds: Fix warnings when PM is disabled for BD2802
PATCH 1/1 leds: Fix warnings when PM is disabled for BD2802
The suspend and resume functions will only be referenced when PM is enabled so they generate warnings due to being unreferenced and unexported.
---
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(-)
drivers/leds/leds-bd2802.c +16 -14
@@ -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 static SIMPLE_DEV_PM_OPS(bd2802_pm, bd2802_suspend, bd2802_resume);
Signature · 1 line
1.7.2.3
Quoted 67 lines · On Fri, 21 Jan 2011 17:33:37 +0000 Mark Brown…
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 <[email protected]>---
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(-)drivers/leds/leds-bd2802.c +15
-14@@ -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);
drivers/leds/leds-bd2802.c static int bd2802_resume(struct device *dev) · line 788
Quoted 5 lines
drivers/leds/leds-bd2802.c +1
-0@@ -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>
Quoted 71 lines · Andrew Morton
Quoted 68 lines · On Fri, 21 Jan 2011 17:33:37 +0000 Mark Brown…
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 <[email protected]>---
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(-)drivers/leds/leds-bd2802.c +15
-14@@ -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)
Quoted 7 lines
drivers/leds/leds-bd2802.c static int bd2802_resume(struct device *dev) · line 788
Quoted 4 lines
drivers/leds/leds-bd2802.c +1
-0return 0; } +#endif That rather sucks. It leaves an all-zeroes instance of
dev_pm_opsuselessly bloating the driver.
It is per-driver, not per device so do we really care?
Quoted 3 lines
And it leaves
bd2802_i2c_driver.driver.pm pointing at that all-zeroes instance ofdev_pm_ops, which is rather dangerous.
Nothing dagerous here - PM core deals with half-filled pm_ops just fine.
Quoted 2 lines
If
CONFIG_PM_SLEEP=n, the .driver.pm field shouldn't exist at all.
Meh, we have _waaay_ too many config options, I'd rather see CONFIG_PM and possibly CONFIG_PM_SLEEP go, maybe leaving us with CONFIG_PM_RUNTIME and maybe not. How many devices out there do not want PM?
Signature · 1 line
Dmitry
Quoted 7 lines · Dmitry Torokhov
Quoted 3 lines · Andrew Morton
And it leaves
bd2802_i2c_driver.driver.pm pointing at that all-zeroes instance ofdev_pm_ops, which is rather dangerous.Nothing dagerous here - PM core deals with half-filled
pm_opsjust fine.
Indeed, all the PM operations are completly optional so there's no problem there except for the empty dev_pm_ops we leave lying around for each driver.
Quoted 6 lines
Quoted 1 line
If
CONFIG_PM_SLEEP=n, the .driver.pm field shouldn't exist at all.Meh, we have _waaay_ too many config options, I'd rather see
CONFIG_PMand possiblyCONFIG_PM_SLEEPgo, maybe leaving us withCONFIG_PM_RUNTIMEand maybe not. How many devices out there do not want PM?
I made the same point earlier; I guess I'll post an RFC patch over the weekend.
Quoted 7 lines · Mark Brown
Quoted 5 lines · Dmitry Torokhov
Quoted 3 lines · Andrew Morton
And it leaves
bd2802_i2c_driver.driver.pm pointing at that all-zeroes instance ofdev_pm_ops, which is rather dangerous.
Quoted 7 lines
Quoted 1 line
Nothing dagerous here - PM core deals with half-filled
pm_opsjust fine.Indeed, all the PM operations are completly optional so there's no problem there except for the empty
dev_pm_opswe leave lying around for each driver.Quoted 1 line
Quoted 1 line
If
CONFIG_PM_SLEEP=n, the .driver.pm field shouldn't exist at all.
Not if CONFIG_PM_RUNTIME is set (that field is for both SLEEP and RUNTIME).
Quoted 4 lines
Quoted 4 lines
Meh, we have _waaay_ too many config options, I'd rather see
CONFIG_PMand possiblyCONFIG_PM_SLEEPgo, maybe leaving us withCONFIG_PM_RUNTIMEand maybe not. How many devices out there do not want PM?
You'd be surprised.
Quoted 2 lines
I made the same point earlier; I guess I'll post an RFC patch over the weekend.
The truth is CONFIG_PM was a mistake, because it's practically meaningless (it basically is always set), so we could remove it, I think, but that would require us to modify _many_ drivers.
CONFIG_PM_SLEEP is distinctly about suspend and hibernation which people tend to switch off sometimes.
Thanks,
Rafael
Quoted 4 lines · On Fri, 21 Jan 2011 15:38:37 -0800 Dmitry Torokhov <[email protected]>…
Quoted 2 lines
That rather sucks. It leaves an all-zeroes instance of
dev_pm_opsuselessly bloating the driver.It is per-driver, not per device so do we really care?
We care about everything. If the objective was to make life easier for ourselves, we'd all be on the golf course.
Quoted 7 lines
Quoted 3 lines
And it leaves
bd2802_i2c_driver.driver.pm pointing at that all-zeroes instance ofdev_pm_ops, which is rather dangerous.Nothing dagerous here - PM core deals with half-filled
pm_opsjust fine.Quoted 1 line
Quoted 6 lines
Quoted 1 line
If
CONFIG_PM_SLEEP=n, the .driver.pm field shouldn't exist at all.Meh, we have _waaay_ too many config options, I'd rather see
CONFIG_PMand possiblyCONFIG_PM_SLEEPgo, maybe leaving us withCONFIG_PM_RUNTIMEand maybe not. How many devices out there do not want PM?
Don't know. How do we determine this?