RE: [PATCH] kobject: introduce kobject_del_and_put()

From: David Laight
Date: Sun Mar 19 2023 - 18:28:29 EST


From: Yangtao Li <frank.li@xxxxxxxx>
> Sent: 18 March 2023 20:17
>
> There are plenty of using kobject_del() and kobject_put() together
> in the kernel tree. This patch wraps these two calls in a single helper.

But why?
You are adding an extra function call for no benefit.
At best, perhaps, a static inline function.

David

...
> +void kobject_del_and_put(struct kobject *kobj)
> +{
> + kobject_del(kobj);
> + kobject_put(kobj);
> +}
> +EXPORT_SYMBOL_GPL(kobject_del_and_put);
> +
> static void dynamic_kobj_release(struct kobject *kobj)
> {
> pr_debug("kobject: (%p): %s\n", kobj, __func__);
> @@ -874,8 +888,7 @@ void kset_unregister(struct kset *k)
> {
> if (!k)
> return;
> - kobject_del(&k->kobj);
> - kobject_put(&k->kobj);
> + kobject_del_and_put(&k->kobj);
> }
> EXPORT_SYMBOL(kset_unregister);
>
> --
> 2.35.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)