public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Mansfield <patmans@us.ibm.com>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: SCSI Mailing List <linux-scsi@vger.kernel.org>, Greg KH <greg@kroah.com>
Subject: Re: [PATCH] correct attribute_container list usage
Date: Mon, 22 Aug 2005 17:39:38 -0700	[thread overview]
Message-ID: <20050823003938.GA29211@us.ibm.com> (raw)
In-Reply-To: <1124753185.5211.50.camel@mulgrave>

On Mon, Aug 22, 2005 at 06:26:25PM -0500, James Bottomley wrote:
> On Mon, 2005-08-22 at 17:47 -0500, James Bottomley wrote:
> > One apparent, but rather nasty, solution would be to embed object get
> > and put into the klist head as functions that take the node, so
> > klist_next would take the object reference as well as the list kref,
> > then drop it on klist_release.
> 
> Well, I'm not enormously fond of this, but it's not as downright nasty
> as I thought.  Patrick, could you try this (assuming you have a fast
> machine ... I'll be done with the complete kernel rebuild that touching
> klist.h requires eventually) you'll have to encode klist to device get
> and put functions and feed them to klist_init_embedded().

But, we have to pass in a struct kref, to affect put/get_device, correct?

While klist (and your patch) need klist_node. These pieces:

> +	void			(*get)(struct klist_node *);
> +	void			(*put)(struct klist_node *);

> +void klist_init_embedded(struct klist * k, void (*get)(struct klist_node *),
> +			 void (*put)(struct klist_node *))
>  {
>  	INIT_LIST_HEAD(&k->k_list);
>  	spin_lock_init(&k->k_lock);
> +	k->get = get;
> +	k->put = put;
>  }

In include/linux/device.h we have:

struct device {

	...
	struct kobject kobj;
	...
}

And get/put_device are:

struct kobject * kobject_get(struct kobject * kobj)
{
        if (kobj)
                kref_get(&kobj->kref);
        return kobj;
}

And then:

void kref_get(struct kref *kref)
{
        WARN_ON(!atomic_read(&kref->refcount));
        atomic_inc(&kref->refcount);
}

-- Patrick Mansfield

  reply	other threads:[~2005-08-23  0:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-22 15:06 [PATCH] correct attribute_container list usage James Bottomley
2005-08-22 21:46 ` Patrick Mansfield
2005-08-22 21:59   ` James Bottomley
2005-08-22 22:14     ` Patrick Mansfield
2005-08-22 22:21       ` Patrick Mansfield
2005-08-22 22:47       ` James Bottomley
2005-08-22 23:26         ` James Bottomley
2005-08-23  0:39           ` Patrick Mansfield [this message]
2005-08-23  2:03             ` James Bottomley
2005-08-23  3:17               ` Patrick Mansfield

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=20050823003938.GA29211@us.ibm.com \
    --to=patmans@us.ibm.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=greg@kroah.com \
    --cc=linux-scsi@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