Skip to content

Commit a57a94d

Browse files
xpardee-createij-intel
authored andcommitted
platform/x86:intel/pmc: Convert index variables to be unsigned
Convert the index variables type to unsigned to avoid confusion and errors. Signed-off-by: Xi Pardee <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ij: Converted also pmc_core_lpm_get_arr_size() to return unsigned int] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 6d413a1 commit a57a94d

File tree

1 file changed

+31
-22
lines changed
  • drivers/platform/x86/intel/pmc

1 file changed

+31
-22
lines changed

drivers/platform/x86/intel/pmc/core.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ static void pmc_core_slps0_display(struct pmc *pmc, struct device *dev,
245245
}
246246
}
247247

248-
static int pmc_core_lpm_get_arr_size(const struct pmc_bit_map **maps)
248+
static unsigned int pmc_core_lpm_get_arr_size(const struct pmc_bit_map **maps)
249249
{
250-
int idx;
250+
unsigned int idx;
251251

252252
for (idx = 0; maps[idx]; idx++)
253253
;/* Nothing */
@@ -260,8 +260,8 @@ static void pmc_core_lpm_display(struct pmc *pmc, struct device *dev,
260260
const char *str,
261261
const struct pmc_bit_map **maps)
262262
{
263-
int index, idx, len = 32, bit_mask, arr_size;
264-
u32 *lpm_regs;
263+
unsigned int index, idx, len = 32, arr_size;
264+
u32 bit_mask, *lpm_regs;
265265

266266
arr_size = pmc_core_lpm_get_arr_size(maps);
267267
lpm_regs = kmalloc_array(arr_size, sizeof(*lpm_regs), GFP_KERNEL);
@@ -314,13 +314,13 @@ static void pmc_core_display_map(struct seq_file *s, int index, int idx, int ip,
314314
static int pmc_core_ppfear_show(struct seq_file *s, void *unused)
315315
{
316316
struct pmc_dev *pmcdev = s->private;
317-
int i;
317+
unsigned int i;
318318

319319
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
320320
struct pmc *pmc = pmcdev->pmcs[i];
321321
const struct pmc_bit_map **maps;
322322
u8 pf_regs[PPFEAR_MAX_NUM_ENTRIES];
323-
int index, iter, idx, ip = 0;
323+
unsigned int index, iter, idx, ip = 0;
324324

325325
if (!pmc)
326326
continue;
@@ -379,7 +379,8 @@ static int pmc_core_mphy_pg_show(struct seq_file *s, void *unused)
379379
const struct pmc_bit_map *map = pmc->map->mphy_sts;
380380
u32 mphy_core_reg_low, mphy_core_reg_high;
381381
u32 val_low, val_high;
382-
int index, err = 0;
382+
unsigned int index;
383+
int err = 0;
383384

384385
if (pmcdev->pmc_xram_read_bit) {
385386
seq_puts(s, "Access denied: please disable PMC_READ_DISABLE setting in BIOS.");
@@ -429,7 +430,8 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
429430
struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
430431
const struct pmc_bit_map *map = pmc->map->pll_sts;
431432
u32 mphy_common_reg, val;
432-
int index, err = 0;
433+
unsigned int index;
434+
int err = 0;
433435

434436
if (pmcdev->pmc_xram_read_bit) {
435437
seq_puts(s, "Access denied: please disable PMC_READ_DISABLE setting in BIOS.");
@@ -462,7 +464,8 @@ int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value, int ignore)
462464
struct pmc *pmc;
463465
const struct pmc_reg_map *map;
464466
u32 reg;
465-
int pmc_index, ltr_index;
467+
unsigned int pmc_index;
468+
int ltr_index;
466469

467470
ltr_index = value;
468471
/* For platforms with multiple pmcs, ltr index value given by user
@@ -615,7 +618,7 @@ static int pmc_core_ltr_show(struct seq_file *s, void *unused)
615618
u64 decoded_snoop_ltr, decoded_non_snoop_ltr;
616619
u32 ltr_raw_data, scale, val;
617620
u16 snoop_ltr, nonsnoop_ltr;
618-
int i, index, ltr_index = 0;
621+
unsigned int i, index, ltr_index = 0;
619622

620623
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
621624
struct pmc *pmc = pmcdev->pmcs[i];
@@ -703,7 +706,8 @@ static int pmc_core_substate_res_show(struct seq_file *s, void *unused)
703706
struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
704707
const int lpm_adj_x2 = pmc->map->lpm_res_counter_step_x2;
705708
u32 offset = pmc->map->lpm_residency_offset;
706-
int i, mode;
709+
unsigned int i;
710+
int mode;
707711

708712
seq_printf(s, "%-10s %-15s\n", "Substate", "Residency");
709713

@@ -719,7 +723,7 @@ DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_res);
719723
static int pmc_core_substate_sts_regs_show(struct seq_file *s, void *unused)
720724
{
721725
struct pmc_dev *pmcdev = s->private;
722-
int i;
726+
unsigned int i;
723727

724728
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
725729
struct pmc *pmc = pmcdev->pmcs[i];
@@ -740,7 +744,7 @@ DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_sts_regs);
740744
static int pmc_core_substate_l_sts_regs_show(struct seq_file *s, void *unused)
741745
{
742746
struct pmc_dev *pmcdev = s->private;
743-
int i;
747+
unsigned int i;
744748

745749
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
746750
struct pmc *pmc = pmcdev->pmcs[i];
@@ -761,7 +765,8 @@ DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_l_sts_regs);
761765
static void pmc_core_substate_req_header_show(struct seq_file *s, int pmc_index)
762766
{
763767
struct pmc_dev *pmcdev = s->private;
764-
int i, mode;
768+
unsigned int i;
769+
int mode;
765770

766771
seq_printf(s, "%30s |", "Element");
767772
pmc_for_each_mode(i, mode, pmcdev)
@@ -775,7 +780,8 @@ static int pmc_core_substate_req_regs_show(struct seq_file *s, void *unused)
775780
struct pmc_dev *pmcdev = s->private;
776781
u32 sts_offset;
777782
u32 *lpm_req_regs;
778-
int num_maps, mp, pmc_index;
783+
unsigned int mp, pmc_index;
784+
int num_maps;
779785

780786
for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs); ++pmc_index) {
781787
struct pmc *pmc = pmcdev->pmcs[pmc_index];
@@ -897,9 +903,10 @@ static int pmc_core_lpm_latch_mode_show(struct seq_file *s, void *unused)
897903
{
898904
struct pmc_dev *pmcdev = s->private;
899905
struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
906+
unsigned int idx;
900907
bool c10;
901908
u32 reg;
902-
int idx, mode;
909+
int mode;
903910

904911
reg = pmc_core_reg_read(pmc, pmc->map->lpm_sts_latch_en_offset);
905912
if (reg & LPM_STS_LATCH_MODE) {
@@ -931,7 +938,8 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
931938
struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
932939
bool clear = false, c10 = false;
933940
unsigned char buf[8];
934-
int idx, m, mode;
941+
unsigned int idx;
942+
int m, mode;
935943
u32 reg;
936944

937945
if (count > sizeof(buf) - 1)
@@ -999,7 +1007,7 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused)
9991007
struct pmc *pmc = s->private;
10001008
const struct pmc_bit_map *map = pmc->map->msr_sts;
10011009
u64 pcstate_count;
1002-
int index;
1010+
unsigned int index;
10031011

10041012
for (index = 0; map[index].name ; index++) {
10051013
if (rdmsrl_safe(map[index].bit_mask, &pcstate_count))
@@ -1017,7 +1025,7 @@ DEFINE_SHOW_ATTRIBUTE(pmc_core_pkgc);
10171025

10181026
static bool pmc_core_pri_verify(u32 lpm_pri, u8 *mode_order)
10191027
{
1020-
int i, j;
1028+
unsigned int i, j;
10211029

10221030
if (!lpm_pri)
10231031
return false;
@@ -1052,7 +1060,8 @@ void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev)
10521060
u8 mode_order[LPM_MAX_NUM_MODES];
10531061
u32 lpm_pri;
10541062
u32 lpm_en;
1055-
int mode, i, p;
1063+
unsigned int i;
1064+
int mode, p;
10561065

10571066
/* Use LPM Maps to indicate support for substates */
10581067
if (!pmc->map->lpm_num_maps)
@@ -1344,7 +1353,7 @@ static void pmc_core_do_dmi_quirks(struct pmc *pmc)
13441353
static void pmc_core_clean_structure(struct platform_device *pdev)
13451354
{
13461355
struct pmc_dev *pmcdev = platform_get_drvdata(pdev);
1347-
int i;
1356+
unsigned int i;
13481357

13491358
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
13501359
struct pmc *pmc = pmcdev->pmcs[i];
@@ -1507,7 +1516,7 @@ int pmc_core_resume_common(struct pmc_dev *pmcdev)
15071516
struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
15081517
const struct pmc_bit_map **maps = pmc->map->lpm_sts;
15091518
int offset = pmc->map->lpm_status_offset;
1510-
int i;
1519+
unsigned int i;
15111520

15121521
/* Check if the syspend used S0ix */
15131522
if (pm_suspend_via_firmware())

0 commit comments

Comments
 (0)