Skip to content

Commit 386cc52

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: SITMDR2 and SIRMDR2 bitfield conversion
Convert MSIOF Transmit and Receive Mode Register 2 field accesses to use the FIELD_PREP() bitfield access macro. This gets rid of explicit shifts and custom field preparation macros. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/135b92d010a71e2c224feab3a5792724b4e60ff1.1747401908.git.geert+renesas@glider.be Signed-off-by: Mark Brown <[email protected]>
1 parent 6bae252 commit 386cc52

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ struct sh_msiof_spi_priv {
100100
/* 0=MSIOF_SYNC, 1=MSIOF_SS1, 2=MSIOF_SS2 */
101101

102102
/* SITMDR2 and SIRMDR2 */
103-
#define SIMDR2_BITLEN1(i) (((i) - 1) << 24) /* Data Size (8-32 bits) */
104-
#define SIMDR2_WDLEN1(i) (((i) - 1) << 16) /* Word Count (1-64/256 (SH, A1))) */
103+
#define SIMDR2_BITLEN1 GENMASK(28, 24) /* Data Size (8-32 bits) */
104+
#define SIMDR2_WDLEN1 GENMASK(23, 16) /* Word Count (1-64/256 (SH, A1))) */
105105
#define SIMDR2_GRPMASK1 BIT(0) /* Group Output Mask 1 (SH, A1) */
106106

107107
/* SITSCR and SIRSCR */
@@ -397,7 +397,8 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
397397
const void *tx_buf, void *rx_buf,
398398
u32 bits, u32 words)
399399
{
400-
u32 dr2 = SIMDR2_BITLEN1(bits) | SIMDR2_WDLEN1(words);
400+
u32 dr2 = FIELD_PREP(SIMDR2_BITLEN1, bits - 1) |
401+
FIELD_PREP(SIMDR2_WDLEN1, words - 1);
401402

402403
if (tx_buf || (p->ctlr->flags & SPI_CONTROLLER_MUST_TX))
403404
sh_msiof_write(p, SITMDR2, dr2);
@@ -931,6 +932,7 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,
931932
struct spi_transfer *t)
932933
{
933934
struct sh_msiof_spi_priv *p = spi_controller_get_devdata(ctlr);
935+
unsigned int max_wdlen = FIELD_MAX(SIMDR2_WDLEN1) + 1;
934936
void (*copy32)(u32 *, const u32 *, unsigned int);
935937
void (*tx_fifo)(struct sh_msiof_spi_priv *, const void *, unsigned int,
936938
unsigned int);
@@ -940,7 +942,6 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,
940942
void *rx_buf = t->rx_buf;
941943
unsigned int len = t->len;
942944
unsigned int bits = t->bits_per_word;
943-
unsigned int max_wdlen = 256;
944945
unsigned int bytes_per_word;
945946
unsigned int words;
946947
int n;

0 commit comments

Comments
 (0)