Re: [PATCH] virt: coco: change tsm_class to a const struct
From: Jori Koolstra
Date: Wed Mar 04 2026 - 04:39:16 EST
Hi Thomas,
> Op 04-03-2026 08:12 CET schreef Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>:
>
> > @@ -114,18 +118,16 @@ static void tsm_release(struct device *dev)
> >
> > static int __init tsm_init(void)
> > {
> > - tsm_class = class_create("tsm");
> > - if (IS_ERR(tsm_class))
> > - return PTR_ERR(tsm_class);
> > + int err;
> >
> > - tsm_class->dev_release = tsm_release;
> > - return 0;
> > + err = class_register(&tsm_class);
> > + return err;
>
> 'err' looks to be unnecessary now.
>
> > }
This was what I had before. I thought that returning class_register() immediately,
even though it saves two lines, might be less readable. You either have to click
through to class_register() or know that these init functions return an error.
Is there convention for this?
thanks,
Jori.