From: Greg KH <greg@kroah.com>
To: "Mike D. Day" <ncmike@us.ibm.com>
Cc: xen-devel@lists.xensource.com, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.12.6-xen] sysfs attributes for xen
Date: Fri, 27 Jan 2006 18:38:28 -0800 [thread overview]
Message-ID: <20060128023828.GA20881@kroah.com> (raw)
In-Reply-To: <43DAD4DB.4090708@us.ibm.com>
> linux-2.6-xen-sparse/arch/xen/kernel/xen_sysfs.c
> --- /dev/null Fri Jan 27 11:48:32 2006
> +++ b/linux-2.6-xen-sparse/arch/xen/kernel/xen_sysfs.c Fri Jan 27 14:28:42
> 2006
> @@ -0,0 +1,73 @@
> +/*
> + copyright (c) 2006 IBM Corporation
> + Mike Day <ncmike@us.ibm.com>
Wrong copyright notice as per the IBM lawyers :)
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
Are you sure about the version 2 or later?
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
These two paragraphs are not needed.
> +*/
> +
> +
> +
> +#include <linux/config.h>
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/kobject.h>
> +#include <linux/sysfs.h>
> +
> +#include <asm-xen/xen_sysfs.h>
> +
> +
> +static struct subsystem hypervisor_subsys = {
> + .kset = {
> + .kobj = {
> + .name = "hypervisor",
> + },
> + },
> +};
No, use the proper macros that define this for you.
> +
> +static struct kset xen_kset = {
> +
> + .kobj = {
> + .name = "xen",
> + },
> +};
Why are you createing a xen kset? You should not have to do this.
> +
> +struct subsystem *
> +get_hyper_subsys(void)
> +{
> + return &hypervisor_subsys;
> +}
What does this do? Just make the hypervisor subsystem structure global
like the rest of the kernel's subsystems are that need this.
> +
> +
> +struct kset *
> +get_xen_kset(void)
> +{
> + return &xen_kset;
> +}
Again, not needed.
> +
> +int __init
> +hyper_sysfs_init(void)
> +{
> + int err ;
> +
> + if( 0 == (err = subsystem_register(&hypervisor_subsys)) ) {
> + xen_kset.subsys = &hypervisor_subsys;
> + err = kset_register(&xen_kset);
> + }
Is this the xen coding style? If so, it's got to change before making
it into mainline... Please fix this up.
Also, don't use a xen kset. Make it a subsystem. Life is much easier
that way.
> +/* xen version info */
> +static ssize_t xen_version_show(struct kobject * kobj,
> + struct attribute * attr,
> + char *page)
Trailing spaces here, and in a lot of other places in your patch.
Please clean them up (there are automatic tools that do this for you...)
> +{
> + long version;
> + long major, minor;
> + char extra_version[16];
> +
> + if ( (version = HYPERVISOR_xen_version(XENVER_version, NULL)) ) {
Do not do assignments within if statments. It's generally considered bad
form. Also the spacing is wrong, but I know you will fix that up for
the rest of the patch too, so I'll just not mention it in every place.
> +
> + major = version >> 16;
> + minor = version & 0xff;
> + if( ! HYPERVISOR_xen_version(XENVER_extraversion,
> + extra_version) ) {
> + page[PAGE_SIZE - 1] = 0x00;
Not needed.
> + return snprintf(page, PAGE_SIZE - 1,
> + "xen-%ld.%ld%s\n",
> + major, minor, extra_version);
> + }
> + }
> + return 0;
Why not return an error number if this isn't successful?
> +}
> +
> +static struct xen_attr xen_ver_attr = {
> + .attr = {
> + .name = "version",
> + .mode = 0444,
> + .owner = THIS_MODULE,
> + },
> + .show = xen_version_show,
> +};
Please use the proper macros to create these, do NOT do it by hand.
> +
> +static struct kobject xen_ver_obj = {
> + .name = "version",
> +};
Wow, a static kobject. Hint, not a good thing to do for a dynamic
thing. This is not how you create a new attribute.
> +
> +/* xen compile info */
> +static ssize_t xen_compile_show(struct kobject * kobj,
> + struct attribute * attr,
> + char * page)
> +{
> + struct xen_compile_info info;
> +
> + if( 0 == HYPERVISOR_xen_version(XENVER_compile_info, &info) ) {
> + page[PAGE_SIZE - 1] = 0x00;
I'll not point this out again...
> + return snprintf(page, PAGE_SIZE - 1,
> + "compiled by %s, using %s, on %s\n",
> + info.compile_by,
> + info.compile_date,
> + info.compiler);
> + }
> + return 0;
Nor this...
> +static struct xen_attr xen_compile_attr = {
> + .attr = {
> + .name = "compilation",
> + .mode = 0444,
> + .owner = THIS_MODULE,
> + },
> + .show = xen_compile_show,
> +};
Nor this...
> +static struct kobject xen_compile_obj = {
> + .name = "compilation",
> +};
Or this...
> linux-2.6-xen-sparse/include/asm-xen/xen_sysfs.h
> --- /dev/null Fri Jan 27 11:48:32 2006
> +++ b/linux-2.6-xen-sparse/include/asm-xen/xen_sysfs.h Fri Jan 27 14:28:42
> 2006
> @@ -0,0 +1,45 @@
> +/*
> + copyright (c) 2006 IBM Corporation
> + Mike Day <ncmike@us.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +*/
> +
> +
> +
> +#ifndef _XEN_SYSFS_H_
> +#define _XEN_SYSFS_H_
> +
> +#ifdef __KERNEL__
Is this really needed? Would an userspace program ever need this?
> +
> +#include <linux/kobject.h>
> +#include <linux/sysfs.h>
> +#include <linux/module.h>
Not needed for this header file
> +#include <asm-xen/asm/hypercall.h>
> +#include <asm-xen/xen-public/version.h>
Nor these.
> +struct xen_attr {
> + struct attribute attr;
> + ssize_t (*show)(struct kobject *, struct attribute *, char *);
> + ssize_t (*store)(struct kobject *, struct attribute *, char *);
> +};
> +
> +extern int HYPERVISOR_xen_version(int, void*);
Shouldn't this be declared somewhere else?
> +extern struct subsystem * get_hyper_subsys(void);
> +extern struct kset * get_xen_kset(void);
Not needed at all.
Hm, is this file even needed?
thanks,
greg k-h
next prev parent reply other threads:[~2006-01-28 2:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-28 2:20 [PATCH 2.6.12.6-xen] sysfs attributes for xen Mike D. Day
2006-01-28 2:25 ` Greg KH
2006-01-28 2:38 ` Greg KH [this message]
2006-01-28 12:23 ` Vincent Hanquez
2006-01-28 3:03 ` [Xen-devel] " Anthony Liguori
2006-01-30 16:18 ` Dave Hansen
2006-01-30 16:58 ` [Xen-devel] " Mike D. Day
2006-01-30 17:04 ` Dave Hansen
2006-01-30 17:17 ` Mike D. Day
2006-01-30 17:26 ` Greg KH
2006-01-30 17:38 ` Dave Hansen
2006-01-30 17:53 ` Keir Fraser
2006-01-30 17:56 ` Dave Hansen
2006-01-30 19:33 ` Greg KH
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=20060128023828.GA20881@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ncmike@us.ibm.com \
--cc=xen-devel@lists.xensource.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