All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] New kobject/kset/ktype documentation and example code
Date: Wed, 28 Nov 2007 21:46:56 -0800	[thread overview]
Message-ID: <20071129054656.GA26327@kroah.com> (raw)
In-Reply-To: <2532.1196221814@lwn.net>

On Tue, Nov 27, 2007 at 08:50:14PM -0700, Jonathan Corbet wrote:
> Greg KH <greg@kroah.com> wrote:
> 
> > Jonathan, I used your old lwn.net article about kobjects as the basis
> > for this document, I hope you don't mind
> 
> Certainly I have no objections, I'm glad it was useful.

Thanks, it was a great framework to work with.

> > It is rare (even unknown) for kernel code to create a standalone kobject;
> > with one major exception explained below.
> 
> You don't keep this promise - bet you thought we wouldn't notice...
> Actually I guess you do, in the "creating simple kobjects" section.
> When you get to that point, you should mention that this is a situation
> where standalone kobjects make sense.

Sorry, yes, that is where I tried to explain it.  I'll flush it out some
more.

> Given that there are quite a few standalone kobjects created by this
> patch set (kernel_kobj, security_kobj, s390_kobj, etc.), the "(even
> unknown)" should probably come out.

Ok.

> > So, for example, UIO code has a structure that defines the memory region
> > associated with a uio device:
> 
> *The* UIO code, presumably.

fixed.

> > the given type. So, for example, a pointer to a struct kobject embedded
> > within a struct cdev called "kp" could be converted to a pointer to the
> > containing structure with:
> 
> That should be "struct uio_mem", I think.

fixed.

> > one.  Calling kobject_init() is not sufficient, however. Kobject users
> > must, at a minimum, set the name of the kobject; this is the name that will
> > be used in sysfs entries.
> 
> Is setting the name mandatory now, or are there still places where
> kobjects (which do not appear in sysfs) do have - and do not need - a
> name?

Any kobject that is registered needs to have a name.  If someone tries
to call kobject_register() or kobject_add() without a name set they will
find out that it is not allowed :)

And yes, there are a few places in the kernel with kobjects that are
never registered.  I'm working on trying to get rid of them...

> > Because kobjects are dynamic, they must not be declared statically or on
> > the stack, but instead, always from the heap.  Future versions of the
> 
> "always be allocated from the heap"?

thanks.

> > "empty" release function, you will be mocked merciously by the kobject
> > maintainer if you attempt this.
> 
> So just how should severely should we mock kobject maintainers who can't
> spell "mercilessly"?  :)

Heh, turns out that a lot of people sent me this privately :)

> >  - A kset can provide a set of default attributes that all kobjects that
> >    belong to it automatically inherit and have created whenever a kobject
> >    is registered belonging to the kset.
> 
> Can we try that one again?
> 
>  - A kset can provide a set of default attributes for all kobjects which
>    belong to it.

No, it's the ktype that does this, I'll go fix that up...

> > There is currently
> > no other way to add a kobject to a kset without directly messing with the
> > list pointers.
> 
> Presumably the latter way is not recommended; I would either say so or
> not mention this possibility at all.

Ah, yes, now removed.

Thanks for the review, I really appreciate it.

