platform/x86/amd: pmc: Add helper function to check the cpu id
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Thu, 25 May 2023 14:19:28 +0000 (19:49 +0530)
committerHans de Goede <hdegoede@redhat.com>
Tue, 30 May 2023 09:08:19 +0000 (11:08 +0200)
Add a helper routine to check the underlying cpu id, that can be used
across the PMC driver to remove the duplicate code.

Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230525141929.866385-4-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/amd/pmc.c

index e2439fda5c02c037fa51cf4251b503f6b256abab..c2f03cdc9ca9d87dc27cbe2f3c0ebd6e9cf74513 100644 (file)
@@ -564,6 +564,18 @@ static void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)
        debugfs_remove_recursive(dev->dbgfs_dir);
 }
 
+static bool amd_pmc_is_stb_supported(struct amd_pmc_dev *dev)
+{
+       switch (dev->cpu_id) {
+       case AMD_CPU_ID_YC:
+       case AMD_CPU_ID_CB:
+       case AMD_CPU_ID_PS:
+               return true;
+       default:
+               return false;
+       }
+}
+
 static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
 {
        dev->dbgfs_dir = debugfs_create_dir("amd_pmc", NULL);
@@ -575,8 +587,7 @@ static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
                            &amd_pmc_idlemask_fops);
        /* Enable STB only when the module_param is set */
        if (enable_stb) {
-               if (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB ||
-                   dev->cpu_id == AMD_CPU_ID_PS)
+               if (amd_pmc_is_stb_supported(dev))
                        debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
                                            &amd_pmc_stb_debugfs_fops_v2);
                else
@@ -1036,7 +1047,7 @@ static int amd_pmc_probe(struct platform_device *pdev)
 
        mutex_init(&dev->lock);
 
-       if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB)) {
+       if (enable_stb && amd_pmc_is_stb_supported(dev)) {
                err = amd_pmc_s2d_init(dev);
                if (err)
                        goto err_pci_dev_put;