Re: [PATCH v2 10/23] HID: uclogic: Support v2 protocol

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/21/19 12:59 PM, Benjamin Tissoires wrote:
On Thu, Feb 21, 2019 at 11:54 AM Nikolai Kondrashov <spbnick@xxxxxxxxx> wrote:

On 2/21/19 12:41 PM, Benjamin Tissoires wrote:
On Sun, Feb 10, 2019 at 11:15 AM Nikolai Kondrashov <spbnick@xxxxxxxxx> wrote:
+/**
+ * uclogic_params_get_le24() - get a 24-bit little-endian number from a
+ * buffer.
+ *
+ * @p: The pointer to the number buffer.
+ *
+ * Returns:
+ *     The retrieved number
+ */
+static s32 uclogic_params_get_le24(const void *p)
+{
+       const __u8 *b = p;
+       return b[0] | (b[1] << 8UL) | (b[2] << 16UL);

Nitpick, I am pretty sure we already have the bits in the kernel for that.

I tried to find it and couldn't, do you have any hints where I can find it?

For non aligned bits in the middle of a report, we have
hid_field_extract()
(https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/tree/drivers/hid/hid-core.c?h=for-next#n1301)

Yeah, that could work. However, if you don't mind, I'd rather keep using my
version for now, since hid_field_extract is only available starting v4.2.
That would let digimend-kernel-drivers build on older distros without having
the code differ that much from upstream. Maybe next year.

For other regular operations, there are the get_unaligned_le*()
operations, but they are for 16, 32 or 64 bits.

Yes, I found these.

include/target/target_core_backend.h has a get_unaligned_be24() but it
requires to read p - 1, and I am not sure you can in your case.

Yeah, I'd rather not use a function which does p - 1, has no hint of that
limitation in its name, and is a part of the unrelated storage subsystem.

Thanks :)

Nick



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux