On Fri, 2012-02-03 at 17:28 +0530, Ashish Jangam wrote:
>
> On Wed, Feb 01, 2012 at 01:58:55PM +0530, Ashish Jangam wrote:
> > On Wed, 2012-02-01 at 13:30 +0530, Ashish Jangam wrote:
>
> > > > + ret = da9052_reg_read(onkey->da9052, DA9052_EVENT_B_REG);
> > > > + if (ret < 0) {
> > > > + dev_err(onkey->da9052->dev,
> > > > + "da9052_onkey_report_event da9052_reg_read error %d\n",
> > > > + ret);
> > > > + ret = 1;
> > > > + } else {
> > > > + ret = ret & DA9052_EVENTB_ENONKEY;
> > > > + input_report_key(onkey->input, KEY_POWER, ret);
> > > > + input_sync(onkey->input);
> > > > + }
>
> > > > + if (ret)
> > > > + schedule_delayed_work(&onkey->work, msecs_to_jiffies(50));
>
> > > Why not just schedule the work directly? The use of ret took a bit
> > > of thinking about to follow.
>
> > schedule_dealyed_work simulates the release of the onkey button since
> > event for release is not generated and ret & DA9052_EVENTB_ENONKEY is
> > used to determine the release
>
> That doesn't seem to address the concern. You're setting ret in exactly one place
> and scheduling the work in exactly one place, why are these two things split?
schedule_delayed_work() is conditional because it should get invoke when onkey button is
pressed and not when released. For this reason onkey event is first queried and work is
scheduled only when event is present. Now when work is scheduled, onkey event gets
queried and in absence of the onkey event work will not get schedule again. By this logic I'm able
to simulated the release of the onkey button.
On Fri, Feb 03, 2012 at 06:54:06PM +0530, Ashish Jangam wrote:
> On Fri, 2012-02-03 at 17:28 +0530, Ashish Jangam wrote:
As *repeatetly* mentioned please fix the word wrapping in your mailer.
> > That doesn't seem to address the concern. You're setting ret in exactly one place
> > and scheduling the work in exactly one place, why are these two things split?
> schedule_delayed_work() is conditional because it should get invoke
> when onkey button is pressed and not when released. For this reason
> onkey event is first queried and work is scheduled only when event is
> present. Now when work is scheduled, onkey event gets queried and in
> absence of the onkey event work will not get schedule again. By this
> logic I'm able to simulated the release of the onkey button.
You're once more completely missing my point. You've got a conditional
which detects if the button is pressed in which you set a flag which is
checked later to see if you should also schedule the work. Since the
only thing that ever sets that flag is the button being pressed having
the flag seems pointless, you may as well just schedule the work instead
of setting the flag.