Re: [PATCH] kref: add function for reading kref value

From: Belisko Marek
Date: Mon Dec 12 2011 - 07:51:25 EST


On Mon, Dec 12, 2011 at 1:44 PM, Daniel Baluta <dbaluta@xxxxxxxxxxx> wrote:
> We can easily get kref refcount value by accesing
> kref->refcount but it is better to have a function
> for this.
>
> Signed-off-by: Daniel Baluta <dbaluta@xxxxxxxxxxx>
> ---
> Âinclude/linux/kref.h | Â Â1 +
> Âlib/kref.c      |  Â9 +++++++++
> Â2 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/kref.h b/include/linux/kref.h
> index d4a62ab..cd1b04a 100644
> --- a/include/linux/kref.h
> +++ b/include/linux/kref.h
> @@ -22,6 +22,7 @@ struct kref {
> Â};
>
> Âvoid kref_init(struct kref *kref);
> +atomic_t kref_read(struct kref *kref);
> Âvoid kref_get(struct kref *kref);
> Âint kref_put(struct kref *kref, void (*release) (struct kref *kref));
> Âint kref_sub(struct kref *kref, unsigned int count,
> diff --git a/lib/kref.c b/lib/kref.c
> index 3efb882..48aaf2a 100644
> --- a/lib/kref.c
> +++ b/lib/kref.c
> @@ -25,6 +25,15 @@ void kref_init(struct kref *kref)
> Â Â Â Âsmp_mb();
> Â}
>
> +/**
> + * kref_read - read refcount for object
> + * @kref: object.
> + */
> +void kref_read(struct kref *kref)
> +{
> + Â Â Â return atomic_read(&kref->refcount);
> +}
Return void? Shouldn't be: atomic_t. Did you compile your code before
submission???
> +
> Â/**
> Â* kref_get - increment refcount for object.
> Â* @kref: object.
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/