greg k-h

  reply	other threads:[~2007-11-29  5:53 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 23:02 [RFC] New kobject/kset/ktype documentation and example code Greg KH
2007-11-27 23:03 ` [RFC] sample kobject implementation Greg KH
2007-11-27 23:04 ` [RFC] Sample kset/ktype/kobject implementation Greg KH
2007-11-28 16:35   ` Cornelia Huck
2007-11-29  6:11     ` Greg KH
2007-11-29  9:39       ` Cornelia Huck
2007-11-29 20:39         ` Greg KH
2007-11-29 22:11           ` Alan Stern
2007-11-30  5:07             ` Dave Young
2007-11-30  5:57               ` Dave Young
2007-11-30 14:51               ` Alan Stern
2007-11-30  6:41             ` Greg KH
2007-11-27 23:10 ` [RFC] New kobject/kset/ktype documentation and example code Kyle McMartin
2007-11-27 23:29   ` Greg KH
2007-11-27 23:21 ` Frans Pop
2007-11-28  3:50 ` Jonathan Corbet
2007-11-29  5:46   ` Greg KH [this message]
2007-11-28  9:01 ` Cornelia Huck
2007-11-28 12:35   ` Kay Sievers
2007-11-28 15:52     ` Cornelia Huck
2007-11-28 16:03       ` Kay Sievers
2007-11-28 16:09         ` Cornelia Huck
2007-11-28 17:06           ` Greg KH
2007-11-28 19:18   ` Alan Stern
2007-11-29 10:12     ` Cornelia Huck
2007-11-29 15:47       ` Alan Stern
2007-11-29 16:28         ` Cornelia Huck
2007-11-29 16:55           ` Alan Stern
2007-11-29 17:52             ` Cornelia Huck
2007-11-29  5:59   ` Greg KH
2007-11-28 11:45 ` Cornelia Huck
2007-11-28 12:23   ` Kay Sievers
2007-11-28 15:48     ` Cornelia Huck
2007-11-28 15:57       ` Kay Sievers
2007-11-28 16:12         ` Cornelia Huck
2007-11-28 16:36           ` Kay Sievers
2007-11-28 16:51             ` Cornelia Huck
2007-11-28 17:00               ` Kay Sievers
2007-11-29  6:08                 ` Greg KH
2007-11-29  7:50                   ` Kay Sievers
2007-11-29  9:35                     ` Cornelia Huck
2007-11-29 10:53                       ` Kay Sievers
2007-11-29  6:02     ` Greg KH
2007-11-29  6:04   ` Greg KH
2007-11-29  9:41     ` Cornelia Huck
2007-11-28 19:03 ` Alan Stern
2007-11-28 19:28   ` Kay Sievers
2007-11-28 19:36     ` Alan Stern
2007-11-28 19:46       ` Kay Sievers
2007-11-28 20:42         ` [PATCH] kobject: make sure kobj->ktype is set before kobject_init Alan Stern
2007-11-28 20:52           ` Kay Sievers
2007-11-28 21:45           ` Greg KH
2007-11-28 22:00             ` Alan Stern
2007-11-28 22:38               ` Greg KH
2007-11-29 10:05               ` Cornelia Huck
2007-11-29 10:59                 ` Kay Sievers
2007-11-29 11:48                   ` Cornelia Huck
2007-11-29 15:54                   ` Alan Stern
2007-11-29 16:04                     ` Kay Sievers
2007-11-29 16:21                       ` Cornelia Huck
2007-11-29 21:53                         ` kobject_init rewrite Greg KH
2007-11-29 21:54                           ` Greg KH
2007-11-30  9:31                             ` Cornelia Huck
2007-11-29 22:16                           ` Alan Stern
2007-11-29 22:24                             ` Greg KH
2007-11-29 17:06                       ` [PATCH] kobject: make sure kobj->ktype is set before kobject_init Alan Stern
2007-11-29 17:17                         ` Kay Sievers
2007-11-29 18:04                           ` Alan Stern
2007-11-29 18:33                             ` Kay Sievers
2007-11-29 19:05                               ` Alan Stern
2007-11-29 19:51                                 ` Kay Sievers
2007-11-29 20:09                                   ` Alan Stern
2007-11-29 20:19                                     ` Kay Sievers
2007-11-29 20:26                                       ` Kay Sievers
2007-11-30  9:30                                         ` Cornelia Huck
2007-11-29  6:18   ` [RFC] New kobject/kset/ktype documentation and example code Greg KH
2007-11-29 15:42     ` Alan Stern

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=20071129054656.GA26327@kroah.com \
    --to=greg@kroah.com \
    --cc=corbet@lwn.net \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.