Skip to content

Commit 8e29bc8

Browse files
andy-shevbroonie
authored andcommitted
regcache: Define iterator inside for-loop and align their types
Some of the iterators may be defined inside the respective for-loop reducing the scope and potential risk of their misuse. While at it, align their types based on the type of the upper or lower limits. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20260302095847.2310066-3-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 37983fa commit 8e29bc8

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/base/regmap/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct regmap {
162162
bool no_sync_defaults;
163163

164164
struct reg_sequence *patch;
165-
int patch_regs;
165+
unsigned int patch_regs;
166166

167167
/* if set, the regmap core can sleep */
168168
bool can_sleep;

drivers/base/regmap/regcache.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ EXPORT_SYMBOL_GPL(regcache_sort_defaults);
4444

4545
static int regcache_count_cacheable_registers(struct regmap *map)
4646
{
47-
int count;
48-
int i;
47+
unsigned int count;
4948

5049
/* calculate the size of reg_defaults */
51-
for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++)
50+
count = 0;
51+
for (unsigned int i = 0; i < map->num_reg_defaults_raw; i++)
5252
if (regmap_readable(map, i * map->reg_stride) &&
5353
!regmap_volatile(map, i * map->reg_stride))
5454
count++;
@@ -62,7 +62,6 @@ static int regcache_count_cacheable_registers(struct regmap *map)
6262

6363
static int regcache_hw_init(struct regmap *map, int count)
6464
{
65-
int i, j;
6665
int ret;
6766
unsigned int reg, val;
6867
void *tmp_buf;
@@ -95,7 +94,7 @@ static int regcache_hw_init(struct regmap *map, int count)
9594
}
9695

9796
/* fill the reg_defaults */
98-
for (i = 0, j = 0; i < map->num_reg_defaults_raw; i++) {
97+
for (unsigned int i = 0, j = 0; i < map->num_reg_defaults_raw; i++) {
9998
reg = i * map->reg_stride;
10099

101100
if (!regmap_readable(map, reg))
@@ -840,13 +839,13 @@ static int regcache_sync_block_raw(struct regmap *map, void *block,
840839
unsigned int block_base, unsigned int start,
841840
unsigned int end)
842841
{
843-
unsigned int i, val;
844842
unsigned int regtmp = 0;
845843
unsigned int base = 0;
846844
const void *data = NULL;
845+
unsigned int val;
847846
int ret;
848847

849-
for (i = start; i < end; i++) {
848+
for (unsigned int i = start; i < end; i++) {
850849
regtmp = block_base + (i * map->reg_stride);
851850

852851
if (!regcache_reg_present(cache_present, i) ||

0 commit comments

Comments
 (0)