drm/imagination: loop counters moved to loop scope
Subsystems (3)
PATCH v2 1/1 drm/imagination: loop counters moved to loop scope
Reduce the scope of some loop counters as these aren't needed outside the loops they're used in.
---
Changes in v2:
- Remove a loop counter variable definition
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/gpu/drm/imagination/pvr_debugfs.c | 3 +-- drivers/gpu/drm/imagination/pvr_free_list.c | 3 +-- drivers/gpu/drm/imagination/pvr_fw.c | 12 ++++-------- drivers/gpu/drm/imagination/pvr_fw_meta.c | 3 +-- drivers/gpu/drm/imagination/pvr_fw_mips.c | 6 ++---- drivers/gpu/drm/imagination/pvr_fw_trace.c | 23 ++++++++--------------- drivers/gpu/drm/imagination/pvr_gem.c | 4 +--- drivers/gpu/drm/imagination/pvr_hwrt.c | 12 ++++-------- drivers/gpu/drm/imagination/pvr_stream.c | 12 ++++-------- drivers/gpu/drm/imagination/pvr_vm_mips.c | 3 +-- 10 files changed, 27 insertions(+), 54 deletions(-)
drivers/gpu/drm/imagination/pvr_debugfs.c +1 -2
@@ -28,9 +28,8 @@ pvr_debugfs_init(struct drm_minor *minor)struct drm_device *drm_dev = minor->dev;struct pvr_device *pvr_dev =to_pvr_device (drm_dev);struct dentry *root = minor->debugfs_root; -size_t i; -for (i =0 ; i <ARRAY_SIZE (pvr_debugfs_entries); ++i) { +for (size_t i =0 ; i <ARRAY_SIZE (pvr_debugfs_entries); ++i) {const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i];struct dentry *dir;
drivers/gpu/drm/imagination/pvr_free_list.c +1 -2
@@ -237,11 +237,10 @@ pvr_free_list_insert_pages_locked(struct pvr_free_list *free_list,dma_addr_t dma_addr =sg_page_iter_dma_address (&dma_iter);u64 dma_pfn = dma_addr >>ROGUE_BIF_PM_PHYSICAL_PAGE_ALIGNSHIFT ; -u32 dma_addr_offset;BUILD_BUG_ON (ROGUE_BIF_PM_PHYSICAL_PAGE_SIZE >PAGE_SIZE ); -for (dma_addr_offset =0 ; dma_addr_offset <PAGE_SIZE ; +for (u32 dma_addr_offset =0 ; dma_addr_offset <PAGE_SIZE ; dma_addr_offset +=ROGUE_BIF_PM_PHYSICAL_PAGE_SIZE ) {WARN_ON_ONCE (dma_pfn >>32 );
drivers/gpu/drm/imagination/pvr_fw.c +4 -8
@@ -50,9 +50,8 @@ pvr_fw_find_layout_entry(struct pvr_device *pvr_dev, enum pvr_fw_section_id id) {const struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num; -u32 entry; -for (entry =0 ; entry < num_layout_entries; entry++) { +for (u32 entry =0 ; entry < num_layout_entries; entry++) {if (layout_entries[entry].id == id)return &layout_entries[entry]; }
@@ -65,9 +64,8 @@ pvr_fw_find_private_data(struct pvr_device *pvr_dev) {const struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num; -u32 entry; -for (entry =0 ; entry < num_layout_entries; entry++) { +for (u32 entry =0 ; entry < num_layout_entries; entry++) {if (layout_entries[entry].id ==META_PRIVATE_DATA || layout_entries[entry].id ==MIPS_PRIVATE_DATA || layout_entries[entry].id ==RISCV_PRIVATE_DATA )
@@ -97,7 +95,6 @@ pvr_fw_validate(struct pvr_device *pvr_dev)const u8 *fw = firmware->data;u32 fw_offset = firmware->size -SZ_4K ;u32 layout_table_size; -u32 entry;if (firmware->size <SZ_4K || (firmware->size %FW_BLOCK_SIZE ))return -EINVAL ;
@@ -144,7 +141,7 @@ pvr_fw_validate(struct pvr_device *pvr_dev)return -EINVAL ; layout_entries = (const struct pvr_fw_layout_entry *)&fw[fw_offset]; -for (entry =0 ; entry < header->layout_entry_num; entry++) { +for (u32 entry =0 ; entry < header->layout_entry_num; entry++) {u32 start_addr = layout_entries[entry].base_addr;u32 end_addr = start_addr + layout_entries[entry].alloc_size;
@@ -233,13 +230,12 @@ pvr_fw_find_mmu_segment(struct pvr_device *pvr_dev, u32 addr, u32 size, void *fwconst struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num;u32 end_addr = addr + size; -int entry =0 ;/* Ensure requested range is not zero, and size is not causing addr to overflow. */ if (end_addr <= addr)return -EINVAL ; -for (entry =0 ; entry < num_layout_entries; entry++) { +for (int entry =0 ; entry < num_layout_entries; entry++) {u32 entry_start_addr = layout_entries[entry].base_addr;u32 entry_end_addr = entry_start_addr + layout_entries[entry].alloc_size;
drivers/gpu/drm/imagination/pvr_fw_meta.c +1 -2
@@ -370,13 +370,12 @@ configure_seg_mmu(struct pvr_device *pvr_dev, u32 **boot_conf_ptr)const struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num;u64 seg_out_addr_top; -u32 i; seg_out_addr_top =ROGUE_FW_SEGMMU_OUTADDR_TOP_SLC (MMU_CONTEXT_MAPPING_FWPRIV ,ROGUE_FW_SEGMMU_META_BIFDM_ID ); -for (i =0 ; i < num_layout_entries; i++) { +for (u32 i =0 ; i < num_layout_entries; i++) {/* * FW code is using the bootloader segment which is already * configured on boot. FW coremem code and data don't use the
drivers/gpu/drm/imagination/pvr_fw_mips.c +2 -4
@@ -37,10 +37,9 @@ process_elf_command_stream(struct pvr_device *pvr_dev, const u8 *fw, u8 *fw_codestruct elf32_hdr *header = (struct elf32_hdr *)fw;struct elf32_phdr *program_header = (struct elf32_phdr *)(fw + header->e_phoff);struct drm_device *drm_dev =from_pvr_device (pvr_dev); -u32 entry;int err; -for (entry =0 ; entry < header->e_phnum; entry++, program_header++) { +for (u32 entry =0 ; entry < header->e_phnum; entry++, program_header++) {void *write_addr;/* Only consider loadable entries in the ELF segment table */
@@ -97,7 +96,6 @@ pvr_mips_fw_process(struct pvr_device *pvr_dev, const u8 *fw,const struct pvr_fw_layout_entry *stack_entry;struct rogue_mipsfw_boot_data *boot_data;dma_addr_t dma_addr; -u32 page_nr;int err; err = process_elf_command_stream(pvr_dev, fw, fw_code_ptr, fw_data_ptr, fw_core_code_ptr,
@@ -132,7 +130,7 @@ pvr_mips_fw_process(struct pvr_device *pvr_dev, const u8 *fw, boot_data->reg_base = pvr_dev->regs_resource->start; -for (page_nr =0 ; page_nr <ARRAY_SIZE (boot_data->pt_phys_addr); page_nr++) { +for (u32 page_nr =0 ; page_nr <ARRAY_SIZE (boot_data->pt_phys_addr); page_nr++) {/* Firmware expects 4k pages, but host page size might be different. */ u32 src_page_nr = (page_nr *ROGUE_MIPSFW_PAGE_SIZE_4K ) >>PAGE_SHIFT ;u32 page_offset = (page_nr *ROGUE_MIPSFW_PAGE_SIZE_4K ) & ~PAGE_MASK ;
drivers/gpu/drm/imagination/pvr_fw_trace.c +8 -15
@@ -21,7 +21,6 @@ tracebuf_ctrl_init(void *cpu_ptr, void *priv) {struct rogue_fwif_tracebuf *tracebuf_ctrl = cpu_ptr;struct pvr_fw_trace *fw_trace = priv; -u32 thread_nr; tracebuf_ctrl->tracebuf_size_in_dwords =ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS ; tracebuf_ctrl->tracebuf_flags =0 ;
@@ -31,7 +30,7 @@ tracebuf_ctrl_init(void *cpu_ptr, void *priv)else tracebuf_ctrl->log_type =ROGUE_FWIF_LOG_TYPE_NONE ; -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct rogue_fwif_tracebuf_space *tracebuf_space = &tracebuf_ctrl->tracebuf[thread_nr];struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];
@@ -48,10 +47,9 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev) {struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace;struct drm_device *drm_dev =from_pvr_device (pvr_dev); -u32 thread_nr;int err; -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; trace_buffer->buf =
@@ -88,7 +86,7 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev)BUILD_BUG_ON (ARRAY_SIZE (fw_trace->tracebuf_ctrl->tracebuf) !=ARRAY_SIZE (fw_trace->buffers)); -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct rogue_fwif_tracebuf_space *tracebuf_space = &fw_trace->tracebuf_ctrl->tracebuf[thread_nr];struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];
@@ -99,7 +97,7 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev)return 0 ; err_free_buf: -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];if (trace_buffer->buf)
@@ -112,9 +110,8 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev)void pvr_fw_trace_fini (struct pvr_device *pvr_dev) {struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; -u32 thread_nr; -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];pvr_fw_object_unmap_and_destroy (trace_buffer->buf_obj);
@@ -184,9 +181,7 @@ struct pvr_fw_trace_seq_data {static u32 find_sfid (u32 id) { -u32 i; - -for (i =0 ; i <ARRAY_SIZE (stid_fmts); i++) { +for (u32 i =0 ; i <ARRAY_SIZE (stid_fmts); i++) {if (stid_fmts[i].id == id)return i; }
@@ -285,12 +280,11 @@ static void fw_trace_get_first(struct pvr_fw_trace_seq_data *trace_seq_data)static void *fw_trace_seq_start (struct seq_file *s,loff_t *pos) {struct pvr_fw_trace_seq_data *trace_seq_data = s->private; -u32 i;/* Reset trace index, then advance to *pos. */ fw_trace_get_first (trace_seq_data); -for (i =0 ; i < *pos; i++) { +for (u32 i =0 ; i < *pos; i++) {if (!fw_trace_get_next (trace_seq_data))return NULL ; }
@@ -455,12 +449,11 @@ void pvr_fw_trace_debugfs_init(struct pvr_device *pvr_dev, struct dentry *dir) { struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; -u32 thread_nr;static_assert (ARRAY_SIZE (fw_trace->buffers) <=10 ,"The filename buffer is only large enough for a single-digit thread count" ); -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); ++thread_nr) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); ++thread_nr) {char filename[8 ];snprintf (filename,ARRAY_SIZE (filename),"trace_%u" , thread_nr);
drivers/gpu/drm/imagination/pvr_gem.c +1 -3
@@ -76,8 +76,6 @@ pvr_gem_object_flags_validate(u64 flags) DRM_PVR_BO_ALLOW_CPU_USERSPACE_ACCESS), }; -int i; -/* * Check for bits set in undefined regions. Reserved regions refer to * options that can only be set by the kernel. These are explicitly
@@ -91,7 +89,7 @@ pvr_gem_object_flags_validate(u64 flags)* Check for all combinations of flags marked as invalid in the array * above. */ -for (i =0 ; i <ARRAY_SIZE (invalid_combinations); ++i) { +for (int i =0 ; i <ARRAY_SIZE (invalid_combinations); ++i) {u64 combo = invalid_combinations[i];if ((flags & combo) == combo)
drivers/gpu/drm/imagination/pvr_hwrt.c +4 -8
@@ -44,13 +44,12 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file, {struct pvr_device *pvr_dev = pvr_file->pvr_dev;int err; -int i; hwrt->pvr_dev = pvr_dev; hwrt->max_rts = args->layers;/* Get pointers to the free lists */ -for (i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { +for (int i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { hwrt->free_lists[i] =pvr_free_list_lookup (pvr_file, args->free_list_handles[i]);if (!hwrt->free_lists[i]) { err = -EINVAL ;
@@ -67,7 +66,7 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file,return 0 ; err_put_free_lists: -for (i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { +for (int i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) {pvr_free_list_put (hwrt->free_lists[i]); hwrt->free_lists[i] =NULL ; }
@@ -78,9 +77,7 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file,static void hwrt_fini_kernel_structure (struct pvr_hwrt_dataset *hwrt) { -int i; - -for (i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { +for (int i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) {pvr_free_list_put (hwrt->free_lists[i]); hwrt->free_lists[i] =NULL ; }
@@ -363,13 +360,12 @@ hwrt_data_init_fw_structure(struct pvr_file *pvr_file,struct drm_pvr_create_hwrt_geom_data_args *geom_data_args = &args->geom_data_args;struct pvr_device *pvr_dev = pvr_file->pvr_dev;struct rogue_fwif_rta_ctl *rta_ctl; -int free_list_i;int err;pvr_fw_object_get_fw_addr (hwrt->common_fw_obj, &hwrt_data->data.hwrt_data_common_fw_addr); -for (free_list_i =0 ; free_list_i <ARRAY_SIZE (hwrt->free_lists); free_list_i++) { +for (int free_list_i =0 ; free_list_i <ARRAY_SIZE (hwrt->free_lists); free_list_i++) {pvr_fw_object_get_fw_addr (hwrt->free_lists[free_list_i]->fw_obj, &hwrt_data->data.freelists_fw_addr[free_list_i]); }
drivers/gpu/drm/imagination/pvr_stream.c +4 -8
@@ -67,9 +67,8 @@ pvr_stream_process_1(struct pvr_device *pvr_dev, const struct pvr_stream_def *st u8 *dest, u32 dest_size, u32 *stream_offset_out) { int err = 0; -u32 i; -for (i =0 ; i < nr_entries; i++) { +for (u32 i =0 ; i < nr_entries; i++) {if (stream_def[i].offset >= dest_size) { err = -EINVAL ;break ;
@@ -131,7 +130,6 @@ pvr_stream_process_ext_stream(struct pvr_device *pvr_dev,u32 musthave_masks[PVR_STREAM_EXTHDR_TYPE_MAX ];u32 ext_header;int err =0 ; -u32 i;/* Copy "must have" mask from device. We clear this as we process the stream. */ memcpy(musthave_masks, pvr_dev->stream_musthave_quirks[cmd_defs->type],
@@ -159,7 +157,7 @@ pvr_stream_process_ext_stream(struct pvr_device *pvr_dev, musthave_masks[type] &= ~data; -for (i =0 ; i < header->ext_streams_num; i++) { +for (u32 i =0 ; i < header->ext_streams_num; i++) {const struct pvr_stream_ext_def *ext_def = &header->ext_streams[i];if (!(ext_header & ext_def->header_mask))
@@ -181,7 +179,7 @@ pvr_stream_process_ext_stream(struct pvr_device *pvr_dev,* Verify that "must have" mask is now zero. If it isn't then one of the "must have" quirks * for this command was not present. */ -for (i =0 ; i < cmd_defs->ext_nr_headers; i++) { +for (u32 i =0 ; i < cmd_defs->ext_nr_headers; i++) {if (musthave_masks[i])return -EINVAL ; }
@@ -245,13 +243,11 @@ pvr_stream_process(struct pvr_device *pvr_dev, const struct pvr_stream_cmd_defsif (err)return err; }else { -u32 i; -/* * If we don't have an extension stream then there must not be any "must have" * quirks for this command. */ -for (i =0 ; i < cmd_defs->ext_nr_headers; i++) { +for (u32 i =0 ; i < cmd_defs->ext_nr_headers; i++) {if (pvr_dev->stream_musthave_quirks[cmd_defs->type][i])return -EINVAL ; }
drivers/gpu/drm/imagination/pvr_vm_mips.c +1 -2
@@ -100,10 +100,9 @@ pvr_vm_mips_fini(struct pvr_device *pvr_dev) {struct pvr_fw_device *fw_dev = &pvr_dev->fw_dev;struct pvr_fw_mips_data *mips_data = fw_dev->processor_data.mips_data; -int page_nr;vunmap (mips_data->pt); -for (page_nr =PVR_MIPS_PT_PAGE_COUNT -1 ; page_nr >=0 ; page_nr--) { +for (int page_nr =PVR_MIPS_PT_PAGE_COUNT -1 ; page_nr >=0 ; page_nr--) {dma_unmap_page (from_pvr_device (pvr_dev)->dev, mips_data->pt_dma_addr[page_nr],PAGE_SIZE ,DMA_TO_DEVICE );
---
base-commit: 2f9d51740cc30e0d2c8a23a55b1e20cf2513c250
change-id: 20250401-for-loop-counter-scope-115373392913
Best regards,
Signature · 1 line
Alexandru Dadu <[email protected]>
Quoted 4 lines · Alexandru Dadu
Reduce the scope of some loop counters as these aren't needed outside the loops they're used in.
Signed-off-by Alexandru Dadu <[email protected]>
Hi Alexandru,
Thanks for dragging us into the bright, bright future of (C)99!
I'll apply this to drm-misc-next on Monday if nobody has any objections.
Cheers,
Matt
Quoted 417 lines
---
Changes in v2:
- Remove a loop counter variable definition
- Link to v1: https://lore.kernel.org/r/[email protected]--- drivers/gpu/drm/imagination/pvr_debugfs.c | 3 +-- drivers/gpu/drm/imagination/pvr_free_list.c | 3 +-- drivers/gpu/drm/imagination/pvr_fw.c | 12 ++++-------- drivers/gpu/drm/imagination/pvr_fw_meta.c | 3 +-- drivers/gpu/drm/imagination/pvr_fw_mips.c | 6 ++---- drivers/gpu/drm/imagination/pvr_fw_trace.c | 23 ++++++++--------------- drivers/gpu/drm/imagination/pvr_gem.c | 4 +--- drivers/gpu/drm/imagination/pvr_hwrt.c | 12 ++++-------- drivers/gpu/drm/imagination/pvr_stream.c | 12 ++++-------- drivers/gpu/drm/imagination/pvr_vm_mips.c | 3 +-- 10 files changed, 27 insertions(+), 54 deletions(-)drivers/gpu/drm/imagination/pvr_debugfs.c +1
-2@@ -28,9 +28,8 @@ pvr_debugfs_init(struct drm_minor *minor)struct drm_device *drm_dev = minor->dev;struct pvr_device *pvr_dev =to_pvr_device (drm_dev);struct dentry *root = minor->debugfs_root; -size_t i; -for (i =0 ; i <ARRAY_SIZE (pvr_debugfs_entries); ++i) { +for (size_t i =0 ; i <ARRAY_SIZE (pvr_debugfs_entries); ++i) {const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i];struct dentry *dir;drivers/gpu/drm/imagination/pvr_free_list.c +1
-2@@ -237,11 +237,10 @@ pvr_free_list_insert_pages_locked(struct pvr_free_list *free_list,dma_addr_t dma_addr =sg_page_iter_dma_address (&dma_iter);u64 dma_pfn = dma_addr >>ROGUE_BIF_PM_PHYSICAL_PAGE_ALIGNSHIFT ; -u32 dma_addr_offset;BUILD_BUG_ON (ROGUE_BIF_PM_PHYSICAL_PAGE_SIZE >PAGE_SIZE ); -for (dma_addr_offset =0 ; dma_addr_offset <PAGE_SIZE ; +for (u32 dma_addr_offset =0 ; dma_addr_offset <PAGE_SIZE ; dma_addr_offset +=ROGUE_BIF_PM_PHYSICAL_PAGE_SIZE ) {WARN_ON_ONCE (dma_pfn >>32 );drivers/gpu/drm/imagination/pvr_fw.c +4
-8@@ -50,9 +50,8 @@ pvr_fw_find_layout_entry(struct pvr_device *pvr_dev, enum pvr_fw_section_id id) {const struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num; -u32 entry; -for (entry =0 ; entry < num_layout_entries; entry++) { +for (u32 entry =0 ; entry < num_layout_entries; entry++) {if (layout_entries[entry].id == id)return &layout_entries[entry]; }@@ -65,9 +64,8 @@ pvr_fw_find_private_data(struct pvr_device *pvr_dev) {const struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num; -u32 entry; -for (entry =0 ; entry < num_layout_entries; entry++) { +for (u32 entry =0 ; entry < num_layout_entries; entry++) {if (layout_entries[entry].id ==META_PRIVATE_DATA || layout_entries[entry].id ==MIPS_PRIVATE_DATA || layout_entries[entry].id ==RISCV_PRIVATE_DATA )@@ -97,7 +95,6 @@ pvr_fw_validate(struct pvr_device *pvr_dev)const u8 *fw = firmware->data;u32 fw_offset = firmware->size -SZ_4K ;u32 layout_table_size; -u32 entry;if (firmware->size <SZ_4K || (firmware->size %FW_BLOCK_SIZE ))return -EINVAL ;@@ -144,7 +141,7 @@ pvr_fw_validate(struct pvr_device *pvr_dev)return -EINVAL ; layout_entries = (const struct pvr_fw_layout_entry *)&fw[fw_offset]; -for (entry =0 ; entry < header->layout_entry_num; entry++) { +for (u32 entry =0 ; entry < header->layout_entry_num; entry++) {u32 start_addr = layout_entries[entry].base_addr;u32 end_addr = start_addr + layout_entries[entry].alloc_size;@@ -233,13 +230,12 @@ pvr_fw_find_mmu_segment(struct pvr_device *pvr_dev, u32 addr, u32 size, void *fwconst struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num;u32 end_addr = addr + size; -int entry =0 ;/* Ensure requested range is not zero, and size is not causing addr to overflow. */ if (end_addr <= addr)return -EINVAL ; -for (entry =0 ; entry < num_layout_entries; entry++) { +for (int entry =0 ; entry < num_layout_entries; entry++) {u32 entry_start_addr = layout_entries[entry].base_addr;u32 entry_end_addr = entry_start_addr + layout_entries[entry].alloc_size;drivers/gpu/drm/imagination/pvr_fw_meta.c +1
-2@@ -370,13 +370,12 @@ configure_seg_mmu(struct pvr_device *pvr_dev, u32 **boot_conf_ptr)const struct pvr_fw_layout_entry *layout_entries = pvr_dev->fw_dev.layout_entries;u32 num_layout_entries = pvr_dev->fw_dev.header->layout_entry_num;u64 seg_out_addr_top; -u32 i; seg_out_addr_top =ROGUE_FW_SEGMMU_OUTADDR_TOP_SLC (MMU_CONTEXT_MAPPING_FWPRIV ,ROGUE_FW_SEGMMU_META_BIFDM_ID ); -for (i =0 ; i < num_layout_entries; i++) { +for (u32 i =0 ; i < num_layout_entries; i++) {/* * FW code is using the bootloader segment which is already * configured on boot. FW coremem code and data don't use the drivers/gpu/drm/imagination/pvr_fw_mips.c +2
-4@@ -37,10 +37,9 @@ process_elf_command_stream(struct pvr_device *pvr_dev, const u8 *fw, u8 *fw_codestruct elf32_hdr *header = (struct elf32_hdr *)fw;struct elf32_phdr *program_header = (struct elf32_phdr *)(fw + header->e_phoff);struct drm_device *drm_dev =from_pvr_device (pvr_dev); -u32 entry;int err; -for (entry =0 ; entry < header->e_phnum; entry++, program_header++) { +for (u32 entry =0 ; entry < header->e_phnum; entry++, program_header++) {void *write_addr;/* Only consider loadable entries in the ELF segment table */ @@ -97,7 +96,6 @@ pvr_mips_fw_process(struct pvr_device *pvr_dev, const u8 *fw,const struct pvr_fw_layout_entry *stack_entry;struct rogue_mipsfw_boot_data *boot_data;dma_addr_t dma_addr; -u32 page_nr;int err; err = process_elf_command_stream(pvr_dev, fw, fw_code_ptr, fw_data_ptr, fw_core_code_ptr,@@ -132,7 +130,7 @@ pvr_mips_fw_process(struct pvr_device *pvr_dev, const u8 *fw, boot_data->reg_base = pvr_dev->regs_resource->start; -for (page_nr =0 ; page_nr <ARRAY_SIZE (boot_data->pt_phys_addr); page_nr++) { +for (u32 page_nr =0 ; page_nr <ARRAY_SIZE (boot_data->pt_phys_addr); page_nr++) {/* Firmware expects 4k pages, but host page size might be different. */ u32 src_page_nr = (page_nr *ROGUE_MIPSFW_PAGE_SIZE_4K ) >>PAGE_SHIFT ;u32 page_offset = (page_nr *ROGUE_MIPSFW_PAGE_SIZE_4K ) & ~PAGE_MASK ;drivers/gpu/drm/imagination/pvr_fw_trace.c +8
-15@@ -21,7 +21,6 @@ tracebuf_ctrl_init(void *cpu_ptr, void *priv) {struct rogue_fwif_tracebuf *tracebuf_ctrl = cpu_ptr;struct pvr_fw_trace *fw_trace = priv; -u32 thread_nr; tracebuf_ctrl->tracebuf_size_in_dwords =ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS ; tracebuf_ctrl->tracebuf_flags =0 ;@@ -31,7 +30,7 @@ tracebuf_ctrl_init(void *cpu_ptr, void *priv)else tracebuf_ctrl->log_type =ROGUE_FWIF_LOG_TYPE_NONE ; -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct rogue_fwif_tracebuf_space *tracebuf_space = &tracebuf_ctrl->tracebuf[thread_nr];struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];@@ -48,10 +47,9 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev) {struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace;struct drm_device *drm_dev =from_pvr_device (pvr_dev); -u32 thread_nr;int err; -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; trace_buffer->buf =@@ -88,7 +86,7 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev)BUILD_BUG_ON (ARRAY_SIZE (fw_trace->tracebuf_ctrl->tracebuf) !=ARRAY_SIZE (fw_trace->buffers)); -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct rogue_fwif_tracebuf_space *tracebuf_space = &fw_trace->tracebuf_ctrl->tracebuf[thread_nr];struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];@@ -99,7 +97,7 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev)return 0 ; err_free_buf: -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];if (trace_buffer->buf)@@ -112,9 +110,8 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev)void pvr_fw_trace_fini (struct pvr_device *pvr_dev) {struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; -u32 thread_nr; -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); thread_nr++) {struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr];pvr_fw_object_unmap_and_destroy (trace_buffer->buf_obj);@@ -184,9 +181,7 @@ struct pvr_fw_trace_seq_data {static u32 find_sfid (u32 id) { -u32 i; - -for (i =0 ; i <ARRAY_SIZE (stid_fmts); i++) { +for (u32 i =0 ; i <ARRAY_SIZE (stid_fmts); i++) {if (stid_fmts[i].id == id)return i; }@@ -285,12 +280,11 @@ static void fw_trace_get_first(struct pvr_fw_trace_seq_data *trace_seq_data)static void *fw_trace_seq_start (struct seq_file *s,loff_t *pos) {struct pvr_fw_trace_seq_data *trace_seq_data = s->private; -u32 i;/* Reset trace index, then advance to *pos. */ fw_trace_get_first (trace_seq_data); -for (i =0 ; i < *pos; i++) { +for (u32 i =0 ; i < *pos; i++) {if (!fw_trace_get_next (trace_seq_data))return NULL ; }@@ -455,12 +449,11 @@ void pvr_fw_trace_debugfs_init(struct pvr_device *pvr_dev, struct dentry *dir) { struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; -u32 thread_nr;static_assert (ARRAY_SIZE (fw_trace->buffers) <=10 ,"The filename buffer is only large enough for a single-digit thread count" ); -for (thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); ++thread_nr) { +for (u32 thread_nr =0 ; thread_nr <ARRAY_SIZE (fw_trace->buffers); ++thread_nr) {char filename[8 ];snprintf (filename,ARRAY_SIZE (filename),"trace_%u" , thread_nr);drivers/gpu/drm/imagination/pvr_gem.c +1
-3@@ -76,8 +76,6 @@ pvr_gem_object_flags_validate(u64 flags) DRM_PVR_BO_ALLOW_CPU_USERSPACE_ACCESS), }; -int i; -/* * Check for bits set in undefined regions. Reserved regions refer to * options that can only be set by the kernel. These are explicitly @@ -91,7 +89,7 @@ pvr_gem_object_flags_validate(u64 flags)* Check for all combinations of flags marked as invalid in the array * above. */ -for (i =0 ; i <ARRAY_SIZE (invalid_combinations); ++i) { +for (int i =0 ; i <ARRAY_SIZE (invalid_combinations); ++i) {u64 combo = invalid_combinations[i];if ((flags & combo) == combo)drivers/gpu/drm/imagination/pvr_hwrt.c +4
-8@@ -44,13 +44,12 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file, {struct pvr_device *pvr_dev = pvr_file->pvr_dev;int err; -int i; hwrt->pvr_dev = pvr_dev; hwrt->max_rts = args->layers;/* Get pointers to the free lists */ -for (i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { +for (int i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { hwrt->free_lists[i] =pvr_free_list_lookup (pvr_file, args->free_list_handles[i]);if (!hwrt->free_lists[i]) { err = -EINVAL ;@@ -67,7 +66,7 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file,return 0 ; err_put_free_lists: -for (i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { +for (int i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) {pvr_free_list_put (hwrt->free_lists[i]); hwrt->free_lists[i] =NULL ; }@@ -78,9 +77,7 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file,static void hwrt_fini_kernel_structure (struct pvr_hwrt_dataset *hwrt) { -int i; - -for (i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) { +for (int i =0 ; i <ARRAY_SIZE (hwrt->free_lists); i++) {pvr_free_list_put (hwrt->free_lists[i]); hwrt->free_lists[i] =NULL ; }@@ -363,13 +360,12 @@ hwrt_data_init_fw_structure(struct pvr_file *pvr_file,struct drm_pvr_create_hwrt_geom_data_args *geom_data_args = &args->geom_data_args;struct pvr_device *pvr_dev = pvr_file->pvr_dev;struct rogue_fwif_rta_ctl *rta_ctl; -int free_list_i;int err;pvr_fw_object_get_fw_addr (hwrt->common_fw_obj, &hwrt_data->data.hwrt_data_common_fw_addr); -for (free_list_i =0 ; free_list_i <ARRAY_SIZE (hwrt->free_lists); free_list_i++) { +for (int free_list_i =0 ; free_list_i <ARRAY_SIZE (hwrt->free_lists); free_list_i++) {pvr_fw_object_get_fw_addr (hwrt->free_lists[free_list_i]->fw_obj, &hwrt_data->data.freelists_fw_addr[free_list_i]); }drivers/gpu/drm/imagination/pvr_stream.c +4
-8@@ -67,9 +67,8 @@ pvr_stream_process_1(struct pvr_device *pvr_dev, const struct pvr_stream_def *st u8 *dest, u32 dest_size, u32 *stream_offset_out) { int err = 0; -u32 i; -for (i =0 ; i < nr_entries; i++) { +for (u32 i =0 ; i < nr_entries; i++) {if (stream_def[i].offset >= dest_size) { err = -EINVAL ;break ;@@ -131,7 +130,6 @@ pvr_stream_process_ext_stream(struct pvr_device *pvr_dev,u32 musthave_masks[PVR_STREAM_EXTHDR_TYPE_MAX ];u32 ext_header;int err =0 ; -u32 i;/* Copy "must have" mask from device. We clear this as we process the stream. */ memcpy(musthave_masks, pvr_dev->stream_musthave_quirks[cmd_defs->type],@@ -159,7 +157,7 @@ pvr_stream_process_ext_stream(struct pvr_device *pvr_dev, musthave_masks[type] &= ~data; -for (i =0 ; i < header->ext_streams_num; i++) { +for (u32 i =0 ; i < header->ext_streams_num; i++) {const struct pvr_stream_ext_def *ext_def = &header->ext_streams[i];if (!(ext_header & ext_def->header_mask))@@ -181,7 +179,7 @@ pvr_stream_process_ext_stream(struct pvr_device *pvr_dev,* Verify that "must have" mask is now zero. If it isn't then one of the "must have" quirks * for this command was not present. */ -for (i =0 ; i < cmd_defs->ext_nr_headers; i++) { +for (u32 i =0 ; i < cmd_defs->ext_nr_headers; i++) {if (musthave_masks[i])return -EINVAL ; }@@ -245,13 +243,11 @@ pvr_stream_process(struct pvr_device *pvr_dev, const struct pvr_stream_cmd_defsif (err)return err; }else { -u32 i; -/* * If we don't have an extension stream then there must not be any "must have" * quirks for this command. */ -for (i =0 ; i < cmd_defs->ext_nr_headers; i++) { +for (u32 i =0 ; i < cmd_defs->ext_nr_headers; i++) {if (pvr_dev->stream_musthave_quirks[cmd_defs->type][i])return -EINVAL ; }drivers/gpu/drm/imagination/pvr_vm_mips.c +1
-3@@ -100,10 +100,9 @@ pvr_vm_mips_fini(struct pvr_device *pvr_dev) {struct pvr_fw_device *fw_dev = &pvr_dev->fw_dev;struct pvr_fw_mips_data *mips_data = fw_dev->processor_data.mips_data; -int page_nr;vunmap (mips_data->pt); -for (page_nr =PVR_MIPS_PT_PAGE_COUNT -1 ; page_nr >=0 ; page_nr--) { +for (int page_nr =PVR_MIPS_PT_PAGE_COUNT -1 ; page_nr >=0 ; page_nr--) {dma_unmap_page (from_pvr_device (pvr_dev)->dev, mips_data->pt_dma_addr[page_nr],PAGE_SIZE ,DMA_TO_DEVICE ); ---base-commit:
2f9d51740cc30e0d2c8a23a55b1e20cf2513c250
change-id: 20250401-for-loop-counter-scope-115373392913Best regards,
--
Alexandru Dadu <[email protected]>
Signature · 2 lines
Matt Coster E: [email protected]
Matt Coster
AppliedQuoted 4 lines · Alexandru Dadu
Reduce the scope of some loop counters as these aren't needed outside the loops they're used in.
Applied, thanks!
[1/1] drm/imagination: loop counters moved to loop scope
commit: 81feddc12613567d8206a9697d068711140e9c47
Best regards,
Signature · 1 line
Matt Coster <[email protected]>