Re: [PATCH RFC 12/20] ctlv: Add device and operation dispatch
From: Jason Gunthorpe
Date: Fri Oct 23 2026 - 10:31:24 EST
On Fri, Oct 23, 2026 at 02:58:33PM +0200, Jiri Pirko wrote:
> >> Jason did some nice handling in the fwctl stuff for
> >> device alloc and hand over after device_initialize()
> >> (I've copied it into a few places recently :)
> >>
> >> I'd like to see something similar here as it made
> >> it easier to follow lifetimes etc.
> >
> >This is really at the wrong layer.. Attestation subsystem is the lead
> >subsystem, it should be allocating the struct device memory and the
> >driver should see the typical
> >
> > struct attestation_dev *adev;
> >
> > adev = attestation_alloc()
> > [..]
> > attestation_register(adev)
>
> Er, the driver would call attestation_create() which will be a wrapper
> of ctvl_create. The reason is inheritance chain and each parent being
> passed info to and doing its own init()
We really want it to look like the above so we get proper container_of
stuff.
struct driver_attestion_dev {
struct attestaion_dev adev;
}
driver_adev = attestaion_alloc(..)
Don't want "create" to allocate the memory, it is upside down. The
fixed memory ctvl needs should be buried in the attestaion_Dev
struct attestation_dev {
struct device dev; // sysfs dev inside class attestation
struct ctlv_XX ctlv; // ctlv instance
struct cdev cdev;
const struct attestation_ops *ops;
}
That's the essential skeleton of what a subsystem should look like in
linux, ctvl shouldn't co-opt it, it should embed like cdev does.
Look at fwctl for reference
Jason