[Nouveau] [PATCH 42/44] drm/nouveau/nvenc/r535: initial support

Martin Roukala martin.peres at free.fr
Wed Oct 25 09:35:19 UTC 2023


On 10/24/23 12:51, Philipp Stanner wrote:
> On Tue, 2023-09-19 at 06:21 +1000, Ben Skeggs wrote:
>> From: Ben Skeggs <bskeggs at redhat.com>
>>
>> Adds support for allocating VIDEO_ENCODER classes from RM.
>>
>> Signed-off-by: Ben Skeggs <bskeggs at redhat.com>

[...]

>> +static void *
>> +r535_nvenc_dtor(struct nvkm_engine *engine)
>> +{
>> +       struct nvkm_nvenc *nvenc = nvkm_nvenc(engine);
>> +
>> +       kfree(nvenc->engine.func);
>> +       return nvenc;
>> +}
> 
> Why is nvenc returned as void * when it's clearly always of type
> struct nvkm_nvenc * ?
> 
> If it's sometimes necessary to convert it to a void-pointer I think it
> would be better to do that by assigning to a void-pointer at the place
> where r535_nvenc_dtor() is actually called. This void-pointer's
> subsequent usage then would make it obvious why it's void *
> 
> Is it necessary to return it in an opaque form? If so, that should be
> commented.

This is part of Nouveau's conventions for object-oriented programming. 
This would be part of the so-called "core". It's been a while since I 
worked with it, but the reason why it is a `void *` is because it makes 
other functions easier to write.

I hope this helps!

Cheers,
Martin

PS: I am not checking out Nouveau's mailing list often, so if anyone has 
some questions related to the kernel driver, feel free to ping me 
(mupuf) on #nouveau and I will try my best to provide some context or a 
pointer to someone else could be a good person to answer :)


More information about the Nouveau mailing list