Skip to contentSkip to conversation

topology: Fix up build warning in topology_is_visible()

PATCH In review Greg Kroah-Hartman 2 participants 3 messages Apr 22, 2022 – Apr 24, 2022 Driver core

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 topology: Fix up build warning in topology_is_visible()

Commit aa63a74d4535 ("topology/sysfs: Hide PPIN on systems that do not support it.") caused a build warning on some configurations:

drivers/base/topology.c: In function 'topology_is_visible':
drivers/base/topology.c:158:24: warning: unused variable 'dev' [-Wunused-variable]
158 | struct device *dev = kobj_to_dev(kobj);

Fix this up by getting rid of the variable entirely.

Fixes aa63a74d4535 ("topology/sysfs: Hide PPIN on systems that do not support it.")
Cc Tony Luck <[email protected]>
---
 drivers/base/topology.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/base/topology.c +1 -3
index 706dbf8bf249..ac6ad9ab67f9 100644
@@ -155,9 +155,7 @@ static struct attribute *default_attrs[] = {
 static umode_t topology_is_visible(struct kobject *kobj,
 				   struct attribute *attr, int unused)
 {
-	struct device *dev = kobj_to_dev(kobj);
-
-	if (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id))
+	if (attr == &dev_attr_ppin.attr && !topology_ppin(kobj_to_dev(kobj)->id))
 		return 0;
 
 	return attr->mode;
Signature · 1 line
2.36.0
author maintainer
#1 lore raw
Quoted 35 lines · Greg Kroah-Hartman

Commit aa63a74d4535 ("topology/sysfs: Hide PPIN on systems that do not support it.") caused a build warning on some configurations:

drivers/base/topology.c: In function 'topology_is_visible':
drivers/base/topology.c:158:24: warning: unused variable 'dev' [-Wunused-variable]
158 | struct device *dev = kobj_to_dev(kobj);

Fix this up by getting rid of the variable entirely.

Fixes aa63a74d4535 ("topology/sysfs: Hide PPIN on systems that do not support it.")
Cc Tony Luck <[email protected]>
---
 drivers/base/topology.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/base/topology.c +1 -3
index 706dbf8bf249..ac6ad9ab67f9 100644
@@ -155,9 +155,7 @@ static struct attribute *default_attrs[] = {
 static umode_t topology_is_visible(struct kobject *kobj,
 				   struct attribute *attr, int unused)
 {
-	struct device *dev = kobj_to_dev(kobj);
-
-	if (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id))
+	if (attr == &dev_attr_ppin.attr && !topology_ppin(kobj_to_dev(kobj)->id))
 		return 0;
 
 	return attr->mode;
Signature · 1 line
2.36.0

Given no comments that this is a bad idea, I'll go apply this now.

thanks,

greg k-h

#2 lore raw
Quoted 1 line

Given no comments that this is a bad idea, I'll go apply this now.

FWIW (very little) 0-day didn't find issues with changing from macro to static inline. But your fix is much neater.

-Tony