diff options
| author | Dario Pagani <> | 2021-01-24 10:07:24 +0100 |
|---|---|---|
| committer | Dario Pagani <> | 2021-01-24 10:07:24 +0100 |
| commit | 901baf3790f03687e02064d702c90c25f831b7de (patch) | |
| tree | ca84aa11914b6756ef35a1b9deaddf653f45e679 /hid-tminit.h | |
| parent | 5f48f29eb8fb7036ad8ae45bdda1f2c3db21f0cf (diff) | |
| download | hid-tminit-901baf3790f03687e02064d702c90c25f831b7de.tar.gz hid-tminit-901baf3790f03687e02064d702c90c25f831b7de.zip | |
Indented code according to Linux style in a way that passes checkpatch.cl. Replaced boilerplate code with the module_hid_driver macro
Diffstat (limited to 'hid-tminit.h')
| -rw-r--r-- | hid-tminit.h | 64 |
1 files changed, 26 insertions, 38 deletions
diff --git a/hid-tminit.h b/hid-tminit.h index 28ae827..729f493 100644 --- a/hid-tminit.h +++ b/hid-tminit.h @@ -1,37 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0*/ /** * These interrupts are used to prevent a nasty crash when initializing the * T300RS. Used in tminit_interrupts(). */ -u8 setup_0[] = { 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -u8 setup_1[] = { 0x0a, 0x04, 0x90, 0x03, 0x00, 0x00, 0x00, 0x00 }; -u8 setup_2[] = { 0x0a, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 }; -u8 setup_3[] = { 0x0a, 0x04, 0x12, 0x10, 0x00, 0x00, 0x00, 0x00 }; -u8 setup_4[] = { 0x0a, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00 }; -u8 *setup_arr[] = { setup_0, setup_1, setup_2, setup_3, setup_4 }; -unsigned int setup_arr_sizes[] = { +static const u8 setup_0[] = { 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const u8 setup_1[] = { 0x0a, 0x04, 0x90, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const u8 setup_2[] = { 0x0a, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 }; +static const u8 setup_3[] = { 0x0a, 0x04, 0x12, 0x10, 0x00, 0x00, 0x00, 0x00 }; +static const u8 setup_4[] = { 0x0a, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00 }; +static const u8 *const setup_arr[] = { setup_0, setup_1, setup_2, setup_3, setup_4 }; +static const unsigned int setup_arr_sizes[] = { ARRAY_SIZE(setup_0), ARRAY_SIZE(setup_1), ARRAY_SIZE(setup_2), ARRAY_SIZE(setup_3), - ARRAY_SIZE(setup_4) + ARRAY_SIZE(setup_4) }; /** * This struct contains for each type of * Thrustmaster wheel - * + * * Note: The values are stored in the CPU * endianess, the USB protocols always use * little endian; the macro cpu_to_le[BIT]() - * must be used when preparing USB packets + * must be used when preparing USB packets * and vice-versa */ -struct th_wheel_info -{ +struct th_wheel_info { uint16_t wheel_type; - /** See when the USB control out packet is prepared... - * @TODO The TMX seems to require to control codes to switch. - * Probabilly this field needs to be converted to an array, + /** See when the USB control out packet is prepared... + * @TODO The TMX seems to require multiple control codes to switch. */ uint16_t switch_value; @@ -40,12 +39,8 @@ struct th_wheel_info /** * All wheel I know. TO BE TESTED - * I can't find of a clever way to store them, but I do - * not think a O(n) cycle for each wheel attached to the - * machine is too bad... */ -static const struct th_wheel_info th_wheels_infos[] = -{ +static const struct th_wheel_info th_wheels_infos[] = { {0x0306, 0x0006, "Thrustmaster T150RS"}, {0x0206, 0x0005, "Thrustmaster T300RS"}, {0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"}, @@ -53,15 +48,15 @@ static const struct th_wheel_info th_wheels_infos[] = {0x0407, 0x0001, "Thrustmaster TMX"} }; -const uint8_t th_wheels_infos_length = 5; +static const uint8_t th_wheels_infos_length = 5; /** * This structs contains (in little endian) the response data * of the wheel to the request 73 - * + * * A sufficient research to understand what each field does is not - * beign conducted yet. The position and meaning of fields are a - * just a very optimistic guess based on instinct.... + * beign conducted yet. The position and meaning of fields are a + * just a very optimistic guess based on instinct.... */ struct __packed tm_wheel_response { @@ -72,10 +67,8 @@ struct __packed tm_wheel_response */ uint16_t type; - union - { - struct __packed - { + union { + struct __packed { uint16_t field0; uint16_t field1; /** @@ -89,8 +82,7 @@ struct __packed tm_wheel_response uint16_t field4; uint16_t field5; } a; - struct __packed - { + struct __packed { uint16_t field0; uint16_t field1; uint16_t model; @@ -98,8 +90,7 @@ struct __packed tm_wheel_response } data; }; -struct tm_wheel -{ +struct tm_wheel { struct usb_device *usb_dev; struct urb *urb; @@ -109,10 +100,8 @@ struct tm_wheel struct usb_ctrlrequest *change_request; }; -/** - * The control packet to send to wheel */ -struct usb_ctrlrequest model_request = -{ +/** The control packet to send to wheel */ +static const struct usb_ctrlrequest model_request = { .bRequestType = 0xc1, .bRequest = 73, .wValue = 0, @@ -120,8 +109,7 @@ struct usb_ctrlrequest model_request = .wLength = cpu_to_le16(0x0010) }; -struct usb_ctrlrequest change_request = -{ +static const struct usb_ctrlrequest change_request = { .bRequestType = 0x41, .bRequest = 83, .wValue = 0, // Will be filled by the driver |
