Skip to contentSkip to conversation

mmc: sdhci-acpi: Spring cleanup

PATCH In review Andy Shevchenko 3 participants 6 messages Apr 12, 2024 – Apr 15, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mmc: sdhci-acpi: Spring cleanup

Two independent cleanups for the driver because of new available APIs.

Andy Shevchenko (2):
mmc: sdhci-acpi: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and

    pm_ptr()

mmc: sdhci-acpi: Use devm_platform_ioremap_resource()

 drivers/mmc/host/sdhci-acpi.c | 35 ++++++-----------------------------
 1 file changed, 6 insertions(+), 29 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw

PATCH 1/2 mmc: sdhci-acpi: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr()

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated now and require an ifdeffery protection against unused function warnings. The usage of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() allows the compiler to see the functions, thus suppressing the warning. Thus drop the ifdeffery protection.

---
 drivers/mmc/host/sdhci-acpi.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-acpi.c +3 -12
index acf5fc3ad7e4..32ae6f763c1d 100644
@@ -957,8 +957,6 @@ static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
-
 static int sdhci_acpi_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
@@ -985,10 +983,6 @@ static int sdhci_acpi_resume(struct device *dev)
 	return sdhci_resume_host(c->host);
 }
 
-#endif
-
-#ifdef CONFIG_PM
-
 static int sdhci_acpi_runtime_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
@@ -1015,12 +1009,9 @@ static int sdhci_acpi_runtime_resume(struct device *dev)
 	return sdhci_runtime_resume_host(c->host, 0);
 }
 
-#endif
-
 static const struct dev_pm_ops sdhci_acpi_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
