diff mbox series

[v2,6/8] perf: qcom_l2_pmu: Refactor _UID handling to use acpi_dev_uid_to_integer()

Message ID 20220908132910.62122-7-andriy.shevchenko@linux.intel.com
State New
Headers show
Series ACPI: unify _UID handling as integer | expand

Commit Message

Andy Shevchenko Sept. 8, 2022, 1:29 p.m. UTC
ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/perf/qcom_l2_pmu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

kernel test robot Sept. 9, 2022, 4:40 a.m. UTC | #1
Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on wsa/i2c/for-next broonie-spi/for-next efi/next linus/master v6.0-rc4 next-20220908]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/ACPI-unify-_UID-handling-as-integer/20220908-213543
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220909/202209091254.rIFedxQL-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/9441434beecbf7fcd74ca58adbb06cc53c874179
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/ACPI-unify-_UID-handling-as-integer/20220908-213543
        git checkout 9441434beecbf7fcd74ca58adbb06cc53c874179
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/perf/

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

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from include/linux/acpi.h:15,
                    from drivers/perf/qcom_l2_pmu.c:4:
   drivers/perf/qcom_l2_pmu.c: In function 'l2_cache_pmu_probe_cluster':
>> drivers/perf/qcom_l2_pmu.c:882:17: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u64' {aka 'long long unsigned int'} [-Wformat=]
     882 |                 "Registered L2 cache PMU cluster %ld\n", fw_cluster_id);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
     150 |         dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                          ^~~~~~~
   drivers/perf/qcom_l2_pmu.c:881:9: note: in expansion of macro 'dev_info'
     881 |         dev_info(&pdev->dev,
         |         ^~~~~~~~
   drivers/perf/qcom_l2_pmu.c:882:52: note: format string is defined here
     882 |                 "Registered L2 cache PMU cluster %ld\n", fw_cluster_id);
         |                                                  ~~^
         |                                                    |
         |                                                    long int
         |                                                  %lld


vim +882 drivers/perf/qcom_l2_pmu.c

