diff mbox

[4/6] Input: elantech - work around EC buffer

Message ID 1313632629-23603-5-git-send-email-jj_ding@emc.com.tw (mailing list archive)
State New, archived
Headers show

Commit Message

JJ Ding Aug. 18, 2011, 1:57 a.m. UTC
With some EC chips, when we resync due to bad packets, those bad bytes would
still remain in EC's buffer area. That makes us always get bad data back,
no matter what.

So shift packet for 1 byte when encounter bad packet, until we get rid of those
bytes.

Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
---
 drivers/input/mouse/elantech.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

Comments

Daniel Kurtz Aug. 18, 2011, 2:50 a.m. UTC | #1
On Thu, Aug 18, 2011 at 9:57 AM, JJ Ding <jj_ding@emc.com.tw> wrote:
> With some EC chips, when we resync due to bad packets, those bad bytes would
> still remain in EC's buffer area. That makes us always get bad data back,
> no matter what.
>
> So shift packet for 1 byte when encounter bad packet, until we get rid of those
> bytes.
>
> Signed-off-by: JJ Ding <jj_ding@emc.com.tw>

Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
--
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
Wanlong Gao Aug. 18, 2011, 3:07 a.m. UTC | #2
On 08/18/2011 09:57 AM, JJ Ding wrote:
> With some EC chips, when we resync due to bad packets, those bad bytes would
> still remain in EC's buffer area. That makes us always get bad data back,
> no matter what.
>
> So shift packet for 1 byte when encounter bad packet, until we get rid of those
> bytes.
>
> Signed-off-by: JJ Ding<jj_ding@emc.com.tw>
> ---
>   drivers/input/mouse/elantech.c |    9 +++++++--
>   1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
> index 032181c..7b9b6e5 100644
> --- a/drivers/input/mouse/elantech.c
> +++ b/drivers/input/mouse/elantech.c
> @@ -411,20 +411,25 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
>   	switch (etd->hw_version) {
>   	case 1:
>   		if (etd->paritycheck&&  !elantech_check_parity_v1(psmouse))
> -			return PSMOUSE_BAD_DATA;
> +			goto bad_packet;
>
>   		elantech_report_absolute_v1(psmouse);
>   		break;
>
>   	case 2:
>   		if (etd->paritycheck&&  !packet_simple_check_v2(psmouse))
> -			return PSMOUSE_BAD_DATA;
> +			goto bad_packet;
>
>   		elantech_report_absolute_v2(psmouse);
>   		break;
>   	}
>
>   	return PSMOUSE_FULL_PACKET;
> +
> + bad_packet:
You may introduce space here.
> +	memmove(psmouse->packet, psmouse->packet + 1, psmouse->pktsize - 1);
> +	psmouse->pktcnt--;
> +	return PSMOUSE_GOOD_DATA;
>   }
>
>   /*
Dmitry Torokhov Aug. 18, 2011, 6:39 a.m. UTC | #3
On Thu, Aug 18, 2011 at 09:57:07AM +0800, JJ Ding wrote:
> With some EC chips, when we resync due to bad packets, those bad bytes would
> still remain in EC's buffer area. That makes us always get bad data back,
> no matter what.
> 
> So shift packet for 1 byte when encounter bad packet, until we get rid of those
> bytes.

If we want to do this I think it should be done in psmouse core.

Thanks.
JJ Ding Aug. 18, 2011, 6:48 a.m. UTC | #4
Hi Wanlong Gao,

On Thu, 18 Aug 2011 11:07:23 +0800, Wanlong Gao <gaowanlong@cn.fujitsu.com> wrote:
> On 08/18/2011 09:57 AM, JJ Ding wrote:
> >
> >   	return PSMOUSE_FULL_PACKET;
> > +
> > + bad_packet:
> You may introduce space here.
Sorry, I am following you here.
Do you want me to add one more line below bad_packet:,
or you want me to remove the space before bad_packet?

I keep that space to make the goto tags look consistent with other
places in this file.

Should I remove all starting spaces in goto tags in the file?

Thanks,

jj

> > +	memmove(psmouse->packet, psmouse->packet + 1, psmouse->pktsize - 1);
> > +	psmouse->pktcnt--;
> > +	return PSMOUSE_GOOD_DATA;
> >   }
> >
> >   /*
> 
> 
> -- 
> Thanks
> Wanlong Gao
--
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
JJ Ding Aug. 18, 2011, 6:54 a.m. UTC | #5
Hi Dmitry,

On Wed, 17 Aug 2011 23:39:18 -0700, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Thu, Aug 18, 2011 at 09:57:07AM +0800, JJ Ding wrote:
> > With some EC chips, when we resync due to bad packets, those bad bytes would
> > still remain in EC's buffer area. That makes us always get bad data back,
> > no matter what.
> > 
> > So shift packet for 1 byte when encounter bad packet, until we get rid of those
> > bytes.
> 
> If we want to do this I think it should be done in psmouse core.
> 
> Thanks.
OK. That sounds more appropriate.
I will remove this patch from the series.

Thanks, 

jj

> 
> -- 
> 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
Wanlong Gao Aug. 18, 2011, 6:54 a.m. UTC | #6
On 08/18/2011 02:48 PM, JJ Ding wrote:
> Hi Wanlong Gao,
>
> On Thu, 18 Aug 2011 11:07:23 +0800, Wanlong Gao<gaowanlong@cn.fujitsu.com>  wrote:
>> On 08/18/2011 09:57 AM, JJ Ding wrote:
>>>
>>>    	return PSMOUSE_FULL_PACKET;
>>> +
>>> + bad_packet:
>> You may introduce space here.
> Sorry, I am following you here.
> Do you want me to add one more line below bad_packet:,
> or you want me to remove the space before bad_packet?
>
> I keep that space to make the goto tags look consistent with other
> places in this file.
>
> Should I remove all starting spaces in goto tags in the file?
>
> Thanks,
>
> jj

aha, I see that some with space but some without.
Now, I'm not sure....;)

Thanks
-Wanlong Gao
>
>>> +	memmove(psmouse->packet, psmouse->packet + 1, psmouse->pktsize - 1);
>>> +	psmouse->pktcnt--;
>>> +	return PSMOUSE_GOOD_DATA;
>>>    }
>>>
>>>    /*
>>
>>
>> --
>> Thanks
>> Wanlong Gao
> --
> 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
>

--
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
diff mbox

Patch

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 032181c..7b9b6e5 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -411,20 +411,25 @@  static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
 	switch (etd->hw_version) {
 	case 1:
 		if (etd->paritycheck && !elantech_check_parity_v1(psmouse))
-			return PSMOUSE_BAD_DATA;
+			goto bad_packet;
 
 		elantech_report_absolute_v1(psmouse);
 		break;
 
 	case 2:
 		if (etd->paritycheck && !packet_simple_check_v2(psmouse))
-			return PSMOUSE_BAD_DATA;
+			goto bad_packet;
 
 		elantech_report_absolute_v2(psmouse);
 		break;
 	}
 
 	return PSMOUSE_FULL_PACKET;
+
+ bad_packet:
+	memmove(psmouse->packet, psmouse->packet + 1, psmouse->pktsize - 1);
+	psmouse->pktcnt--;
+	return PSMOUSE_GOOD_DATA;
 }
 
 /*