--- zzzz-none-000/linux-2.6.32.61/drivers/spi/spi_gpio.c 2013-06-10 09:43:48.000000000 +0000 +++ ar10-7272-687/linux-2.6.32.61/drivers/spi/spi_gpio.c 2011-07-20 07:23:51.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -69,6 +70,7 @@ * #define SPI_MOSI_GPIO 120 * #define SPI_SCK_GPIO 121 * #define SPI_N_CHIPSEL 4 + * #undef NEED_SPIDELAY * #include "spi_gpio.c" */ @@ -76,6 +78,7 @@ #define DRIVER_NAME "spi_gpio" #define GENERIC_BITBANG /* vs tight inlines */ +#define NEED_SPIDELAY 1 /* all functions referencing these symbols must define pdata */ #define SPI_MISO_GPIO ((pdata)->miso) @@ -120,12 +123,20 @@ #undef pdata /* - * NOTE: this clocks "as fast as we can". It "should" be a function of the - * requested device clock. Software overhead means we usually have trouble - * reaching even one Mbit/sec (except when we can inline bitops), so for now - * we'll just assume we never need additional per-bit slowdowns. + * NOTE: to clock "as fast as we can", set spi_device.max_speed_hz + * and spi_transfer.speed_hz to 0. + * Otherwise this is a function of the requested device clock. + * Software overhead means we usually have trouble + * reaching even one Mbit/sec (except when we can inline bitops). So on small + * embedded devices with fast SPI slaves you usually don't need a delay. */ -#define spidelay(nsecs) do {} while (0) +static inline void spidelay(unsigned nsecs) +{ +#ifdef NEED_SPIDELAY + if (unlikely(nsecs)) + ndelay(nsecs); +#endif /* NEED_SPIDELAY */ +} #define EXPAND_BITBANG_TXRX #include @@ -218,7 +229,7 @@ spi_bitbang_cleanup(spi); } -static int __init spi_gpio_alloc(unsigned pin, const char *label, bool is_in) +static int __devinit spi_gpio_alloc(unsigned pin, const char *label, bool is_in) { int value; @@ -232,7 +243,7 @@ return value; } -static int __init +static int __devinit spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label) { int value; @@ -261,7 +272,7 @@ return value; } -static int __init spi_gpio_probe(struct platform_device *pdev) +static int __devinit spi_gpio_probe(struct platform_device *pdev) { int status; struct spi_master *master; @@ -317,7 +328,7 @@ return status; } -static int __exit spi_gpio_remove(struct platform_device *pdev) +static int __devexit spi_gpio_remove(struct platform_device *pdev) { struct spi_gpio *spi_gpio; struct spi_gpio_platform_data *pdata; @@ -344,12 +355,13 @@ static struct platform_driver spi_gpio_driver = { .driver.name = DRIVER_NAME, .driver.owner = THIS_MODULE, - .remove = __exit_p(spi_gpio_remove), + .probe = spi_gpio_probe, + .remove = __devexit_p(spi_gpio_remove), }; static int __init spi_gpio_init(void) { - return platform_driver_probe(&spi_gpio_driver, spi_gpio_probe); + return platform_driver_register(&spi_gpio_driver); } module_init(spi_gpio_init);