ata: sata_highbank: use devm_platform_ioremap_resource
PATCH 1/1 ata: sata_highbank: use devm_platform_ioremap_resource
Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with devm_platform_ioremap_resource(), which fetches the resource, requests the region and maps it in one call. Switch the error check to IS_ERR()/PTR_ERR() and drop the now-unused struct resource pointer.
There is a single IORESOURCE_MEM resource, and the SATA PHY registers are mapped separately via of_iomap() from distinct DT nodes, so the region reservation added by devm_ioremap_resource() is exclusive and does not introduce overlap failures.
The mem-based ata_port_desc() line is dropped along with the resource pointer; the remaining per-port description is retained.
Built for ARM (drivers/ata/sata_highbank.o) with LLVM=1.
--- drivers/ata/sata_highbank.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/ata/sata_highbank.c +5 -13
@@ -455,7 +455,7 @@ static int ahci_highbank_probe(struct platform_device *pdev)struct ahci_host_priv *hpriv;struct ecx_plat_data *pdata;struct ata_host *host; -struct resource *mem; +void __iomem *mmio;int irq;int i;int rc;
@@ -463,11 +463,9 @@ static int ahci_highbank_probe(struct platform_device *pdev)struct ata_port_info pi = ahci_highbank_port_info;const struct ata_port_info *ppi[] = { &pi,NULL }; - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!mem) { -dev_err (dev,"no mmio space\n" ); -return -EINVAL ; - } + mmio =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (mmio)) +return PTR_ERR (mmio); irq =platform_get_irq (pdev,0 );if (irq <0 )
@@ -488,12 +486,7 @@ static int ahci_highbank_probe(struct platform_device *pdev) hpriv->irq = irq; hpriv->flags |= (unsigned long )pi.private_data; - - hpriv->mmio =devm_ioremap (dev, mem->start,resource_size (mem)); -if (!hpriv->mmio) { -dev_err (dev,"can't map %pR\n" , mem); -return -ENOMEM ; - } + hpriv->mmio = mmio; rc =highbank_initialize_phys (dev, hpriv->mmio);if (rc)
@@ -537,7 +530,6 @@ static int ahci_highbank_probe(struct platform_device *pdev)for (i =0 ; i < host->n_ports; i++) {struct ata_port *ap = host->ports[i]; -ata_port_desc (ap,"mmio %pR" , mem);ata_port_desc (ap,"port 0x%x" ,0x100 + ap->port_no *0x80 );/* set enclosure management message type */
Signature · 1 line
2.55.0
Quoted 11 lines · Rosen Penev
Replace the open-coded
platform_get_resource()plusdevm_ioremap()sequence withdevm_platform_ioremap_resource(), which fetches the resource, requests the region and maps it in one call. Switch the error check to IS_ERR()/PTR_ERR() and drop the now-unused struct resource pointer.There is a single
IORESOURCE_MEMresource, and the SATA PHY registers are mapped separately viaof_iomap()from distinct DT nodes, so the region reservation added bydevm_ioremap_resource()is exclusive and does not introduce overlap failures.
Quoted 7 lines
The mem-based
ata_port_desc()line is dropped along with the resource pointer; the remaining per-port description is retained.Built for ARM (
drivers/ata/sata_highbank.o) with LLVM=1.Assisted-by opencode:hy3-freeSigned-off-by Rosen Penev <[email protected]>
Applied to for-7.3. Thanks!
Signature · 2 lines
Damien Le Moal Western Digital Research