-	SET_RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend,
-			sdhci_acpi_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
+	RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend, sdhci_acpi_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_acpi_driver = {
@@ -1028,7 +1019,7 @@ static struct platform_driver sdhci_acpi_driver = {
 		.name			= "sdhci-acpi",
 		.probe_type		= PROBE_PREFER_ASYNCHRONOUS,
 		.acpi_match_table	= sdhci_acpi_ids,
-		.pm			= &sdhci_acpi_pm_ops,
+		.pm			= pm_ptr(&sdhci_acpi_pm_ops),
 	},
 	.probe	= sdhci_acpi_probe,
 	.remove_new = sdhci_acpi_remove,
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#2 lore raw

Re: [PATCH v1 1/2] mmc: sdhci-acpi: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr()

kernel test robot noticed the following build errors:

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.9-rc4 next-20240412]
[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/mmc-sdhci-acpi-Switch-to-SYSTEM_SLEEP_PM_OPS-RUNTIME_PM_OPS-and-pm_ptr/20240415-093843
base:   linus/master
patch link:    https://lore.kernel.org/r/20240412184706.366879-3-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 1/2] mmc: sdhci-acpi: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr()
config: i386-randconfig-002-20240415 (https://download.01.org/0day-ci/archive/20240415/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240415/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/mmc/host/sdhci-acpi.c:969:8: error: call to undeclared function 'sdhci_suspend_host'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     969 |         ret = sdhci_suspend_host(host);
         |               ^
>> drivers/mmc/host/sdhci-acpi.c:983:9: error: call to undeclared function 'sdhci_resume_host'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     983 |         return sdhci_resume_host(c->host);
         |                ^
   drivers/mmc/host/sdhci-acpi.c:983:9: note: did you mean 'sdhci_remove_host'?
   drivers/mmc/host/sdhci.h:771:6: note: 'sdhci_remove_host' declared here
     771 | void sdhci_remove_host(struct sdhci_host *host, int dead);
         |      ^
>> drivers/mmc/host/sdhci-acpi.c:995:8: error: call to undeclared function 'sdhci_runtime_suspend_host'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     995 |         ret = sdhci_runtime_suspend_host(host);
         |               ^
>> drivers/mmc/host/sdhci-acpi.c:1009:9: error: call to undeclared function 'sdhci_runtime_resume_host'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1009 |         return sdhci_runtime_resume_host(c->host, 0);
         |                ^

4 errors generated.

vim +/sdhci_suspend_host +969 drivers/mmc/host/sdhci-acpi.c

84d49b3d08a1d3 Hans de Goede 2020-03-16   959  
c4e050376c69bb Adrian Hunter 2012-11-23   960  static int sdhci_acpi_suspend(struct device *dev)
c4e050376c69bb Adrian Hunter 2012-11-23   961  {
c4e050376c69bb Adrian Hunter 2012-11-23   962  	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
d38dcad4e7b48f Adrian Hunter 2017-03-20   963  	struct sdhci_host *host = c->host;
84d49b3d08a1d3 Hans de Goede 2020-03-16   964  	int ret;
c4e050376c69bb Adrian Hunter 2012-11-23   965  
d38dcad4e7b48f Adrian Hunter 2017-03-20   966  	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
d38dcad4e7b48f Adrian Hunter 2017-03-20   967  		mmc_retune_needed(host->mmc);
d38dcad4e7b48f Adrian Hunter 2017-03-20   968  
84d49b3d08a1d3 Hans de Goede 2020-03-16  @969  	ret = sdhci_suspend_host(host);
84d49b3d08a1d3 Hans de Goede 2020-03-16   970  	if (ret)
84d49b3d08a1d3 Hans de Goede 2020-03-16   971  		return ret;
84d49b3d08a1d3 Hans de Goede 2020-03-16   972  
84d49b3d08a1d3 Hans de Goede 2020-03-16   973  	sdhci_acpi_reset_signal_voltage_if_needed(dev);
84d49b3d08a1d3 Hans de Goede 2020-03-16   974  	return 0;
c4e050376c69bb Adrian Hunter 2012-11-23   975  }
c4e050376c69bb Adrian Hunter 2012-11-23   976  
c4e050376c69bb Adrian Hunter 2012-11-23   977  static int sdhci_acpi_resume(struct device *dev)
c4e050376c69bb Adrian Hunter 2012-11-23   978  {
c4e050376c69bb Adrian Hunter 2012-11-23   979  	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
c4e050376c69bb Adrian Hunter 2012-11-23   980  
6e1c7d6103fe70 Adrian Hunter 2016-04-15   981  	sdhci_acpi_byt_setting(&c->pdev->dev);
6e1c7d6103fe70 Adrian Hunter 2016-04-15   982  
c4e050376c69bb Adrian Hunter 2012-11-23  @983  	return sdhci_resume_host(c->host);
c4e050376c69bb Adrian Hunter 2012-11-23   984  }
c4e050376c69bb Adrian Hunter 2012-11-23   985  
c4e050376c69bb Adrian Hunter 2012-11-23   986  static int sdhci_acpi_runtime_suspend(struct device *dev)
c4e050376c69bb Adrian Hunter 2012-11-23   987  {
c4e050376c69bb Adrian Hunter 2012-11-23   988  	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
d38dcad4e7b48f Adrian Hunter 2017-03-20   989  	struct sdhci_host *host = c->host;
84d49b3d08a1d3 Hans de Goede 2020-03-16   990  	int ret;
d38dcad4e7b48f Adrian Hunter 2017-03-20   991  
d38dcad4e7b48f Adrian Hunter 2017-03-20   992  	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
d38dcad4e7b48f Adrian Hunter 2017-03-20   993  		mmc_retune_needed(host->mmc);
c4e050376c69bb Adrian Hunter 2012-11-23   994  
84d49b3d08a1d3 Hans de Goede 2020-03-16  @995  	ret = sdhci_runtime_suspend_host(host);
84d49b3d08a1d3 Hans de Goede 2020-03-16   996  	if (ret)
84d49b3d08a1d3 Hans de Goede 2020-03-16   997  		return ret;
84d49b3d08a1d3 Hans de Goede 2020-03-16   998  
84d49b3d08a1d3 Hans de Goede 2020-03-16   999  	sdhci_acpi_reset_signal_voltage_if_needed(dev);
84d49b3d08a1d3 Hans de Goede 2020-03-16  1000  	return 0;
c4e050376c69bb Adrian Hunter 2012-11-23  1001  }
c4e050376c69bb Adrian Hunter 2012-11-23  1002  
c4e050376c69bb Adrian Hunter 2012-11-23  1003  static int sdhci_acpi_runtime_resume(struct device *dev)
c4e050376c69bb Adrian Hunter 2012-11-23  1004  {
c4e050376c69bb Adrian Hunter 2012-11-23  1005  	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
c4e050376c69bb Adrian Hunter 2012-11-23  1006  
6e1c7d6103fe70 Adrian Hunter 2016-04-15  1007  	sdhci_acpi_byt_setting(&c->pdev->dev);
6e1c7d6103fe70 Adrian Hunter 2016-04-15  1008  

c6303c5d52d5ec Baolin Wang 2019-07-25 @1009 return sdhci_runtime_resume_host(c->host, 0);
c4e050376c69bb Adrian Hunter 2012-11-23 1010 }
c4e050376c69bb Adrian Hunter 2012-11-23 1011

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

PATCH 2/2 mmc: sdhci-acpi: Use devm_platform_ioremap_resource()

In reply to Andy Shevchenko

The struct resource is not used for anything else, so we can simplify the code a bit by using the helper function.

---
 drivers/mmc/host/sdhci-acpi.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/mmc/host/sdhci-acpi.c +3 -17
index 32ae6f763c1d..b9c8eb87a01a 100644
@@ -779,8 +779,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 	struct acpi_device *device;
 	struct sdhci_acpi_host *c;
 	struct sdhci_host *host;
-	struct resource *iomem;
-	resource_size_t len;
 	size_t priv_size;
 	int quirks = 0;
 	int err;
@@ -801,17 +799,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 	if (sdhci_acpi_byt_defer(dev))
 		return -EPROBE_DEFER;
 
-	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!iomem)
-		return -ENOMEM;
-
-	len = resource_size(iomem);
-	if (len < 0x100)
-		dev_err(dev, "Invalid iomem size!\n");
-
-	if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev)))
-		return -ENOMEM;
-
 	priv_size = slot ? slot->priv_size : 0;
 	host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host) + priv_size);
 	if (IS_ERR(host))
@@ -833,10 +820,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 		goto err_free;
 	}
 
-	host->ioaddr = devm_ioremap(dev, iomem->start,
-					    resource_size(iomem));
-	if (host->ioaddr == NULL) {
-		err = -ENOMEM;
+	host->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(host->ioaddr)) {
+		err = PTR_ERR(host->ioaddr);
 		goto err_free;
 	}
 
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#4 lore raw

Re: [PATCH v1 2/2] mmc: sdhci-acpi: Use devm_platform_ioremap_resource()

Le 12/04/2024 à 20:46, Andy Shevchenko a écrit :

Quoted 22 lines

The struct resource is not used for anything else, so we can simplify the code a bit by using the helper function.

---
  drivers/mmc/host/sdhci-acpi.c | 20 +++-----------------
  1 file changed, 3 insertions(+), 17 deletions(-)
drivers/mmc/host/sdhci-acpi.c +0 -2
index 32ae6f763c1d..b9c8eb87a01a 100644
@@ -779,8 +779,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
  	struct acpi_device *device;
  	struct sdhci_acpi_host *c;
  	struct sdhci_host *host;
-	struct resource *iomem;
-	resource_size_t len;
  	size_t priv_size;
  	int quirks = 0;
  	int err;

drivers/mmc/host/sdhci-acpi.c static int sdhci_acpi_probe(struct platform_device *pdev) · line 810

Quoted 10 lines
drivers/mmc/host/sdhci-acpi.c +0 -7
@@ -801,17 +799,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
  	if (sdhci_acpi_byt_defer(dev))
  		return -EPROBE_DEFER;
 
-	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!iomem)
-		return -ENOMEM;
-
-	len = resource_size(iomem);
-	if (len < 0x100)
-		dev_err(dev, "Invalid iomem size!\n");

HI,

Was this test useful?
Should it be mentioned in the commit message?

CJ

Quoted 21 lines
drivers/mmc/host/sdhci-acpi.c +3 -8
-
-	if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev)))
-		return -ENOMEM;
-
  	priv_size = slot ? slot->priv_size : 0;
  	host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host) + priv_size);
  	if (IS_ERR(host))
@@ -833,10 +820,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
  		goto err_free;
  	}
 
-	host->ioaddr = devm_ioremap(dev, iomem->start,
-					    resource_size(iomem));
-	if (host->ioaddr == NULL) {
-		err = -ENOMEM;
+	host->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(host->ioaddr)) {
+		err = PTR_ERR(host->ioaddr);
  		goto err_free;
  	}
 
#5 lore raw

Re: [PATCH v1 2/2] mmc: sdhci-acpi: Use devm_platform_ioremap_resource()

Quoted 1 line · Christophe JAILLET

Le 12/04/2024 à 20:46, Andy Shevchenko a écrit :

...

Quoted 5 lines

drivers/mmc/host/sdhci-acpi.c static int sdhci_acpi_probe(struct platform_device *pdev) · line 810

Quoted 3 lines
drivers/mmc/host/sdhci-acpi.c +0 -3
-	len = resource_size(iomem);
-	if (len < 0x100)
-		dev_err(dev, "Invalid iomem size!\n");

Was this test useful?

I'm not sure. ioremap anyway works on page size granularity on many architectures, but even besides that, the check was from day 1 for unknown reasons. Perhaps can be safely removed.

Quoted 1 line

Should it be mentioned in the commit message?

Or in a separate patch. I'll think about it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko