aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2008-12-13 00:56:11 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-13 00:56:11 -0500
commit23d30f027d1e8ad3bcd6192613122ce925947563 (patch)
tree3de1d9ed2940e68a52c6933ec73145b44a0f34b9
parenta17102b1ba847ca31d9151b877fbf9a38a39a8bb (diff)
sfc: Change SPI lengths to type size_t
Based on a patch by Andrew Morton. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/sfc/falcon.c19
-rw-r--r--drivers/net/sfc/spi.h2
2 files changed, 11 insertions, 10 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 71e0bed60616..271cbf8980ad 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1605,7 +1605,7 @@ void falcon_fini_interrupt(struct efx_nic *efx)
1605 ************************************************************************** 1605 **************************************************************************
1606 */ 1606 */
1607 1607
1608#define FALCON_SPI_MAX_LEN ((unsigned) sizeof(efx_oword_t)) 1608#define FALCON_SPI_MAX_LEN sizeof(efx_oword_t)
1609 1609
1610/* Wait for SPI command completion */ 1610/* Wait for SPI command completion */
1611static int falcon_spi_wait(struct efx_nic *efx) 1611static int falcon_spi_wait(struct efx_nic *efx)
@@ -1630,7 +1630,7 @@ static int falcon_spi_wait(struct efx_nic *efx)
1630 1630
1631int falcon_spi_cmd(const struct efx_spi_device *spi, 1631int falcon_spi_cmd(const struct efx_spi_device *spi,
1632 unsigned int command, int address, 1632 unsigned int command, int address,
1633 const void *in, void *out, unsigned int len) 1633 const void *in, void *out, size_t len)
1634{ 1634{
1635 struct efx_nic *efx = spi->efx; 1635 struct efx_nic *efx = spi->efx;
1636 bool addressed = (address >= 0); 1636 bool addressed = (address >= 0);
@@ -1686,8 +1686,8 @@ int falcon_spi_cmd(const struct efx_spi_device *spi,
1686 return 0; 1686 return 0;
1687} 1687}
1688 1688
1689static unsigned int 1689static size_t
1690falcon_spi_write_limit(const struct efx_spi_device *spi, unsigned int start) 1690falcon_spi_write_limit(const struct efx_spi_device *spi, size_t start)
1691{ 1691{
1692 return min(FALCON_SPI_MAX_LEN, 1692 return min(FALCON_SPI_MAX_LEN,
1693 (spi->block_size - (start & (spi->block_size - 1)))); 1693 (spi->block_size - (start & (spi->block_size - 1))));
@@ -1725,12 +1725,12 @@ int falcon_spi_fast_wait(const struct efx_spi_device *spi)
1725int falcon_spi_read(const struct efx_spi_device *spi, loff_t start, 1725int falcon_spi_read(const struct efx_spi_device *spi, loff_t start,
1726 size_t len, size_t *retlen, u8 *buffer) 1726 size_t len, size_t *retlen, u8 *buffer)
1727{ 1727{
1728 unsigned int command, block_len, pos = 0; 1728 size_t block_len, pos = 0;
1729 unsigned int command;
1729 int rc = 0; 1730 int rc = 0;
1730 1731
1731 while (pos < len) { 1732 while (pos < len) {
1732 block_len = min((unsigned int)len - pos, 1733 block_len = min(len - pos, FALCON_SPI_MAX_LEN);
1733 FALCON_SPI_MAX_LEN);
1734 1734
1735 command = efx_spi_munge_command(spi, SPI_READ, start + pos); 1735 command = efx_spi_munge_command(spi, SPI_READ, start + pos);
1736 rc = falcon_spi_cmd(spi, command, start + pos, NULL, 1736 rc = falcon_spi_cmd(spi, command, start + pos, NULL,
@@ -1756,7 +1756,8 @@ int falcon_spi_write(const struct efx_spi_device *spi, loff_t start,
1756 size_t len, size_t *retlen, const u8 *buffer) 1756 size_t len, size_t *retlen, const u8 *buffer)
1757{ 1757{
1758 u8 verify_buffer[FALCON_SPI_MAX_LEN]; 1758 u8 verify_buffer[FALCON_SPI_MAX_LEN];
1759 unsigned int command, block_len, pos = 0; 1759 size_t block_len, pos = 0;
1760 unsigned int command;
1760 int rc = 0; 1761 int rc = 0;
1761 1762
1762 while (pos < len) { 1763 while (pos < len) {
@@ -1764,7 +1765,7 @@ int falcon_spi_write(const struct efx_spi_device *spi, loff_t start,
1764 if (rc) 1765 if (rc)
1765 break; 1766 break;
1766 1767
1767 block_len = min((unsigned int)len - pos, 1768 block_len = min(len - pos,
1768 falcon_spi_write_limit(spi, start + pos)); 1769 falcon_spi_write_limit(spi, start + pos));
1769 command = efx_spi_munge_command(spi, SPI_WRITE, start + pos); 1770 command = efx_spi_munge_command(spi, SPI_WRITE, start + pos);
1770 rc = falcon_spi_cmd(spi, command, start + pos, 1771 rc = falcon_spi_cmd(spi, command, start + pos,
diff --git a/drivers/net/sfc/spi.h b/drivers/net/sfc/spi.h
index c4aca132348a..38e22ff4d7af 100644
--- a/drivers/net/sfc/spi.h
+++ b/drivers/net/sfc/spi.h
@@ -68,7 +68,7 @@ struct efx_spi_device {
68}; 68};
69 69
70int falcon_spi_cmd(const struct efx_spi_device *spi, unsigned int command, 70int falcon_spi_cmd(const struct efx_spi_device *spi, unsigned int command,
71 int address, const void* in, void *out, unsigned int len); 71 int address, const void* in, void *out, size_t len);
72int falcon_spi_fast_wait(const struct efx_spi_device *spi); 72int falcon_spi_fast_wait(const struct efx_spi_device *spi);
73int falcon_spi_read(const struct efx_spi_device *spi, loff_t start, 73int falcon_spi_read(const struct efx_spi_device *spi, loff_t start,
74 size_t len, size_t *retlen, u8 *buffer); 74 size_t len, size_t *retlen, u8 *buffer);