* [PATCH v1 1/3] sata_dwc_460ex: use np local variable in ->probe()
@ 2015-01-08 10:50 Andy Shevchenko
2015-01-08 10:50 ` [PATCH v1 2/3] sata_dwc_460ex: remove extra message Andy Shevchenko
2015-01-08 10:50 ` [PATCH v1 3/3] sata_dwc_460ex: convert to devm_kzalloc in ->probe() Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-01-08 10:50 UTC (permalink / raw)
To: Rupjyoti Sarmah, Tejun Heo, linux-ide; +Cc: Andy Shevchenko
This patch fixes the style of usage of a node pointer. There is no functional
change.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ata/sata_dwc_460ex.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 6c1b649..b206017 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -1691,7 +1691,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
host_pvt.dma_channel = dma_chan;
/* Ioremap SATA registers */
- base = of_iomap(ofdev->dev.of_node, 0);
+ base = of_iomap(np, 0);
if (!base) {
dev_err(&ofdev->dev, "ioremap failed for SATA register"
" address\n");
@@ -1727,7 +1727,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
idr, ver[0], ver[1], ver[2]);
/* Get SATA DMA interrupt number */
- irq = irq_of_parse_and_map(ofdev->dev.of_node, 1);
+ irq = irq_of_parse_and_map(np, 1);
if (irq == NO_IRQ) {
dev_err(&ofdev->dev, "no SATA DMA irq\n");
err = -ENODEV;
@@ -1735,7 +1735,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
}
/* Get physical SATA DMA register base address */
- host_pvt.sata_dma_regs = (void *)of_iomap(ofdev->dev.of_node, 1);
+ host_pvt.sata_dma_regs = (void *)of_iomap(np, 1);
if (!(host_pvt.sata_dma_regs)) {
dev_err(&ofdev->dev, "ioremap failed for AHBDMA register"
" address\n");
@@ -1755,7 +1755,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
sata_dwc_enable_interrupts(hsdev);
/* Get SATA interrupt number */
- irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+ irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) {
dev_err(&ofdev->dev, "no SATA DMA irq\n");
err = -ENODEV;
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/3] sata_dwc_460ex: remove extra message
2015-01-08 10:50 [PATCH v1 1/3] sata_dwc_460ex: use np local variable in ->probe() Andy Shevchenko
@ 2015-01-08 10:50 ` Andy Shevchenko
2015-01-08 10:50 ` [PATCH v1 3/3] sata_dwc_460ex: convert to devm_kzalloc in ->probe() Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-01-08 10:50 UTC (permalink / raw)
To: Rupjyoti Sarmah, Tejun Heo, linux-ide; +Cc: Andy Shevchenko
There is no need to print a message about failure of memory allocation. The
caller will get an error code and may print the same.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ata/sata_dwc_460ex.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index b206017..169cbca 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -1677,11 +1677,8 @@ static int sata_dwc_probe(struct platform_device *ofdev)
/* Allocate DWC SATA device */
hsdev = kzalloc(sizeof(*hsdev), GFP_KERNEL);
- if (hsdev == NULL) {
- dev_err(&ofdev->dev, "kmalloc failed for hsdev\n");
- err = -ENOMEM;
- goto error;
- }
+ if (hsdev == NULL)
+ return -ENOMEM;
if (of_property_read_u32(np, "dma-channel", &dma_chan)) {
dev_warn(&ofdev->dev, "no dma-channel property set."
@@ -1783,7 +1780,6 @@ error_iomap:
iounmap(base);
error_kmalloc:
kfree(hsdev);
-error:
return err;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 3/3] sata_dwc_460ex: convert to devm_kzalloc in ->probe()
2015-01-08 10:50 [PATCH v1 1/3] sata_dwc_460ex: use np local variable in ->probe() Andy Shevchenko
2015-01-08 10:50 ` [PATCH v1 2/3] sata_dwc_460ex: remove extra message Andy Shevchenko
@ 2015-01-08 10:50 ` Andy Shevchenko
2015-01-08 13:31 ` Tejun Heo
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2015-01-08 10:50 UTC (permalink / raw)
To: Rupjyoti Sarmah, Tejun Heo, linux-ide; +Cc: Andy Shevchenko
The patch converts ->probe() to use devm_kzalloc that simplifies error path.
Note that ata_host_alloc_pinfo() has been using device resources already.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ata/sata_dwc_460ex.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 169cbca..fdb0f28 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -1676,10 +1676,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
u32 dma_chan;
/* Allocate DWC SATA device */
- hsdev = kzalloc(sizeof(*hsdev), GFP_KERNEL);
- if (hsdev == NULL)
+ host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
+ hsdev = devm_kzalloc(&ofdev->dev, sizeof(*hsdev), GFP_KERNEL);
+ if (!host || !hsdev)
return -ENOMEM;
+ host->private_data = hsdev;
+
if (of_property_read_u32(np, "dma-channel", &dma_chan)) {
dev_warn(&ofdev->dev, "no dma-channel property set."
" Use channel 0\n");
@@ -1692,8 +1695,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
if (!base) {
dev_err(&ofdev->dev, "ioremap failed for SATA register"
" address\n");
- err = -ENODEV;
- goto error_kmalloc;
+ return -ENODEV;
}
hsdev->reg_base = base;
dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
@@ -1701,16 +1703,6 @@ static int sata_dwc_probe(struct platform_device *ofdev)
/* Synopsys DWC SATA specific Registers */
hsdev->sata_dwc_regs = (void *__iomem)(base + SATA_DWC_REG_OFFSET);
- /* Allocate and fill host */
- host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
- if (!host) {
- dev_err(&ofdev->dev, "ata_host_alloc_pinfo failed\n");
- err = -ENOMEM;
- goto error_iomap;
- }
-
- host->private_data = hsdev;
-
/* Setup port */
host->ports[0]->ioaddr.cmd_addr = base;
host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET;
@@ -1778,8 +1770,6 @@ error_dma_iomap:
iounmap((void __iomem *)host_pvt.sata_dma_regs);
error_iomap:
iounmap(base);
-error_kmalloc:
- kfree(hsdev);
return err;
}
@@ -1796,8 +1786,6 @@ static int sata_dwc_remove(struct platform_device *ofdev)
iounmap((void __iomem *)host_pvt.sata_dma_regs);
iounmap(hsdev->reg_base);
- kfree(hsdev);
- kfree(host);
dev_dbg(&ofdev->dev, "done\n");
return 0;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 3/3] sata_dwc_460ex: convert to devm_kzalloc in ->probe()
2015-01-08 10:50 ` [PATCH v1 3/3] sata_dwc_460ex: convert to devm_kzalloc in ->probe() Andy Shevchenko
@ 2015-01-08 13:31 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2015-01-08 13:31 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Rupjyoti Sarmah, linux-ide
On Thu, Jan 08, 2015 at 12:50:14PM +0200, Andy Shevchenko wrote:
> The patch converts ->probe() to use devm_kzalloc that simplifies error path.
> Note that ata_host_alloc_pinfo() has been using device resources already.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied 1-3 to libata/for-3.20.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-08 13:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 10:50 [PATCH v1 1/3] sata_dwc_460ex: use np local variable in ->probe() Andy Shevchenko
2015-01-08 10:50 ` [PATCH v1 2/3] sata_dwc_460ex: remove extra message Andy Shevchenko
2015-01-08 10:50 ` [PATCH v1 3/3] sata_dwc_460ex: convert to devm_kzalloc in ->probe() Andy Shevchenko
2015-01-08 13:31 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).