Re: [v1 2/3] include: move lookup_or_create_module_kobject()/to_module* to module.h
From: Christoph Hellwig
Date: Tue Feb 04 2025 - 00:27:59 EST
> +static inline struct module_kobject * __init lookup_or_create_module_kobject(const char *name)
Crazily unreadable line.
Either way this is not a function that should be inline in a header.
Both due to sheer size, but also due to what it does and what it pulls
in.
> +{
> + struct module_kobject *mk;
> + struct kobject *kobj;
> + int err;
> +
> + kobj = kset_find_obj(module_kset, name);
> + if (kobj) {
> + mk = to_module_kobject(kobj);
> + } else {
And I know this is just moving the code, but an ealy return here
would significanty clean up the function..
> + mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
> + BUG_ON(!mk);
.. and a BUG_ON on allocation failure is a no-go.