linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier@dowhile0.org>
To: Henrik Rydberg <rydberg@euromail.se>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Mohan Pallaka <mpallaka@codeaurora.org>,
	Kevin McNeely <kev@cypress.com>,
	Shubhrajyoti Datta <omaplinuxkernel@gmail.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 1/3] Input: cyttsp - Cypress TTSP capacitive multi-touch screen support
Date: Mon, 9 Jan 2012 21:41:20 +0100	[thread overview]
Message-ID: <CABxcv==QfPnXgBLjFLxQmpWRGRDPE11aP8xMGsMbh-dJBVtQjQ@mail.gmail.com> (raw)
In-Reply-To: <20120109173523.GA5613@polaris.bitmath.org>

On Mon, Jan 9, 2012 at 6:35 PM, Henrik Rydberg <rydberg@euromail.se> 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-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2012-01-09 20:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05  0:16 [PATCH v8 0/3] Input: Cypress TTSP device driver Javier Martinez Canillas
2012-01-05  0:16 ` [PATCH v8 1/3] Input: cyttsp - Cypress TTSP capacitive multi-touch screen support Javier Martinez Canillas
2012-01-09 17:35   ` Henrik Rydberg
2012-01-09 20:41     ` Javier Martinez Canillas [this message]
2012-01-05  0:16 ` [PATCH v8 2/3] Input: cyttsp - add support for Cypress TTSP touchscreen I2C bus interface Javier Martinez Canillas
2012-01-05  0:16 ` [PATCH v8 3/3] Input: cyttsp - add support for Cypress TTSP touchscreen SPI " Javier Martinez Canillas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABxcv==QfPnXgBLjFLxQmpWRGRDPE11aP8xMGsMbh-dJBVtQjQ@mail.gmail.com' \
    --to=javier@dowhile0.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kev@cypress.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpallaka@codeaurora.org \
    --cc=omaplinuxkernel@gmail.com \
    --cc=rydberg@euromail.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).