Re: [PATCH 1/2] kobject: Add kobject_initialized() function
On Tue, Oct 28, 2014 at 04:26:47PM +0100, Tomeu Vizoso wrote: > To be used by users of kobject to tell when one hasn't been initialized yet. > > Signed-off-by: Tomeu Vizoso > --- > include/linux/kobject.h | 5 + > 1 file changed, 5 insertions(+) > > diff --git a/include/linux/kobject.h b/include/linux/kobject.h > index 2d61b90..6bb5a92 100644 > --- a/include/linux/kobject.h > +++ b/include/linux/kobject.h > @@ -88,6 +88,11 @@ static inline const char *kobject_name(const struct > kobject *kobj) > return kobj->name; > } > > +static inline bool kobject_initialized(const struct kobject *kobj) > +{ > + return kobj->state_initialized; > +} Ick, no. Why would you ever need this? You "own" the kobject, and you better know if you initialized it or not. If not, you should fix your use of a kobject. And why are you even using a kobject at all? greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] kobject: Add kobject_initialized() function
To be used by users of kobject to tell when one hasn't been initialized yet. Signed-off-by: Tomeu Vizoso --- include/linux/kobject.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 2d61b90..6bb5a92 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -88,6 +88,11 @@ static inline const char *kobject_name(const struct kobject *kobj) return kobj->name; } +static inline bool kobject_initialized(const struct kobject *kobj) +{ + return kobj->state_initialized; +} + extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); extern __printf(3, 4) __must_check int kobject_add(struct kobject *kobj, struct kobject *parent, -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] kobject: Add kobject_initialized() function
To be used by users of kobject to tell when one hasn't been initialized yet. Signed-off-by: Tomeu Vizoso tomeu.viz...@collabora.com --- include/linux/kobject.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 2d61b90..6bb5a92 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -88,6 +88,11 @@ static inline const char *kobject_name(const struct kobject *kobj) return kobj-name; } +static inline bool kobject_initialized(const struct kobject *kobj) +{ + return kobj-state_initialized; +} + extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); extern __printf(3, 4) __must_check int kobject_add(struct kobject *kobj, struct kobject *parent, -- 1.9.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/2] kobject: Add kobject_initialized() function
On Tue, Oct 28, 2014 at 04:26:47PM +0100, Tomeu Vizoso wrote: To be used by users of kobject to tell when one hasn't been initialized yet. Signed-off-by: Tomeu Vizoso tomeu.viz...@collabora.com --- include/linux/kobject.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 2d61b90..6bb5a92 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -88,6 +88,11 @@ static inline const char *kobject_name(const struct kobject *kobj) return kobj-name; } +static inline bool kobject_initialized(const struct kobject *kobj) +{ + return kobj-state_initialized; +} Ick, no. Why would you ever need this? You own the kobject, and you better know if you initialized it or not. If not, you should fix your use of a kobject. And why are you even using a kobject at all? greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/