Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757275Ab0LIUfM (ORCPT ); Thu, 9 Dec 2010 15:35:12 -0500 Received: from na3sys009aog112.obsmtp.com ([74.125.149.207]:33712 "HELO na3sys009aog112.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756388Ab0LIUfF (ORCPT ); Thu, 9 Dec 2010 15:35:05 -0500 From: Ben Gardiner To: spi-devel-general@lists.sourceforge.net, Grant Likely , David Brownell Cc: linux-kernel@vger.kernel.org, Michael Buesch Subject: [RFC][PATCH v2 3/3] spi-gpio: use _cansleep when CONFIG_SLOWER_SPI_GPIO is defined Date: Thu, 9 Dec 2010 15:34:56 -0500 Message-Id: <986eb10f4a662940f631235efa4b679acdcdab80.1291925752.git.bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: <1290205185-11956-1-git-send-email-bengardiner@nanometrics.ca> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4996 Lines: 102 When users have elected to enable delays in the spi-gpio driver, use the _cansleep variant of gpio_set_value. This allows the use of GPIOs on an IO expander. Signed-off-by: Ben Gardiner --- changes since v1: * none; new in v2 I was testing the slowed-down spio-gpio driver on a I2C pca953x expander when I noticed the WARNs that the spio-gpio driver was calling into the I2C expander drivers gpio_set functions without using the _cansleep variant. This patch removes all the warnings except for one on startup when the spi-gpio instance is registered: BUG: scheduling while atomic: swapper/1/0x00000002 Modules linked in: [] (unwind_backtrace+0x0/0xec) from [] (schedule+0x74/0x408) [] (schedule+0x74/0x408) from [] (schedule_timeout+0x1d4/0x214) [] (schedule_timeout+0x1d4/0x214) from [] (wait_for_common+0xf0/0x1b8) [] (wait_for_common+0xf0/0x1b8) from [] (i2c_davinci_xfer+0x1ec/0x304) [] (i2c_davinci_xfer+0x1ec/0x304) from [] (i2c_transfer+0xc4/0x120) [] (i2c_transfer+0xc4/0x120) from [] (i2c_smbus_xfer+0x3ac/0x4ec) [] (i2c_smbus_xfer+0x3ac/0x4ec) from [] (i2c_smbus_write_word_data+0x38/0x40) [] (i2c_smbus_write_word_data+0x38/0x40) from [] (pca953x_write_reg+0x38/0x64) [] (pca953x_write_reg+0x38/0x64) from [] (pca953x_gpio_set_value+0x3c/0x48) [] (pca953x_gpio_set_value+0x3c/0x48) from [] (gpio_set_value_cansleep+0x30/0x38) [] (gpio_set_value_cansleep+0x30/0x38) from [] (spi_bitbang_setup+0xb4/0x104) [] (spi_bitbang_setup+0xb4/0x104) from [] (spi_gpio_setup+0x6c/0xa0) [] (spi_gpio_setup+0x6c/0xa0) from [] (spi_setup+0x48/0x50) [] (spi_setup+0x48/0x50) from [] (spi_add_device+0xa0/0x118) [] (spi_add_device+0xa0/0x118) from [] (spi_new_device+0x80/0xa4) [] (spi_new_device+0x80/0xa4) from [] (spi_match_master_to_boardinfo+0x20/0x40) [] (spi_match_master_to_boardinfo+0x20/0x40) from [] (spi_register_master+0xc4/0x10c) [] (spi_register_master+0xc4/0x10c) from [] (spi_bitbang_start+0x11c/0x154) [] (spi_bitbang_start+0x11c/0x154) from [] (spi_gpio_probe+0x1ac/0x23c) [] (spi_gpio_probe+0x1ac/0x23c) from [] (platform_drv_probe+0x18/0x1c) [] (platform_drv_probe+0x18/0x1c) from [] (driver_probe_device+0xb0/0x16c) [] (driver_probe_device+0xb0/0x16c) from [] (__driver_attach+0x60/0x84) [] (__driver_attach+0x60/0x84) from [] (bus_for_each_dev+0x44/0x74) [] (bus_for_each_dev+0x44/0x74) from [] (bus_add_driver+0xa8/0x228) [] (bus_add_driver+0xa8/0x228) from [] (driver_register+0xa8/0x134) [] (driver_register+0xa8/0x134) from [] (platform_driver_probe+0x18/0x98) [] (platform_driver_probe+0x18/0x98) from [] (do_one_initcall+0xc8/0x1a4) [] (do_one_initcall+0xc8/0x1a4) from [] (kernel_init+0x94/0x14c) [] (kernel_init+0x94/0x14c) from [] (kernel_thread_exit+0x0/0x8) --- drivers/spi/spi_gpio.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi_gpio.c b/drivers/spi/spi_gpio.c index b31fddd..537ce13 100644 --- a/drivers/spi/spi_gpio.c +++ b/drivers/spi/spi_gpio.c @@ -78,6 +78,12 @@ struct spi_gpio { #define GENERIC_BITBANG /* vs tight inlines */ +#if defined(CONFIG_SLOWER_SPI_GPIO) +#define spi_gpio_gpio_set_value gpio_set_value_cansleep +#else +#define spi_gpio_gpio_set_value gpio_set_value +#endif + /* all functions referencing these symbols must define pdata */ #define SPI_MISO_GPIO ((pdata)->miso) #define SPI_MOSI_GPIO ((pdata)->mosi) @@ -105,12 +111,12 @@ spi_to_pdata(const struct spi_device *spi) static inline void setsck(const struct spi_device *spi, int is_on) { - gpio_set_value(SPI_SCK_GPIO, is_on); + spi_gpio_gpio_set_value(SPI_SCK_GPIO, is_on); } static inline void setmosi(const struct spi_device *spi, int is_on) { - gpio_set_value(SPI_MOSI_GPIO, is_on); + spi_gpio_gpio_set_value(SPI_MOSI_GPIO, is_on); } static inline int getmiso(const struct spi_device *spi) @@ -222,7 +228,8 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active) if (cs != SPI_GPIO_NO_CHIPSELECT) { /* SPI is normally active-low */ - gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); + spi_gpio_gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? + is_active : !is_active); } } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/