From: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro returns the ACPI handle of the ACPI device
object returned by the ACPI_COMPANION() macro, so it is more
straightforward to evaluate the latter directly instead of passing
the handle produced by the former to acpi_bus_get_device().
Modify the code accordingly (no intentional functional impact).
Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/acpi_lpss.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Index: linux-pm/drivers/acpi/acpi_lpss.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_lpss.c
+++ linux-pm/drivers/acpi/acpi_lpss.c
@@ -712,14 +712,13 @@ static void __lpss_reg_write(u32 val, st
static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val)
{
- struct acpi_device *adev;
+ struct acpi_device *adev = ACPI_COMPANION(dev);
struct lpss_private_data *pdata;
unsigned long flags;
int ret;
- ret = acpi_bus_get_device(ACPI_HANDLE(dev), &adev);
- if (WARN_ON(ret))
- return ret;
+ if (WARN_ON(!adev))
+ return -ENODEV;
spin_lock_irqsave(&dev->power.lock, flags);
if (pm_runtime_suspended(dev)) {
@@ -1266,7 +1265,8 @@ static int acpi_lpss_platform_notify(str
if (!id || !id->driver_data)
return 0;
- if (acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev))
+ adev = ACPI_COMPANION(&pdev->dev);
+ if (!adev)
return 0;
pdata = acpi_driver_data(adev);
Hi "Rafael,
I love your patch! Perhaps something to improve:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on v5.15-rc4 next-20211008]
[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]
url: https://github.com/0day-ci/linux/commits/Rafael-J-Wysocki/ACPI-LPSS-Use-ACPI_COMPANION-directly/20211009-222505
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: i386-randconfig-a013-20211009 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 30caca39f401ae17927439c0a0bd6d1b1916dd6a)
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/0day-ci/linux/commit/6fd0aa7da4af33b790cf8e5a943fe2795a8f215a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Rafael-J-Wysocki/ACPI-LPSS-Use-ACPI_COMPANION-directly/20211009-222505
git checkout 6fd0aa7da4af33b790cf8e5a943fe2795a8f215a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
>> drivers/acpi/acpi_lpss.c:729:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (WARN_ON(!pdata || !pdata->mmio_base)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/bug.h:120:28: note: expanded from macro 'WARN_ON'
#define WARN_ON(condition) ({ \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/acpi_lpss.c:737:9: note: uninitialized use occurs here
return ret;
^~~
drivers/acpi/acpi_lpss.c:729:2: note: remove the 'if' if its condition is always true
if (WARN_ON(!pdata || !pdata->mmio_base)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/acpi_lpss.c:718:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.
vim +729 drivers/acpi/acpi_lpss.c
1a8f83515c1646 Rafael J. Wysocki 2014-02-11 712
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 713 static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val)
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 714 {
6fd0aa7da4af33 Rafael J. Wysocki 2021-10-09 715 struct acpi_device *adev = ACPI_COMPANION(dev);
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 716 struct lpss_private_data *pdata;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 717 unsigned long flags;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 718 int ret;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 719
6fd0aa7da4af33 Rafael J. Wysocki 2021-10-09 720 if (WARN_ON(!adev))
6fd0aa7da4af33 Rafael J. Wysocki 2021-10-09 721 return -ENODEV;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 722
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 723 spin_lock_irqsave(&dev->power.lock, flags);
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 724 if (pm_runtime_suspended(dev)) {
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 725 ret = -EAGAIN;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 726 goto out;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 727 }
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 728 pdata = acpi_driver_data(adev);
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 @729 if (WARN_ON(!pdata || !pdata->mmio_base)) {
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 730 ret = -ENODEV;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 731 goto out;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 732 }
1a8f83515c1646 Rafael J. Wysocki 2014-02-11 733 *val = __lpss_reg_read(pdata, reg);
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 734
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 735 out:
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 736 spin_unlock_irqrestore(&dev->power.lock, flags);
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 737 return ret;
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 738 }
2e0f8822d1a6d8 Rafael J. Wysocki 2013-03-06 739
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]