[v1,1/4] platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic for platforms that support sub-states
diff mbox series

Message ID 4ed31a98bbb65717f5182f6d512dd4df80c78272.1582770011.git.gayatri.kammela@intel.com
State Superseded
Headers show
Series
  • platform/x86: intel_pmc_core: Add bug fixes or code
Related show

Commit Message

Kammela, Gayatri Feb. 27, 2020, 2:43 a.m. UTC
Currently pmc_core_lpm_display() uses array of struct pointers i.e.,
tgl_lpm_maps for Tiger Lake directly to iterate through and to get the
number of status/live status registers which is hardcoded and will not
work for future platforms that support sub-states. To maintain
readability, make pmc_core_lpm_display() generic, so that it can re-used
for future platforms.

Cc: Chen Zhou <chenzhou10@huawei.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: David E. Box <david.e.box@intel.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Gayatri Kammela <gayatri.kammela@intel.com>
---
 drivers/platform/x86/intel_pmc_core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

kbuild test robot Feb. 27, 2020, 6:28 a.m. UTC | #1
Hi Gayatri,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on platform-drivers-x86/for-next]
[also build test WARNING on next-20200226]
[cannot apply to tip/auto-latest linux/master linus/master v5.6-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Gayatri-Kammela/platform-x86-intel_pmc_core-Add-bug-fixes-or-code/20200227-105701
base:   git://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git for-next
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/platform/x86/intel_pmc_core.c: In function 'pmc_core_lpm_display':
>> drivers/platform/x86/intel_pmc_core.c:987:2: warning: ISO C90 forbids variable length array 'lpm_regs' [-Wvla]
     u32 lpm_regs[arr_size];
     ^~~
>> drivers/platform/x86/intel_pmc_core.c:987:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

vim +/lpm_regs +987 drivers/platform/x86/intel_pmc_core.c

   976	
   977	static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
   978					 struct seq_file *s, u32 offset,
   979					 const char *str,
   980					 const struct pmc_bit_map **maps)
   981	{
   982		int index, idx, len = 32, bit_mask, arr_size = 0;
   983	
   984		for (index = 0; maps[index]; index++)
   985			arr_size++;
   986	
 > 987		u32 lpm_regs[arr_size];
   988	
   989		for (index = 0; maps[index]; index++) {
   990			lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
   991			offset += 4;
   992		}
   993	
   994		for (idx = 0; maps[idx]; idx++) {
   995			if (dev)
   996				dev_dbg(dev, "\nLPM_%s_%d:\t0x%x\n", str, idx,
   997					lpm_regs[idx]);
   998			if (s)
   999				seq_printf(s, "\nLPM_%s_%d:\t0x%x\n", str, idx,
  1000					   lpm_regs[idx]);
  1001			for (index = 0; maps[idx][index].name && index < len; index++) {
  1002				bit_mask = maps[idx][index].bit_mask;
  1003				if (dev)
  1004					dev_dbg(dev, "%-30s %-30d\n",
  1005						maps[idx][index].name,
  1006						lpm_regs[idx] & bit_mask ? 1 : 0);
  1007				if (s)
  1008					seq_printf(s, "%-30s %-30d\n",
  1009						   maps[idx][index].name,
  1010						   lpm_regs[idx] & bit_mask ? 1 : 0);
  1011			}
  1012		}
  1013	}
  1014	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Patch
diff mbox series

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index f4a36fbabf4c..333c6963d270 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -979,10 +979,14 @@  static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
 				 const char *str,
 				 const struct pmc_bit_map **maps)
 {
-	u32 lpm_regs[ARRAY_SIZE(tgl_lpm_maps)-1];
-	int index, idx, len = 32, bit_mask;
+	int index, idx, len = 32, bit_mask, arr_size = 0;
 
-	for (index = 0; tgl_lpm_maps[index]; index++) {
+	for (index = 0; maps[index]; index++)
+		arr_size++;
+
+	u32 lpm_regs[arr_size];
+
+	for (index = 0; maps[index]; index++) {
 		lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
 		offset += 4;
 	}