On Wed, 26 Jan 2022, Lucas De Marchi wrote:
> linux/string_helpers.h provides a helper to return "yes"/"no" strings.
> Replace the open coded versions with str_yes_no(). The places were
> identified with the following semantic patch:
>
> @@
> expression b;
> @@
>
> - b ? "yes" : "no"
> + str_yes_no(b)
>
> Then the includes were added, so we include-what-we-use, and parenthesis
> adjusted in drivers/gpu/drm/v3d/v3d_debugfs.c. After the conversion we
> still see the same binary sizes:
>
>textdata bss dec hex filename
> 511493295 212 54656d580 virtio/virtio-gpu.ko.old
> 511493295 212 54656d580 virtio/virtio-gpu.ko
> 1441491 60340 800 1502631 16eda7 radeon/radeon.ko.old
> 1441491 60340 800 1502631 16eda7 radeon/radeon.ko
> 6125369 328538 34000 6487907 62ff63 amd/amdgpu/amdgpu.ko.old
> 6125369 328538 34000 6487907 62ff63 amd/amdgpu/amdgpu.ko
> 411986 104906176 428652 68a6c drm.ko.old
> 411986 104906176 428652 68a6c drm.ko
> 981291636 264 100029 186bd dp/drm_dp_helper.ko.old
> 981291636 264 100029 186bd dp/drm_dp_helper.ko
> 1973432 1096402352 2085424 1fd230 nouveau/nouveau.ko.old
> 1973432 1096402352 2085424 1fd230 nouveau/nouveau.ko
>
> Signed-off-by: Lucas De Marchi
Reviewed-by: Jani Nikula
> ---
> drivers/gpu/drm/amd/amdgpu/atom.c | 4 +++-
> drivers/gpu/drm/dp/drm_dp.c | 3 ++-
> drivers/gpu/drm/drm_client_modeset.c | 3 ++-
> drivers/gpu/drm/drm_gem.c | 3 ++-
> drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c | 5 -
> drivers/gpu/drm/radeon/atom.c | 3 ++-
> drivers/gpu/drm/v3d/v3d_debugfs.c | 11 ++-
> drivers/gpu/drm/virtio/virtgpu_debugfs.c | 4 +++-
> 8 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 6fa2229b7229..1c5d9388ad0b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -25,6 +25,8 @@
> #include
> #include
> #include
> +#include
> +
> #include
>
> #include
> @@ -740,7 +742,7 @@ static void atom_op_jump(atom_exec_context *ctx, int
> *ptr, int arg)
> break;
> }
> if (arg != ATOM_COND_ALWAYS)
> - SDEBUG(" taken: %s\n", execute ? "yes" : "no");
> + SDEBUG(" taken: %s\n", str_yes_no(execute));
> SDEBUG(" target: 0x%04X\n", target);
> if (execute) {
> if (ctx->last_jump == (ctx->start + target)) {
> diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
> index 6d43325acca5..c43577c8ac4d 100644
> --- a/drivers/gpu/drm/dp/drm_dp.c
> +++ b/drivers/gpu/drm/dp/drm_dp.c
> @@ -28,6 +28,7 @@
> #include
> #include
> #include
> +#include
>
> #include
> #include
> @@ -1239,7 +1240,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
> bool branch_device = drm_dp_is_branch(dpcd);
>
> seq_printf(m, "\tDP branch device present: %s\n",
> -branch_device ? "yes" : "no");
> +str_yes_no(branch_device));
>
> if (!branch_device)
> return;
> diff --git a/drivers/gpu/drm/drm_client_modeset.c
> b/drivers/gpu/drm/drm_client_modeset.c
> index ced09c7c06f9..e6346a67cd98 100644
> --- a/drivers/gpu/drm/drm_client_modeset.c
> +++ b/drivers/gpu/drm/drm_client_modeset.c
> @@ -11,6 +11,7 @@
> #include
> #include
> #include
> +#include
>
> #include
> #include
> @@ -241,7 +242,7 @@ static void drm_client_connectors_enabled(struct
> drm_connector **connectors,
> connector = connectors[i];
> enabled[i] = drm_connector_enabled(connector, true);
> DRM_DEBUG_KMS("connector %d enabled? %s\n", connector->base.id,
> - connector->display_info.non_desktop ? "non
> desktop" : enabled[i] ? "yes" : "no");
> + connector->display_info.non_desktop ? "non
> desktop" : str_yes_no(enabled[i]));
>
> any_enabled |= enabled[i];
> }
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 21631c22b374..3c888db59ea4 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -37,6 +37,7 @@
> #include
> #include
> #include
> +#include
> #include
> #include
>
> @@ -1145,7 +1146,7 @@ void drm_gem_print_info(struct drm_printer *p, unsigned
> int indent,
> drm_vma_node_start(&obj->vma_node));
> drm_printf_indent(p, indent, "size=%zu\n", obj->size);
> drm_printf_indent(p, indent, "imported=%s\n",
> - obj->import_attach ? "yes" : "no");
> + str_yes_no(obj->import_attach));
>
> if (obj->funcs->print_info)
> obj->funcs->print_info(p, indent, obj);
> diff --git a/drivers/gpu/drm/no