Re: [PATCH 1/2] can: dev: add can_len2dll_len()

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

 





On 15.12.20 14:41, Marc Kleine-Budde wrote:
On 12/15/20 2:36 PM, Vincent MAILHOL wrote:
On Mar 15 Dec. 2020 at 21:55, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:

Cc: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
  drivers/net/can/dev.c   | 21 +++++++++++++++++++++
  include/linux/can/dev.h |  3 +++
  2 files changed, 24 insertions(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 68f37ac54327..fa81e3067b3b 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -60,6 +60,27 @@ u8 can_len2dlc(u8 len)
  }
  EXPORT_SYMBOL_GPL(can_len2dlc);

+static const u8 len2dll_len[] = {
+       0, 1, 2, 3, 4, 5, 6, 7, 8,      /* 0 - 8 */
+       12, 12, 12, 12,                 /* 9 - 12 */
+       16, 16, 16, 16,                 /* 13 - 16 */
+       20, 20, 20, 20,                 /* 17 - 20 */
+       24, 24, 24, 24,                 /* 21 - 24 */
+       32, 32, 32, 32, 32, 32, 32, 32, /* 25 - 32 */
+       40, 40, 40, 40, 40, 40, 40, 40, /* 33 - 40 */
+       48, 48, 48, 48, 48, 48, 48, 48  /* 41 - 48 */
+};

I totally misunderstood what you wanted to do in my previous
email. I thought that the numbers were placeholders and that
the final goal was to take into account the CRC as you previously
mentioned in your first email.

Sorry, should have been clearer about functionality of that table/function.

This function is just here to sanitize the data length, right?
Then we could simply name it can_fd_sanitize_len().

sanitized_len sounds good.

Yes and once you are a it:

Won't it make more sense to use

return can_fd_dlc2len(can_fd_len2dlc(len));

instead of creating a new table telling the same as the existing static const u8 len2dlc[] table?

Regards,
Oliver



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux