Skip to content

Commit

Permalink
spi: xcomm: Remove duplicate code to set default bits_per_word and ma…
Browse files Browse the repository at this point in the history
…x speed

In the implementation of __spi_validate(), spi core will set transfer
bits_per_word and max speed as spi device default if it is not set for
this transfer. So we can remove the same logic in spi_xcomm_setup_transfer().
Also remove a redundant code to initialize is_first variable.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Axel Lin authored and Mark Brown committed Mar 4, 2014
1 parent 38dbfb5 commit af34851
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/spi/spi-xcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,21 @@ static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm,
static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm,
struct spi_device *spi, struct spi_transfer *t, unsigned int *settings)
{
unsigned int speed;

if (t->len > 62)
return -EINVAL;

speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz;
if (t->speed_hz != spi_xcomm->current_speed) {
unsigned int divider;

if (speed != spi_xcomm->current_speed) {
unsigned int divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, speed);
divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, t->speed_hz);
if (divider >= 64)
*settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64;
else if (divider >= 16)
*settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_16;
else
*settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4;

spi_xcomm->current_speed = speed;
spi_xcomm->current_speed = t->speed_hz;
}

if (spi->mode & SPI_CPOL)
Expand Down Expand Up @@ -148,8 +146,6 @@ static int spi_xcomm_transfer_one(struct spi_master *master,
int status = 0;
bool is_last;

is_first = true;

spi_xcomm_chipselect(spi_xcomm, spi, true);

list_for_each_entry(t, &msg->transfers, transfer_list) {
Expand Down

0 comments on commit af34851

Please sign in to comment.