Skip to content

Commit 74cb19c

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: Make words/fs unsigned in FIFO helpers
Make the words and fs parameters of the various FIFO filler and emptier functions unsigned, as they can never be negative. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/a7b13ecb1811148227ec8c883079085ed1ea6eac.1747401908.git.geert+renesas@glider.be Signed-off-by: Mark Brown <[email protected]>
1 parent b4eec5c commit 74cb19c

File tree

1 file changed

+51
-33
lines changed

1 file changed

+51
-33
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -412,140 +412,154 @@ static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
412412
}
413413

414414
static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p,
415-
const void *tx_buf, int words, int fs)
415+
const void *tx_buf, unsigned int words,
416+
unsigned int fs)
416417
{
417418
const u8 *buf_8 = tx_buf;
418-
int k;
419+
unsigned int k;
419420

420421
for (k = 0; k < words; k++)
421422
sh_msiof_write(p, SITFDR, buf_8[k] << fs);
422423
}
423424

424425
static void sh_msiof_spi_write_fifo_16(struct sh_msiof_spi_priv *p,
425-
const void *tx_buf, int words, int fs)
426+
const void *tx_buf, unsigned int words,
427+
unsigned int fs)
426428
{
427429
const u16 *buf_16 = tx_buf;
428-
int k;
430+
unsigned int k;
429431

430432
for (k = 0; k < words; k++)
431433
sh_msiof_write(p, SITFDR, buf_16[k] << fs);
432434
}
433435

434436
static void sh_msiof_spi_write_fifo_16u(struct sh_msiof_spi_priv *p,
435-
const void *tx_buf, int words, int fs)
437+
const void *tx_buf, unsigned int words,
438+
unsigned int fs)
436439
{
437440
const u16 *buf_16 = tx_buf;
438-
int k;
441+
unsigned int k;
439442

440443
for (k = 0; k < words; k++)
441444
sh_msiof_write(p, SITFDR, get_unaligned(&buf_16[k]) << fs);
442445
}
443446

444447
static void sh_msiof_spi_write_fifo_32(struct sh_msiof_spi_priv *p,
445-
const void *tx_buf, int words, int fs)
448+
const void *tx_buf, unsigned int words,
449+
unsigned int fs)
446450
{
447451
const u32 *buf_32 = tx_buf;
448-
int k;
452+
unsigned int k;
449453

450454
for (k = 0; k < words; k++)
451455
sh_msiof_write(p, SITFDR, buf_32[k] << fs);
452456
}
453457

454458
static void sh_msiof_spi_write_fifo_32u(struct sh_msiof_spi_priv *p,
455-
const void *tx_buf, int words, int fs)
459+
const void *tx_buf, unsigned int words,
460+
unsigned int fs)
456461
{
457462
const u32 *buf_32 = tx_buf;
458-
int k;
463+
unsigned int k;
459464

460465
for (k = 0; k < words; k++)
461466
sh_msiof_write(p, SITFDR, get_unaligned(&buf_32[k]) << fs);
462467
}
463468

464469
static void sh_msiof_spi_write_fifo_s32(struct sh_msiof_spi_priv *p,
465-
const void *tx_buf, int words, int fs)
470+
const void *tx_buf, unsigned int words,
471+
unsigned int fs)
466472
{
467473
const u32 *buf_32 = tx_buf;
468-
int k;
474+
unsigned int k;
469475

470476
for (k = 0; k < words; k++)
471477
sh_msiof_write(p, SITFDR, swab32(buf_32[k] << fs));
472478
}
473479

474480
static void sh_msiof_spi_write_fifo_s32u(struct sh_msiof_spi_priv *p,
475-
const void *tx_buf, int words, int fs)
481+
const void *tx_buf,
482+
unsigned int words, unsigned int fs)
476483
{
477484
const u32 *buf_32 = tx_buf;
478-
int k;
485+
unsigned int k;
479486

480487
for (k = 0; k < words; k++)
481488
sh_msiof_write(p, SITFDR, swab32(get_unaligned(&buf_32[k]) << fs));
482489
}
483490

484491
static void sh_msiof_spi_read_fifo_8(struct sh_msiof_spi_priv *p,
485-
void *rx_buf, int words, int fs)
492+
void *rx_buf, unsigned int words,
493+
unsigned int fs)
486494
{
487495
u8 *buf_8 = rx_buf;
488-
int k;
496+
unsigned int k;
489497

490498
for (k = 0; k < words; k++)
491499
buf_8[k] = sh_msiof_read(p, SIRFDR) >> fs;
492500
}
493501

