Skip to content

Commit a6bfc42

Browse files
Yang Yingliangbroonie
authored andcommitted
spi: s3c24xx: Switch to use devm_spi_alloc_master()
Switch to use devm_spi_alloc_master() to simpify error path. Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2d06458 commit a6bfc42

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

drivers/spi/spi-s3c24xx.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
449449
struct spi_master *master;
450450
int err = 0;
451451

452-
master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
452+
master = devm_spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
453453
if (master == NULL) {
454454
dev_err(&pdev->dev, "No memory for spi_master\n");
455455
return -ENOMEM;
@@ -463,8 +463,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
463463

464464
if (pdata == NULL) {
465465
dev_err(&pdev->dev, "No platform data supplied\n");
466-
err = -ENOENT;
467-
goto err_no_pdata;
466+
return -ENOENT;
468467
}
469468

470469
platform_set_drvdata(pdev, hw);
@@ -499,29 +498,24 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
499498

500499
/* find and map our resources */
501500
hw->regs = devm_platform_ioremap_resource(pdev, 0);
502-
if (IS_ERR(hw->regs)) {
503-
err = PTR_ERR(hw->regs);
504-
goto err_no_pdata;
505-
}
501+
if (IS_ERR(hw->regs))
502+
return PTR_ERR(hw->regs);
506503

507504
hw->irq = platform_get_irq(pdev, 0);
508-
if (hw->irq < 0) {
509-
err = -ENOENT;
510-
goto err_no_pdata;
511-
}
505+
if (hw->irq < 0)
506+
return -ENOENT;
512507

513508
err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0,
514509
pdev->name, hw);
515510
if (err) {
516511
dev_err(&pdev->dev, "Cannot claim IRQ\n");
517-
goto err_no_pdata;
512+
return err;
518513
}
519514

520515
hw->clk = devm_clk_get(&pdev->dev, "spi");
521516
if (IS_ERR(hw->clk)) {
522517
dev_err(&pdev->dev, "No clock for device\n");
523-
err = PTR_ERR(hw->clk);
524-
goto err_no_pdata;
518+
return PTR_ERR(hw->clk);
525519
}
526520

527521
s3c24xx_spi_initialsetup(hw);
@@ -539,8 +533,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
539533
err_register:
540534
clk_disable(hw->clk);
541535

542-
err_no_pdata:
543-
spi_master_put(hw->master);
544536
return err;
545537
}
546538

0 commit comments

Comments
 (0)