[PATCH v2 1/2] drm/ttm: Change ttm_device_init to use a struct instead of multiple bools

Jani Nikula jani.nikula at linux.intel.com
Wed Oct 2 12:56:44 UTC 2024


On Wed, 02 Oct 2024, Thomas Hellström <thomas.hellstrom at linux.intel.com> wrote:
> The ttm_device_init funcition uses multiple bool arguments. That means
> readability in the caller becomes poor, and all callers need to change if
> yet another bool is added.
>
> Instead use a struct with multiple single-bit flags. This addresses both
> problems. Prefer it over using defines or enums with explicit bit shifts,
> since converting to and from these bit values uses logical operations or
> tests which are implicit with the struct usage, and ofc type-checking.
>
> This is in preparation of adding yet another bool flag parameter to the
> function.

Funny, the other day Ville and I were throwing ideas around, and we
talked about something like this to implement keyword arguments in C. :)

Cheers,
Jani.


-- 
Jani Nikula, Intel


More information about the Intel-gfx mailing list