Use devm_platform_get_and_ioremap_resource() and
devm_platform_ioremap_resource() APIs instead of their
open coded analogues.
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/ata/sata_dwc_460ex.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 338c2e50f759..513bee589d12 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -237,7 +237,6 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
struct sata_dwc_device *hsdev)
{
struct device_node *np = pdev->dev.of_node;
- struct resource *res;
hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL);
if (!hsdev->dma)
@@ -254,8 +253,7 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
}
/* Get physical SATA DMA register base address */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res);
+ hsdev->dma->regs = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(hsdev->dma->regs))
return PTR_ERR(hsdev->dma->regs);
@@ -1228,8 +1226,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
host->private_data = hsdev;
/* Ioremap SATA registers */
- res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
- base = devm_ioremap_resource(&ofdev->dev, res);
+ base = devm_platform_get_and_ioremap_resource(ofdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
--
2.33.0
Use temporary variable for struct device to make code neater.
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/ata/sata_dwc_460ex.c | 37 ++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 513bee589d12..5421f74c0199 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -215,9 +215,10 @@ static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
{
struct sata_dwc_device *hsdev = hsdevp->hsdev;
struct dw_dma_slave *dws = &sata_dwc_dma_dws;
+ struct device *dev = hsdev->dev;
dma_cap_mask_t mask;
- dws->dma_dev = hsdev->dev;
+ dws->dma_dev = dev;
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
@@ -225,8 +226,7 @@ static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
/* Acquire DMA channel */
hsdevp->chan = dma_request_channel(mask, sata_dwc_dma_filter, hsdevp);
if (!hsdevp->chan) {
- dev_err(hsdev->dev, "%s: dma channel unavailable\n",
- __func__);
+ dev_err(dev, "%s: dma channel unavailable\n", __func__);
return -EAGAIN;
}
@@ -236,19 +236,20 @@ static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
static int sata_dwc_dma_init_old(struct platform_device *pdev,
struct sata_dwc_device *hsdev)
{
- struct device_node *np = pdev->dev.of_node;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
- hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL);
+ hsdev->dma = devm_kzalloc(dev, sizeof(*hsdev->dma), GFP_KERNEL);
if (!hsdev->dma)
return -ENOMEM;
- hsdev->dma->dev = &pdev->dev;
+ hsdev->dma->dev = dev;
hsdev->dma->id = pdev->id;
/* Get SATA DMA interrupt number */
hsdev->dma->irq = irq_of_parse_and_map(np, 1);
if (hsdev->dma->irq == NO_IRQ) {
- dev_err(&pdev->dev, "no SATA DMA irq\n");
+ dev_err(dev, "no SATA DMA irq\n");
return -ENODEV;
}
@@ -1205,6 +1206,8 @@ static const struct ata_port_info sata_dwc_port_info[] = {
static int sata_dwc_probe(struct platform_device *ofdev)
{
+ struct device *dev = &ofdev->dev;
+ struct device_node *np = dev->of_node;
struct sata_dwc_device *hsdev;
u32 idr, versionr;
char *ver = (char *)&versionr;
@@ -1214,12 +1217,11 @@ static int sata_dwc_probe(struct platform_device *ofdev)
struct ata_host *host;
struct ata_port_info pi = sata_dwc_port_info[0];
const struct ata_port_info *ppi[] = { &pi, NULL };
- struct device_node *np = ofdev->dev.of_node;
struct resource *res;
/* Allocate DWC SATA device */
- host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
- hsdev = devm_kzalloc(&ofdev->dev, sizeof(*hsdev), GFP_KERNEL);
+ host = ata_host_alloc_pinfo(dev, ppi, SATA_DWC_MAX_PORTS);
+ hsdev = devm_kzalloc(dev, sizeof(*hsdev), GFP_KERNEL);
if (!host || !hsdev)
return -ENOMEM;
@@ -1229,7 +1231,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
base = devm_platform_get_and_ioremap_resource(ofdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
- dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
+ dev_dbg(dev, "ioremap done for SATA register address\n");
/* Synopsys DWC SATA specific Registers */
hsdev->sata_dwc_regs = base + SATA_DWC_REG_OFFSET;
@@ -1243,11 +1245,10 @@ static int sata_dwc_probe(struct platform_device *ofdev)
/* Read the ID and Version Registers */
idr = sata_dwc_readl(&hsdev->sata_dwc_regs->idr);
versionr = sata_dwc_readl(&hsdev->sata_dwc_regs->versionr);
- dev_notice(&ofdev->dev, "id %d, controller version %c.%c%c\n",
- idr, ver[0], ver[1], ver[2]);
+ dev_notice(dev, "id %d, controller version %c.%c%c\n", idr, ver[0], ver[1], ver[2]);
/* Save dev for later use in dev_xxx() routines */
- hsdev->dev = &ofdev->dev;
+ hsdev->dev = dev;
/* Enable SATA Interrupts */
sata_dwc_enable_interrupts(hsdev);
@@ -1255,7 +1256,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
/* Get SATA interrupt number */
irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) {
- dev_err(&ofdev->dev, "no SATA DMA irq\n");
+ dev_err(dev, "no SATA DMA irq\n");
return -ENODEV;
}
@@ -1267,7 +1268,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
}
#endif
- hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
+ hsdev->phy = devm_phy_optional_get(dev, "sata-phy");
if (IS_ERR(hsdev->phy))
return PTR_ERR(hsdev->phy);
@@ -1282,7 +1283,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
*/
err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
if (err)
- dev_err(&ofdev->dev, "failed to activate host");
+ dev_err(dev, "failed to activate host");
return 0;
@@ -1306,7 +1307,7 @@ static int sata_dwc_remove(struct platform_device *ofdev)
sata_dwc_dma_exit_old(hsdev);
#endif
- dev_dbg(&ofdev->dev, "done\n");
+ dev_dbg(dev, "done\n");
return 0;
}
--
2.33.0
On 2021/12/09 23:35, Andy Shevchenko wrote:
> Use temporary variable for struct device to make code neater.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
What is this based on ? Is this on top of Hannes series ?
> ---
> drivers/ata/sata_dwc_460ex.c | 37 ++++++++++++++++++------------------
> 1 file changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
> index 513bee589d12..5421f74c0199 100644
> --- a/drivers/ata/sata_dwc_460ex.c
> +++ b/drivers/ata/sata_dwc_460ex.c
> @@ -215,9 +215,10 @@ static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
> {
> struct sata_dwc_device *hsdev = hsdevp->hsdev;
> struct dw_dma_slave *dws = &sata_dwc_dma_dws;
> + struct device *dev = hsdev->dev;
> dma_cap_mask_t mask;
>
> - dws->dma_dev = hsdev->dev;
> + dws->dma_dev = dev;
>
> dma_cap_zero(mask);
> dma_cap_set(DMA_SLAVE, mask);
> @@ -225,8 +226,7 @@ static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
> /* Acquire DMA channel */
> hsdevp->chan = dma_request_channel(mask, sata_dwc_dma_filter, hsdevp);
> if (!hsdevp->chan) {
> - dev_err(hsdev->dev, "%s: dma channel unavailable\n",
> - __func__);
> + dev_err(dev, "%s: dma channel unavailable\n", __func__);
> return -EAGAIN;
> }
>
> @@ -236,19 +236,20 @@ static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
> static int sata_dwc_dma_init_old(struct platform_device *pdev,
> struct sata_dwc_device *hsdev)
> {
> - struct device_node *np = pdev->dev.of_node;
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node;
>
> - hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL);
> + hsdev->dma = devm_kzalloc(dev, sizeof(*hsdev->dma), GFP_KERNEL);
> if (!hsdev->dma)
> return -ENOMEM;
>
> - hsdev->dma->dev = &pdev->dev;
> + hsdev->dma->dev = dev;
> hsdev->dma->id = pdev->id;
>
> /* Get SATA DMA interrupt number */
> hsdev->dma->irq = irq_of_parse_and_map(np, 1);
> if (hsdev->dma->irq == NO_IRQ) {
> - dev_err(&pdev->dev, "no SATA DMA irq\n");
> + dev_err(dev, "no SATA DMA irq\n");
> return -ENODEV;
> }
>
> @@ -1205,6 +1206,8 @@ static const struct ata_port_info sata_dwc_port_info[] = {
>
> static int sata_dwc_probe(struct platform_device *ofdev)
> {
> + struct device *dev = &ofdev->dev;
> + struct device_node *np = dev->of_node;
> struct sata_dwc_device *hsdev;
> u32 idr, versionr;
> char *ver = (char *)&versionr;
> @@ -1214,12 +1217,11 @@ static int sata_dwc_probe(struct platform_device *ofdev)
> struct ata_host *host;
> struct ata_port_info pi = sata_dwc_port_info[0];
> const struct ata_port_info *ppi[] = { &pi, NULL };
> - struct device_node *np = ofdev->dev.of_node;
> struct resource *res;
>
> /* Allocate DWC SATA device */
> - host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
> - hsdev = devm_kzalloc(&ofdev->dev, sizeof(*hsdev), GFP_KERNEL);
> + host = ata_host_alloc_pinfo(dev, ppi, SATA_DWC_MAX_PORTS);
> + hsdev = devm_kzalloc(dev, sizeof(*hsdev), GFP_KERNEL);
> if (!host || !hsdev)
> return -ENOMEM;
>
> @@ -1229,7 +1231,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
> base = devm_platform_get_and_ioremap_resource(ofdev, 0, &res);
> if (IS_ERR(base))
> return PTR_ERR(base);
> - dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
> + dev_dbg(dev, "ioremap done for SATA register address\n");
>
> /* Synopsys DWC SATA specific Registers */
> hsdev->sata_dwc_regs = base + SATA_DWC_REG_OFFSET;
> @@ -1243,11 +1245,10 @@ static int sata_dwc_probe(struct platform_device *ofdev)
> /* Read the ID and Version Registers */
> idr = sata_dwc_readl(&hsdev->sata_dwc_regs->idr);
> versionr = sata_dwc_readl(&hsdev->sata_dwc_regs->versionr);
> - dev_notice(&ofdev->dev, "id %d, controller version %c.%c%c\n",
> - idr, ver[0], ver[1], ver[2]);
> + dev_notice(dev, "id %d, controller version %c.%c%c\n", idr, ver[0], ver[1], ver[2]);
>
> /* Save dev for later use in dev_xxx() routines */
> - hsdev->dev = &ofdev->dev;
> + hsdev->dev = dev;
>
> /* Enable SATA Interrupts */
> sata_dwc_enable_interrupts(hsdev);
> @@ -1255,7 +1256,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
> /* Get SATA interrupt number */
> irq = irq_of_parse_and_map(np, 0);
> if (irq == NO_IRQ) {
> - dev_err(&ofdev->dev, "no SATA DMA irq\n");
> + dev_err(dev, "no SATA DMA irq\n");
> return -ENODEV;
> }
>
> @@ -1267,7 +1268,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
> }
> #endif
>
> - hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
> + hsdev->phy = devm_phy_optional_get(dev, "sata-phy");
> if (IS_ERR(hsdev->phy))
> return PTR_ERR(hsdev->phy);
>
> @@ -1282,7 +1283,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
> */
> err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
> if (err)
> - dev_err(&ofdev->dev, "failed to activate host");
> + dev_err(dev, "failed to activate host");
>
> return 0;
>
> @@ -1306,7 +1307,7 @@ static int sata_dwc_remove(struct platform_device *ofdev)
> sata_dwc_dma_exit_old(hsdev);
> #endif
>
> - dev_dbg(&ofdev->dev, "done\n");
> + dev_dbg(dev, "done\n");
> return 0;
> }
>
--
Damien Le Moal
Western Digital Research
On Fri, Dec 10, 2021 at 4:25 AM Damien Le Moal
<[email protected]> wrote:
>
> On 2021/12/09 23:35, Andy Shevchenko wrote:
> > Use temporary variable for struct device to make code neater.
> >
> > Signed-off-by: Andy Shevchenko <[email protected]>
>
> What is this based on ? Is this on top of Hannes series ?
Nope, on latest (available) Linux Next.
Hannes, can you incorporate this to yours maybe? I see one conflict
with the last patch.
--
With Best Regards,
Andy Shevchenko
On 12/10/21 9:42 AM, Andy Shevchenko wrote:
> On Fri, Dec 10, 2021 at 4:25 AM Damien Le Moal
> <[email protected]> wrote:
>>
>> On 2021/12/09 23:35, Andy Shevchenko wrote:
>>> Use temporary variable for struct device to make code neater.
>>>
>>> Signed-off-by: Andy Shevchenko <[email protected]>
>>
>> What is this based on ? Is this on top of Hannes series ?
>
> Nope, on latest (available) Linux Next.
> Hannes, can you incorporate this to yours maybe? I see one conflict
> with the last patch.
>
Sure.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
[email protected] +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
On 12/9/21 23:35, Andy Shevchenko wrote:
> Use temporary variable for struct device to make code neater.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
Applied all 3 patche to for-5.17.
Hannes,
Please rebase your v3 series on that branch.
(if possible, I would like to get it soon, pleasse !)
--
Damien Le Moal
Western Digital Research