linuxkpi: Move class_create to .c file

class_create encodes the size of struct class into the generated
code. Move from .h file to .c file to move this knowledge from the
client modules that call this into the linuxkpi module.

Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34769
This commit is contained in:
Warner Losh 2022-04-04 23:05:43 -06:00
parent 702b687503
commit 1341ac9f9c
2 changed files with 21 additions and 19 deletions

View file

@ -289,6 +289,8 @@ put_device(struct device *dev)
kobject_put(&dev->kobj);
}
struct class *class_create(struct module *owner, const char *name);
static inline int
class_register(struct class *class)
{
@ -525,25 +527,6 @@ linux_class_kfree(struct class *class)
kfree(class);
}
static inline struct class *
class_create(struct module *owner, const char *name)
{
struct class *class;
int error;
class = kzalloc(sizeof(*class), M_WAITOK);
class->owner = owner;
class->name = name;
class->class_release = linux_class_kfree;
error = class_register(class);
if (error) {
kfree(class);
return (NULL);
}
return (class);
}
static inline void
class_destroy(struct class *class)
{

View file

@ -496,6 +496,25 @@ error:
return ERR_PTR(retval);
}
struct class *
class_create(struct module *owner, const char *name)
{
struct class *class;
int error;
class = kzalloc(sizeof(*class), M_WAITOK);
class->owner = owner;
class->name = name;
class->class_release = linux_class_kfree;
error = class_register(class);
if (error) {
kfree(class);
return (NULL);
}
return (class);
}
int
kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype,
struct kobject *parent, const char *fmt, ...)