* [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch @ 2012-01-29 5:53 Javier Martinez Canillas 2012-01-29 6:18 ` Dmitry Torokhov 0 siblings, 1 reply; 5+ messages in thread From: Javier Martinez Canillas @ 2012-01-29 5:53 UTC (permalink / raw) To: Dmitry Torokhov Cc: Henrik Rydberg, Kevin McNeely, linux-input, Javier Martinez Canillas This is patch fixes two bugs in Dmitry's last cleanup patch. 1- The hardware tracking ids are stored in the ids array and the information for each contact is obtained calling cyttsp_get_tch() with an index. In the clean-up patch the value of the tracking id was used instead of the contact index. 2- i2c_set_clientdata() is called after the generic cyttsp_probe() function and this function calls cyttsp_power_on() that sends an ttsp command to the device and needs the client data before is set. The fix is to execute cyttsp_power_on inside the transport specific probe function (I2C, SPI) after the generic probe function is executed and the client data is set. This patch is an incremental one to be applied on top of: Javier Martinez Canillas (3): Input: cyttsp - Cypress TTSP capacitive multi-touch screen support Input: cyttsp - add support for Cypress TTSP touchscreen I2C bus interface Input: cyttsp - add support for Cypress TTSP touchscreen SPI bus interface Dmitry Torokhov (1): Input: cyttsp - random edits Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org> --- drivers/input/touchscreen/cyttsp_core.c | 25 +++++++++---------------- drivers/input/touchscreen/cyttsp_core.h | 1 + drivers/input/touchscreen/cyttsp_i2c.c | 5 ++++- drivers/input/touchscreen/cyttsp_spi.c | 4 +++- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c index ff74a33..cee8c05 100644 --- a/drivers/input/touchscreen/cyttsp_core.c +++ b/drivers/input/touchscreen/cyttsp_core.c @@ -305,7 +305,7 @@ static void cyttsp_report_tchdata(struct cyttsp *ts) bitmap_zero(used, CY_MAX_ID); for (i = 0; i < num_tch; i++) { - tch = cyttsp_get_tch(xy_data, ids[i]); + tch = cyttsp_get_tch(xy_data, i); input_mt_slot(input, ids[i]); input_mt_report_slot_state(input, MT_TOOL_FINGER, true); @@ -374,7 +374,7 @@ out: return IRQ_HANDLED; } -static int cyttsp_power_on(struct cyttsp *ts) +int cyttsp_power_on(struct cyttsp *ts) { int error; @@ -419,21 +419,18 @@ static int cyttsp_power_on(struct cyttsp *ts) return 0; } +EXPORT_SYMBOL_GPL(cyttsp_power_on); static int cyttsp_enable(struct cyttsp *ts) { int error; - // FIXME: Why do we need wakeup? The system is already woken up - // so I assume this is device wakeup. It should be generic, just - // like suspend is generic. - // Is there CY_FULL_POWER_MODE that is opposite to CY_LOW_POWER_MODE? - if (ts->pdata->wakeup) { - error = ts->pdata->wakeup(); - if (error) - return error; - } - + /* + * The device firmware can wake on an I2C or SPI memory slave address + * match. So just reading a register is sufficient to wake up the device + * The first read attempt will fail but it will wake it up making the + * second read attempt successful. + */ error = ttsp_read_block_data(ts, CY_REG_BASE, sizeof(ts->xy_data), &ts->xy_data); if (error) @@ -586,10 +583,6 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, goto err_platform_exit; } - error = cyttsp_power_on(ts); - if (error) - goto err_free_irq; - disable_irq(ts->irq); error = input_register_device(input_dev); diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h index b16582e..ad7aaf0 100644 --- a/drivers/input/touchscreen/cyttsp_core.h +++ b/drivers/input/touchscreen/cyttsp_core.h @@ -141,6 +141,7 @@ struct cyttsp { struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, struct device *dev, int irq, size_t xfer_buf_size); void cyttsp_remove(struct cyttsp *ts); +int cyttsp_power_on(struct cyttsp *ts); extern const struct dev_pm_ops cyttsp_pm_ops; diff --git a/drivers/input/touchscreen/cyttsp_i2c.c b/drivers/input/touchscreen/cyttsp_i2c.c index 6394c8e..6e39b8b 100644 --- a/drivers/input/touchscreen/cyttsp_i2c.c +++ b/drivers/input/touchscreen/cyttsp_i2c.c @@ -86,6 +86,7 @@ static int __devinit cyttsp_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct cyttsp *ts; + int ret; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "I2C functionality not Supported\n"); @@ -100,7 +101,9 @@ static int __devinit cyttsp_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, ts); - return 0; + ret = cyttsp_power_on(ts); + + return ret; } static int __devexit cyttsp_i2c_remove(struct i2c_client *client) diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c index d404cd2..bc26300 100644 --- a/drivers/input/touchscreen/cyttsp_spi.c +++ b/drivers/input/touchscreen/cyttsp_spi.c @@ -169,7 +169,9 @@ static int __devinit cyttsp_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, ts); - return 0; + error = cyttsp_power_on(ts); + + return error; } static int __devexit cyttsp_spi_remove(struct spi_device *spi) -- 1.7.7.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch 2012-01-29 5:53 [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch Javier Martinez Canillas @ 2012-01-29 6:18 ` Dmitry Torokhov 2012-01-29 15:28 ` Javier Martinez Canillas 0 siblings, 1 reply; 5+ messages in thread From: Dmitry Torokhov @ 2012-01-29 6:18 UTC (permalink / raw) To: Javier Martinez Canillas; +Cc: Henrik Rydberg, Kevin McNeely, linux-input On Sun, Jan 29, 2012 at 06:53:50AM +0100, Javier Martinez Canillas wrote: > This is patch fixes two bugs in Dmitry's last cleanup patch. > > 1- The hardware tracking ids are stored in the ids array and the information for > each contact is obtained calling cyttsp_get_tch() with an index. In the clean-up > patch the value of the tracking id was used instead of the contact index. > Oops, thank you for fixing that. > 2- i2c_set_clientdata() is called after the generic cyttsp_probe() function and > this function calls cyttsp_power_on() that sends an ttsp command to the device > and needs the client data before is set. The fix is to execute cyttsp_power_on > inside the transport specific probe function (I2C, SPI) after the generic probe > function is executed and the client data is set. > Not quite happy about this one, how about we pass cyttsp directly to bus methods instead of relying on drvdata (as in the patch below)? Thanks. -- Dmitry Input: cyttsp - pass cyttsp structure to bus methods We may not have set drvdata by the time we try to access the bus, so let's pass cyttsp structure directly instead. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> --- drivers/input/touchscreen/cyttsp_core.c | 4 ++-- drivers/input/touchscreen/cyttsp_core.h | 6 ++++-- drivers/input/touchscreen/cyttsp_i2c.c | 9 ++++----- drivers/input/touchscreen/cyttsp_spi.c | 28 ++++++++++++++-------------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c index ff74a33..12cd1da 100644 --- a/drivers/input/touchscreen/cyttsp_core.c +++ b/drivers/input/touchscreen/cyttsp_core.c @@ -84,7 +84,7 @@ static int ttsp_read_block_data(struct cyttsp *ts, u8 command, int tries; for (tries = 0; tries < CY_NUM_RETRY; tries++) { - error = ts->bus_ops->read(ts->dev, command, length, buf); + error = ts->bus_ops->read(ts, command, length, buf); if (!error) return 0; @@ -101,7 +101,7 @@ static int ttsp_write_block_data(struct cyttsp *ts, u8 command, int tries; for (tries = 0; tries < CY_NUM_RETRY; tries++) { - error = ts->bus_ops->write(ts->dev, command, length, buf); + error = ts->bus_ops->write(ts, command, length, buf); if (!error) return 0; diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h index 560f959..1aa3c69 100644 --- a/drivers/input/touchscreen/cyttsp_core.h +++ b/drivers/input/touchscreen/cyttsp_core.h @@ -108,11 +108,13 @@ struct cyttsp_bootloader_data { u8 cid_2; }; +struct cyttsp; + struct cyttsp_bus_ops { u16 bustype; - int (*write)(struct device *dev, + int (*write)(struct cyttsp *ts, u8 addr, u8 length, const void *values); - int (*read)(struct device *dev, u8 addr, u8 length, void *values); + int (*read)(struct cyttsp *ts, u8 addr, u8 length, void *values); }; enum cyttsp_state { diff --git a/drivers/input/touchscreen/cyttsp_i2c.c b/drivers/input/touchscreen/cyttsp_i2c.c index 6394c8e..c7110cc 100644 --- a/drivers/input/touchscreen/cyttsp_i2c.c +++ b/drivers/input/touchscreen/cyttsp_i2c.c @@ -34,10 +34,10 @@ #define CY_I2C_DATA_SIZE 128 -static int cyttsp_i2c_read_block_data(struct device *dev, +static int cyttsp_i2c_read_block_data(struct cyttsp *ts, u8 addr, u8 length, void *values) { - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client = to_i2c_client(ts->dev); struct i2c_msg msgs[] = { { .addr = client->addr, @@ -61,11 +61,10 @@ static int cyttsp_i2c_read_block_data(struct device *dev, return retval != ARRAY_SIZE(msgs) ? -EIO : 0; } -static int cyttsp_i2c_write_block_data(struct device *dev, +static int cyttsp_i2c_write_block_data(struct cyttsp *ts, u8 addr, u8 length, const void *values) { - struct i2c_client *client = to_i2c_client(dev); - struct cyttsp *ts = i2c_get_clientdata(client); + struct i2c_client *client = to_i2c_client(ts->dev); int retval; ts->xfer_buf[0] = addr; diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c index d404cd2..9db5f87 100644 --- a/drivers/input/touchscreen/cyttsp_spi.c +++ b/drivers/input/touchscreen/cyttsp_spi.c @@ -43,11 +43,10 @@ #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(u8 op, struct device *dev, - u8 reg, u8 *buf, int length) +static int cyttsp_spi_xfer(struct cyttsp *ts, + u8 op, u8 reg, u8 *buf, int length) { - struct spi_device *spi = to_spi_device(dev); - struct cyttsp *ts = spi_get_drvdata(spi); + struct spi_device *spi = to_spi_device(ts->dev); struct spi_message msg; struct spi_transfer xfer[2]; u8 *wr_buf = &ts->xfer_buf[0]; @@ -56,7 +55,8 @@ static int cyttsp_spi_xfer(u8 op, struct device *dev, int i; if (length > CY_SPI_DATA_SIZE) { - dev_err(dev, "%s: length %d is too big.\n", __func__, length); + dev_err(ts->dev, "%s: length %d is too big.\n", + __func__, length); return -EINVAL; } @@ -95,13 +95,13 @@ static int cyttsp_spi_xfer(u8 op, struct device *dev, break; default: - dev_err(dev, "%s: bad operation code=%d\n", __func__, op); + dev_err(ts->dev, "%s: bad operation code=%d\n", __func__, op); return -EINVAL; } retval = spi_sync(spi, &msg); if (retval < 0) { - dev_dbg(dev, "%s: spi_sync() error %d, len=%d, op=%d\n", + dev_dbg(ts->dev, "%s: spi_sync() error %d, len=%d, op=%d\n", __func__, retval, xfer[1].len, op); /* @@ -114,13 +114,13 @@ static int cyttsp_spi_xfer(u8 op, struct device *dev, if (rd_buf[CY_SPI_SYNC_BYTE] != CY_SPI_SYNC_ACK1 || rd_buf[CY_SPI_SYNC_BYTE + 1] != CY_SPI_SYNC_ACK2) { - dev_dbg(dev, "%s: operation %d failed\n", __func__, op); + dev_dbg(ts->dev, "%s: operation %d failed\n", __func__, op); for (i = 0; i < CY_SPI_CMD_BYTES; i++) - dev_dbg(dev, "%s: test rd_buf[%d]:0x%02x\n", + dev_dbg(ts->dev, "%s: test rd_buf[%d]:0x%02x\n", __func__, i, rd_buf[i]); for (i = 0; i < length; i++) - dev_dbg(dev, "%s: test buf[%d]:0x%02x\n", + dev_dbg(ts->dev, "%s: test buf[%d]:0x%02x\n", __func__, i, buf[i]); return -EIO; @@ -129,16 +129,16 @@ static int cyttsp_spi_xfer(u8 op, struct device *dev, return 0; } -static int cyttsp_spi_read_block_data(struct device *dev, +static int cyttsp_spi_read_block_data(struct cyttsp *ts, u8 addr, u8 length, void *data) { - return cyttsp_spi_xfer(CY_SPI_RD_OP, dev, addr, data, length); + return cyttsp_spi_xfer(ts, CY_SPI_RD_OP, addr, data, length); } -static int cyttsp_spi_write_block_data(struct device *dev, +static int cyttsp_spi_write_block_data(struct cyttsp *ts, u8 addr, u8 length, const void *data) { - return cyttsp_spi_xfer(CY_SPI_WR_OP, dev, addr, (void *)data, length); + return cyttsp_spi_xfer(ts, CY_SPI_WR_OP, addr, (void *)data, length); } static const struct cyttsp_bus_ops cyttsp_spi_bus_ops = { ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch 2012-01-29 6:18 ` Dmitry Torokhov @ 2012-01-29 15:28 ` Javier Martinez Canillas 2012-01-31 8:21 ` Dmitry Torokhov 0 siblings, 1 reply; 5+ messages in thread From: Javier Martinez Canillas @ 2012-01-29 15:28 UTC (permalink / raw) To: Dmitry Torokhov Cc: Javier Martinez Canillas, Henrik Rydberg, Kevin McNeely, linux-input On Sun, Jan 29, 2012 at 7:18 AM, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > On Sun, Jan 29, 2012 at 06:53:50AM +0100, Javier Martinez Canillas wrote: >> This is patch fixes two bugs in Dmitry's last cleanup patch. >> >> 1- The hardware tracking ids are stored in the ids array and the information for >> each contact is obtained calling cyttsp_get_tch() with an index. In the clean-up >> patch the value of the tracking id was used instead of the contact index. >> > > Oops, thank you for fixing that. > >> 2- i2c_set_clientdata() is called after the generic cyttsp_probe() function and >> this function calls cyttsp_power_on() that sends an ttsp command to the device >> and needs the client data before is set. The fix is to execute cyttsp_power_on >> inside the transport specific probe function (I2C, SPI) after the generic probe >> function is executed and the client data is set. >> > > Not quite happy about this one, how about we pass cyttsp directly to bus > methods instead of relying on drvdata (as in the patch below)? > > Thanks. > > -- > Dmitry Hi Dmitry, Yes, you are right that is a much more clever solution to the issue. Thank you for suggesting that. I just sent an v2 of the incremental patch to be applied on top of your last clean-up. This fixes the index bug stated before and the dev->i2c_client->cyttsp reference being NULL issue changing the read/write methods signature as you suggested. It also fixes an unbalanced IRQ warning since soft_reset() now is called inside the probe function and removes the wake_up platform function in enable() as with the incremental v1. Thanks a lot for your help and best regards, Javier -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch 2012-01-29 15:28 ` Javier Martinez Canillas @ 2012-01-31 8:21 ` Dmitry Torokhov 2012-01-31 16:52 ` Javier Martinez Canillas 0 siblings, 1 reply; 5+ messages in thread From: Dmitry Torokhov @ 2012-01-31 8:21 UTC (permalink / raw) To: Javier Martinez Canillas Cc: Javier Martinez Canillas, Henrik Rydberg, Kevin McNeely, linux-input On Sun, Jan 29, 2012 at 04:28:12PM +0100, Javier Martinez Canillas wrote: > On Sun, Jan 29, 2012 at 7:18 AM, Dmitry Torokhov > <dmitry.torokhov@gmail.com> wrote: > > On Sun, Jan 29, 2012 at 06:53:50AM +0100, Javier Martinez Canillas wrote: > >> This is patch fixes two bugs in Dmitry's last cleanup patch. > >> > >> 1- The hardware tracking ids are stored in the ids array and the information for > >> each contact is obtained calling cyttsp_get_tch() with an index. In the clean-up > >> patch the value of the tracking id was used instead of the contact index. > >> > > > > Oops, thank you for fixing that. > > > >> 2- i2c_set_clientdata() is called after the generic cyttsp_probe() function and > >> this function calls cyttsp_power_on() that sends an ttsp command to the device > >> and needs the client data before is set. The fix is to execute cyttsp_power_on > >> inside the transport specific probe function (I2C, SPI) after the generic probe > >> function is executed and the client data is set. > >> > > > > Not quite happy about this one, how about we pass cyttsp directly to bus > > methods instead of relying on drvdata (as in the patch below)? > > > > Thanks. > > > > -- > > Dmitry > > Hi Dmitry, > > Yes, you are right that is a much more clever solution to the issue. > Thank you for suggesting that. > > I just sent an v2 of the incremental patch to be applied on top of > your last clean-up. > > This fixes the index bug stated before and the dev->i2c_client->cyttsp > reference being NULL issue changing the read/write methods signature > as you suggested. > > It also fixes an unbalanced IRQ warning since soft_reset() now is > called inside the probe function and removes the wake_up platform > function in enable() as with the incremental v1. > > Thanks a lot for your help and best regards, Folded everything up and applied to my 3.4 queue. Thank you Javier. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch 2012-01-31 8:21 ` Dmitry Torokhov @ 2012-01-31 16:52 ` Javier Martinez Canillas 0 siblings, 0 replies; 5+ messages in thread From: Javier Martinez Canillas @ 2012-01-31 16:52 UTC (permalink / raw) To: Dmitry Torokhov Cc: Javier Martinez Canillas, Henrik Rydberg, Kevin McNeely, linux-input On Tue, Jan 31, 2012 at 8:21 AM, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > On Sun, Jan 29, 2012 at 04:28:12PM +0100, Javier Martinez Canillas wrote: >> On Sun, Jan 29, 2012 at 7:18 AM, Dmitry Torokhov >> <dmitry.torokhov@gmail.com> wrote: >> > On Sun, Jan 29, 2012 at 06:53:50AM +0100, Javier Martinez Canillas wrote: >> >> This is patch fixes two bugs in Dmitry's last cleanup patch. >> >> >> >> 1- The hardware tracking ids are stored in the ids array and the information for >> >> each contact is obtained calling cyttsp_get_tch() with an index. In the clean-up >> >> patch the value of the tracking id was used instead of the contact index. >> >> >> > >> > Oops, thank you for fixing that. >> > >> >> 2- i2c_set_clientdata() is called after the generic cyttsp_probe() function and >> >> this function calls cyttsp_power_on() that sends an ttsp command to the device >> >> and needs the client data before is set. The fix is to execute cyttsp_power_on >> >> inside the transport specific probe function (I2C, SPI) after the generic probe >> >> function is executed and the client data is set. >> >> >> > >> > Not quite happy about this one, how about we pass cyttsp directly to bus >> > methods instead of relying on drvdata (as in the patch below)? >> > >> > Thanks. >> > >> > -- >> > Dmitry >> >> Hi Dmitry, >> >> Yes, you are right that is a much more clever solution to the issue. >> Thank you for suggesting that. >> >> I just sent an v2 of the incremental patch to be applied on top of >> your last clean-up. >> >> This fixes the index bug stated before and the dev->i2c_client->cyttsp >> reference being NULL issue changing the read/write methods signature >> as you suggested. >> >> It also fixes an unbalanced IRQ warning since soft_reset() now is >> called inside the probe function and removes the wake_up platform >> function in enable() as with the incremental v1. >> >> Thanks a lot for your help and best regards, > > Folded everything up and applied to my 3.4 queue. > > Thank you Javier. > > -- > Dmitry Great, thank you very much for your help Dmitry! Regards, Javier -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-31 16:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-01-29 5:53 [PATCH 1/1][INCREMENTAL] Input: cyttsp - Fixes to clean-up patch Javier Martinez Canillas 2012-01-29 6:18 ` Dmitry Torokhov 2012-01-29 15:28 ` Javier Martinez Canillas 2012-01-31 8:21 ` Dmitry Torokhov 2012-01-31 16:52 ` Javier Martinez Canillas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).