All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Roderick Colenbrander <roderick@gaikai.com>
Cc: linux-input@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
	Tim Bird <tim.bird@am.sony.com>,
	Roderick Colenbrander <roderick.colenbrander@sony.com>
Subject: Re: [PATCH 3/5] HID: sony: Perform CRC check on bluetooth input packets
Date: Wed, 5 Oct 2016 10:24:46 +0200	[thread overview]
Message-ID: <20161005082446.GA19261@mail.corp.redhat.com> (raw)
In-Reply-To: <1475636338-3779-4-git-send-email-roderick@gaikai.com>

Hi Roderick,

Thanks for the fast respin.

On Oct 04 2016 or thereabouts, Roderick Colenbrander wrote:
> From: Roderick Colenbrander <roderick.colenbrander@sony.com>
> 
> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
> ---
>  drivers/hid/hid-sony.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 43bb24c..34988ce 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -36,6 +36,8 @@
>  #include <linux/list.h>
>  #include <linux/idr.h>
>  #include <linux/input/mt.h>
> +#include <linux/crc32.h>
> +#include <asm/unaligned.h>
>  
>  #include "hid-ids.h"
>  
> @@ -1021,6 +1023,7 @@ struct motion_output_report_02 {
>  
>  #define DS4_FEATURE_REPORT_0x02_SIZE 37
>  #define DS4_FEATURE_REPORT_0x81_SIZE 7
> +#define DS4_INPUT_REPORT_0x11_SIZE 78

Just nitpicking, keeping the old define would have not changed a bit,
given that input and output reports on 0x11 are the same :)

Anyway, the 3 first patches are:
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

(you can add this to the patches in case of a resubmission, that's
easier to track which patches are reviewed and which are not).

I have a few comments on the 2 next.

Cheers,
Benjamin

>  #define DS4_OUTPUT_REPORT_0x05_SIZE 32
>  #define DS4_OUTPUT_REPORT_0x11_SIZE 78
>  #define SIXAXIS_REPORT_0xF2_SIZE 17
> @@ -1324,6 +1327,21 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
>  	} else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
>  			size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
>  			&& rd[0] == 0x11 && size == 78)) {
> +		if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) {
> +			/* CRC check */
> +			u8 bthdr = 0xA1;
> +			u32 crc;
> +			u32 report_crc;
> +
> +			crc = crc32_le(0xFFFFFFFF, &bthdr, 1);
> +			crc = ~crc32_le(crc, rd, DS4_INPUT_REPORT_0x11_SIZE-4);
> +			report_crc = get_unaligned_le32(&rd[DS4_INPUT_REPORT_0x11_SIZE-4]);
> +			if (crc != report_crc) {
> +				hid_dbg(sc->hdev, "DualShock 4 input report's CRC check failed, received crc 0x%0x != 0x%0x\n",
> +					report_crc, crc);
> +				return -EILSEQ;
> +			}
> +		}
>  		dualshock4_parse_report(sc, rd, size);
>  	}
>  
> -- 
> 2.7.4
> 

  reply	other threads:[~2016-10-05  8:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05  2:58 [PATCH 0/5] HID: sony: game controller updates Roderick Colenbrander
2016-10-05  2:58 ` [PATCH 1/5] HID: sony: Fix race condition in sony_probe Roderick Colenbrander
2016-10-05  2:58 ` [PATCH 2/5] HID: sony: Adjust HID report size name definitions Roderick Colenbrander
2016-10-05  2:58 ` [PATCH 3/5] HID: sony: Perform CRC check on bluetooth input packets Roderick Colenbrander
2016-10-05  8:24   ` Benjamin Tissoires [this message]
2016-10-05  2:58 ` [PATCH 4/5] HID: sony: Send ds4 output reports on output end-point Roderick Colenbrander
2016-10-05  8:31   ` Benjamin Tissoires
2016-10-05 16:54     ` Frank Praznik
2016-10-05 17:35       ` Simon Wood
2016-10-05 20:35         ` Frank Praznik
2016-10-07 15:56           ` Benjamin Tissoires
2016-10-05 18:53       ` Roderick Colenbrander
2016-10-05  2:58 ` [PATCH 5/5] HID: sony: Handle multiple touch events input record Roderick Colenbrander
2016-10-05  8:35   ` Benjamin Tissoires
2016-10-05 15:29     ` Simon Wood
2016-10-05 17:25       ` Roderick Colenbrander
2016-10-07 16:02         ` Benjamin Tissoires
2016-10-18 23:27           ` Roderick Colenbrander
2016-10-31  8:21             ` Benjamin Tissoires

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=20161005082446.GA19261@mail.corp.redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=roderick.colenbrander@sony.com \
    --cc=roderick@gaikai.com \
    --cc=tim.bird@am.sony.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.