From: "stephane eranian" <eranian@googlemail.com>
To: "Greg KH" <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch 12/21] perfmon2 minimal: sysfs interface
Date: Sat, 14 Jun 2008 00:31:43 +0200 [thread overview]
Message-ID: <7c86c4470806131531n4b24bc4dmc22d4b2277e75f24@mail.gmail.com> (raw)
In-Reply-To: <20080613035339.GE17872@kroah.com>
Greg,
On Fri, Jun 13, 2008 at 5:53 AM, Greg KH <greg@kroah.com> wrote:
> On Thu, Jun 12, 2008 at 02:54:15PM +0200, stephane eranian wrote:
>>
>> In any case, let me know if there are still things that must be
>> changed/simplified in my file.
>
> This looks much better. I wonder if you could use the "default" kobject
> attributes, which might allow you to remove some of your show/store
> wrappers, but in general, it's much better than before.
>
Well, I wondered about that myself, but I think I am missing one piece.
The difference between some of the show/store functions and others
is that if you look closely, you see that some make reference to global
structures, e.g., pfm_controls, or call out to routines in others modules.
For those, I have switched to the default attribute. But the other show/store
functions need to access the particular object where the kobj is embedded.
And for that, it seems you need to glue function:
#define to_pmu(n) container_of(n, struct pfm_pmu_config, kobj)
static ssize_t pfm_pmu_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct pfm_pmu_config *pmu = to_pmu(kobj);
struct pfm_attribute *attribute = to_attr(attr);
return attribute->show ? attribute->show(pmu, attribute, buf) : -EIO;
}
which basically calls the container_of() routine..
Yet, I get the feeling that is the show routein gets the same kobj,
then I could as well do the
to_pmu() there. And the attr (use the the strcmp()) would be the default.
If you tell me this is the way to go, I will certainly be happy to
make the change and remove even
more code!
Thanks.
next prev parent reply other threads:[~2008-06-13 22:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-09 22:34 eranian
2008-06-11 14:49 ` Greg KH
2008-06-11 15:00 ` stephane eranian
2008-06-12 12:54 ` stephane eranian
2008-06-13 3:50 ` Greg KH
2008-06-13 3:53 ` Greg KH
2008-06-13 22:31 ` stephane eranian [this message]
2008-06-17 8:52 ` stephane eranian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c86c4470806131531n4b24bc4dmc22d4b2277e75f24@mail.gmail.com \
--to=eranian@googlemail.com \
--cc=eranian@gmail.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®