Re: [PATCH] correct attribute_container list usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-
: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux