aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jonathanh@nvidia.com>2015-10-09 10:45:55 -0400
committerMark Brown <broonie@kernel.org>2015-10-12 12:34:05 -0400
commit44af7927316e83eb8865933f7c836dcc85f8eb74 (patch)
treebecd407b8c6c2ffb7ee833373a67b08117e51aa6
parent6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f (diff)
spi: Map SPI OF client IRQ at probe time
Currently the IRQs for SPI client devices, registered via device-tree, are mapped when the client devices are registered. If the corresponding irq-chip has not been probed yet, then the probing of the client device will fail and will not be retried. Resolve this by mapping the IRQ at probe time and allow the probe to be deferred if the IRQ is not yet available. If of_irq_get() returns an error that is not -EPROBE_DEFER, then assume that the SPI client does not have an IRQ and set the IRQ number to zero (which is equivalent to irq_of_parse_and_map()). This is based on some inputs from Thierry Reding <treding@nvidia.com>. Cc: Thierry Reding <treding@nvidia.com> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com> Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3abb3903f2ad..40c9afac047f 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -270,15 +270,24 @@ EXPORT_SYMBOL_GPL(spi_bus_type);
270static int spi_drv_probe(struct device *dev) 270static int spi_drv_probe(struct device *dev)
271{ 271{
272 const struct spi_driver *sdrv = to_spi_driver(dev->driver); 272 const struct spi_driver *sdrv = to_spi_driver(dev->driver);
273 struct spi_device *spi = to_spi_device(dev);
273 int ret; 274 int ret;
274 275
275 ret = of_clk_set_defaults(dev->of_node, false); 276 ret = of_clk_set_defaults(dev->of_node, false);
276 if (ret) 277 if (ret)
277 return ret; 278 return ret;
278 279
280 if (dev->of_node) {
281 spi->irq = of_irq_get(dev->of_node, 0);
282 if (spi->irq == -EPROBE_DEFER)
283 return -EPROBE_DEFER;
284 if (spi->irq < 0)
285 spi->irq = 0;
286 }
287
279 ret = dev_pm_domain_attach(dev, true); 288 ret = dev_pm_domain_attach(dev, true);
280 if (ret != -EPROBE_DEFER) { 289 if (ret != -EPROBE_DEFER) {
281 ret = sdrv->probe(to_spi_device(dev)); 290 ret = sdrv->probe(spi);
282 if (ret) 291 if (ret)
283 dev_pm_domain_detach(dev, true); 292 dev_pm_domain_detach(dev, true);
284 } 293 }
@@ -1433,9 +1442,6 @@ of_register_spi_device(struct spi_master *master, struct device_node *nc)
1433 } 1442 }
1434 spi->max_speed_hz = value; 1443 spi->max_speed_hz = value;
1435 1444
1436 /* IRQ */
1437 spi->irq = irq_of_parse_and_map(nc, 0);
1438
1439 /* Store a pointer to the node in the device structure */ 1445 /* Store a pointer to the node in the device structure */
1440 of_node_get(nc); 1446 of_node_get(nc);
1441 spi->dev.of_node = nc; 1447 spi->dev.of_node = nc;