Skip to content

Commit c4887bd

Browse files
morimotobroonie
authored andcommitted
spi: sh-msiof: use dev in sh_msiof_spi_probe()
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 <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 8ffd015 commit c4887bd

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,32 +1276,31 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
12761276
const struct sh_msiof_chipdata *chipdata;
12771277
struct sh_msiof_spi_info *info;
12781278
struct sh_msiof_spi_priv *p;
1279+
struct device *dev = &pdev->dev;
12791280
unsigned long clksrc;
12801281
int i;
12811282
int ret;
12821283

1283-
chipdata = of_device_get_match_data(&pdev->dev);
1284+
chipdata = of_device_get_match_data(dev);
12841285
if (chipdata) {
1285-
info = sh_msiof_spi_parse_dt(&pdev->dev);
1286+
info = sh_msiof_spi_parse_dt(dev);
12861287
} else {
12871288
chipdata = (const void *)pdev->id_entry->driver_data;
1288-
info = dev_get_platdata(&pdev->dev);
1289+
info = dev_get_platdata(dev);
12891290
}
12901291

12911292
if (!info) {
1292-
dev_err(&pdev->dev, "failed to obtain device info\n");
1293+
dev_err(dev, "failed to obtain device info\n");
12931294
return -ENXIO;
12941295
}
12951296

12961297
if (chipdata->flags & SH_MSIOF_FLAG_FIXED_DTDL_200)
12971298
info->dtdl = 200;
12981299

12991300
if (info->mode == MSIOF_SPI_TARGET)
1300-
ctlr = spi_alloc_target(&pdev->dev,
1301-
sizeof(struct sh_msiof_spi_priv));
1301+
ctlr = spi_alloc_target(dev, sizeof(struct sh_msiof_spi_priv));
13021302
else
1303-
ctlr = spi_alloc_host(&pdev->dev,
1304-
sizeof(struct sh_msiof_spi_priv));
1303+
ctlr = spi_alloc_host(dev, sizeof(struct sh_msiof_spi_priv));
13051304
if (ctlr == NULL)
13061305
return -ENOMEM;
13071306

@@ -1315,9 +1314,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13151314
init_completion(&p->done);
13161315
init_completion(&p->done_txdma);
13171316

1318-
p->clk = devm_clk_get(&pdev->dev, NULL);
1317+
p->clk = devm_clk_get(dev, NULL);
13191318
if (IS_ERR(p->clk)) {
1320-
dev_err(&pdev->dev, "cannot get clock\n");
1319+
dev_err(dev, "cannot get clock\n");
13211320
ret = PTR_ERR(p->clk);
13221321
goto err1;
13231322
}
@@ -1334,15 +1333,14 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13341333
goto err1;
13351334
}
13361335

1337-
ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0,
1338-
dev_name(&pdev->dev), p);
1336+
ret = devm_request_irq(dev, i, sh_msiof_spi_irq, 0, dev_name(&pdev->dev), p);
13391337
if (ret) {
1340-
dev_err(&pdev->dev, "unable to request irq\n");
1338+
dev_err(dev, "unable to request irq\n");
13411339
goto err1;
13421340
}
13431341

13441342
p->pdev = pdev;
1345-
pm_runtime_enable(&pdev->dev);
1343+
pm_runtime_enable(dev);
13461344

13471345
/* Platform data may override FIFO sizes */
13481346
p->tx_fifo_size = chipdata->tx_fifo_size;
@@ -1361,7 +1359,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13611359
ctlr->flags = chipdata->ctlr_flags;
13621360
ctlr->bus_num = pdev->id;
13631361
ctlr->num_chipselect = p->info->num_chipselect;
1364-
ctlr->dev.of_node = pdev->dev.of_node;
1362+
ctlr->dev.of_node = dev->of_node;
13651363
ctlr->setup = sh_msiof_spi_setup;
13661364
ctlr->prepare_message = sh_msiof_prepare_message;
13671365
ctlr->target_abort = sh_msiof_target_abort;
@@ -1373,19 +1371,19 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13731371

13741372
ret = sh_msiof_request_dma(p);
13751373
if (ret < 0)
1376-
dev_warn(&pdev->dev, "DMA not available, using PIO\n");
1374+
dev_warn(dev, "DMA not available, using PIO\n");
13771375

1378-
ret = devm_spi_register_controller(&pdev->dev, ctlr);
1376+
ret = devm_spi_register_controller(dev, ctlr);
13791377
if (ret < 0) {
1380-
dev_err(&pdev->dev, "devm_spi_register_controller error.\n");
1378+
dev_err(dev, "devm_spi_register_controller error.\n");
13811379
goto err2;
13821380
}
13831381

13841382
return 0;
13851383

13861384
err2:
13871385
sh_msiof_release_dma(p);
1388-
pm_runtime_disable(&pdev->dev);
1386+
pm_runtime_disable(dev);
13891387
err1:
13901388
spi_controller_put(ctlr);
13911389
return ret;

0 commit comments

Comments
 (0)