Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: gpio: Enable a single always-selected device

Merge series from Andy Shevchenko <andriy.shevchenko@linux.intel.com>:

Enable a single always-selected device hardware setup for SPI GPIO driver,
so some custom SPI bitbang code may be replaced with the generic implementation
in the future (e.g. Up Board FPGA driver).

+7 -38
+7 -38
drivers/spi/spi-gpio.c
··· 39 39 40 40 /*----------------------------------------------------------------------*/ 41 41 42 - /* 43 - * Because the overhead of going through four GPIO procedure calls 44 - * per transferred bit can make performance a problem, this code 45 - * is set up so that you can use it in either of two ways: 46 - * 47 - * - The slow generic way: set up platform_data to hold the GPIO 48 - * numbers used for MISO/MOSI/SCK, and issue procedure calls for 49 - * each of them. This driver can handle several such busses. 50 - * 51 - * - The quicker inlined way: only helps with platform GPIO code 52 - * that inlines operations for constant GPIOs. This can give 53 - * you tight (fast!) inner loops, but each such bus needs a 54 - * new driver. You'll define a new C file, with Makefile and 55 - * Kconfig support; the C code can be a total of six lines: 56 - * 57 - * #define DRIVER_NAME "myboard_spi2" 58 - * #define SPI_MISO_GPIO 119 59 - * #define SPI_MOSI_GPIO 120 60 - * #define SPI_SCK_GPIO 121 61 - * #define SPI_N_CHIPSEL 4 62 - * #include "spi-gpio.c" 63 - */ 64 - 65 - #ifndef DRIVER_NAME 66 42 #define DRIVER_NAME "spi_gpio" 67 - 68 - #define GENERIC_BITBANG /* vs tight inlines */ 69 - 70 - #endif 71 43 72 44 /*----------------------------------------------------------------------*/ 73 45 ··· 313 341 struct spi_gpio *spi_gpio = spi_controller_get_devdata(host); 314 342 int i; 315 343 316 - #ifdef GENERIC_BITBANG 317 - if (!pdata || !pdata->num_chipselect) 344 + if (!pdata) 318 345 return -ENODEV; 319 - #endif 320 - /* 321 - * The host needs to think there is a chipselect even if not 322 - * connected 323 - */ 324 - host->num_chipselect = pdata->num_chipselect ?: 1; 325 346 347 + /* It's just one always-selected device, fine to continue */ 348 + if (!pdata->num_chipselect) 349 + return 0; 350 + 351 + host->num_chipselect = pdata->num_chipselect; 326 352 spi_gpio->cs_gpios = devm_kcalloc(dev, host->num_chipselect, 327 353 sizeof(*spi_gpio->cs_gpios), 328 354 GFP_KERNEL); ··· 415 445 return devm_spi_register_controller(&pdev->dev, host); 416 446 } 417 447 418 - MODULE_ALIAS("platform:" DRIVER_NAME); 419 - 420 448 static const struct of_device_id spi_gpio_dt_ids[] = { 421 449 { .compatible = "spi-gpio" }, 422 450 {} ··· 433 465 MODULE_DESCRIPTION("SPI host driver using generic bitbanged GPIO "); 434 466 MODULE_AUTHOR("David Brownell"); 435 467 MODULE_LICENSE("GPL"); 468 + MODULE_ALIAS("platform:" DRIVER_NAME);