Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: renesas: Use guard() for spin locks

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark, Iwai-san

This patch-set follows Iwai-san's guard() update on Renesas drivers.

Kuninori Morimoto (4):
ASoC: renesas: msiof: Use guard() for spin locks
ASoC: renesas: rsnd: Use guard() for spin locks
ASoC: renesas: fsi: Use guard() for spin locks
ASoC: renesas: rz-ssi: Use guard() for spin locks

sound/soc/renesas/fsi.c | 30 ++++++++---------------------
sound/soc/renesas/rcar/core.c | 18 +++++------------
sound/soc/renesas/rcar/msiof.c | 26 ++++++++-----------------
sound/soc/renesas/rcar/src.c | 19 ++++++++----------
sound/soc/renesas/rcar/ssi.c | 35 +++++++++++++++++-----------------
sound/soc/renesas/rz-ssi.c | 14 ++++----------
6 files changed, 50 insertions(+), 92 deletions(-)

--
2.43.0

+51 -93
+8 -22
sound/soc/renesas/fsi.c
··· 343 343 #define fsi_core_read(p, r) _fsi_master_read(p, p->core->r) 344 344 static u32 _fsi_master_read(struct fsi_master *master, u32 reg) 345 345 { 346 - u32 ret; 347 - unsigned long flags; 346 + guard(spinlock_irqsave)(&master->lock); 348 347 349 - spin_lock_irqsave(&master->lock, flags); 350 - ret = __fsi_reg_read(master->base + reg); 351 - spin_unlock_irqrestore(&master->lock, flags); 352 - 353 - return ret; 348 + return __fsi_reg_read(master->base + reg); 354 349 } 355 350 356 351 #define fsi_master_mask_set(p, r, m, d) _fsi_master_mask_set(p, MST_##r, m, d) ··· 353 358 static void _fsi_master_mask_set(struct fsi_master *master, 354 359 u32 reg, u32 mask, u32 data) 355 360 { 356 - unsigned long flags; 361 + guard(spinlock_irqsave)(&master->lock); 357 362 358 - spin_lock_irqsave(&master->lock, flags); 359 363 __fsi_reg_mask_set(master->base + reg, mask, data); 360 - spin_unlock_irqrestore(&master->lock, flags); 361 364 } 362 365 363 366 /* ··· 492 499 struct fsi_stream *io) 493 500 { 494 501 struct fsi_master *master = fsi_get_master(fsi); 495 - unsigned long flags; 496 - int ret; 497 502 498 - spin_lock_irqsave(&master->lock, flags); 499 - ret = !!(io->substream && io->substream->runtime); 500 - spin_unlock_irqrestore(&master->lock, flags); 503 + guard(spinlock_irqsave)(&master->lock); 501 504 502 - return ret; 505 + return !!(io->substream && io->substream->runtime); 503 506 } 504 507 505 508 static struct fsi_priv *fsi_stream_to_priv(struct fsi_stream *io) ··· 509 520 { 510 521 struct snd_pcm_runtime *runtime = substream->runtime; 511 522 struct fsi_master *master = fsi_get_master(fsi); 512 - unsigned long flags; 513 523 514 - spin_lock_irqsave(&master->lock, flags); 524 + guard(spinlock_irqsave)(&master->lock); 525 + 515 526 io->substream = substream; 516 527 io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size); 517 528 io->buff_sample_pos = 0; ··· 522 533 io->oerr_num = -1; /* ignore 1st err */ 523 534 io->uerr_num = -1; /* ignore 1st err */ 524 535 fsi_stream_handler_call(io, init, fsi, io); 525 - spin_unlock_irqrestore(&master->lock, flags); 526 536 } 527 537 528 538 static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io) 529 539 { 530 540 struct snd_soc_dai *dai = fsi_get_dai(io->substream); 531 541 struct fsi_master *master = fsi_get_master(fsi); 532 - unsigned long flags; 533 542 534 - spin_lock_irqsave(&master->lock, flags); 543 + guard(spinlock_irqsave)(&master->lock); 535 544 536 545 if (io->oerr_num > 0) 537 546 dev_err(dai->dev, "over_run = %d\n", io->oerr_num); ··· 547 560 io->bus_option = 0; 548 561 io->oerr_num = 0; 549 562 io->uerr_num = 0; 550 - spin_unlock_irqrestore(&master->lock, flags); 551 563 } 552 564 553 565 static int fsi_stream_transfer(struct fsi_stream *io)
+5 -13
sound/soc/renesas/rcar/core.c
··· 696 696 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); 697 697 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); 698 698 int ret; 699 - unsigned long flags; 700 699 701 - spin_lock_irqsave(&priv->lock, flags); 700 + guard(spinlock_irqsave)(&priv->lock); 702 701 703 702 switch (cmd) { 704 703 case SNDRV_PCM_TRIGGER_START: 705 704 case SNDRV_PCM_TRIGGER_RESUME: 706 705 ret = rsnd_dai_call(init, io, priv); 707 706 if (ret < 0) 708 - goto dai_trigger_end; 707 + break; 709 708 710 709 ret = rsnd_dai_call(start, io, priv); 711 710 if (ret < 0) 712 - goto dai_trigger_end; 711 + break; 713 712 714 713 ret = rsnd_dai_call(irq, io, priv, 1); 715 - if (ret < 0) 716 - goto dai_trigger_end; 717 - 718 714 break; 719 715 case SNDRV_PCM_TRIGGER_STOP: 720 716 case SNDRV_PCM_TRIGGER_SUSPEND: ··· 724 728 default: 725 729 ret = -EINVAL; 726 730 } 727 - 728 - dai_trigger_end: 729 - spin_unlock_irqrestore(&priv->lock, flags); 730 731 731 732 return ret; 732 733 } ··· 1538 1545 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); 1539 1546 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); 1540 1547 struct rsnd_priv *priv = rsnd_io_to_priv(io); 1541 - unsigned long flags; 1542 1548 int ret; 1543 1549 1544 - spin_lock_irqsave(&priv->lock, flags); 1550 + guard(spinlock_irqsave)(&priv->lock); 1551 + 1545 1552 if (hw_params) 1546 1553 ret = rsnd_dai_call(hw_params, io, substream, hw_params); 1547 1554 else 1548 1555 ret = rsnd_dai_call(hw_free, io, substream); 1549 - spin_unlock_irqrestore(&priv->lock, flags); 1550 1556 1551 1557 return ret; 1552 1558 }
+8 -18
sound/soc/renesas/rcar/msiof.c
··· 372 372 { 373 373 struct device *dev = component->dev; 374 374 struct msiof_priv *priv = dev_get_drvdata(dev); 375 - unsigned long flags; 376 375 int ret = -EINVAL; 377 376 378 - spin_lock_irqsave(&priv->lock, flags); 377 + guard(spinlock_irqsave)(&priv->lock); 379 378 380 379 switch (cmd) { 381 380 case SNDRV_PCM_TRIGGER_START: ··· 391 392 break; 392 393 } 393 394 394 - spin_unlock_irqrestore(&priv->lock, flags); 395 - 396 395 return ret; 397 396 } 398 397 ··· 401 404 struct msiof_priv *priv = dev_get_drvdata(component->dev); 402 405 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); 403 406 struct dma_slave_config cfg = {}; 404 - unsigned long flags; 405 407 int ret; 406 408 407 - spin_lock_irqsave(&priv->lock, flags); 409 + guard(spinlock_irqsave)(&priv->lock); 408 410 409 411 ret = snd_hwparams_to_dma_slave_config(substream, params, &cfg); 410 412 if (ret < 0) 411 - goto hw_params_out; 413 + return ret; 412 414 413 415 cfg.dst_addr = priv->phy_addr + SITFDR; 414 416 cfg.src_addr = priv->phy_addr + SIRFDR; 415 417 416 - ret = dmaengine_slave_config(chan, &cfg); 417 - hw_params_out: 418 - spin_unlock_irqrestore(&priv->lock, flags); 419 - 420 - return ret; 418 + return dmaengine_slave_config(chan, &cfg); 421 419 } 422 420 423 421 static const struct snd_soc_component_driver msiof_component_driver = { ··· 431 439 struct snd_pcm_substream *substream; 432 440 u32 sistr; 433 441 434 - spin_lock(&priv->lock); 435 - 436 - sistr = msiof_read(priv, SISTR); 437 - msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX); 438 - 439 - spin_unlock(&priv->lock); 442 + scoped_guard(spinlock, &priv->lock) { 443 + sistr = msiof_read(priv, SISTR); 444 + msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX); 445 + } 440 446 441 447 /* overflow/underflow error */ 442 448 substream = priv->substream[SNDRV_PCM_STREAM_PLAYBACK];
+8 -11
sound/soc/renesas/rcar/src.c
··· 558 558 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 559 559 bool stop = false; 560 560 561 - spin_lock(&priv->lock); 561 + scoped_guard(spinlock, &priv->lock) { 562 + /* ignore all cases if not working */ 563 + if (!rsnd_io_is_working(io)) 564 + break; 562 565 563 - /* ignore all cases if not working */ 564 - if (!rsnd_io_is_working(io)) 565 - goto rsnd_src_interrupt_out; 566 + if (rsnd_src_error_occurred(mod)) 567 + stop = true; 566 568 567 - if (rsnd_src_error_occurred(mod)) 568 - stop = true; 569 - 570 - rsnd_src_status_clear(mod); 571 - rsnd_src_interrupt_out: 572 - 573 - spin_unlock(&priv->lock); 569 + rsnd_src_status_clear(mod); 570 + } 574 571 575 572 if (stop) 576 573 snd_pcm_stop_xrun(io->substream);
+18 -19
sound/soc/renesas/rcar/ssi.c
··· 680 680 bool elapsed = false; 681 681 bool stop = false; 682 682 683 - spin_lock(&priv->lock); 683 + scoped_guard(spinlock, &priv->lock) { 684 684 685 - /* ignore all cases if not working */ 686 - if (!rsnd_io_is_working(io)) 687 - goto rsnd_ssi_interrupt_out; 685 + /* ignore all cases if not working */ 686 + if (!rsnd_io_is_working(io)) 687 + break; 688 688 689 - status = rsnd_ssi_status_get(mod); 689 + status = rsnd_ssi_status_get(mod); 690 690 691 - /* PIO only */ 692 - if (!is_dma && (status & DIRQ)) 693 - elapsed = rsnd_ssi_pio_interrupt(mod, io); 691 + /* PIO only */ 692 + if (!is_dma && (status & DIRQ)) 693 + elapsed = rsnd_ssi_pio_interrupt(mod, io); 694 694 695 - /* DMA only */ 696 - if (is_dma && (status & (UIRQ | OIRQ))) { 697 - rsnd_print_irq_status(dev, "%s err status : 0x%08x\n", 698 - rsnd_mod_name(mod), status); 695 + /* DMA only */ 696 + if (is_dma && (status & (UIRQ | OIRQ))) { 697 + rsnd_print_irq_status(dev, "%s err status : 0x%08x\n", 698 + rsnd_mod_name(mod), status); 699 699 700 - stop = true; 700 + stop = true; 701 + } 702 + 703 + stop |= rsnd_ssiu_busif_err_status_clear(mod); 704 + 705 + rsnd_ssi_status_clear(mod); 701 706 } 702 - 703 - stop |= rsnd_ssiu_busif_err_status_clear(mod); 704 - 705 - rsnd_ssi_status_clear(mod); 706 - rsnd_ssi_interrupt_out: 707 - spin_unlock(&priv->lock); 708 707 709 708 if (elapsed) 710 709 snd_pcm_period_elapsed(io->substream);
+4 -10
sound/soc/renesas/rz-ssi.c
··· 188 188 struct snd_pcm_substream *substream) 189 189 { 190 190 struct rz_ssi_priv *ssi = strm->priv; 191 - unsigned long flags; 192 191 193 - spin_lock_irqsave(&ssi->lock, flags); 192 + guard(spinlock_irqsave)(&ssi->lock); 193 + 194 194 strm->substream = substream; 195 - spin_unlock_irqrestore(&ssi->lock, flags); 196 195 } 197 196 198 197 static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, 199 198 struct rz_ssi_stream *strm) 200 199 { 201 - unsigned long flags; 202 - bool ret; 200 + guard(spinlock_irqsave)(&ssi->lock); 203 201 204 - spin_lock_irqsave(&ssi->lock, flags); 205 - ret = strm->substream && strm->substream->runtime; 206 - spin_unlock_irqrestore(&ssi->lock, flags); 207 - 208 - return ret; 202 + return strm->substream && strm->substream->runtime; 209 203 } 210 204 211 205 static inline bool rz_ssi_is_stream_running(struct rz_ssi_stream *strm)