21bdbb7102edea Neil Leeder     2017-02-07  838  
21bdbb7102edea Neil Leeder     2017-02-07  839  static int l2_cache_pmu_probe_cluster(struct device *dev, void *data)
21bdbb7102edea Neil Leeder     2017-02-07  840  {
21bdbb7102edea Neil Leeder     2017-02-07  841  	struct platform_device *pdev = to_platform_device(dev->parent);
21bdbb7102edea Neil Leeder     2017-02-07  842  	struct platform_device *sdev = to_platform_device(dev);
21bdbb7102edea Neil Leeder     2017-02-07  843  	struct l2cache_pmu *l2cache_pmu = data;
21bdbb7102edea Neil Leeder     2017-02-07  844  	struct cluster_pmu *cluster;
9441434beecbf7 Andy Shevchenko 2022-09-08  845  	u64 fw_cluster_id;
21bdbb7102edea Neil Leeder     2017-02-07  846  	int err;
21bdbb7102edea Neil Leeder     2017-02-07  847  	int irq;
21bdbb7102edea Neil Leeder     2017-02-07  848  
9441434beecbf7 Andy Shevchenko 2022-09-08  849  	err = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &fw_cluster_id);
9441434beecbf7 Andy Shevchenko 2022-09-08  850  	if (err) {
21bdbb7102edea Neil Leeder     2017-02-07  851  		dev_err(&pdev->dev, "unable to read ACPI uid\n");
9441434beecbf7 Andy Shevchenko 2022-09-08  852  		return err;
21bdbb7102edea Neil Leeder     2017-02-07  853  	}
21bdbb7102edea Neil Leeder     2017-02-07  854  
21bdbb7102edea Neil Leeder     2017-02-07  855  	cluster = devm_kzalloc(&pdev->dev, sizeof(*cluster), GFP_KERNEL);
21bdbb7102edea Neil Leeder     2017-02-07  856  	if (!cluster)
21bdbb7102edea Neil Leeder     2017-02-07  857  		return -ENOMEM;
21bdbb7102edea Neil Leeder     2017-02-07  858  
21bdbb7102edea Neil Leeder     2017-02-07  859  	INIT_LIST_HEAD(&cluster->next);
21bdbb7102edea Neil Leeder     2017-02-07  860  	list_add(&cluster->next, &l2cache_pmu->clusters);
21bdbb7102edea Neil Leeder     2017-02-07  861  	cluster->cluster_id = fw_cluster_id;
21bdbb7102edea Neil Leeder     2017-02-07  862  
21bdbb7102edea Neil Leeder     2017-02-07  863  	irq = platform_get_irq(sdev, 0);
228f855fb57ae2 Stephen Boyd    2019-07-30  864  	if (irq < 0)
21bdbb7102edea Neil Leeder     2017-02-07  865  		return irq;
21bdbb7102edea Neil Leeder     2017-02-07  866  	cluster->irq = irq;
21bdbb7102edea Neil Leeder     2017-02-07  867  
21bdbb7102edea Neil Leeder     2017-02-07  868  	cluster->l2cache_pmu = l2cache_pmu;
21bdbb7102edea Neil Leeder     2017-02-07  869  	cluster->on_cpu = -1;
21bdbb7102edea Neil Leeder     2017-02-07  870  
21bdbb7102edea Neil Leeder     2017-02-07  871  	err = devm_request_irq(&pdev->dev, irq, l2_cache_handle_irq,
0d0f144a8f5f98 Tian Tao        2021-06-02  872  			       IRQF_NOBALANCING | IRQF_NO_THREAD |
0d0f144a8f5f98 Tian Tao        2021-06-02  873  			       IRQF_NO_AUTOEN,
21bdbb7102edea Neil Leeder     2017-02-07  874  			       "l2-cache-pmu", cluster);
21bdbb7102edea Neil Leeder     2017-02-07  875  	if (err) {
21bdbb7102edea Neil Leeder     2017-02-07  876  		dev_err(&pdev->dev,
21bdbb7102edea Neil Leeder     2017-02-07  877  			"Unable to request IRQ%d for L2 PMU counters\n", irq);
21bdbb7102edea Neil Leeder     2017-02-07  878  		return err;
21bdbb7102edea Neil Leeder     2017-02-07  879  	}
21bdbb7102edea Neil Leeder     2017-02-07  880  
21bdbb7102edea Neil Leeder     2017-02-07  881  	dev_info(&pdev->dev,
21bdbb7102edea Neil Leeder     2017-02-07 @882  		"Registered L2 cache PMU cluster %ld\n", fw_cluster_id);
21bdbb7102edea Neil Leeder     2017-02-07  883  
21bdbb7102edea Neil Leeder     2017-02-07  884  	spin_lock_init(&cluster->pmu_lock);
21bdbb7102edea Neil Leeder     2017-02-07  885  
21bdbb7102edea Neil Leeder     2017-02-07  886  	l2cache_pmu->num_pmus++;
21bdbb7102edea Neil Leeder     2017-02-07  887  
21bdbb7102edea Neil Leeder     2017-02-07  888  	return 0;
21bdbb7102edea Neil Leeder     2017-02-07  889  }
21bdbb7102edea Neil Leeder     2017-02-07  890
Andy Shevchenko Sept. 9, 2022, 8:44 a.m. UTC | #2
On Fri, Sep 09, 2022 at 12:40:36PM +0800, kernel test robot wrote:
> Hi Andy,
> 
> I love your patch! Perhaps something to improve:

Indeed.

> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/device.h:15,
>                     from include/linux/acpi.h:15,
>                     from drivers/perf/qcom_l2_pmu.c:4:
>    drivers/perf/qcom_l2_pmu.c: In function 'l2_cache_pmu_probe_cluster':
> >> drivers/perf/qcom_l2_pmu.c:882:17: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u64' {aka 'long long unsigned int'} [-Wformat=]

Fixed locally.
diff mbox series

Patch

diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c
index 30234c261b05..ad4a41e1287f 100644
--- a/drivers/perf/qcom_l2_pmu.c
+++ b/drivers/perf/qcom_l2_pmu.c
@@ -840,16 +840,16 @@  static int l2_cache_pmu_probe_cluster(struct device *dev, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev->parent);
 	struct platform_device *sdev = to_platform_device(dev);
-	struct acpi_device *adev = ACPI_COMPANION(dev);
 	struct l2cache_pmu *l2cache_pmu = data;
 	struct cluster_pmu *cluster;
-	unsigned long fw_cluster_id;
+	u64 fw_cluster_id;
 	int err;
 	int irq;
 
-	if (!adev || kstrtoul(adev->pnp.unique_id, 10, &fw_cluster_id) < 0) {
+	err = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &fw_cluster_id);
+	if (err) {
 		dev_err(&pdev->dev, "unable to read ACPI uid\n");
-		return -ENODEV;
+		return err;
 	}
 
 	cluster = devm_kzalloc(&pdev->dev, sizeof(*cluster), GFP_KERNEL);