Skip to content

Commit 2b4f431

Browse files
jmberg-intelrafaeljw
authored andcommitted
PM / sysfs: avoid shadowing variables
The global variable "enabled" is shadowed in a number of functions in this file, rename it to "_enabled" to avoid that. For consistency, also rename "disabled" and move them both into the #ifdef where they're needed. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 2ce7598 commit 2b4f431

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

drivers/base/power/sysfs.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@
9292
* wakeup_count - Report the number of wakeup events related to the device
9393
*/
9494

95-
static const char enabled[] = "enabled";
96-
static const char disabled[] = "disabled";
97-
9895
const char power_group_name[] = "power";
9996
EXPORT_SYMBOL_GPL(power_group_name);
10097

@@ -336,11 +333,14 @@ static DEVICE_ATTR(pm_qos_remote_wakeup, 0644,
336333
#endif /* CONFIG_PM_RUNTIME */
337334

338335
#ifdef CONFIG_PM_SLEEP
336+
static const char _enabled[] = "enabled";
337+
static const char _disabled[] = "disabled";
338+
339339
static ssize_t
340340
wake_show(struct device * dev, struct device_attribute *attr, char * buf)
341341
{
342342
return sprintf(buf, "%s\n", device_can_wakeup(dev)
343-
? (device_may_wakeup(dev) ? enabled : disabled)
343+
? (device_may_wakeup(dev) ? _enabled : _disabled)
344344
: "");
345345
}
346346

@@ -357,11 +357,11 @@ wake_store(struct device * dev, struct device_attribute *attr,
357357
cp = memchr(buf, '\n', n);
358358
if (cp)
359359
len = cp - buf;
360-
if (len == sizeof enabled - 1
361-
&& strncmp(buf, enabled, sizeof enabled - 1) == 0)
360+
if (len == sizeof _enabled - 1
361+
&& strncmp(buf, _enabled, sizeof _enabled - 1) == 0)
362362
device_set_wakeup_enable(dev, 1);
363-
else if (len == sizeof disabled - 1
364-
&& strncmp(buf, disabled, sizeof disabled - 1) == 0)
363+
else if (len == sizeof _disabled - 1
364+
&& strncmp(buf, _disabled, sizeof _disabled - 1) == 0)
365365
device_set_wakeup_enable(dev, 0);
366366
else
367367
return -EINVAL;
@@ -570,7 +570,8 @@ static ssize_t async_show(struct device *dev, struct device_attribute *attr,
570570
char *buf)
571571
{
572572
return sprintf(buf, "%s\n",
573-
device_async_suspend_enabled(dev) ? enabled : disabled);
573+
device_async_suspend_enabled(dev) ?
574+
_enabled : _disabled);
574575
}
575576

576577
static ssize_t async_store(struct device *dev, struct device_attribute *attr,
@@ -582,9 +583,10 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
582583
cp = memchr(buf, '\n', n);
583584
if (cp)
584585
len = cp - buf;
585-
if (len == sizeof enabled - 1 && strncmp(buf, enabled, len) == 0)
586+
if (len == sizeof _enabled - 1 && strncmp(buf, _enabled, len) == 0)
586587
device_enable_async_suspend(dev);
587-
else if (len == sizeof disabled - 1 && strncmp(buf, disabled, len) == 0)
588+
else if (len == sizeof _disabled - 1 &&
589+
strncmp(buf, _disabled, len) == 0)
588590
device_disable_async_suspend(dev);
589591
else
590592
return -EINVAL;

0 commit comments

Comments
 (0)