494502
static void sh_msiof_spi_read_fifo_16(struct sh_msiof_spi_priv *p,
495-
void *rx_buf, int words, int fs)
503+
void *rx_buf, unsigned int words,
504+
unsigned int fs)
496505
{
497506
u16 *buf_16 = rx_buf;
498-
int k;
507+
unsigned int k;
499508

500509
for (k = 0; k < words; k++)
501510
buf_16[k] = sh_msiof_read(p, SIRFDR) >> fs;
502511
}
503512

504513
static void sh_msiof_spi_read_fifo_16u(struct sh_msiof_spi_priv *p,
505-
void *rx_buf, int words, int fs)
514+
void *rx_buf, unsigned int words,
515+
unsigned int fs)
506516
{
507517
u16 *buf_16 = rx_buf;
508-
int k;
518+
unsigned int k;
509519

510520
for (k = 0; k < words; k++)
511521
put_unaligned(sh_msiof_read(p, SIRFDR) >> fs, &buf_16[k]);
512522
}
513523

514524
static void sh_msiof_spi_read_fifo_32(struct sh_msiof_spi_priv *p,
515-
void *rx_buf, int words, int fs)
525+
void *rx_buf, unsigned int words,
526+
unsigned int fs)
516527
{
517528
u32 *buf_32 = rx_buf;
518-
int k;
529+
unsigned int k;
519530

520531
for (k = 0; k < words; k++)
521532
buf_32[k] = sh_msiof_read(p, SIRFDR) >> fs;
522533
}
523534

524535
static void sh_msiof_spi_read_fifo_32u(struct sh_msiof_spi_priv *p,
525-
void *rx_buf, int words, int fs)
536+
void *rx_buf, unsigned int words,
537+
unsigned int fs)
526538
{
527539
u32 *buf_32 = rx_buf;
528-
int k;
540+
unsigned int k;
529541

530542
for (k = 0; k < words; k++)
531543
put_unaligned(sh_msiof_read(p, SIRFDR) >> fs, &buf_32[k]);
532544
}
533545

534546
static void sh_msiof_spi_read_fifo_s32(struct sh_msiof_spi_priv *p,
535-
void *rx_buf, int words, int fs)
547+
void *rx_buf, unsigned int words,
548+
unsigned int fs)
536549
{
537550
u32 *buf_32 = rx_buf;
538-
int k;
551+
unsigned int k;
539552

540553
for (k = 0; k < words; k++)
541554
buf_32[k] = swab32(sh_msiof_read(p, SIRFDR) >> fs);
542555
}
543556

544557
static void sh_msiof_spi_read_fifo_s32u(struct sh_msiof_spi_priv *p,
545-
void *rx_buf, int words, int fs)
558+
void *rx_buf, unsigned int words,
559+
unsigned int fs)
546560
{
547561
u32 *buf_32 = rx_buf;
548-
int k;
562+
unsigned int k;
549563

550564
for (k = 0; k < words; k++)
551565
put_unaligned(swab32(sh_msiof_read(p, SIRFDR) >> fs), &buf_32[k]);
@@ -673,13 +687,15 @@ static int sh_msiof_wait_for_completion(struct sh_msiof_spi_priv *p,
673687

674688
static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
675689
void (*tx_fifo)(struct sh_msiof_spi_priv *,
676-
const void *, int, int),
690+
const void *, unsigned int,
691+
unsigned int),
677692
void (*rx_fifo)(struct sh_msiof_spi_priv *,
678-
void *, int, int),
693+
void *, unsigned int,
694+
unsigned int),
679695
const void *tx_buf, void *rx_buf,
680696
unsigned int words, unsigned int bits)
681697
{
682-
int fifo_shift;
698+
unsigned int fifo_shift;
683699
int ret;
684700

685701
/* limit maximum word transfer to rx/tx fifo size */
@@ -913,8 +929,10 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,
913929
{
914930
struct sh_msiof_spi_priv *p = spi_controller_get_devdata(ctlr);
915931
void (*copy32)(u32 *, const u32 *, unsigned int);
916-
void (*tx_fifo)(struct sh_msiof_spi_priv *, const void *, int, int);
917-
void (*rx_fifo)(struct sh_msiof_spi_priv *, void *, int, int);
932+
void (*tx_fifo)(struct sh_msiof_spi_priv *, const void *, unsigned int,
933+
unsigned int);
934+
void (*rx_fifo)(struct sh_msiof_spi_priv *, void *, unsigned int,
935+
unsigned int);
918936
const void *tx_buf = t->tx_buf;
919937
void *rx_buf = t->rx_buf;
920938
unsigned int len = t->len;

0 commit comments

Comments
 (0)