[RFC] Making spi usable on machines without DMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux