spi/xilinx: Eliminate pdata references from common code.
The current code has the OF binding modifying the platform_data pointer which it must not do, and the common code doesn't really need to use a pdata pointer. This patch eliminates the platform_data references from the common part of the driver in preparation for merging the OF and non-OF versions. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Michal Simek <monstr@monstr.eu>
This commit is contained in:
parent
f6614b7bb4
commit
91565c4068
|
@ -351,18 +351,12 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
|
struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
|
||||||
u32 irq, s16 bus_num)
|
u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word)
|
||||||
{
|
{
|
||||||
struct spi_master *master;
|
struct spi_master *master;
|
||||||
struct xilinx_spi *xspi;
|
struct xilinx_spi *xspi;
|
||||||
struct xspi_platform_data *pdata = dev->platform_data;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!pdata) {
|
|
||||||
dev_err(dev, "No platform data attached\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
master = spi_alloc_master(dev, sizeof(struct xilinx_spi));
|
master = spi_alloc_master(dev, sizeof(struct xilinx_spi));
|
||||||
if (!master)
|
if (!master)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -389,21 +383,21 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
|
||||||
}
|
}
|
||||||
|
|
||||||
master->bus_num = bus_num;
|
master->bus_num = bus_num;
|
||||||
master->num_chipselect = pdata->num_chipselect;
|
master->num_chipselect = num_cs;
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
master->dev.of_node = dev->of_node;
|
master->dev.of_node = dev->of_node;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xspi->mem = *mem;
|
xspi->mem = *mem;
|
||||||
xspi->irq = irq;
|
xspi->irq = irq;
|
||||||
if (pdata->little_endian) {
|
if (little_endian) {
|
||||||
xspi->read_fn = xspi_read32;
|
xspi->read_fn = xspi_read32;
|
||||||
xspi->write_fn = xspi_write32;
|
xspi->write_fn = xspi_write32;
|
||||||
} else {
|
} else {
|
||||||
xspi->read_fn = xspi_read32_be;
|
xspi->read_fn = xspi_read32_be;
|
||||||
xspi->write_fn = xspi_write32_be;
|
xspi->write_fn = xspi_write32_be;
|
||||||
}
|
}
|
||||||
xspi->bits_per_word = pdata->bits_per_word;
|
xspi->bits_per_word = bits_per_word;
|
||||||
if (xspi->bits_per_word == 8) {
|
if (xspi->bits_per_word == 8) {
|
||||||
xspi->tx_fn = xspi_tx8;
|
xspi->tx_fn = xspi_tx8;
|
||||||
xspi->rx_fn = xspi_rx8;
|
xspi->rx_fn = xspi_rx8;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define XILINX_SPI_NAME "xilinx_spi"
|
#define XILINX_SPI_NAME "xilinx_spi"
|
||||||
|
|
||||||
struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
|
struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
|
||||||
u32 irq, s16 bus_num);
|
u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word);
|
||||||
|
|
||||||
void xilinx_spi_deinit(struct spi_master *master);
|
void xilinx_spi_deinit(struct spi_master *master);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,12 +42,11 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev,
|
||||||
const struct of_device_id *match)
|
const struct of_device_id *match)
|
||||||
{
|
{
|
||||||
struct spi_master *master;
|
struct spi_master *master;
|
||||||
struct xspi_platform_data *pdata;
|
|
||||||
struct resource r_mem;
|
struct resource r_mem;
|
||||||
struct resource r_irq;
|
struct resource r_irq;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
const u32 *prop;
|
const u32 *prop;
|
||||||
int len;
|
int len, num_cs;
|
||||||
|
|
||||||
rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
|
rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
@ -61,21 +60,15 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev,
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
ofdev->dev.platform_data =
|
|
||||||
kzalloc(sizeof(struct xspi_platform_data), GFP_KERNEL);
|
|
||||||
pdata = ofdev->dev.platform_data;
|
|
||||||
if (!pdata)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
/* number of slave select bits is required */
|
/* number of slave select bits is required */
|
||||||
prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len);
|
prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len);
|
||||||
if (!prop || len < sizeof(*prop)) {
|
if (!prop || len < sizeof(*prop)) {
|
||||||
dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
|
dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
pdata->num_chipselect = *prop;
|
num_cs = __be32_to_cpup(prop);
|
||||||
pdata->bits_per_word = 8;
|
master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1,
|
||||||
master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1);
|
num_cs, 0, 8);
|
||||||
if (!master)
|
if (!master)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@ -88,8 +81,6 @@ static int __devexit xilinx_spi_remove(struct platform_device *ofdev)
|
||||||
{
|
{
|
||||||
xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev));
|
xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev));
|
||||||
dev_set_drvdata(&ofdev->dev, 0);
|
dev_set_drvdata(&ofdev->dev, 0);
|
||||||
kfree(ofdev->dev.platform_data);
|
|
||||||
ofdev->dev.platform_data = NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
|
||||||
if (irq < 0)
|
if (irq < 0)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
master = xilinx_spi_init(&dev->dev, r, irq, dev->id);
|
master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
|
||||||
|
pdata->num_chipselect, pdata->little_endian,
|
||||||
|
pdata->bits_per_word);
|
||||||
if (!master)
|
if (!master)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue