aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/cyttsp_spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/cyttsp_spi.c')
-rw-r--r--drivers/input/touchscreen/cyttsp_spi.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c
index 861b7f77605b..1df625337b84 100644
--- a/drivers/input/touchscreen/cyttsp_spi.c
+++ b/drivers/input/touchscreen/cyttsp_spi.c
@@ -8,6 +8,7 @@
*
* Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
* Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
+ * Copyright (C) 2013 Cypress Semiconductor
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -19,11 +20,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com>
+ * Contact Cypress Semiconductor at www.cypress.com <ttdrivers@cypress.com>
*
*/
@@ -43,19 +40,19 @@
#define CY_SPI_DATA_BUF_SIZE (CY_SPI_CMD_BYTES + CY_SPI_DATA_SIZE)
#define CY_SPI_BITS_PER_WORD 8
-static int cyttsp_spi_xfer(struct cyttsp *ts,
+static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf,
u8 op, u8 reg, u8 *buf, int length)
{
- struct spi_device *spi = to_spi_device(ts->dev);
+ struct spi_device *spi = to_spi_device(dev);
struct spi_message msg;
struct spi_transfer xfer[2];
- u8 *wr_buf = &ts->xfer_buf[0];
- u8 *rd_buf = &ts->xfer_buf[CY_SPI_DATA_BUF_SIZE];
+ u8 *wr_buf = &xfer_buf[0];
+ u8 *rd_buf = &xfer_buf[CY_SPI_DATA_BUF_SIZE];
int retval;
int i;
if (length > CY_SPI_DATA_SIZE) {
- dev_err(ts->dev, "%s: length %d is too big.\n",
+ dev_err(dev, "%s: length %d is too big.\n",
__func__, length);
return -EINVAL;
}
@@ -95,13 +92,13 @@ static int cyttsp_spi_xfer(struct cyttsp *ts,
break;
default:
- dev_err(ts->dev, "%s: bad operation code=%d\n", __func__, op);
+ dev_err(dev, "%s: bad operation code=%d\n", __func__, op);
return -EINVAL;
}
retval = spi_sync(spi, &msg);
if (retval < 0) {
- dev_dbg(ts->dev, "%s: spi_sync() error %d, len=%d, op=%d\n",
+ dev_dbg(dev, "%s: spi_sync() error %d, len=%d, op=%d\n",
__func__, retval, xfer[1].len, op);
/*
@@ -113,14 +110,13 @@ static int cyttsp_spi_xfer(struct cyttsp *ts,
if (rd_buf[CY_SPI_SYNC_BYTE] != CY_SPI_SYNC_ACK1 ||
rd_buf[CY_SPI_SYNC_BYTE + 1] != CY_SPI_SYNC_ACK2) {
-
- dev_dbg(ts->dev, "%s: operation %d failed\n", __func__, op);
+ dev_dbg(dev, "%s: operation %d failed\n", __func__, op);
for (i = 0; i < CY_SPI_CMD_BYTES; i++)
- dev_dbg(ts->dev, "%s: test rd_buf[%d]:0x%02x\n",
+ dev_dbg(dev, "%s: test rd_buf[%d]:0x%02x\n",
__func__, i, rd_buf[i]);
for (i = 0; i < length; i++)
- dev_dbg(ts->dev, "%s: test buf[%d]:0x%02x\n",
+ dev_dbg(dev, "%s: test buf[%d]:0x%02x\n",
__func__, i, buf[i]);
return -EIO;
@@ -129,16 +125,18 @@ static int cyttsp_spi_xfer(struct cyttsp *ts,
return 0;
}
-static int cyttsp_spi_read_block_data(struct cyttsp *ts,
+static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf,
u8 addr, u8 length, void *data)
{
- return cyttsp_spi_xfer(ts, CY_SPI_RD_OP, addr, data, length);
+ return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_RD_OP, addr, data,
+ length);
}
-static int cyttsp_spi_write_block_data(struct cyttsp *ts,
+static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf,
u8 addr, u8 length, const void *data)
{
- return cyttsp_spi_xfer(ts, CY_SPI_WR_OP, addr, (void *)data, length);
+ return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data,
+ length);
}
static const struct cyttsp_bus_ops cyttsp_spi_bus_ops = {