Subject: Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.

From: Greg KH <[email-masked]>
Date: Fri, 22 Apr 2022 08:00:50 +0200

On Thu, Apr 21, 2022 at 07:51:02PM -0700, Luck, Tony wrote:
> On Fri, Apr 22, 2022 at 10:00:54AM +1000, Stephen Rothwell wrote:
> > I assume that there is some good reason that topology_ppin() is not
> > implemented as a static inline function?
> 
> I don't think so. I just cut & pasted how all the other topology_*()
> things were implemented.
> 
> Making it a static inline appears to fix this problem. But before
> embarrassing myself with a third broken version I'll let zero day
> crunch on:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git hide_ppin
> 
> to see if there is some subtle config or arch where the inline trick
> doesn't work.
> 
> Thanks for the idea! :-)

Why not just do the following, which passes my build tests here:

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 706dbf8bf249..ac6ad9ab67f9 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -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;