Re: [PATCH v8 1/3] Input: cyttsp - Cypress TTSP capacitivemulti-touch screen support

From: Javier Martinez Canillas
Date: Mon Jan 09 2012 - 15:41:21 EST


On Mon, Jan 9, 2012 at 6:35 PM, Henrik Rydberg <rydberg@xxxxxxxxxxx> wrote:
>
> Hi Javier,
>
> > Changes for v8:
> > Â Â Dmitry Torokhov (9):
> > Â Â - Fix use-after-free in cyttsp_release
> > Â Â - Remove ext() method from bus ops
> > Â Â - Move up into main touchscreen directory
> > Â Â - Rework Kconfig entries
> > Â Â - Guard PM methods with CONFIG_PM_SLEEP
> > Â Â - Device does not belong in bus structure
> > Â Â - Set up bus type in input device
> > Â Â - Use unified structure for ts object
> > Â Â - Consolidate PM methods
> >
> > Â Â Javier Martinez Canillas (5):
> > Â Â - Add <linux/device.h> macro to cyttsp_core.h
> > Â Â - Soft reset returns negative on error, not 0
> > Â Â - Use CY_NUM_RETRY instead of CY_DELAY_MAX for retries
> > Â Â - Add suspended an on boolean to cyttsp core
> > Â Â - Rework PM functions
>
> Looking a lot better now, thank you. Some tiny comments below.
>

Hi Henrik,

Your welcome. Thank you for the review and your patience.

> > +static int ttsp_read_block_data(struct cyttsp *ts, u8 command,
> > + Â Â u8 length, void *buf)
> > +{
> > + Â Â int retval = -1;
> > + Â Â int tries;
> > +
> > + Â Â if (!buf || !length)
> > + Â Â Â Â Â Â return -EINVAL;
> > +
> > + Â Â for (tries = 0; tries < CY_NUM_RETRY && (retval < 0); tries++) {
> > + Â Â Â Â Â Â retval = ts->bus_ops->read(ts->dev, command, length, buf);
> > + Â Â Â Â Â Â if (retval)
> > + Â Â Â Â Â Â Â Â Â Â msleep(CY_DELAY_DFLT);
> > + Â Â }
> > +
> > + Â Â return retval;
> > +}
>
> Still wondering why (retval > 0) is handled the same way as (retval < 0).
>

Well, that is a convention followed in the driver. All the bus
specific read/write operations (I2C, SPI, etc) never return positive
numbers. They return 0 on success or the error value (retval < 0).

Changing that semantic could be a bit of a hassle since all the driver
assumes that behavior. But to be consistent with the rest of the
kernel and if that could be a reason to not merge the driver I can
rework that.

> > +static int cyttsp_bl_app_valid(struct cyttsp *ts)
> > +{
> > + Â Â int retval;
> > +
> > + Â Â retval = cyttsp_load_bl_regs(ts);
> > +
> > + Â Â if (retval < 0) {
> > + Â Â Â Â Â Â retval = -ENODEV;
> > + Â Â Â Â Â Â goto done;
> > + Â Â }
> > +
> > + Â Â if (GET_BOOTLOADERMODE(ts->bl_data.bl_status)) {
> > + Â Â Â Â Â Â if (IS_VALID_APP(ts->bl_data.bl_status))
> > + Â Â Â Â Â Â Â Â Â Â return 0;
> > + Â Â Â Â Â Â else
> > + Â Â Â Â Â Â Â Â Â Â return -ENODEV;
> > + Â Â }
> > +
> > + Â Â if (GET_HSTMODE(ts->bl_data.bl_file) == CY_OPERATE_MODE) {
> > + Â Â Â Â Â Â if (!(IS_OPERATIONAL_ERR(ts->bl_data.bl_status)))
> > + Â Â Â Â Â Â Â Â Â Â return 1;
> > + Â Â Â Â Â Â else
> > + Â Â Â Â Â Â Â Â Â Â return -ENODEV;
> > + Â Â }
> > +
> > + Â Â retval = -ENODEV;
> > +done:
> > + Â Â return retval;
>
> The function seems to always return ENODEV, something to simplify?
>

Actually, it returns 1 if the device is not in bootloader mode an
operational or 0 otherwise. But you are right, the function is kind of
a mess. I'll simplify this.

> > +static int cyttsp_set_sysinfo_mode(struct cyttsp *ts)
> > +{
> > + Â Â int retval;
> > + Â Â int tries;
> > + Â Â u8 cmd = CY_SYSINFO_MODE;
> > +
> > + Â Â memset(&(ts->sysinfo_data), 0, sizeof(struct cyttsp_sysinfo_data));
> > +
> > + Â Â /* switch to sysinfo mode */
> > + Â Â retval = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd);
> > + Â Â if (retval < 0)
> > + Â Â Â Â Â Â return retval;
> > +
> > + Â Â /* read sysinfo registers */
> > + Â Â tries = 0;
> > + Â Â do {
> > + Â Â Â Â Â Â msleep(CY_DELAY_DFLT);
> > + Â Â Â Â Â Â retval = ttsp_read_block_data(ts, CY_REG_BASE,
> > + Â Â Â Â Â Â Â Â Â Â sizeof(ts->sysinfo_data), &ts->sysinfo_data);
> > + Â Â } while ((retval || (!ts->sysinfo_data.tts_verh &&
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â!ts->sysinfo_data.tts_verl)) &&
> > + Â Â Â Â Â Â Â(tries++ < CY_NUM_RETRY));
> > +
> > + Â Â if (tries >= CY_NUM_RETRY)
> > + Â Â Â Â Â Â return -EAGAIN;
>
> The loop above seems to appear many times in the code. Something to
> simplify?
>

Ok, will simplify this also.

> Thanks,
> Henrik

Thanks a lot and best regards,
Javier
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/