RE: [PATCH v4 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - General]

> -----Original Message-----
> From: S-k, Shyam-sundar <Shyam-sundar.S-k@xxxxxxx>
> Sent: Thursday, May 25, 2023 6:50 AM
> To: hdegoede@xxxxxxxxxx; markgross@xxxxxxxxxx
> Cc: Goswami, Sanket <Sanket.Goswami@xxxxxxx>; Limonciello, Mario
> <Mario.Limonciello@xxxxxxx>; platform-driver-x86@xxxxxxxxxxxxxxx; S-k,
> Shyam-sundar <Shyam-sundar.S-k@xxxxxxx>
> Subject: [PATCH v4 3/4] platform/x86/amd: pmc: Add helper function to
> check the cpu id
>
> 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@xxxxxxx>
> Signed-off-by: Sanket Goswami <Sanket.Goswami@xxxxxxx>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@xxxxxxx>
> ---
>  drivers/platform/x86/amd/pmc.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmc.c
> b/drivers/platform/x86/amd/pmc.c
> index e2439fda5c02..db0c330d4b85 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -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_cpu_supported(struct amd_pmc_dev *dev)

I wonder if it would make things clearer to the casual reader of this
code to name this differently.

Perhaps:

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_cpu_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_cpu_supported(dev)) {
>               err = amd_pmc_s2d_init(dev);
>               if (err)
>                       goto err_pci_dev_put;
> --
> 2.25.1





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux