The struct resource is not used for anything else, so we can simplify
the code a bit by using the helper function.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/mmc/host/sdhci-acpi.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 32ae6f763c1d..b9c8eb87a01a 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -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;
}
--
2.43.0.rc1.1336.g36b5255a03ac
Le 12/04/2024 à 20:46, Andy Shevchenko a écrit :
> The struct resource is not used for anything else, so we can simplify
> the code a bit by using the helper function.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/mmc/host/sdhci-acpi.c | 20 +++-----------------
> 1 file changed, 3 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
> index 32ae6f763c1d..b9c8eb87a01a 100644
> --- a/drivers/mmc/host/sdhci-acpi.c
> +++ b/drivers/mmc/host/sdhci-acpi.c
> @@ -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");
HI,
Was this test useful?
Should it be mentioned in the commit message?
CJ
> -
> - 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;
> }
>
On Mon, Apr 15, 2024 at 07:20:49AM +0200, Christophe JAILLET wrote: > Le 12/04/2024 à 20:46, Andy Shevchenko a écrit : ... > > - 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. > Should it be mentioned in the commit message? Or in a separate patch. I'll think about it. -- With Best Regards, Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.