spi: sh-msiof: use dev in sh_msiof_spi_probe()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 17 Apr 2025 23:23:03 +0000 (23:23 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 24 Apr 2025 11:56:50 +0000 (12:56 +0100)
sh_msiof_spi_probe() is using priv->dev everywhere,
but it makes code long. Create struct device *dev and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/87y0vy2x0o.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sh-msiof.c

index 8a98c313548e372af61958d2bd1ecb846fc99f76..581cec19cb7701864dcdcde7611d91a37d8951b1 100644 (file)
@@ -1276,20 +1276,21 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
        const struct sh_msiof_chipdata *chipdata;
        struct sh_msiof_spi_info *info;
        struct sh_msiof_spi_priv *p;
+       struct device *dev = &pdev->dev;
        unsigned long clksrc;
        int i;
        int ret;
 
-       chipdata = of_device_get_match_data(&pdev->dev);
+       chipdata = of_device_get_match_data(dev);
        if (chipdata) {
-               info = sh_msiof_spi_parse_dt(&pdev->dev);
+               info = sh_msiof_spi_parse_dt(dev);
        } else {
                chipdata = (const void *)pdev->id_entry->driver_data;
-               info = dev_get_platdata(&pdev->dev);
+               info = dev_get_platdata(dev);
        }
 
        if (!info) {
-               dev_err(&pdev->dev, "failed to obtain device info\n");
+               dev_err(dev, "failed to obtain device info\n");
                return -ENXIO;
        }
 
@@ -1297,11 +1298,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
                info->dtdl = 200;
 
        if (info->mode == MSIOF_SPI_TARGET)
-               ctlr = spi_alloc_target(&pdev->dev,
-                                       sizeof(struct sh_msiof_spi_priv));
+               ctlr = spi_alloc_target(dev, sizeof(struct sh_msiof_spi_priv));
        else
-               ctlr = spi_alloc_host(&pdev->dev,
-                                     sizeof(struct sh_msiof_spi_priv));
+               ctlr = spi_alloc_host(dev, sizeof(struct sh_msiof_spi_priv));
        if (ctlr == NULL)
                return -ENOMEM;
 
@@ -1315,9 +1314,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
        init_completion(&p->done);
        init_completion(&p->done_txdma);
 
-       p->clk = devm_clk_get(&pdev->dev, NULL);
+       p->clk = devm_clk_get(dev, NULL);
        if (IS_ERR(p->clk)) {
-               dev_err(&pdev->dev, "cannot get clock\n");
+               dev_err(dev, "cannot get clock\n");
                ret = PTR_ERR(p->clk);
                goto err1;
        }
@@ -1334,15 +1333,14 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
                goto err1;
        }
 
-       ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0,
-                              dev_name(&pdev->dev), p);
+       ret = devm_request_irq(dev, i, sh_msiof_spi_irq, 0, dev_name(&pdev->dev), p);
        if (ret) {
-               dev_err(&pdev->dev, "unable to request irq\n");
+               dev_err(dev, "unable to request irq\n");
                goto err1;
        }
 
        p->pdev = pdev;
-       pm_runtime_enable(&pdev->dev);
+       pm_runtime_enable(dev);
 
        /* Platform data may override FIFO sizes */
        p->tx_fifo_size = chipdata->tx_fifo_size;
@@ -1361,7 +1359,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
        ctlr->flags = chipdata->ctlr_flags;
        ctlr->bus_num = pdev->id;
        ctlr->num_chipselect = p->info->num_chipselect;
-       ctlr->dev.of_node = pdev->dev.of_node;
+       ctlr->dev.of_node = dev->of_node;
        ctlr->setup = sh_msiof_spi_setup;
        ctlr->prepare_message = sh_msiof_prepare_message;
        ctlr->target_abort = sh_msiof_target_abort;
@@ -1373,11 +1371,11 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 
        ret = sh_msiof_request_dma(p);
        if (ret < 0)
-               dev_warn(&pdev->dev, "DMA not available, using PIO\n");
+               dev_warn(dev, "DMA not available, using PIO\n");
 
-       ret = devm_spi_register_controller(&pdev->dev, ctlr);
+       ret = devm_spi_register_controller(dev, ctlr);
        if (ret < 0) {
-               dev_err(&pdev->dev, "devm_spi_register_controller error.\n");
+               dev_err(dev, "devm_spi_register_controller error.\n");
                goto err2;
        }
 
@@ -1385,7 +1383,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 
  err2:
        sh_msiof_release_dma(p);
-       pm_runtime_disable(&pdev->dev);
+       pm_runtime_disable(dev);
  err1:
        spi_controller_put(ctlr);
        return ret;