From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: "Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"David E Box" <david.e.box@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 19/20] platform/x86/intel/tpmi: Declare the loop counters in their loops
Date: Wed, 30 Sep 2026 10:29:16 -0700 [thread overview]
Message-ID: <20260930172918.743656-20-sathyanarayanan.kuppuswamy@linux.intel.com> (raw)
In-Reply-To: <20260930172918.743656-1-sathyanarayanan.kuppuswamy@linux.intel.com>
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@intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
drivers/platform/x86/intel/tpmi_common.c | 26 +++++++++++-------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/platform/x86/intel/tpmi_common.c b/drivers/platform/x86/intel/tpmi_common.c
index 91d8083fecc0..52d843501020 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,10 +578,10 @@ 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 = DEFINE_RES_MEM(pfs->vsec_offset + entry_size_bytes * i, entry_size_bytes);
+ res[i] = DEFINE_RES_MEM(pfs->vsec_offset + entry_size_bytes * i, entry_size_bytes);
}
feature_vsec_dev->dev = tpmi_info->parent;
@@ -605,9 +603,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);
/*
@@ -701,7 +699,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;
@@ -722,7 +720,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
next prev parent reply other threads:[~2026-09-30 17:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 17:28 [PATCH v3 00/20] Decouple PCI and auxbus details from Intel TPMI driver Kuppuswamy Sathyanarayanan
2026-09-30 17:28 ` [PATCH v3 01/20] platform/x86/intel/tpmi: Use static strings for the feature device names Kuppuswamy Sathyanarayanan
2026-09-30 17:28 ` [PATCH v3 02/20] platform/x86/intel/vsec: Pass a struct device to intel_vsec_set_mapping() Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 03/20] platform/x86/intel/tpmi: Remove unused vsec_dev from intel_tpmi_pm_feature Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 04/20] platform/x86/intel/tpmi: Get tpmi_info directly from the parent device Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 05/20] platform/x86/intel/tpmi: Keep the feature resources in intel_tpmi_info Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 06/20] platform/x86/intel/tpmi: Describe a TPMI instance by its two devices Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 07/20] platform/x86/intel/tpmi: Drop unused arg from tpmi_set_control_base() Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 08/20] platform/x86/intel/tpmi: Do not assume TPMI is enumerated from PCI Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 09/20] platform/x86/intel/tpmi: Split out enumeration independent init and exit Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 10/20] platform/x86/intel/tpmi: Split off the PCI VSEC enumeration Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 11/20] platform/x86/intel/tpmi: Include the headers tpmi_common.c relies on Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 12/20] platform/x86/intel/tpmi: Turn TPMI_GET_SINGLE_ENTRY_SIZE() into a function Kuppuswamy Sathyanarayanan
2026-10-01 18:04 ` Andy Shevchenko
2026-09-30 17:29 ` [PATCH v3 13/20] platform/x86/intel/tpmi: Use guard() for tpmi_dev_lock in the status read Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 14/20] platform/x86/intel/tpmi: Use scope based cleanup in the memory dump Kuppuswamy Sathyanarayanan
2026-10-01 18:06 ` Andy Shevchenko
2026-10-01 18:18 ` Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 15/20] platform/x86/intel/tpmi: Build the TPMI control words in one expression Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 16/20] platform/x86/intel/tpmi: Use DEFINE_SHOW_STORE_ATTRIBUTE() for mem_write Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 17/20] platform/x86/intel/tpmi: Use scnprintf() to build the debugfs names Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 18/20] platform/x86/intel/tpmi: Use DEFINE_RES_MEM() for the feature resources Kuppuswamy Sathyanarayanan
2026-10-01 18:09 ` Andy Shevchenko
2026-09-30 17:29 ` Kuppuswamy Sathyanarayanan [this message]
2026-10-01 18:12 ` [PATCH v3 19/20] platform/x86/intel/tpmi: Declare the loop counters in their loops Andy Shevchenko
2026-10-01 21:02 ` Kuppuswamy Sathyanarayanan
2026-09-30 17:29 ` [PATCH v3 20/20] platform/x86/intel/tpmi: Describe the device creation policy on the function Kuppuswamy Sathyanarayanan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260930172918.743656-20-sathyanarayanan.kuppuswamy@linux.intel.com \
--to=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=david.e.box@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®