Commit a96c3588 authored by Mark Brown's avatar Mark Brown

spi: mpc5xxx-psc: Clean up even more and fix

Merge series from Andy Shevchenko <andriy.shevchenko@linux.intel.com>:

The recent cleanup series broke the error path in the drivers.
So fix it and do even more cleanups.
parents 2289fa07 3169c581
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -54,8 +55,6 @@ struct mpc512x_psc_spi { ...@@ -54,8 +55,6 @@ struct mpc512x_psc_spi {
struct mpc512x_psc_fifo __iomem *fifo; struct mpc512x_psc_fifo __iomem *fifo;
unsigned int irq; unsigned int irq;
u8 bits_per_word; u8 bits_per_word;
struct clk *clk_mclk;
struct clk *clk_ipg;
u32 mclk_rate; u32 mclk_rate;
struct completion txisrdone; struct completion txisrdone;
...@@ -480,41 +479,35 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev) ...@@ -480,41 +479,35 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev)
master->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw; master->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw;
master->use_gpio_descriptors = true; master->use_gpio_descriptors = true;
master->cleanup = mpc512x_psc_spi_cleanup; master->cleanup = mpc512x_psc_spi_cleanup;
master->dev.of_node = dev->of_node;
device_set_node(&master->dev, dev_fwnode(dev));
tempp = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); tempp = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (!tempp) if (IS_ERR(tempp))
return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n"); return dev_err_probe(dev, PTR_ERR(tempp), "could not ioremap I/O port range\n");
mps->psc = tempp; mps->psc = tempp;
mps->fifo = mps->fifo =
(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc)); (struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
mps->irq = platform_get_irq(pdev, 0); mps->irq = platform_get_irq(pdev, 0);
if (mps->irq < 0)
return mps->irq;
ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED, ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
"mpc512x-psc-spi", mps); "mpc512x-psc-spi", mps);
if (ret) if (ret)
return ret; return ret;
init_completion(&mps->txisrdone); init_completion(&mps->txisrdone);
clk = devm_clk_get(dev, "mclk"); clk = devm_clk_get_enabled(dev, "mclk");
if (IS_ERR(clk)) if (IS_ERR(clk))
return PTR_ERR(clk); return PTR_ERR(clk);
ret = clk_prepare_enable(clk);
if (ret)
return ret;
mps->clk_mclk = clk;
mps->mclk_rate = clk_get_rate(clk); mps->mclk_rate = clk_get_rate(clk);
clk = devm_clk_get(dev, "ipg"); clk = devm_clk_get_enabled(dev, "ipg");
if (IS_ERR(clk)) { if (IS_ERR(clk))
ret = PTR_ERR(clk); return PTR_ERR(clk);
goto free_mclk_clock;
}
ret = clk_prepare_enable(clk);
if (ret)
goto free_mclk_clock;
mps->clk_ipg = clk;
ret = mpc512x_psc_spi_port_config(master, mps); ret = mpc512x_psc_spi_port_config(master, mps);
if (ret < 0) if (ret < 0)
...@@ -525,24 +518,6 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev) ...@@ -525,24 +518,6 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev)
goto free_ipg_clock; goto free_ipg_clock;
return ret; return ret;
free_ipg_clock:
clk_disable_unprepare(mps->clk_ipg);
free_mclk_clock:
clk_disable_unprepare(mps->clk_mclk);
return ret;
}
static int mpc512x_psc_spi_of_remove(struct platform_device *pdev)
{
struct spi_master *master = dev_get_drvdata(&pdev->dev);
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
clk_disable_unprepare(mps->clk_mclk);
clk_disable_unprepare(mps->clk_ipg);
return 0;
} }
static const struct of_device_id mpc512x_psc_spi_of_match[] = { static const struct of_device_id mpc512x_psc_spi_of_match[] = {
...@@ -555,7 +530,6 @@ MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match); ...@@ -555,7 +530,6 @@ MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);
static struct platform_driver mpc512x_psc_spi_of_driver = { static struct platform_driver mpc512x_psc_spi_of_driver = {
.probe = mpc512x_psc_spi_of_probe, .probe = mpc512x_psc_spi_of_probe,
.remove = mpc512x_psc_spi_of_remove,
.driver = { .driver = {
.name = "mpc512x-psc-spi", .name = "mpc512x-psc-spi",
.of_match_table = mpc512x_psc_spi_of_match, .of_match_table = mpc512x_psc_spi_of_match,
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -309,7 +309,7 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev) ...@@ -309,7 +309,7 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev)
/* the spi->mode bits understood by this driver: */ /* the spi->mode bits understood by this driver: */
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
ret = of_property_read_u32(dev->of_node, "cell-index", &bus_num); ret = device_property_read_u32(dev, "cell-index", &bus_num);
if (ret || bus_num > 5) if (ret || bus_num > 5)
return dev_err_probe(dev, ret ? : -EINVAL, "Invalid cell-index property\n"); return dev_err_probe(dev, ret ? : -EINVAL, "Invalid cell-index property\n");
master->bus_num = bus_num + 1; master->bus_num = bus_num + 1;
...@@ -318,15 +318,20 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev) ...@@ -318,15 +318,20 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev)
master->setup = mpc52xx_psc_spi_setup; master->setup = mpc52xx_psc_spi_setup;
master->transfer_one_message = mpc52xx_psc_spi_transfer_one_message; master->transfer_one_message = mpc52xx_psc_spi_transfer_one_message;
master->cleanup = mpc52xx_psc_spi_cleanup; master->cleanup = mpc52xx_psc_spi_cleanup;
master->dev.of_node = dev->of_node;
device_set_node(&master->dev, dev_fwnode(dev));
mps->psc = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); mps->psc = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (!mps->psc) if (IS_ERR(mps->psc))
return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n"); return dev_err_probe(dev, PTR_ERR(mps->psc), "could not ioremap I/O port range\n");
/* On the 5200, fifo regs are immediately ajacent to the psc regs */ /* On the 5200, fifo regs are immediately ajacent to the psc regs */
mps->fifo = ((void __iomem *)mps->psc) + sizeof(struct mpc52xx_psc); mps->fifo = ((void __iomem *)mps->psc) + sizeof(struct mpc52xx_psc);
mps->irq = platform_get_irq(pdev, 0); mps->irq = platform_get_irq(pdev, 0);
if (mps->irq < 0)
return mps->irq;
ret = devm_request_irq(dev, mps->irq, mpc52xx_psc_spi_isr, 0, ret = devm_request_irq(dev, mps->irq, mpc52xx_psc_spi_isr, 0,
"mpc52xx-psc-spi", mps); "mpc52xx-psc-spi", mps);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment