From: Greg KH <greg@kroah.com>
To: Yanmin Zhang <ymzhang@unix-os.sc.intel.com>
Cc: linux-kernel@vger.kernel.org, discuss@x86-64.org,
linux-ia64@vger.kernel.org, yanmin.zhang@intel.com,
suresh.b.siddha@intel.com, rajesh.shah@intel.com,
venkatesh.pallipadi@intel.com
Subject: Re: [PATCH v2:3/3]Export cpu topology by sysfs
Date: Thu, 22 Dec 2005 16:16:43 -0800 [thread overview]
Message-ID: <20051223001643.GA3088@kroah.com> (raw)
In-Reply-To: <20051220180929.B19129@unix-os.sc.intel.com>
On Tue, Dec 20, 2005 at 06:09:29PM -0800, Yanmin Zhang wrote:
> --- linux-2.6.15-rc5/drivers/base/topology.c 1970-01-01 08:00:00.000000000 +0800
> +++ linux-2.6.15-rc5_topology/drivers/base/topology.c 2005-12-20 00:33:49.000000000 +0800
> @@ -0,0 +1,201 @@
> +/*
> + * driver/base/topology.c - Populate driverfs with cpu topology information
driverfs? Where did you cut/paste this code from?
And why does it have to be in driver/base?
> +struct _topology_attr {
> + struct attribute attr;
> + ssize_t (*show)(int cpu, char *);
> + ssize_t (*store)(const char *, size_t count);
> +};
Don't put a '_' at the beginning of a structure please.
> +static ssize_t topology_show(struct kobject * kobj, struct attribute * attr, char * buf)
> +{
> + unsigned int cpu;
> + struct _topology_attr *fattr = to_attr(attr);
> + ssize_t ret;
> +
> + cpu = container_of(kobj->parent, struct sys_device, kobj)->id;
> + ret = fattr->show ? fattr->show(cpu, buf): 0;
> + return ret;
> +}
Mix of spaces and tabs :(
> +static ssize_t topology_store(struct kobject * kobj, struct attribute * attr,
> + const char * buf, size_t count)
> +{
> + return 0;
> +}
Why is this function even needed?
> +static struct sysfs_ops topology_sysfs_ops = {
> + .show = topology_show,
> + .store = topology_store,
> +};
> +
> +static struct kobj_type topology_ktype = {
> + .sysfs_ops = &topology_sysfs_ops,
> + .default_attrs = topology_default_attrs,
> +};
> +
> +/* Add/Remove cpu_topology interface for CPU device */
> +static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
> +{
> + unsigned int cpu = sys_dev->id;
> +
> + memset(&cpu_topology_kobject[cpu], 0, sizeof(struct kobject));
> +
> + cpu_topology_kobject[cpu].parent = &sys_dev->kobj;
> + kobject_set_name(&cpu_topology_kobject[cpu], "%s", "topology");
> + cpu_topology_kobject[cpu].ktype = &topology_ktype;
> +
> + return kobject_register(&cpu_topology_kobject[cpu]);
> +}
Can't you just use an attribute group and attach it to the cpu kobject?
That would save an array of kobjects I think.
> +static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
> + unsigned long action, void *hcpu)
> +{
> + unsigned int cpu = (unsigned long)hcpu;
> + struct sys_device *sys_dev;
> +
> + sys_dev = get_cpu_sysdev(cpu);
> + switch (action) {
> + case CPU_ONLINE:
> + topology_add_dev(sys_dev);
> + break;
> +#ifdef CONFIG_HOTPLUG_CPU
> + case CPU_DEAD:
> + topology_remove_dev(sys_dev);
> + break;
> +#endif
Why ifdef? Isn't it safe to just always have this in?
thanks,
greg k-h
next prev parent reply other threads:[~2005-12-23 0:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-21 2:09 [PATCH v2:3/3]Export cpu topology by sysfs Yanmin Zhang
2005-12-23 0:16 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-12-23 4:03 Zhang, Yanmin
2005-12-23 19:16 ` Greg KH
2005-12-26 7:38 Zhang, Yanmin
2005-12-26 8:28 ` Yanmin Zhang
2005-12-27 5:36 ` Greg KH
2005-12-27 5:35 ` Greg KH
2005-12-27 10:22 Zhang, Yanmin
2005-12-27 10:41 ` Yanmin Zhang
2005-12-27 21:19 ` Nathan Lynch
2005-12-28 13:46 Zhang, Yanmin
2005-12-28 19:14 ` Nathan Lynch
2005-12-31 8:43 Zhang, Yanmin
2006-01-09 4:51 ` Nathan Lynch
2006-01-09 6:35 Zhang, Yanmin
2006-01-09 17:41 ` Russ Anderson
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=20051223001643.GA3088@kroah.com \
--to=greg@kroah.com \
--cc=discuss@x86-64.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rajesh.shah@intel.com \
--cc=suresh.b.siddha@intel.com \
--cc=venkatesh.pallipadi@intel.com \
--cc=yanmin.zhang@intel.com \
--cc=ymzhang@unix-os.sc.intel.com \
/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