public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* using a single sysfs show function for multiple device attributes
@ 2011-06-29 18:53 johnlinn
  2011-06-29 20:00 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: johnlinn @ 2011-06-29 18:53 UTC (permalink / raw)
  To: linux-kernel

In a platform driver, I'm trying to use a single function for multiple device attributes and use the attr input to ID which attribute.

After the driver is up and running, the sysfs attributes exist.  In my show function getting a device_attribute as an input, I never see the device attribute (attr) having anything in it (all 0s).  I see the attr pointer be valid, but pointing to all 0's.  

I don't see others using the attr input, but it seems like the way to ID which attribute is being accessed so that one show function can be used for many attributes.

I'm sure it's obvious, but I don't see what I'm doing wrong.

Thanks,
John

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: using a single sysfs show function for multiple device attributes
  2011-06-29 18:53 using a single sysfs show function for multiple device attributes johnlinn
@ 2011-06-29 20:00 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2011-06-29 20:00 UTC (permalink / raw)
  To: johnlinn; +Cc: linux-kernel

johnlinn@comcast.net writes:
>
> I'm sure it's obvious, but I don't see what I'm doing wrong.

The standard way is to define your own attribute structure that
has the standard attribute as the first entry and use container_of()
to get at the "parent" object.

(basically poor man's OO inheritance)

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-29 20:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29 18:53 using a single sysfs show function for multiple device attributes johnlinn
2011-06-29 20:00 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox