mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-29 04:41:21 -04:00
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.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <linux/completion.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/spi/spi.h>
|
||||
@@ -54,8 +55,6 @@ struct mpc512x_psc_spi {
|
||||
struct mpc512x_psc_fifo __iomem *fifo;
|
||||
unsigned int irq;
|
||||
u8 bits_per_word;
|
||||
struct clk *clk_mclk;
|
||||
struct clk *clk_ipg;
|
||||
u32 mclk_rate;
|
||||
|
||||
struct completion txisrdone;
|
||||
@@ -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->use_gpio_descriptors = true;
|
||||
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);
|
||||
if (!tempp)
|
||||
return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n");
|
||||
if (IS_ERR(tempp))
|
||||
return dev_err_probe(dev, PTR_ERR(tempp), "could not ioremap I/O port range\n");
|
||||
mps->psc = tempp;
|
||||
mps->fifo =
|
||||
(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
|
||||
|
||||
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,
|
||||
"mpc512x-psc-spi", mps);
|
||||
if (ret)
|
||||
return ret;
|
||||
init_completion(&mps->txisrdone);
|
||||
|
||||
clk = devm_clk_get(dev, "mclk");
|
||||
clk = devm_clk_get_enabled(dev, "mclk");
|
||||
if (IS_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);
|
||||
|
||||
clk = devm_clk_get(dev, "ipg");
|
||||
if (IS_ERR(clk)) {
|
||||
ret = PTR_ERR(clk);
|
||||
goto free_mclk_clock;
|
||||
}
|
||||
ret = clk_prepare_enable(clk);
|
||||
if (ret)
|
||||
goto free_mclk_clock;
|
||||
mps->clk_ipg = clk;
|
||||
clk = devm_clk_get_enabled(dev, "ipg");
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
ret = mpc512x_psc_spi_port_config(master, mps);
|
||||
if (ret < 0)
|
||||
@@ -525,24 +518,6 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev)
|
||||
goto free_ipg_clock;
|
||||
|
||||
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[] = {
|
||||
@@ -555,7 +530,6 @@ MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);
|
||||
|
||||
static struct platform_driver mpc512x_psc_spi_of_driver = {
|
||||
.probe = mpc512x_psc_spi_of_probe,
|
||||
.remove = mpc512x_psc_spi_of_remove,
|
||||
.driver = {
|
||||
.name = "mpc512x-psc-spi",
|
||||
.of_match_table = mpc512x_psc_spi_of_match,
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/io.h>
|
||||
@@ -309,7 +309,7 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev)
|
||||
/* the spi->mode bits understood by this driver: */
|
||||
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)
|
||||
return dev_err_probe(dev, ret ? : -EINVAL, "Invalid cell-index property\n");
|
||||
master->bus_num = bus_num + 1;
|
||||
@@ -318,15 +318,20 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev)
|
||||
master->setup = mpc52xx_psc_spi_setup;
|
||||
master->transfer_one_message = mpc52xx_psc_spi_transfer_one_message;
|
||||
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);
|
||||
if (!mps->psc)
|
||||
return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n");
|
||||
if (IS_ERR(mps->psc))
|
||||
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 */
|
||||
mps->fifo = ((void __iomem *)mps->psc) + sizeof(struct mpc52xx_psc);
|
||||
|
||||
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,
|
||||
"mpc52xx-psc-spi", mps);
|
||||
if (ret)
|
||||
|
||||
Reference in New Issue
Block a user