lkml.org 
[lkml]   [2023]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 09/18] mtd: rawnand: davinci: Convert to devm_platform_ioremap_resource()
    Date
    Use devm_platform_ioremap_resource() to simplify code.

    Signed-off-by: Yangtao Li <frank.li@vivo.com>
    ---
    drivers/mtd/nand/raw/davinci_nand.c | 21 +++++++++------------
    1 file changed, 9 insertions(+), 12 deletions(-)

    diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
    index 415d6aaa8255..2db1cd1d3d03 100644
    --- a/drivers/mtd/nand/raw/davinci_nand.c
    +++ b/drivers/mtd/nand/raw/davinci_nand.c
    @@ -710,8 +710,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
    {
    struct davinci_nand_pdata *pdata;
    struct davinci_nand_info *info;
    - struct resource *res1;
    - struct resource *res2;
    + struct resource *res;
    void __iomem *vaddr;
    void __iomem *base;
    int ret;
    @@ -736,26 +735,24 @@ static int nand_davinci_probe(struct platform_device *pdev)

    platform_set_drvdata(pdev, info);

    - res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    - res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
    - if (!res1 || !res2) {
    - dev_err(&pdev->dev, "resource missing\n");
    - return -EINVAL;
    - }
    -
    - vaddr = devm_ioremap_resource(&pdev->dev, res1);
    + vaddr = devm_platform_ioremap_resource(pdev, 0);
    if (IS_ERR(vaddr))
    return PTR_ERR(vaddr);

    + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
    + if (!res) {
    + dev_err(&pdev->dev, "resource missing\n");
    + return -EINVAL;
    + }
    /*
    * This registers range is used to setup NAND settings. In case with
    * TI AEMIF driver, the same memory address range is requested already
    * by AEMIF, so we cannot request it twice, just ioremap.
    * The AEMIF and NAND drivers not use the same registers in this range.
    */
    - base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
    + base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
    if (!base) {
    - dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
    + dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res);
    return -EADDRNOTAVAIL;
    }

    --
    2.39.0
    \
     
     \ /
      Last update: 2023-07-07 06:08    [W:6.344 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site