linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Making spi usable on machines without DMA
@ 2014-04-06  9:02 Daniel Palmer
  0 siblings, 0 replies; only message in thread
From: Daniel Palmer @ 2014-04-06  9:02 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA

Hi,

I'm writing a driver for the SPI controller in the DragonBall m68k based SoCs.
Currently the kernel fails to link because of undefined symbols in
spi.c because the platform doesn't have DMA and therefor doesn't
provide some DMA related symbols.

I have attached below my workaround for this that seems to work enough
for my driver to get probed. Is this change acceptable? I'm not sure
if my driver for the SPI controller will end up in the mainline kernel
as the only user for it is me but it seems like some of my fixes for
these chips will get merged so the probability is a little higher than
zero.

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 4eb9bf0..ae309de 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -580,6 +580,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
                spi->master->set_cs(spi, !enable);
 }

+#ifdef HAVE_DMA
 static int spi_map_buf(struct spi_master *master, struct device *dev,
                       struct sg_table *sgt, void *buf, size_t len,
                       enum dma_data_direction dir)
@@ -636,6 +637,7 @@ static void spi_unmap_buf(struct spi_master
*master, struct device *dev,
                sg_free_table(sgt);
        }
 }
+#endif

 static int spi_map_msg(struct spi_master *master, struct spi_message *msg)
 {
@@ -686,6 +688,9 @@ static int spi_map_msg(struct spi_master *master,
struct spi_message *msg)
                }
        }

+#ifndef HAVE_DMA
+       return 0;
+#else
        if (!master->can_dma)
                return 0;

@@ -719,6 +724,7 @@ static int spi_map_msg(struct spi_master *master,
struct spi_message *msg)
        master->cur_msg_mapped = true;

        return 0;
+#endif
 }

 static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg)
@@ -726,6 +732,9 @@ static int spi_unmap_msg(struct spi_master
*master, struct spi_message *msg)
        struct spi_transfer *xfer;
        struct device *tx_dev, *rx_dev;

+#ifndef HAVE_DMA
+       return 0;
+#else
        if (!master->cur_msg_mapped || !master->can_dma)
                return 0;

@@ -741,6 +750,7 @@ static int spi_unmap_msg(struct spi_master
*master, struct spi_message *msg)
        }

        return 0;
+#endif
 }

 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-06  9:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-06  9:02 [RFC] Making spi usable on machines without DMA Daniel Palmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).