diff options
Diffstat (limited to 'sound/hda/core')
-rw-r--r-- | sound/hda/core/bus.c | 8 | ||||
-rw-r--r-- | sound/hda/core/component.c | 6 | ||||
-rw-r--r-- | sound/hda/core/controller.c | 58 | ||||
-rw-r--r-- | sound/hda/core/device.c | 23 | ||||
-rw-r--r-- | sound/hda/core/ext/controller.c | 6 | ||||
-rw-r--r-- | sound/hda/core/ext/stream.c | 38 | ||||
-rw-r--r-- | sound/hda/core/intel-dsp-config.c | 28 | ||||
-rw-r--r-- | sound/hda/core/regmap.c | 35 | ||||
-rw-r--r-- | sound/hda/core/stream.c | 34 |
9 files changed, 104 insertions, 132 deletions
diff --git a/sound/hda/core/bus.c b/sound/hda/core/bus.c index d497414a5538..9b196c915f37 100644 --- a/sound/hda/core/bus.c +++ b/sound/hda/core/bus.c @@ -87,12 +87,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_exit); int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr, unsigned int cmd, unsigned int *res) { - int err; - - mutex_lock(&bus->cmd_mutex); - err = snd_hdac_bus_exec_verb_unlocked(bus, addr, cmd, res); - mutex_unlock(&bus->cmd_mutex); - return err; + guard(mutex)(&bus->cmd_mutex); + return snd_hdac_bus_exec_verb_unlocked(bus, addr, cmd, res); } /** diff --git a/sound/hda/core/component.c b/sound/hda/core/component.c index 9c82a2864a2f..04755903880e 100644 --- a/sound/hda/core/component.c +++ b/sound/hda/core/component.c @@ -69,14 +69,14 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) dev_dbg(bus->dev, "display power %s\n", str_enable_disable(enable)); - mutex_lock(&bus->lock); + guard(mutex)(&bus->lock); if (enable) set_bit(idx, &bus->display_power_status); else clear_bit(idx, &bus->display_power_status); if (!acomp || !acomp->ops) - goto unlock; + return; if (bus->display_power_status) { if (!bus->display_power_active) { @@ -99,8 +99,6 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) bus->display_power_active = 0; } } - unlock: - mutex_unlock(&bus->lock); } EXPORT_SYMBOL_GPL(snd_hdac_display_power); diff --git a/sound/hda/core/controller.c b/sound/hda/core/controller.c index b5c833b9f8b9..a7c00ad80117 100644 --- a/sound/hda/core/controller.c +++ b/sound/hda/core/controller.c @@ -44,7 +44,7 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus) { WARN_ON_ONCE(!bus->rb.area); - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); /* CORB set up */ bus->corb.addr = bus->rb.addr; bus->corb.buf = (__le32 *)bus->rb.area; @@ -86,7 +86,6 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus) snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN); /* Accept unsolicited responses */ snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL); - spin_unlock_irq(&bus->reg_lock); } EXPORT_SYMBOL_GPL(snd_hdac_bus_init_cmd_io); @@ -112,18 +111,17 @@ static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus) */ void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus) { - spin_lock_irq(&bus->reg_lock); - /* disable ringbuffer DMAs */ - snd_hdac_chip_writeb(bus, RIRBCTL, 0); - snd_hdac_chip_writeb(bus, CORBCTL, 0); - spin_unlock_irq(&bus->reg_lock); + scoped_guard(spinlock_irq, &bus->reg_lock) { + /* disable ringbuffer DMAs */ + snd_hdac_chip_writeb(bus, RIRBCTL, 0); + snd_hdac_chip_writeb(bus, CORBCTL, 0); + } hdac_wait_for_cmd_dmas(bus); - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); /* disable unsolicited responses */ snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0); - spin_unlock_irq(&bus->reg_lock); } EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_cmd_io); @@ -171,9 +169,8 @@ static int snd_hdac_bus_send_cmd_pio(struct hdac_bus *bus, unsigned int val) { unsigned int addr = azx_command_addr(val); int timeout = 50; - int ret = -EIO; - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); while (timeout--) { /* check ICB bit */ @@ -184,8 +181,7 @@ static int snd_hdac_bus_send_cmd_pio(struct hdac_bus *bus, unsigned int val) /* Set ICB bit */ snd_hdac_chip_updatew(bus, IRS, AZX_IRS_BUSY, AZX_IRS_BUSY); - ret = snd_hdac_bus_wait_for_pio_response(bus, addr); - goto out; + return snd_hdac_bus_wait_for_pio_response(bus, addr); } udelay(1); } @@ -193,10 +189,7 @@ static int snd_hdac_bus_send_cmd_pio(struct hdac_bus *bus, unsigned int val) dev_dbg_ratelimited(bus->dev, "send_cmd_pio timeout: IRS=%#x, val=%#x\n", snd_hdac_chip_readw(bus, IRS), val); -out: - spin_unlock_irq(&bus->reg_lock); - - return ret; + return -EIO; } /** @@ -228,7 +221,7 @@ static int snd_hdac_bus_send_cmd_corb(struct hdac_bus *bus, unsigned int val) unsigned int addr = azx_command_addr(val); unsigned int wp, rp; - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); bus->last_cmd[azx_command_addr(val)] = val; @@ -236,7 +229,6 @@ static int snd_hdac_bus_send_cmd_corb(struct hdac_bus *bus, unsigned int val) wp = snd_hdac_chip_readw(bus, CORBWP); if (wp == 0xffff) { /* something wrong, controller likely turned to D3 */ - spin_unlock_irq(&bus->reg_lock); return -EIO; } wp++; @@ -245,7 +237,6 @@ static int snd_hdac_bus_send_cmd_corb(struct hdac_bus *bus, unsigned int val) rp = snd_hdac_chip_readw(bus, CORBRP); if (wp == rp) { /* oops, it's full */ - spin_unlock_irq(&bus->reg_lock); return -EAGAIN; } @@ -253,8 +244,6 @@ static int snd_hdac_bus_send_cmd_corb(struct hdac_bus *bus, unsigned int val) bus->corb.buf[wp] = cpu_to_le32(val); snd_hdac_chip_writew(bus, CORBWP, wp); - spin_unlock_irq(&bus->reg_lock); - return 0; } @@ -333,21 +322,20 @@ static int snd_hdac_bus_get_response_rirb(struct hdac_bus *bus, timeout = jiffies + msecs_to_jiffies(1000); for (loopcounter = 0;; loopcounter++) { - spin_lock_irq(&bus->reg_lock); - if (!bus->polling_mode) - prepare_to_wait(&bus->rirb_wq, &wait, - TASK_UNINTERRUPTIBLE); - if (bus->polling_mode) - snd_hdac_bus_update_rirb(bus); - if (!bus->rirb.cmds[addr]) { - if (res) - *res = bus->rirb.res[addr]; /* the last value */ + scoped_guard(spinlock_irq, &bus->reg_lock) { if (!bus->polling_mode) - finish_wait(&bus->rirb_wq, &wait); - spin_unlock_irq(&bus->reg_lock); - return 0; + prepare_to_wait(&bus->rirb_wq, &wait, + TASK_UNINTERRUPTIBLE); + if (bus->polling_mode) + snd_hdac_bus_update_rirb(bus); + if (!bus->rirb.cmds[addr]) { + if (res) + *res = bus->rirb.res[addr]; /* the last value */ + if (!bus->polling_mode) + finish_wait(&bus->rirb_wq, &wait); + return 0; + } } - spin_unlock_irq(&bus->reg_lock); if (time_after(jiffies, timeout)) break; #define LOOP_COUNT_MAX 3000 diff --git a/sound/hda/core/device.c b/sound/hda/core/device.c index 018f9e176b1b..160c8d0453b0 100644 --- a/sound/hda/core/device.c +++ b/sound/hda/core/device.c @@ -147,9 +147,9 @@ int snd_hdac_device_register(struct hdac_device *codec) err = device_add(&codec->dev); if (err < 0) return err; - mutex_lock(&codec->widget_lock); - err = hda_widget_sysfs_init(codec); - mutex_unlock(&codec->widget_lock); + scoped_guard(mutex, &codec->widget_lock) { + err = hda_widget_sysfs_init(codec); + } if (err < 0) { device_del(&codec->dev); return err; @@ -166,9 +166,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_register); void snd_hdac_device_unregister(struct hdac_device *codec) { if (device_is_registered(&codec->dev)) { - mutex_lock(&codec->widget_lock); - hda_widget_sysfs_exit(codec); - mutex_unlock(&codec->widget_lock); + scoped_guard(mutex, &codec->widget_lock) { + hda_widget_sysfs_exit(codec); + } device_del(&codec->dev); snd_hdac_bus_remove_device(codec->bus, codec); } @@ -411,25 +411,22 @@ int snd_hdac_refresh_widgets(struct hdac_device *codec) * Serialize against multiple threads trying to update the sysfs * widgets array. */ - mutex_lock(&codec->widget_lock); + guard(mutex)(&codec->widget_lock); nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); if (!start_nid || nums <= 0 || nums >= 0xff) { dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", codec->afg); - err = -EINVAL; - goto unlock; + return -EINVAL; } err = hda_widget_sysfs_reinit(codec, start_nid, nums); if (err < 0) - goto unlock; + return err; codec->num_nodes = nums; codec->start_nid = start_nid; codec->end_nid = start_nid + nums; -unlock: - mutex_unlock(&codec->widget_lock); - return err; + return 0; } EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets); diff --git a/sound/hda/core/ext/controller.c b/sound/hda/core/ext/controller.c index c84754434d16..9eea3ea2dae0 100644 --- a/sound/hda/core/ext/controller.c +++ b/sound/hda/core/ext/controller.c @@ -300,7 +300,7 @@ int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, unsigned long codec_mask; int ret = 0; - mutex_lock(&bus->lock); + guard(mutex)(&bus->lock); /* * if we move from 0 to 1, count will be 1 so power up this link @@ -331,7 +331,6 @@ int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, bus->codec_mask = codec_mask; } - mutex_unlock(&bus->lock); return ret; } EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_get); @@ -343,7 +342,7 @@ int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *hlink_tmp; bool link_up = false; - mutex_lock(&bus->lock); + guard(mutex)(&bus->lock); /* * if we move from 1 to 0, count will be 0 @@ -369,7 +368,6 @@ int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, } } - mutex_unlock(&bus->lock); return ret; } EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_put); diff --git a/sound/hda/core/ext/stream.c b/sound/hda/core/ext/stream.c index a3ac738f1130..b4759198e51d 100644 --- a/sound/hda/core/ext/stream.c +++ b/sound/hda/core/ext/stream.c @@ -163,9 +163,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked); void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, struct hdac_ext_stream *hext_stream, bool decouple) { - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); snd_hdac_ext_stream_decouple_locked(bus, hext_stream, decouple); - spin_unlock_irq(&bus->reg_lock); } EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple); @@ -265,7 +264,7 @@ hdac_ext_link_dma_stream_assign(struct hdac_bus *bus, return NULL; } - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); list_for_each_entry(hstream, &bus->stream_list, list) { struct hdac_ext_stream *hext_stream = container_of(hstream, struct hdac_ext_stream, @@ -285,7 +284,6 @@ hdac_ext_link_dma_stream_assign(struct hdac_bus *bus, res->link_locked = 1; res->link_substream = substream; } - spin_unlock_irq(&bus->reg_lock); return res; } @@ -301,7 +299,7 @@ hdac_ext_host_dma_stream_assign(struct hdac_bus *bus, return NULL; } - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); list_for_each_entry(hstream, &bus->stream_list, list) { struct hdac_ext_stream *hext_stream = container_of(hstream, struct hdac_ext_stream, @@ -320,7 +318,6 @@ hdac_ext_host_dma_stream_assign(struct hdac_bus *bus, res->hstream.running = 0; res->hstream.substream = substream; } - spin_unlock_irq(&bus->reg_lock); return res; } @@ -387,22 +384,22 @@ void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type) break; case HDAC_EXT_STREAM_TYPE_HOST: - spin_lock_irq(&bus->reg_lock); - /* couple link only if not in use */ - if (!hext_stream->link_locked) - snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); - snd_hdac_stream_release_locked(&hext_stream->hstream); - spin_unlock_irq(&bus->reg_lock); + scoped_guard(spinlock_irq, &bus->reg_lock) { + /* couple link only if not in use */ + if (!hext_stream->link_locked) + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); + snd_hdac_stream_release_locked(&hext_stream->hstream); + } break; case HDAC_EXT_STREAM_TYPE_LINK: - spin_lock_irq(&bus->reg_lock); - /* couple host only if not in use */ - if (!hext_stream->hstream.opened) - snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); - hext_stream->link_locked = 0; - hext_stream->link_substream = NULL; - spin_unlock_irq(&bus->reg_lock); + scoped_guard(spinlock_irq, &bus->reg_lock) { + /* couple host only if not in use */ + if (!hext_stream->hstream.opened) + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); + hext_stream->link_locked = 0; + hext_stream->link_substream = NULL; + } break; default: @@ -427,7 +424,7 @@ struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus, struct hdac_ext_stream *res = NULL; struct hdac_stream *hstream; - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); list_for_each_entry(hstream, &bus->stream_list, list) { struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream); @@ -446,7 +443,6 @@ struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus, res->hstream.running = 0; res->hstream.cstream = cstream; } - spin_unlock_irq(&bus->reg_lock); return res; } diff --git a/sound/hda/core/intel-dsp-config.c b/sound/hda/core/intel-dsp-config.c index 3cb1e7fc3b3b..2a9e35cddcf7 100644 --- a/sound/hda/core/intel-dsp-config.c +++ b/sound/hda/core/intel-dsp-config.c @@ -116,6 +116,13 @@ static const struct config_entry config_table[] = { .flags = FLAG_SST, .device = PCI_DEVICE_ID_INTEL_HDA_FCL, }, +#else /* AVS disabled; force to legacy as SOF doesn't work for SKL or KBL */ + { + .device = PCI_DEVICE_ID_INTEL_HDA_SKL_LP, + }, + { + .device = PCI_DEVICE_ID_INTEL_HDA_KBL_LP, + }, #endif #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE) { @@ -167,9 +174,9 @@ static const struct config_entry config_table[] = { /* * CoffeeLake, CannonLake, CometLake, IceLake, TigerLake, AlderLake, - * RaptorLake use legacy HDAudio driver except for Google Chromebooks - * and when DMICs are present. Two cases are required since Coreboot - * does not expose NHLT tables. + * RaptorLake, MeteorLake use legacy HDAudio driver except for Google + * Chromebooks and when DMICs are present. Two cases are required since + * Coreboot does not expose NHLT tables. * * When the Chromebook quirk is not present, it's based on information * that no such device exists. When the quirk is present, it could be @@ -517,6 +524,19 @@ static const struct config_entry config_table[] = { #if IS_ENABLED(CONFIG_SND_SOC_SOF_METEORLAKE) /* Meteorlake-P */ { + .flags = FLAG_SOF, + .device = PCI_DEVICE_ID_INTEL_HDA_MTL, + .dmi_table = (const struct dmi_system_id []) { + { + .ident = "Google Chromebooks", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Google"), + } + }, + {} + } + }, + { .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, .device = PCI_DEVICE_ID_INTEL_HDA_MTL, }, @@ -630,6 +650,8 @@ static int snd_intel_dsp_check_soundwire(struct pci_dev *pci) int ret; handle = ACPI_HANDLE(&pci->dev); + if (!handle) + return -ENODEV; ret = sdw_intel_acpi_scan(handle, &info); if (ret < 0) diff --git a/sound/hda/core/regmap.c b/sound/hda/core/regmap.c index 97cee096a286..e7b866fc52c1 100644 --- a/sound/hda/core/regmap.c +++ b/sound/hda/core/regmap.c @@ -425,15 +425,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_add_vendor_verb); static int reg_raw_write(struct hdac_device *codec, unsigned int reg, unsigned int val) { - int err; - - mutex_lock(&codec->regmap_lock); + guard(mutex)(&codec->regmap_lock); if (!codec->regmap) - err = hda_reg_write(codec, reg, val); + return hda_reg_write(codec, reg, val); else - err = regmap_write(codec->regmap, reg, val); - mutex_unlock(&codec->regmap_lock); - return err; + return regmap_write(codec->regmap, reg, val); } /* a helper macro to call @func_call; retry with power-up if failed */ @@ -466,15 +462,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_write_raw); static int reg_raw_read(struct hdac_device *codec, unsigned int reg, unsigned int *val, bool uncached) { - int err; - - mutex_lock(&codec->regmap_lock); + guard(mutex)(&codec->regmap_lock); if (uncached || !codec->regmap) - err = hda_reg_read(codec, reg, val); + return hda_reg_read(codec, reg, val); else - err = regmap_read(codec->regmap, reg, val); - mutex_unlock(&codec->regmap_lock); - return err; + return regmap_read(codec->regmap, reg, val); } static int __snd_hdac_regmap_read_raw(struct hdac_device *codec, @@ -515,7 +507,7 @@ static int reg_raw_update(struct hdac_device *codec, unsigned int reg, bool change; int err; - mutex_lock(&codec->regmap_lock); + guard(mutex)(&codec->regmap_lock); if (codec->regmap) { err = regmap_update_bits_check(codec->regmap, reg, mask, val, &change); @@ -533,7 +525,6 @@ static int reg_raw_update(struct hdac_device *codec, unsigned int reg, } } } - mutex_unlock(&codec->regmap_lock); return err; } @@ -556,17 +547,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw); static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg, unsigned int mask, unsigned int val) { - int err = 0; - if (!codec->regmap) return reg_raw_update(codec, reg, mask, val); - mutex_lock(&codec->regmap_lock); + guard(mutex)(&codec->regmap_lock); /* Discard any updates to already initialised registers. */ if (!regcache_reg_cached(codec->regmap, reg)) - err = regmap_update_bits(codec->regmap, reg, mask, val); - mutex_unlock(&codec->regmap_lock); - return err; + return regmap_update_bits(codec->regmap, reg, mask, val); + return 0; } /** @@ -593,9 +581,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw_once); */ void snd_hdac_regmap_sync(struct hdac_device *codec) { - mutex_lock(&codec->regmap_lock); + guard(mutex)(&codec->regmap_lock); if (codec->regmap) regcache_sync(codec->regmap); - mutex_unlock(&codec->regmap_lock); } EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync); diff --git a/sound/hda/core/stream.c b/sound/hda/core/stream.c index 4a87bef8834f..579ec544ef4a 100644 --- a/sound/hda/core/stream.c +++ b/sound/hda/core/stream.c @@ -370,7 +370,7 @@ struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus, if (substream->pcm) key |= (substream->pcm->device << 16); - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); list_for_each_entry(azx_dev, &bus->stream_list, list) { if (azx_dev->direction != substream->stream) continue; @@ -389,7 +389,6 @@ struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus, res->assigned_key = key; res->substream = substream; } - spin_unlock_irq(&bus->reg_lock); return res; } EXPORT_SYMBOL_GPL(snd_hdac_stream_assign); @@ -419,9 +418,8 @@ void snd_hdac_stream_release(struct hdac_stream *azx_dev) { struct hdac_bus *bus = azx_dev->bus; - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); snd_hdac_stream_release_locked(azx_dev); - spin_unlock_irq(&bus->reg_lock); } EXPORT_SYMBOL_GPL(snd_hdac_stream_release); @@ -922,15 +920,12 @@ int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, struct hdac_bus *bus = azx_dev->bus; int err; - snd_hdac_dsp_lock(azx_dev); - spin_lock_irq(&bus->reg_lock); - if (azx_dev->running || azx_dev->locked) { - spin_unlock_irq(&bus->reg_lock); - err = -EBUSY; - goto unlock; + guard(snd_hdac_dsp_lock)(azx_dev); + scoped_guard(spinlock_irq, &bus->reg_lock) { + if (azx_dev->running || azx_dev->locked) + return -EBUSY; + azx_dev->locked = true; } - azx_dev->locked = true; - spin_unlock_irq(&bus->reg_lock); err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, bus->dev, byte_size, bufp); @@ -951,17 +946,14 @@ int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, goto error; snd_hdac_stream_setup(azx_dev, true); - snd_hdac_dsp_unlock(azx_dev); return azx_dev->stream_tag; error: snd_dma_free_pages(bufp); err_alloc: - spin_lock_irq(&bus->reg_lock); - azx_dev->locked = false; - spin_unlock_irq(&bus->reg_lock); - unlock: - snd_hdac_dsp_unlock(azx_dev); + scoped_guard(spinlock_irq, &bus->reg_lock) { + azx_dev->locked = false; + } return err; } EXPORT_SYMBOL_GPL(snd_hdac_dsp_prepare); @@ -993,7 +985,7 @@ void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev, if (!dmab->area || !azx_dev->locked) return; - snd_hdac_dsp_lock(azx_dev); + guard(snd_hdac_dsp_lock)(azx_dev); /* reset BDL address */ snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0); snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0); @@ -1005,10 +997,8 @@ void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev, snd_dma_free_pages(dmab); dmab->area = NULL; - spin_lock_irq(&bus->reg_lock); + guard(spinlock_irq)(&bus->reg_lock); azx_dev->locked = false; - spin_unlock_irq(&bus->reg_lock); - snd_hdac_dsp_unlock(azx_dev); } EXPORT_SYMBOL_GPL(snd_hdac_dsp_cleanup); #endif /* CONFIG_SND_HDA_DSP_LOADER */ |