[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <161297912701.418021.12174983952645253802@swboyd.mtv.corp.google.com>
Date: Wed, 10 Feb 2021 09:45:27 -0800
From: Stephen Boyd <swboyd@...omium.org>
To: Gwendal Grignou <gwendal@...omium.org>
Cc: Jonathan Cameron <jic23@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-iio <linux-iio@...r.kernel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Benson Leung <bleung@...omium.org>,
Guenter Roeck <groeck@...omium.org>,
Douglas Anderson <dianders@...omium.org>,
Enric Balletbo i Serra <enric.balletbo@...labora.com>
Subject: Re: [PATCH v5 3/3] iio: proximity: Add a ChromeOS EC MKBP proximity driver
Quoting Gwendal Grignou (2021-02-10 00:29:45)
> On Tue, Feb 9, 2021 at 6:51 PM Stephen Boyd <swboyd@...omium.org> wrote:
> > + if (event_type == EC_MKBP_EVENT_SWITCH) {
> > + data = container_of(nb, struct cros_ec_mkbp_proximity_data,
> > + notifier);
> > + indio_dev = data->indio_dev;
> > +
> > + mutex_lock(&data->lock);
> > + if (data->enabled) {
> > + timestamp = ktime_to_ns(ec->last_event_time);
> Note to self, ktime_to_ns is a noop, but make code cleaner: need to
> change other access to ec->last_event_time.
>
> > + if (iio_device_get_clock(indio_dev) != CLOCK_BOOTTIME)
> > + timestamp = iio_get_time_ns(indio_dev);
> > + state = cros_ec_mkbp_proximity_parse_state(switches);
>
> There can be several switches in the EC (lid open, tablet mode, ...),
> so you can get a switch event even when the proximity switch did not
> trigger.
> You can keep the current state and push an iio event only when there
> is a change. See cbas_ec_notify().
>
Ah ok. So we'll have to save a state tracking variable and poll the bit
once at boot and then at resume time? What happens to events that happen
across suspend/resume? We drop them? Or we need to inject the last state
if it's different into IIO with the time of resume?
> > + dir = state ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING;
> > +
> > + ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0,
> > + IIO_EV_TYPE_THRESH, dir);
> > + iio_push_event(indio_dev, ev, timestamp);
> > + }
> > + mutex_unlock(&data->lock);
> > + }
> > +
> > + return NOTIFY_OK;
> > +}
> > +
> > +static int cros_ec_mkbp_proximity_read_raw(struct iio_dev *indio_dev,
> > + const struct iio_chan_spec *chan, int *val,
> > + int *val2, long mask)
> > +{
> > + struct cros_ec_mkbp_proximity_data *data = iio_priv(indio_dev);
> > + struct cros_ec_device *ec = data->ec;
> > +
> > + if (chan->type != IIO_PROXIMITY)
> > + return -EINVAL;
> > +
> > + switch (mask) {
>
> A switch is not necessary here.
Ok.
> > + case IIO_CHAN_INFO_RAW:
Powered by blists - more mailing lists