Skip to content

Commit

Permalink
net: dsa: sja1105: convert sja1105_spi_message_pack() to packed_field…
Browse files Browse the repository at this point in the history
…s array

Signed-off-by: Vladimir Oltean <[email protected]>
  • Loading branch information
vladimiroltean authored and jacob-keller committed Sep 6, 2024
1 parent e310531 commit 25e2d5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions drivers/net/dsa/sja1105/sja1105.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ struct sja1105_private {
#include "sja1105_dynamic_config.h"

struct sja1105_spi_message {
u64 access;
u64 read_count;
u64 address;
u8 access;
u8 read_count;
u32 address;
};

/* From sja1105_main.c */
Expand Down
12 changes: 9 additions & 3 deletions drivers/net/dsa/sja1105/sja1105_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ struct sja1105_chunk {
u64 reg_addr;
};

static const struct packed_field sja1105_spi_message_fields[] = {
PACKED_FIELD(31, 31, struct sja1105_spi_message, access),
PACKED_FIELD(30, 25, struct sja1105_spi_message, read_count),
PACKED_FIELD(24, 4, struct sja1105_spi_message, address),
};

static void
sja1105_spi_message_pack(void *buf, const struct sja1105_spi_message *msg)
{
const int size = SJA1105_SIZE_SPI_MSG_HEADER;

CHECK_PACKED_FIELDS_3(sja1105_spi_message_fields, SJA1105_SIZE_SPI_MSG_HEADER);

memset(buf, 0, size);

sja1105_pack(buf, msg->access, 31, 31, size);
sja1105_pack(buf, msg->read_count, 30, 25, size);
sja1105_pack(buf, msg->address, 24, 4, size);
sja1105_pack_fields(buf, size, msg, sja1105_spi_message_fields);
}

/* If @rw is:
Expand Down

0 comments on commit 25e2d5f

Please sign in to comment.