linuxkpi: move kobject_create to .c file

kobject_create knows the size of struct kobject. Move it to
linux_compat.c so this knowledge is confined to the loadable module and
not the clients.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34767
This commit is contained in:
Warner Losh 2022-04-04 23:05:26 -06:00
parent 6e671ec1e6
commit 36929b5584
2 changed files with 15 additions and 13 deletions

View File

@ -107,23 +107,11 @@ kobject_get(struct kobject *kobj)
return kobj;
}
struct kobject *kobject_create(void);
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list);
int kobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...);
static inline struct kobject *
kobject_create(void)
{
struct kobject *kobj;
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
if (kobj == NULL)
return (NULL);
kobject_init(kobj, &linux_kfree_type);
return (kobj);
}
static inline struct kobject *
kobject_create_and_add(const char *name, struct kobject *parent)
{

View File

@ -156,6 +156,20 @@ RB_GENERATE(linux_root, rb_node, __entry, panic_cmp);
INTERVAL_TREE_DEFINE(struct interval_tree_node, rb, unsigned long,, START,
LAST,, lkpi_interval_tree)
struct kobject *
kobject_create(void)
{
struct kobject *kobj;
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
if (kobj == NULL)
return (NULL);
kobject_init(kobj, &linux_kfree_type);
return (kobj);
}
int
kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
{