Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Convert open-coded yes/no strings to yesno()

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:

text data bss dec hex filename
51149 3295 212 54656 d580 virtio/virtio-gpu.ko.old
51149 3295 212 54656 d580 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 10490 6176 428652 68a6c drm.ko.old
411986 10490 6176 428652 68a6c drm.ko
98129 1636 264 100029 186bd dp/drm_dp_helper.ko.old
98129 1636 264 100029 186bd dp/drm_dp_helper.ko
1973432 109640 2352 2085424 1fd230 nouveau/nouveau.ko.old
1973432 109640 2352 2085424 1fd230 nouveau/nouveau.ko

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220126093951.1470898-10-lucas.demarchi@intel.com

+24 -12
+3 -1
drivers/gpu/drm/amd/amdgpu/atom.c
··· 25 25 #include <linux/module.h> 26 26 #include <linux/sched.h> 27 27 #include <linux/slab.h> 28 + #include <linux/string_helpers.h> 29 + 28 30 #include <asm/unaligned.h> 29 31 30 32 #include <drm/drm_util.h> ··· 742 740 break; 743 741 } 744 742 if (arg != ATOM_COND_ALWAYS) 745 - SDEBUG(" taken: %s\n", execute ? "yes" : "no"); 743 + SDEBUG(" taken: %s\n", str_yes_no(execute)); 746 744 SDEBUG(" target: 0x%04X\n", target); 747 745 if (execute) { 748 746 if (ctx->last_jump == (ctx->start + target)) {
+2 -1
drivers/gpu/drm/dp/drm_dp.c
··· 28 28 #include <linux/module.h> 29 29 #include <linux/sched.h> 30 30 #include <linux/seq_file.h> 31 + #include <linux/string_helpers.h> 31 32 32 33 #include <drm/dp/drm_dp_helper.h> 33 34 #include <drm/drm_print.h> ··· 1240 1239 bool branch_device = drm_dp_is_branch(dpcd); 1241 1240 1242 1241 seq_printf(m, "\tDP branch device present: %s\n", 1243 - branch_device ? "yes" : "no"); 1242 + str_yes_no(branch_device)); 1244 1243 1245 1244 if (!branch_device) 1246 1245 return;
+2 -1
drivers/gpu/drm/drm_client_modeset.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/mutex.h> 13 13 #include <linux/slab.h> 14 + #include <linux/string_helpers.h> 14 15 15 16 #include <drm/drm_atomic.h> 16 17 #include <drm/drm_client.h> ··· 242 241 connector = connectors[i]; 243 242 enabled[i] = drm_connector_enabled(connector, true); 244 243 DRM_DEBUG_KMS("connector %d enabled? %s\n", connector->base.id, 245 - connector->display_info.non_desktop ? "non desktop" : enabled[i] ? "yes" : "no"); 244 + connector->display_info.non_desktop ? "non desktop" : str_yes_no(enabled[i])); 246 245 247 246 any_enabled |= enabled[i]; 248 247 }
+2 -1
drivers/gpu/drm/drm_gem.c
··· 37 37 #include <linux/pagevec.h> 38 38 #include <linux/shmem_fs.h> 39 39 #include <linux/slab.h> 40 + #include <linux/string_helpers.h> 40 41 #include <linux/types.h> 41 42 #include <linux/uaccess.h> 42 43 ··· 1146 1145 drm_vma_node_start(&obj->vma_node)); 1147 1146 drm_printf_indent(p, indent, "size=%zu\n", obj->size); 1148 1147 drm_printf_indent(p, indent, "imported=%s\n", 1149 - obj->import_attach ? "yes" : "no"); 1148 + str_yes_no(obj->import_attach)); 1150 1149 1151 1150 if (obj->funcs->print_info) 1152 1151 obj->funcs->print_info(p, indent, obj);
+4 -1
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
··· 21 21 * 22 22 * Authors: Ben Skeggs 23 23 */ 24 + 25 + #include <linux/string_helpers.h> 26 + 24 27 #include "aux.h" 25 28 #include "pad.h" 26 29 ··· 97 94 nvkm_i2c_aux_monitor(struct nvkm_i2c_aux *aux, bool monitor) 98 95 { 99 96 struct nvkm_i2c_pad *pad = aux->pad; 100 - AUX_TRACE(aux, "monitor: %s", monitor ? "yes" : "no"); 97 + AUX_TRACE(aux, "monitor: %s", str_yes_no(monitor)); 101 98 if (monitor) 102 99 nvkm_i2c_pad_mode(pad, NVKM_I2C_PAD_AUX); 103 100 else
+2 -1
drivers/gpu/drm/radeon/atom.c
··· 25 25 #include <linux/module.h> 26 26 #include <linux/sched.h> 27 27 #include <linux/slab.h> 28 + #include <linux/string_helpers.h> 28 29 29 30 #include <asm/unaligned.h> 30 31 ··· 723 722 break; 724 723 } 725 724 if (arg != ATOM_COND_ALWAYS) 726 - SDEBUG(" taken: %s\n", execute ? "yes" : "no"); 725 + SDEBUG(" taken: %s\n", str_yes_no(execute)); 727 726 SDEBUG(" target: 0x%04X\n", target); 728 727 if (execute) { 729 728 if (ctx->last_jump == (ctx->start + target)) {
+6 -5
drivers/gpu/drm/v3d/v3d_debugfs.c
··· 6 6 #include <linux/debugfs.h> 7 7 #include <linux/pm_runtime.h> 8 8 #include <linux/seq_file.h> 9 + #include <linux/string_helpers.h> 9 10 10 11 #include <drm/drm_debugfs.h> 11 12 ··· 149 148 V3D_GET_FIELD(ident3, V3D_HUB_IDENT3_IPREV), 150 149 V3D_GET_FIELD(ident3, V3D_HUB_IDENT3_IPIDX)); 151 150 seq_printf(m, "MMU: %s\n", 152 - (ident2 & V3D_HUB_IDENT2_WITH_MMU) ? "yes" : "no"); 151 + str_yes_no(ident2 & V3D_HUB_IDENT2_WITH_MMU)); 153 152 seq_printf(m, "TFU: %s\n", 154 - (ident1 & V3D_HUB_IDENT1_WITH_TFU) ? "yes" : "no"); 153 + str_yes_no(ident1 & V3D_HUB_IDENT1_WITH_TFU)); 155 154 seq_printf(m, "TSY: %s\n", 156 - (ident1 & V3D_HUB_IDENT1_WITH_TSY) ? "yes" : "no"); 155 + str_yes_no(ident1 & V3D_HUB_IDENT1_WITH_TSY)); 157 156 seq_printf(m, "MSO: %s\n", 158 - (ident1 & V3D_HUB_IDENT1_WITH_MSO) ? "yes" : "no"); 157 + str_yes_no(ident1 & V3D_HUB_IDENT1_WITH_MSO)); 159 158 seq_printf(m, "L3C: %s (%dkb)\n", 160 - (ident1 & V3D_HUB_IDENT1_WITH_L3C) ? "yes" : "no", 159 + str_yes_no(ident1 & V3D_HUB_IDENT1_WITH_L3C), 161 160 V3D_GET_FIELD(ident2, V3D_HUB_IDENT2_L3C_NKB)); 162 161 163 162 for (core = 0; core < cores; core++) {
+3 -1
drivers/gpu/drm/virtio/virtgpu_debugfs.c
··· 23 23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 24 */ 25 25 26 + #include <linux/string_helpers.h> 27 + 26 28 #include <drm/drm_debugfs.h> 27 29 #include <drm/drm_file.h> 28 30 ··· 33 31 static void virtio_gpu_add_bool(struct seq_file *m, const char *name, 34 32 bool value) 35 33 { 36 - seq_printf(m, "%-16s : %s\n", name, value ? "yes" : "no"); 34 + seq_printf(m, "%-16s : %s\n", name, str_yes_no(value)); 37 35 } 38 36 39 37 static void virtio_gpu_add_int(struct seq_file *m, const char *name, int value)