summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/spi.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-07-22 00:45:06 +0300
committerGreg Kroah-Hartman <gregkh@google.com>2016-07-22 05:03:05 +0300
commit92bcaddea3197e477bb37439805fcb5a2f9942d7 (patch)
treec38580b183820a61bd7f7579591116175d833157 /drivers/staging/greybus/spi.c
parentadac4b95941189ca301759a67da4a132fc2804d5 (diff)
downloadlinux-92bcaddea3197e477bb37439805fcb5a2f9942d7.tar.xz
greybus: spilib: make spilib independent of gbphy
spilib is used by multiple users currently (spi.c and fw-core.c) but commit aa52b62a0556 broke that hierarchy and introduced gbphy dependent code in spilib. This may have unreliable consequences as we are doing following operation unconditionally now: gbphy_dev = to_gbphy_dev(spi->parent); gbphy_runtime_get_sync(gbphy_dev); which may not go well when the parent is of type &bundle->dev (fw-core.c). This patch introduces spilib_ops and lets the users of the core register them. This shall have no functional change for the spi.c usecase and shall fix the unreliable results for the fw-core.c usecase. Tested by writing to mtd0 dev and verifying (with print messages) that the below routines are getting called for a gpbridge-test module. Fixes: aa52b62a0556 ("spi: Add runtime_pm support") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/spi.c')
-rw-r--r--drivers/staging/greybus/spi.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/staging/greybus/spi.c b/drivers/staging/greybus/spi.c
index 2e6e328bae9e..bb76b3c0118d 100644
--- a/drivers/staging/greybus/spi.c
+++ b/drivers/staging/greybus/spi.c
@@ -13,6 +13,27 @@
#include "gbphy.h"
#include "spilib.h"
+#ifndef SPI_CORE_SUPPORT_PM
+static int gbphy_spi_prepare_transfer_hardware(struct device *dev)
+{
+ return gbphy_runtime_get_sync(to_gbphy_dev(dev));
+}
+
+static void gbphy_spi_unprepare_transfer_hardware(struct device *dev)
+{
+ gbphy_runtime_put_autosuspend(to_gbphy_dev(dev));
+}
+
+static struct spilib_ops __spilib_ops = {
+ .prepare_transfer_hardware = gbphy_spi_prepare_transfer_hardware,
+ .unprepare_transfer_hardware = gbphy_spi_unprepare_transfer_hardware,
+};
+
+static struct spilib_ops *spilib_ops = &__spilib_ops;
+#else
+static struct spilib_ops *spilib_ops = NULL;
+#endif
+
static int gb_spi_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
@@ -29,7 +50,7 @@ static int gb_spi_probe(struct gbphy_device *gbphy_dev,
if (ret)
goto exit_connection_destroy;
- ret = gb_spilib_master_init(connection, &gbphy_dev->dev);
+ ret = gb_spilib_master_init(connection, &gbphy_dev->dev, spilib_ops);
if (ret)
goto exit_connection_disable;