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

Configure Feed

Select the types of activity you want to include in your feed.

spi-imx: strip down chipselect function to only drive the chipselect

spi_imx_chipselect() made things that should be (and mostly are) done by
spi_imx_setupxfer. Only setting the tx and rx functions was missing.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Uwe Kleine-König and committed by
Linus Torvalds
e6a0a8bf d1c627b5

+17 -33
+17 -33
drivers/spi/spi_imx.c
··· 354 354 static void spi_imx_chipselect(struct spi_device *spi, int is_active) 355 355 { 356 356 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); 357 - unsigned int cs = 0; 358 357 int gpio = spi_imx->chipselect[spi->chip_select]; 359 - struct spi_imx_config config; 358 + int active = is_active != BITBANG_CS_INACTIVE; 359 + int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH); 360 360 361 - if (spi->mode & SPI_CS_HIGH) 362 - cs = 1; 363 - 364 - if (is_active == BITBANG_CS_INACTIVE) { 365 - if (gpio >= 0) 366 - gpio_set_value(gpio, !cs); 361 + if (gpio < 0) 367 362 return; 368 - } 369 363 370 - config.bpw = spi->bits_per_word; 371 - config.speed_hz = spi->max_speed_hz; 372 - config.mode = spi->mode; 373 - config.cs = spi_imx->chipselect[spi->chip_select]; 374 - 375 - spi_imx->config(spi_imx, &config); 376 - 377 - /* Initialize the functions for transfer */ 378 - if (config.bpw <= 8) { 379 - spi_imx->rx = spi_imx_buf_rx_u8; 380 - spi_imx->tx = spi_imx_buf_tx_u8; 381 - } else if (config.bpw <= 16) { 382 - spi_imx->rx = spi_imx_buf_rx_u16; 383 - spi_imx->tx = spi_imx_buf_tx_u16; 384 - } else if (config.bpw <= 32) { 385 - spi_imx->rx = spi_imx_buf_rx_u32; 386 - spi_imx->tx = spi_imx_buf_tx_u32; 387 - } else 388 - BUG(); 389 - 390 - if (gpio >= 0) 391 - gpio_set_value(gpio, cs); 392 - 393 - return; 364 + gpio_set_value(gpio, dev_is_lowactive ^ active); 394 365 } 395 366 396 367 static void spi_imx_push(struct spi_imx_data *spi_imx) ··· 421 450 config.bpw = spi->bits_per_word; 422 451 if (!config.speed_hz) 423 452 config.speed_hz = spi->max_speed_hz; 453 + 454 + /* Initialize the functions for transfer */ 455 + if (config.bpw <= 8) { 456 + spi_imx->rx = spi_imx_buf_rx_u8; 457 + spi_imx->tx = spi_imx_buf_tx_u8; 458 + } else if (config.bpw <= 16) { 459 + spi_imx->rx = spi_imx_buf_rx_u16; 460 + spi_imx->tx = spi_imx_buf_tx_u16; 461 + } else if (config.bpw <= 32) { 462 + spi_imx->rx = spi_imx_buf_rx_u32; 463 + spi_imx->tx = spi_imx_buf_tx_u32; 464 + } else 465 + BUG(); 424 466 425 467 spi_imx->config(spi_imx, &config); 426 468