Skip to content

Commit

Permalink
Merge remote-tracking branches 'spi/topic/spidev' and 'spi/topic/txx9…
Browse files Browse the repository at this point in the history
…' into spi-next
  • Loading branch information
Mark Brown committed Dec 8, 2014
3 parents f56be67 + 9169051 + 7d57cd8 commit 0e64703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions drivers/spi/spi-txx9.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ static int txx9spi_probe(struct platform_device *dev)
exit:
if (c->workqueue)
destroy_workqueue(c->workqueue);
if (c->clk)
clk_disable(c->clk);
clk_disable(c->clk);
spi_master_put(master);
return ret;
}
Expand Down
16 changes: 13 additions & 3 deletions drivers/spi/spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct spidev_data {
unsigned users;
u8 *tx_buffer;
u8 *rx_buffer;
u32 speed_hz;
};

static LIST_HEAD(device_list);
Expand Down Expand Up @@ -138,6 +139,7 @@ spidev_sync_write(struct spidev_data *spidev, size_t len)
struct spi_transfer t = {
.tx_buf = spidev->tx_buffer,
.len = len,
.speed_hz = spidev->speed_hz,
};
struct spi_message m;

Expand All @@ -152,6 +154,7 @@ spidev_sync_read(struct spidev_data *spidev, size_t len)
struct spi_transfer t = {
.rx_buf = spidev->rx_buffer,
.len = len,
.speed_hz = spidev->speed_hz,
};
struct spi_message m;

Expand Down Expand Up @@ -274,6 +277,8 @@ static int spidev_message(struct spidev_data *spidev,
k_tmp->bits_per_word = u_tmp->bits_per_word;
k_tmp->delay_usecs = u_tmp->delay_usecs;
k_tmp->speed_hz = u_tmp->speed_hz;
if (!k_tmp->speed_hz)
k_tmp->speed_hz = spidev->speed_hz;
#ifdef VERBOSE
dev_dbg(&spidev->spi->dev,
" xfer len %zd %s%s%s%dbits %u usec %uHz\n",
Expand Down Expand Up @@ -377,7 +382,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
retval = __put_user(spi->bits_per_word, (__u8 __user *)arg);
break;
case SPI_IOC_RD_MAX_SPEED_HZ:
retval = __put_user(spi->max_speed_hz, (__u32 __user *)arg);
retval = __put_user(spidev->speed_hz, (__u32 __user *)arg);
break;

/* write requests */
Expand Down Expand Up @@ -441,10 +446,11 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

spi->max_speed_hz = tmp;
retval = spi_setup(spi);
if (retval < 0)
spi->max_speed_hz = save;
if (retval >= 0)
spidev->speed_hz = tmp;
else
dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
spi->max_speed_hz = save;
}
break;

Expand Down Expand Up @@ -570,6 +576,8 @@ static int spidev_release(struct inode *inode, struct file *filp)
kfree(spidev->rx_buffer);
spidev->rx_buffer = NULL;

spidev->speed_hz = spidev->spi->max_speed_hz;

/* ... after we unbound from the underlying device? */
spin_lock_irq(&spidev->spi_lock);
dofree = (spidev->spi == NULL);
Expand Down Expand Up @@ -650,6 +658,8 @@ static int spidev_probe(struct spi_device *spi)
}
mutex_unlock(&device_list_lock);

spidev->speed_hz = spi->max_speed_hz;

if (status == 0)
spi_set_drvdata(spi, spidev);
else
Expand Down

0 comments on commit 0e64703

Please sign in to comment.