[PATCH v2 18/19] platform/x86/intel/tpmi: Declare the loop counters in their loops
From: Kuppuswamy Sathyanarayanan
Date: Thu Sep 24 2026 - 14:34:34 EST
Declare the loop counters in the for statements that use them, so that
they are scoped to their loops.
In tpmi_create_device() this also replaces the tmp cursor, which moved
in step with the counter, with res[i].
No functional change intended.
Suggested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
---
drivers/platform/x86/intel/tpmi_common.c | 30 +++++++++++-------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/platform/x86/intel/tpmi_common.c b/drivers/platform/x86/intel/tpmi_common.c
index 097754365897..0ef2642bd920 100644
--- a/drivers/platform/x86/intel/tpmi_common.c
+++ b/drivers/platform/x86/intel/tpmi_common.c
@@ -359,11 +359,11 @@ static int tpmi_pfs_dbg_show(struct seq_file *s, void *unused)
int locked, disabled, read_blocked, write_blocked;
struct tpmi_feature_state feature_state;
struct intel_tpmi_pm_feature *pfs;
- int ret, i;
+ int ret;
seq_printf(s, "tpmi PFS start offset 0x:%llx\n", tpmi_info->pfs_start);
seq_puts(s, "tpmi_id\t\tentries\t\tsize\t\tcap_offset\tattribute\tvsec_offset\tlocked\tdisabled\tread_blocked\twrite_blocked\n");
- for (i = 0; i < tpmi_info->feature_count; ++i) {
+ for (int i = 0; i < tpmi_info->feature_count; ++i) {
pfs = &tpmi_info->tpmi_features[i];
ret = tpmi_read_feature_status(tpmi_info, pfs->pfs_header.tpmi_id, &feature_state);
if (ret) {
@@ -395,7 +395,6 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)
size_t row_size = MEM_DUMP_COLUMN_COUNT * sizeof(u32);
struct intel_tpmi_pm_feature *pfs = s->private;
void __iomem *mem;
- int count;
u32 size;
u64 off;
@@ -411,7 +410,7 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)
guard(mutex)(&tpmi_dev_lock);
- for (count = 0; count < pfs->pfs_header.num_entries; ++count) {
+ for (int count = 0; count < pfs->pfs_header.num_entries; ++count) {
seq_printf(s, "TPMI Instance:%d offset:0x%llx\n", count, off);
mem = ioremap(off, size);
@@ -490,14 +489,13 @@ DEFINE_SHOW_STORE_ATTRIBUTE(mem_write);
static void tpmi_dbgfs_register(struct intel_tpmi_info *tpmi_info)
{
char name[64];
- int i;
scnprintf(name, sizeof(name), "tpmi-%s", dev_name(tpmi_info->parent));
tpmi_info->dbgfs_dir = debugfs_create_dir(name, NULL);
debugfs_create_file("pfs_dump", 0444, tpmi_info->dbgfs_dir, tpmi_info, &tpmi_pfs_dbg_fops);
- for (i = 0; i < tpmi_info->feature_count; ++i) {
+ for (int i = 0; i < tpmi_info->feature_count; ++i) {
struct intel_tpmi_pm_feature *pfs;
struct dentry *dir;
@@ -554,9 +552,9 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
{
struct intel_vsec_device *feature_vsec_dev;
struct tpmi_feature_state feature_state;
- struct resource *res, *tmp;
+ struct resource *res;
const char *name;
- int i, ret;
+ int ret;
ret = tpmi_read_feature_status(tpmi_info, pfs->pfs_header.tpmi_id, &feature_state);
if (ret)
@@ -580,12 +578,12 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
feature_vsec_dev->num_resources = pfs->pfs_header.num_entries;
res = feature_vsec_dev->resource;
- for (i = 0, tmp = res; i < pfs->pfs_header.num_entries; i++, tmp++) {
+ for (int i = 0; i < pfs->pfs_header.num_entries; i++) {
u64 entry_size_bytes = pfs->pfs_header.entry_size * sizeof(u32);
- tmp->start = pfs->vsec_offset + entry_size_bytes * i;
- tmp->end = tmp->start + entry_size_bytes - 1;
- tmp->flags = IORESOURCE_MEM;
+ res[i].start = pfs->vsec_offset + entry_size_bytes * i;
+ res[i].end = res[i].start + entry_size_bytes - 1;
+ res[i].flags = IORESOURCE_MEM;
}
feature_vsec_dev->dev = tpmi_info->parent;
@@ -607,9 +605,9 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info)
{
- int ret, i;
+ int ret;
- for (i = 0; i < tpmi_info->feature_count; i++) {
+ for (int i = 0; i < tpmi_info->feature_count; i++) {
ret = tpmi_create_device(tpmi_info, &tpmi_info->tpmi_features[i],
tpmi_info->pfs_start);
/*
@@ -703,7 +701,7 @@ int intel_tpmi_init(struct intel_tpmi_info *tpmi_info, struct device *tpmi_dev,
{
struct pci_dev *pci_dev = dev_is_pci(parent) ? to_pci_dev(parent) : NULL;
u64 pfs_start = 0;
- int ret, i;
+ int ret;
tpmi_info->tpmi_dev = tpmi_dev;
tpmi_info->parent = parent;
@@ -724,7 +722,7 @@ int intel_tpmi_init(struct intel_tpmi_info *tpmi_info, struct device *tpmi_dev,
if (!tpmi_info->tpmi_features)
return -ENOMEM;
- for (i = 0; i < tpmi_info->feature_count; i++) {
+ for (int i = 0; i < tpmi_info->feature_count; i++) {
struct intel_tpmi_pm_feature *pfs;
struct resource *res;
u64 res_start;
--
2.43.0