Alsa-devel
Threads by month
- ----- 2025 -----
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 5 participants
- 50781 discussions
11 Jun '24
When headphones are plugged in, they appear absent; when they are removed,
they appear present.
Add a specific entry in bytcr_rt5640 for this device
Signed-off-by: Thomas GENTY <tomlohave(a)gmail.com>
Reviewed-by: Hans de Goede <hdegoede(a)redhat.com>
---
sound/soc/intel/boards/bytcr_rt5640.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index b41a1147f1c3..a64d1989e28a 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -610,6 +610,17 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
BYT_RT5640_SSP0_AIF1 |
BYT_RT5640_MCLK_EN),
},
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 101 CESIUM"),
+ },
+ .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
+ BYT_RT5640_JD_NOT_INV |
+ BYT_RT5640_DIFF_MIC |
+ BYT_RT5640_SSP0_AIF1 |
+ BYT_RT5640_MCLK_EN),
+ },
{
.matches = {
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
--
2.45.2
1
0
[PATCH 0/3] ACPI/ALSA/soundwire: add acpi_get_local_u64_address() helper
by Pierre-Louis Bossart 11 Jun '24
by Pierre-Louis Bossart 11 Jun '24
11 Jun '24
The acpi_get_local_address() helper assumes a 32-bit ADR is used. If
we want to use this helper for SoundWire/SDCA ASoC codecs, we need an
extension where the native 64-bits are used. This patchset suggests a
new helper, acpi_get_local_address() may be renamed if desired in a
folow-up patch.
The path of least resistance would be to merge this patchset in the
ASoC tree, since I have additional changes for ASoC/SDCA (SoundWire
Device Class) that depend on the new helper.
Pierre-Louis Bossart (3):
ACPI: utils: introduce acpi_get_local_u64_address()
soundwire: slave: simplify code with acpi_get_local_u64_address()
ALSA: hda: intel-sdw-acpi: use acpi_get_local_u64_address()
drivers/acpi/utils.c | 22 ++++++++++++++++------
drivers/soundwire/slave.c | 13 ++++---------
include/linux/acpi.h | 1 +
sound/hda/intel-sdw-acpi.c | 6 +++---
4 files changed, 24 insertions(+), 18 deletions(-)
--
2.43.0
6
11
[RESEND v5 0/7] ASoC: codecs: wcd937x: add wcd937x audio codec support
by Mohammad Rafi Shaik 11 Jun '24
by Mohammad Rafi Shaik 11 Jun '24
11 Jun '24
This patchset adds support for Qualcomm WCD9370/WCD9375 codec.
Qualcomm WCD9370/WCD9375 Codec is a standalone Hi-Fi audio codec IC
connected over SoundWire. This device has two SoundWire devices, RX and
TX respectively supporting 3 x ADCs, ClassH, Ear, Aux PA, 2xHPH,
6 DMICs and MBHC.
For codec driver to be functional it would need both tx and rx Soundwire devices
to be up and this is taken care by using device component framework and device-links
are used to ensure proper pm dependencies. Ex tx does not enter suspend
before rx or codec is suspended.
This patchset along with other SoundWire patches on the list
have been tested on QCM6490 IDP device.
Changes since v4:
- Removed volatile/read-only registers from defaults list
- Added wcd939x_volatile_register() with only volatile registers
- Added a wcd939x_readable_register() with read-only and read-write registers, so cache does it's job
- Fixed Spurious events for mixer controls and validated with mixer selftest tool
- Used TLV instead of enum for ear_pa_gain mixer control
- Used enum constraints instead of OneOf in dt-binding patch
- Added vdd-px supply property as non optional in dt-binding patch
- Reworked and done driver cleanup
Changes since v3:
- Fixed dt binding check errors.
- Added constraints on values in v4-0001 binding patch as suggested by Krzysztof
- Change the patch sequence soundwire driver first then codec driver
- Added missing .remove soundwire driver function
- Reworked and done driver cleanup
Changes since v2:
- Used common qcom,wcd93xx-common.yaml. removed duplicate properties.
- Merged bindings patches "v2-0001" and "v2-0003" in single patch for easy review.
- Fixed dt binding check errors.
- Added missing "qcom,wcd9375-codec" in v3-0001 dt binding patch.
- Added constraints on values in v3-0001 binding patch as suggested by Krzysztof
- Fix the typo mistake in v2 cover letter
Changes since v1:
- Split the patch per driver for easier review as suggested by Krzysztof
- Used devm_gpiod_get api to get reset gpio as suggested by Krzysztof
Prasad Kumpatla (7):
ASoC: dt-bindings: document wcd937x Audio Codec
ASoC: codecs: wcd937x-sdw: add SoundWire driver
ASoC: codecs: wcd937x: add wcd937x codec driver
ASoC: codecs: wcd937x: add basic controls
ASoC: codecs: wcd937x: add playback dapm widgets
ASoC: codecs: wcd937x: add capture dapm widgets
ASoC: codecs: wcd937x: add audio routing and Kconfig
.../bindings/sound/qcom,wcd937x-sdw.yaml | 91 +
.../bindings/sound/qcom,wcd937x.yaml | 82 +
sound/soc/codecs/Kconfig | 20 +
sound/soc/codecs/Makefile | 7 +
sound/soc/codecs/wcd937x-sdw.c | 1139 +++++++
sound/soc/codecs/wcd937x.c | 3029 +++++++++++++++++
sound/soc/codecs/wcd937x.h | 653 ++++
7 files changed, 5021 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd937x-sdw.yaml
create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd937x.yaml
create mode 100644 sound/soc/codecs/wcd937x-sdw.c
create mode 100644 sound/soc/codecs/wcd937x.c
create mode 100644 sound/soc/codecs/wcd937x.h
base-commit: 3689b0ef08b70e4e03b82ebd37730a03a672853a
--
2.25.1
2
9
11 Jun '24
Requesting to see if we can get some Acked-By tags, and merge on usb-next.
Several Qualcomm based chipsets can support USB audio offloading to a
dedicated audio DSP, which can take over issuing transfers to the USB
host controller. The intention is to reduce the load on the main
processors in the SoC, and allow them to be placed into lower power modes.
There are several parts to this design:
1. Adding ASoC binding layer
2. Create a USB backend for Q6DSP
3. Introduce XHCI interrupter support
4. Create vendor ops for the USB SND driver
USB | ASoC
--------------------------------------------------------------------
| _________________________
| |sm8250 platform card |
| |_________________________|
| | |
| ___V____ ____V____
| |Q6USB | |Q6AFE |
| |"codec" | |"cpu" |
| |________| |_________|
| ^ ^ ^
| | |________|
| ___V____ |
| |SOC-USB | |
________ ________ | | |
|USB SND |<--->|QC offld|<------------>|________| |
|(card.c)| | |<---------- |
|________| |________|___ | | |
^ ^ | | | ____________V_________
| | | | | |APR/GLINK |
__ V_______________V_____ | | | |______________________|
|USB SND (endpoint.c) | | | | ^
|_________________________| | | | |
^ | | | ___________V___________
| | | |->|audio DSP |
___________V_____________ | | |_______________________|
|XHCI HCD |<- |
|_________________________| |
Adding ASoC binding layer:
soc-usb: Intention is to treat a USB port similar to a headphone jack.
The port is always present on the device, but cable/pin status can be
enabled/disabled. Expose mechanisms for USB backend ASoC drivers to
communicate with USB SND.
Create a USB backend for Q6DSP:
q6usb: Basic backend driver that will be responsible for maintaining the
resources needed to initiate a playback stream using the Q6DSP. Will
be the entity that checks to make sure the connected USB audio device
supports the requested PCM format. If it does not, the PCM open call will
fail, and userpsace ALSA can take action accordingly.
Introduce XHCI interrupter support:
XHCI HCD supports multiple interrupters, which allows for events to be routed
to different event rings. This is determined by "Interrupter Target" field
specified in Section "6.4.1.1 Normal TRB" of the XHCI specification.
Events in the offloading case will be routed to an event ring that is assigned
to the audio DSP.
Create vendor ops for the USB SND driver:
qc_audio_offload: This particular driver has several components associated
with it:
- QMI stream request handler
- XHCI interrupter and resource management
- audio DSP memory management
When the audio DSP wants to enable a playback stream, the request is first
received by the ASoC platform sound card. Depending on the selected route,
ASoC will bring up the individual DAIs in the path. The Q6USB backend DAI
will send an AFE port start command (with enabling the USB playback path), and
the audio DSP will handle the request accordingly.
Part of the AFE USB port start handling will have an exchange of control
messages using the QMI protocol. The qc_audio_offload driver will populate the
buffer information:
- Event ring base address
- EP transfer ring base address
and pass it along to the audio DSP. All endpoint management will now be handed
over to the DSP, and the main processor is not involved in transfers.
Overall, implementing this feature will still expose separate sound card and PCM
devices for both the platorm card and USB audio device:
0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D
SM8250-MTP-WCD9380-WSA8810-VA-DMIC
1 [Audio ]: USB-Audio - USB Audio
Generic USB Audio at usb-xhci-hcd.1.auto-1.4, high speed
This is to ensure that userspace ALSA entities can decide which route to take
when executing the audio playback. In the above, if card#1 is selected, then
USB audio data will take the legacy path over the USB PCM drivers, etc...
This feature was validated using:
- tinymix: set/enable the multimedia path to route to USB backend
- tinyplay: issue playback on platform card
Changelog
--------------------------------------------
Changes in v22:
- Removed components tag for the ASoC platform card, as the USB SND kcontrol for
notifying userspace of offload capable card achieves similar results.
- Due to the above, had to remove the review-by tag for the RST documentation,
as changes were made to remove the components tag section.
- Took in feedback to make the SOC USB add/remove ports void.
- Fixed an issue w/ the USB SND kcontrol management for devices that have multi
UAC interfaces. (would attempt to create the kcontrol more than once)
- Modified SOC USB card and PCM index select to be based off the num_supported
streams that is specified by the USB BE DAI.
- Modified comments on selecting the latest USB headset for offloading.
Changes in v21:
- Added an offload jack disable path from the ASoC platform driver and SOC USB.
- Refactored some of the existing SOC USB context look up APIs and created some
new helpers to search for the USB context.
- Renamed snd_soc_usb_find_format to snd_soc_usb_find_supported_format
- Removed some XHCI sideband calls that would allow clients to actually enable
the IRQ line associated w/ the secondary interrupter. This is removed because
there are other dependencies that are required for that to happen, which are not
covered as part of this series, and to avoid confusion.
- Due to the above, removed the need to export IMOD setting, and enable/disable
interrupter APIs.
Changes in v20:
- Fixed up some formatting changes pointed out in the usb.rst
- Added SB null check during XHCI sideband unregister in case caller passes
improper argument (xhci_sideband_unregister())
Changes in v19:
- Rebased to usb-next to account for some new changes in dependent drivers.
Changes in v18:
- Rebased to usb-next, which merged in part of the series. Removed these patches.
- Reworked Kconfigs for the ASoC USB related components from QCOM Q6DSP drivers
to keep dependencies in place for SoC USB and USB SND.
- Removed the repurposing of the stop ep sync API into existing XHCI operations.
This will be solely used by the XHCI sideband for now.
Changes in v17:
- Fixed an issue where one patch was squashed into another.
- Re-added some kconfig checks for helpers exposed in USB SND for the soc usb
driver, after running different kconfigs.
Changes in v16:
- Modified some code layer dependencies so that soc usb can be split as a separate
module.
- Split the kcontrols from ASoC QCOM common layer into a separate driver
- Reworked SOC USB kcontrols for controlling card + pcm offload routing and status
so that there are individual controls for card and pcm devices.
- Added a kcontrol remove API in SOC USB to remove the controls on the fly. This
required to add some kcontrol management to SOC USB.
- Removed the disconnect work and workqueue for the QC USB offload as it is not
required, since QMI interface driver ensures events are handled in its own WQ.
Changes in v15:
- Removed some already merged XHCI changes
- Separated SOC USB driver from being always compiled into SOC core. Now
configurable from kconfig.
- Fixed up ASoC kcontrol naming to fit guidelines.
- Removed some unnecessary dummy ifdefs.
- Moved usb snd offload capable kcontrol to be initialized by the platform offloading
driver.
Changes in v14:
- Cleaned up some USB SND related feedback:
- Renamed SNDUSB OFFLD playback available --> USB offload capable card
- Fixed locking while checking if stream is in use
- Replaced some mutex pairs with guard(mutex)
Changes in v13:
- Pulled in secondary/primary interrupter rework from Mathias from:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/drivers…
- Did some cleanup and commit message updates, and tested on current code base.
- Added mutex locking to xhci sideband to help prevent any race conditions, esp. for when accessing shared
references.
- Addresed concerns from Hillf about gfp_flags and locking used in qc_usb_audio_offload.
- Rebased onto usb-next
Changes in v12:
- Updated copyright year to 2024. Happy new years!
- Fixed newline format on mixer offload driver.
Changes in v11:
- Modified QMI format structures to be const
Changes in v10:
- Added new mixer for exposing kcontrol for sound card created by USB SND. This
allows for applications to know which platform sound card has offload support.
Will return the card number.
- Broke down and cleaned up some functions/APIs within qc_audio_offload driver.
- Exported xhci_initialize_ring_info(), and modified XHCI makefile to allow for
the XHCI sideband to exist as a module.
- Reworked the jack registration and moved it to the QCOM platform card driver,
ie sm8250.
- Added an SOC USB API to fetch a standard component tag that can be appended to
the platform sound card. Added this tag to sm8250 if any USB path exists within
the DT node.
- Moved kcontrols that existed in the Q6USB driver, and made it a bit more generic,
so that naming can be standardized across solutions. SOC USB is now responsible
for creation of these kcontrols.
- Added a SOC USB RST document explaining some code flows and implementation details
so that other vendors can utilize the framework.
- Addressed a case where USB device connection events are lost if usb offload driver
(qc_audio_offload) is not probed when everything else has been initialized, ie
USB SND, SOC USB and ASoC sound card. Add a rediscover device call during module
init, to ensure that connection events will be propagated.
- Rebased to usb-next.
Changes in v9:
- Fixed the dt binding check issue with regards to num-hc-interrupters.
Changes in v8:
- Cleaned up snd_soc_usb_find_priv_data() based on Mark's feedback. Removed some of
the duplicate looping code that was present on previous patches. Also renamed the API.
- Integrated Mathias' suggestions on his new sideband changes:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feat…
- Addressed some of Mathias' fixme tags, such as:
- Resetting transfer ring dequeue/enqueue pointers
- Issuing stop endpoint command during ep removal
- Reset ERDP properly to first segment ring during interrupter removal. (this is currently
just being cleared to 0, but should be pointing to a valid segment if controller is still
running.
Changes in v7:
- Fixed dt check error for q6usb bindings
- Updated q6usb property from qcom,usb-audio-intr-num --> qcom,usb-audio-intr-idx
- Removed separate DWC3 HC interrupters num property, and place limits to XHCI one.
- Modified xhci_ring_to_sgtable() to use assigned IOVA/DMA address to fetch pages, as
it is not ensured event ring allocated is always done in the vmalloc range.
Changes in v6:
- Fixed limits and description on several DT bindings (XHCI and Q6USB)
- Fixed patch subjects to follow other ALSA/ASoC notations.
USB SND
- Addressed devices which expose multiple audio (UAC) interfaces. These devices will
create a single USB sound card with multiple audio streams, and receive multiple
interface probe routines. QC offload was not properly considering cases with multiple
probe calls.
- Renamed offload module name and kconfig to fit within the SND domain.
- Renamed attach/detach endpoint API to keep the hw_params notation.
Changes in v5:
- Removed some unnescessary files that were included
- Fixed some typos mentioned
- Addressed dt-binding issues and added hc-interrupters definition to usb-xhci.yaml
XHCI:
- Moved secondary skip events API to xhci-ring and updated implementation
- Utilized existing XHCI APIs, such as inc_deq and xhci_update_erst_dequeue()
USB SND
- Renamed and reworked the APIs in "sound: usb: Export USB SND APIs for modules" patch to
include suggestions to utilize snd_usb_hw_params/free and to avoid generic naming.
- Added a resume_cb() op for completion sake.
- Addressed some locking concerns with regards to when registering for platform hooks.
- Added routine to disconnect all offloaded devices during module unbind.
ASoC
- Replaced individual PCM parameter arguments in snd_soc_usb_connect() with new
snd_soc_usb_device structure to pass along PCM info.
- Modified snd_jack set report to notify HEADPHONE event, as we do not support record path.
Changes in v4:
- Rebased to xhci/for-usb-next
- Addressed some dt-bindings comments
XHCI:
- Pulled in latest changes from Mathias' feature_interrupters branch:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feat…
- Fixed commit text and signage for the XHCI sideband/interrupter related changes
- Added some logic to address the FIXME tags mentioned throughout the commits, such
as handling multi segment rings and building the SGT, locking concerns, and ep
cleanup operations.
- Removed some fixme tags for conditions that may not be needed/addressed.
- Repurposed the new endpoint stop sync API to be utilized in other places.
- Fixed potential compile issue if XHCI sideband config is not defined.
ASoC:
- Added sound jack control into the Q6USB driver. Allows for userpsace to know when
an offload capable device is connected.
USB SND:
- Avoided exporting _snd_pcm_hw_param_set based on Takashi's recommendation.
- Split USB QMI packet header definitions into a separate commit. This is used to
properly allow the QMI interface driver to parse and route QMI packets accordingly
- Added a "depends on" entry when enabling QC audio offload to avoid compile time
issues.
Changes in v3:
- Changed prefix from RFC to PATCH
- Rebased entire series to usb-next
- Updated copyright years
XHCI:
- Rebased changes on top of XHCI changes merged into usb-next, and only added
changes that were still under discussion.
- Added change to read in the "num-hc-interrupters" device property.
ASoC:
- qusb6 USB backend
- Incorporated suggestions to fetch iommu information with existing APIs
- Added two new sound kcontrols to fetch offload status and offload device
selection.
- offload status - will return the card and pcm device in use
tinymix -D 0 get 1 --> 1, 0 (offload in progress on card#1 pcm#0)
- device selection - set the card and pcm device to enable offload on. Ex.:
tinymix -D 0 set 1 2 0 --> sets offload on card#2 pcm#0
(this should be the USB card)
USB SND:
- Fixed up some locking related concerns for registering platform ops.
- Moved callbacks under the register_mutex, so that
- Modified APIs to properly pass more information about the USB SND device, so
that the Q6USB backend can build a device list/map, in order to monitor offload
status and device selection.
Changes in v2:
XHCI:
- Replaced XHCI and HCD changes with Mathias' XHCI interrupter changes
in his tree:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feat…
Adjustments made to Mathias' changes:
- Created xhci-intr.h to export/expose interrupter APIs versus exposing xhci.h.
Moved dependent structures to this file as well. (so clients can parse out
information from "struct xhci_interrupter")
- Added some basic locking when requesting interrupters.
- Fixed up some sanity checks.
- Removed clearing of the ERSTBA during freeing of the interrupter. (pending
issue where SMMU fault occurs if DMA addr returned is 64b - TODO)
- Clean up pending events in the XHCI secondary interrupter. While testing USB
bus suspend, it was seen that on bus resume, the xHCI HC would run into a command
timeout.
- Added offloading APIs to xHCI to fetch transfer and event ring information.
ASoC:
- Modified soc-usb to allow for multiple USB port additions. For this to work,
the USB offload driver has to have a reference to the USB backend by adding
a "usb-soc-be" DT entry to the device saved into XHCI sysdev.
- Created separate dt-bindings for defining USB_RX port.
- Increased APR timeout to accommodate the situation where the AFE port start
command could be delayed due to having to issue a USB bus resume while
handling the QMI stream start command.
USB SND:
- Added a platform ops during usb_audio_suspend(). This allows for the USB
offload driver to halt the audio stream when system enters PM suspend. This
ensures the audio DSP is not issuing transfers on the USB bus.
- Do not override platform ops if they are already populated.
- Introduce a shared status variable between the USB offload and USB SND layers,
to ensure that only one path is active at a time. If the USB bus is occupied,
then userspace is notified that the path is busy.
Mathias Nyman (2):
xhci: add helper to stop endpoint and wait for completion
xhci: sideband: add initial api to register a sideband entity
Wesley Cheng (36):
usb: host: xhci: Repurpose event handler for skipping interrupter
events
usb: xhci: Allow for secondary interrupter to set IMOD
usb: host: xhci-mem: Cleanup pending secondary event ring events
usb: host: xhci-mem: Allow for interrupter clients to choose specific
index
ASoC: Add SOC USB APIs for adding an USB backend
ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port
ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp
ASoC: qdsp6: q6afe: Increase APR timeout
ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6
ALSA: usb-audio: Introduce USB SND platform op callbacks
ALSA: usb-audio: Export USB SND APIs for modules
ALSA: usb-audio: Save UAC sample size information
usb: dwc3: Specify maximum number of XHCI interrupters
usb: host: xhci-plat: Set XHCI max interrupters if property is present
ALSA: usb-audio: qcom: Add USB QMI definitions
ALSA: usb-audio: qcom: Introduce QC USB SND offloading support
ALSA: usb-audio: Check for support for requested audio format
ASoC: usb: Add PCM format check API for USB backend
ASoC: qcom: qdsp6: Ensure PCM format is supported by USB audio device
ALSA: usb-audio: Prevent starting of audio stream if in use
ALSA: usb-audio: Do not allow USB offload path if PCM device is in use
ASoC: dt-bindings: Update example for enabling USB offload on SM8250
ALSA: usb-audio: qcom: Populate PCM and USB chip information
ASoC: qcom: qdsp6: Add support to track available USB PCM devices
ASoC: Introduce SND kcontrols to select sound card and PCM device
ASoC: qcom: qdsp6: Add SOC USB offload select get/put callbacks
ASoC: Introduce SND kcontrols to track USB offloading state
ASoC: qcom: qdsp6: Add PCM ops to track current state
ASoC: usb: Create SOC USB SND jack kcontrol
ASoC: qcom: qdsp6: Add headphone jack for offload connection status
ASoC: usb: Fetch ASoC sound card information
ALSA: usb-audio: Add USB offloading capable kcontrol
ALSA: usb-audio: Allow for rediscovery of connected USB SND devices
ALSA: usb-audio: qcom: Use card and PCM index from QMI request
ASoC: usb: Rediscover USB SND devices on USB port add
ASoC: doc: Add documentation for SOC USB
.../bindings/sound/qcom,sm8250.yaml | 15 +
Documentation/sound/soc/index.rst | 1 +
Documentation/sound/soc/usb.rst | 603 ++++++
drivers/usb/dwc3/core.c | 12 +
drivers/usb/dwc3/core.h | 2 +
drivers/usb/dwc3/host.c | 3 +
drivers/usb/host/Kconfig | 9 +
drivers/usb/host/Makefile | 2 +
drivers/usb/host/xhci-mem.c | 36 +-
drivers/usb/host/xhci-plat.c | 2 +
drivers/usb/host/xhci-ring.c | 50 +-
drivers/usb/host/xhci-sideband.c | 418 ++++
drivers/usb/host/xhci.c | 43 +-
drivers/usb/host/xhci.h | 18 +-
.../sound/qcom,q6dsp-lpass-ports.h | 1 +
include/linux/usb/xhci-sideband.h | 68 +
include/sound/q6usboffload.h | 20 +
include/sound/soc-usb.h | 188 ++
sound/soc/Kconfig | 10 +
sound/soc/Makefile | 2 +
sound/soc/qcom/Kconfig | 15 +
sound/soc/qcom/Makefile | 2 +
sound/soc/qcom/qdsp6/Makefile | 1 +
sound/soc/qcom/qdsp6/q6afe-dai.c | 60 +
sound/soc/qcom/qdsp6/q6afe.c | 193 +-
sound/soc/qcom/qdsp6/q6afe.h | 36 +-
sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c | 23 +
sound/soc/qcom/qdsp6/q6dsp-lpass-ports.h | 1 +
sound/soc/qcom/qdsp6/q6routing.c | 9 +
sound/soc/qcom/qdsp6/q6usb.c | 417 ++++
sound/soc/qcom/sm8250.c | 23 +-
sound/soc/qcom/usb_offload_utils.c | 55 +
sound/soc/qcom/usb_offload_utils.h | 29 +
sound/soc/soc-usb.c | 684 ++++++
sound/usb/Kconfig | 25 +
sound/usb/Makefile | 2 +-
sound/usb/card.c | 109 +
sound/usb/card.h | 15 +
sound/usb/endpoint.c | 1 +
sound/usb/format.c | 1 +
sound/usb/helper.c | 1 +
sound/usb/pcm.c | 104 +-
sound/usb/pcm.h | 11 +
sound/usb/qcom/Makefile | 6 +
sound/usb/qcom/mixer_usb_offload.c | 65 +
sound/usb/qcom/mixer_usb_offload.h | 17 +
sound/usb/qcom/qc_audio_offload.c | 1915 +++++++++++++++++
sound/usb/qcom/usb_audio_qmi_v01.c | 892 ++++++++
sound/usb/qcom/usb_audio_qmi_v01.h | 162 ++
49 files changed, 6327 insertions(+), 50 deletions(-)
create mode 100644 Documentation/sound/soc/usb.rst
create mode 100644 drivers/usb/host/xhci-sideband.c
create mode 100644 include/linux/usb/xhci-sideband.h
create mode 100644 include/sound/q6usboffload.h
create mode 100644 include/sound/soc-usb.h
create mode 100644 sound/soc/qcom/qdsp6/q6usb.c
create mode 100644 sound/soc/qcom/usb_offload_utils.c
create mode 100644 sound/soc/qcom/usb_offload_utils.h
create mode 100644 sound/soc/soc-usb.c
create mode 100644 sound/usb/qcom/Makefile
create mode 100644 sound/usb/qcom/mixer_usb_offload.c
create mode 100644 sound/usb/qcom/mixer_usb_offload.h
create mode 100644 sound/usb/qcom/qc_audio_offload.c
create mode 100644 sound/usb/qcom/usb_audio_qmi_v01.c
create mode 100644 sound/usb/qcom/usb_audio_qmi_v01.h
2
42
Hi Mark, Rob, Krzysztof
Cc Kochetkov
This patch-set adds link-trigger-order to Simple-Card / Audio-Graph-Card.
Kuninori Morimoto (5):
ASoC: audio-graph-port: add link-trigger-order
ASoC: simple-card-utils: add link-trigger-order support
ASoC: simple-audio-card: add link-trigger-order support
ASoC: audio-graph-card: add link-trigger-order support
ASoC: audio-graph-card2: add link-trigger-order support
.../bindings/sound/audio-graph-port.yaml | 9 +++
include/dt-bindings/sound/audio-graph.h | 21 ++++++
include/sound/simple_card_utils.h | 4 ++
sound/soc/generic/audio-graph-card.c | 13 ++++
sound/soc/generic/audio-graph-card2.c | 13 ++++
sound/soc/generic/simple-card-utils.c | 71 +++++++++++++++++++
sound/soc/generic/simple-card.c | 10 +++
7 files changed, 141 insertions(+)
create mode 100644 include/dt-bindings/sound/audio-graph.h
--
2.43.0
2
8
10 Jun '24
The cs42l43 reports as cs42l43-spk in the speaker case, the regex in
sof-soundwire needs updated to recognise that.
Fixes: 035d9206cffd ("sof-soundwire: Add basic support for cs42l43's speaker")
Signed-off-by: Charles Keepax <ckeepax(a)opensource.cirrus.com>
---
ucm2/sof-soundwire/sof-soundwire.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ucm2/sof-soundwire/sof-soundwire.conf b/ucm2/sof-soundwire/sof-soundwire.conf
index 31492e3..2f61d11 100644
--- a/ucm2/sof-soundwire/sof-soundwire.conf
+++ b/ucm2/sof-soundwire/sof-soundwire.conf
@@ -21,7 +21,7 @@ Define {
DefineRegex {
SpeakerCodec {
- Regex " spk:([a-z0-9]+(-sdca)?)"
+ Regex " spk:([a-z0-9]+((-sdca)|(-spk))?)"
String "${CardComponents}"
}
SpeakerChannels {
--
2.39.2
1
0
10 Jun '24
This driver was ported from an old version in linux 2.6.27 and adjusted
for the new ASoC framework and DMA API.
Signed-off-by: Piotr Wojtaszczyk <piotr.wojtaszczyk(a)timesys.com>
---
.../bindings/sound/nxp,lpc3220-i2s.yaml | 50 +++
arch/arm/boot/dts/lpc32xx.dtsi | 4 +
arch/arm/mach-lpc32xx/phy3250.c | 60 +++
sound/soc/fsl/Kconfig | 7 +
sound/soc/fsl/Makefile | 2 +
sound/soc/fsl/lpc3xxx-i2s.c | 411 ++++++++++++++++++
sound/soc/fsl/lpc3xxx-i2s.h | 94 ++++
sound/soc/fsl/lpc3xxx-pcm.c | 75 ++++
8 files changed, 703 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
create mode 100644 sound/soc/fsl/lpc3xxx-i2s.c
create mode 100644 sound/soc/fsl/lpc3xxx-i2s.h
create mode 100644 sound/soc/fsl/lpc3xxx-pcm.c
diff --git a/Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml b/Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
new file mode 100644
index 000000000000..e41330b6775c
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nxp,lpc3220-i2s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP LPC32XX I2S Controller
+
+description:
+ The block adds I2S and PCM drivers for LPC32XX
+
+properties:
+ compatible:
+ enum:
+ - nxp,lpc3220-i2s
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: input clock of the peripheral.
+
+ clock-names:
+ items:
+ - const: i2s_clk
+
+ interrupts:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/lpc32xx-clock.h>
+
+ i2s0: i2s@20094000 {
+ compatible = "nxp,lpc3220-i2s";
+ reg = <0x20094000 0x1000>;
+ clocks = <&clk LPC32XX_CLK_I2S0>;
+ clock-names = "i2s_clk";
+ };
+
+...
diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi
index c87066d6c995..dc5738f2b42d 100644
--- a/arch/arm/boot/dts/lpc32xx.dtsi
+++ b/arch/arm/boot/dts/lpc32xx.dtsi
@@ -221,6 +221,8 @@ spi2: spi@20090000 {
i2s0: i2s@20094000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x20094000 0x1000>;
+ clocks = <&clk LPC32XX_CLK_I2S0>;
+ clock-names = "i2s_clk";
status = "disabled";
};
@@ -237,6 +239,8 @@ sd: sd@20098000 {
i2s1: i2s@2009c000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x2009c000 0x1000>;
+ clocks = <&clk LPC32XX_CLK_I2S1>;
+ clock-names = "i2s_clk";
status = "disabled";
};
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index 66701bf43248..b866b9a75558 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -9,6 +9,7 @@
*/
#include <linux/amba/pl08x.h>
+#include <linux/amba/pl022.h>
#include <linux/mtd/lpc32xx_mlc.h>
#include <linux/mtd/lpc32xx_slc.h>
#include <linux/of_platform.h>
@@ -29,6 +30,46 @@ static struct pl08x_channel_data pl08x_slave_channels[] = {
.max_signal = 12,
.periph_buses = PL08X_AHB1,
},
+ {
+ .bus_id = "i2s-tx",
+ .min_signal = 13,
+ .max_signal = 13,
+ .periph_buses = PL08X_AHB1,
+ },
+ {
+ .bus_id = "i2s-rx",
+ .min_signal = 0,
+ .max_signal = 0,
+ .periph_buses = PL08X_AHB1,
+ },
+ {
+ .bus_id = "ssp0-tx",
+ .min_signal = 15,
+ .max_signal = 15,
+ .muxval = 1,
+ .periph_buses = PL08X_AHB1,
+ },
+ {
+ .bus_id = "ssp0-rx",
+ .min_signal = 14,
+ .max_signal = 14,
+ .muxval = 1,
+ .periph_buses = PL08X_AHB1,
+ },
+ {
+ .bus_id = "ssp1-tx",
+ .min_signal = 11,
+ .max_signal = 11,
+ .muxval = 1,
+ .periph_buses = PL08X_AHB1,
+ },
+ {
+ .bus_id = "ssp1-rx",
+ .min_signal = 3,
+ .max_signal = 3,
+ .muxval = 1,
+ .periph_buses = PL08X_AHB1,
+ },
};
static int pl08x_get_signal(const struct pl08x_channel_data *cd)
@@ -60,12 +101,31 @@ static struct lpc32xx_mlc_platform_data lpc32xx_mlc_data = {
.dma_filter = pl08x_filter_id,
};
+static struct pl022_ssp_controller lpc32xx_ssp_data[] = {
+ {
+ .bus_id = 0,
+ .enable_dma = 0,
+ .dma_filter = pl08x_filter_id,
+ .dma_tx_param = "ssp0-tx",
+ .dma_rx_param = "ssp0-rx",
+ },
+ {
+ .bus_id = 1,
+ .enable_dma = 0,
+ .dma_filter = pl08x_filter_id,
+ .dma_tx_param = "ssp1-tx",
+ .dma_rx_param = "ssp1-rx",
+ }
+};
+
static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
OF_DEV_AUXDATA("arm,pl080", 0x31000000, "pl08xdmac", &pl08x_pd),
OF_DEV_AUXDATA("nxp,lpc3220-slc", 0x20020000, "20020000.flash",
&lpc32xx_slc_data),
OF_DEV_AUXDATA("nxp,lpc3220-mlc", 0x200a8000, "200a8000.flash",
&lpc32xx_mlc_data),
+ OF_DEV_AUXDATA("arm,pl022", 0x20084000, NULL, &lpc32xx_ssp_data[0]),
+ OF_DEV_AUXDATA("arm,pl022", 0x2008c000, NULL, &lpc32xx_ssp_data[1]),
{ }
};
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 258306d8ce51..5f25aa7d632c 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -132,6 +132,13 @@ config SND_SOC_FSL_RPMSG
This option is only useful for out-of-tree drivers since
in-tree drivers select it automatically.
+config SND_SOC_FSL_LPC3XXX
+ tristate "SoC Audio for NXP LPC32XX CPUs"
+ depends on ARCH_LPC32XX && SND_SOC
+ select SND_SOC_GENERIC_DMAENGINE_PCM
+ help
+ Say Y or M if you want to add support for the LPC3XXX I2S interface.
+
config SND_SOC_IMX_PCM_DMA
tristate
select SND_SOC_GENERIC_DMAENGINE_PCM
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 9f743fcc0e02..988dc98cdfc6 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -29,6 +29,7 @@ snd-soc-fsl-easrc-objs := fsl_easrc.o
snd-soc-fsl-xcvr-objs := fsl_xcvr.o
snd-soc-fsl-aud2htx-objs := fsl_aud2htx.o
snd-soc-fsl-rpmsg-objs := fsl_rpmsg.o
+snd-soc-fsl-lpc3xxx-objs := lpc3xxx-pcm.o lpc3xxx-i2s.o
obj-$(CONFIG_SND_SOC_FSL_AUDMIX) += snd-soc-fsl-audmix.o
obj-$(CONFIG_SND_SOC_FSL_ASOC_CARD) += snd-soc-fsl-asoc-card.o
@@ -45,6 +46,7 @@ obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o
obj-$(CONFIG_SND_SOC_FSL_XCVR) += snd-soc-fsl-xcvr.o
obj-$(CONFIG_SND_SOC_FSL_AUD2HTX) += snd-soc-fsl-aud2htx.o
obj-$(CONFIG_SND_SOC_FSL_RPMSG) += snd-soc-fsl-rpmsg.o
+obj-$(CONFIG_SND_SOC_FSL_LPC3XXX) += snd-soc-fsl-lpc3xxx.o
# MPC5200 Platform Support
obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
diff --git a/sound/soc/fsl/lpc3xxx-i2s.c b/sound/soc/fsl/lpc3xxx-i2s.c
new file mode 100644
index 000000000000..853284eb14f1
--- /dev/null
+++ b/sound/soc/fsl/lpc3xxx-i2s.c
@@ -0,0 +1,411 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Author: Kevin Wells <kevin.wells(a)nxp.com>
+ *
+ * Copyright (C) 2008 NXP Semiconductors
+ * Copyright 2023 Timesys Corporation <piotr.wojtaszczyk(a)timesys.com>
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/dmaengine_pcm.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+
+#include "lpc3xxx-i2s.h"
+
+#define I2S_PLAYBACK_FLAG 0x1
+#define I2S_CAPTURE_FLAG 0x2
+
+#define LPC3XXX_I2S_RATES ( \
+ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
+ SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
+ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
+
+#define LPC3XXX_I2S_FORMATS ( \
+ SNDRV_PCM_FMTBIT_S8 | \
+ SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_S32_LE)
+
+static u32 absd32(u32 v1, u32 v2)
+{
+ if (v1 > v2) {
+ return v1 - v2;
+ }
+ return v2 - v1;
+}
+
+static void __lpc3xxx_find_clkdiv(u32 *clkx, u32 *clky, int freq,
+ int xbytes, u32 clkrate)
+{
+ u32 i2srate;
+ u32 idxx, idyy;
+ u32 savedbitclkrate, diff, trate, baseclk;
+
+ /* Adjust rate for sample size (bits) and 2 channels and offset for
+ * divider in clock output
+ */
+ i2srate = (freq / 100) * 2 * (8 * xbytes);
+ i2srate = i2srate << 1;
+ clkrate = clkrate / 100;
+ baseclk = clkrate;
+ *clkx = 1;
+ *clky = 1;
+
+ /* Find the best divider */
+ *clkx = *clky = 0;
+ savedbitclkrate = 0;
+ diff = ~0;
+ for (idxx = 1; idxx < 0xFF; idxx++) {
+ for (idyy = 1; idyy < 0xFF; idyy++) {
+ trate = (baseclk * idxx) / idyy;
+ if (absd32(trate, i2srate) < diff) {
+ diff = absd32(trate, i2srate);
+ savedbitclkrate = trate;
+ *clkx = idxx;
+ *clky = idyy;
+ }
+ }
+ }
+}
+
+static int lpc3xxx_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
+ struct device *dev = i2s_info_p->dev;
+ u32 flag;
+ int ret = 0;
+
+ mutex_lock(&i2s_info_p->lock);
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ flag = I2S_PLAYBACK_FLAG;
+ } else {
+ flag = I2S_CAPTURE_FLAG;
+ }
+
+ if (flag & i2s_info_p->streams_in_use) {
+ dev_warn(dev, "I2S channel is busy\n");
+ ret = -EBUSY;
+ goto lpc32xx_unlock;
+ }
+
+ if (i2s_info_p->streams_in_use == 0) {
+ ret = clk_prepare_enable(i2s_info_p->clk);
+ if (ret) {
+ dev_err(dev, "Can't enable clock, err=%d\n", ret);
+ goto lpc32xx_unlock;
+ }
+ }
+
+ i2s_info_p->streams_in_use |= flag;
+
+lpc32xx_unlock:
+ mutex_unlock(&i2s_info_p->lock);
+ return ret;
+}
+
+static void lpc3xxx_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
+ struct regmap *regs = i2s_info_p->regs;
+ const u32 stop_bits = (I2S_RESET | I2S_STOP);
+ u32 flag;
+
+ mutex_lock(&i2s_info_p->lock);
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ flag = I2S_PLAYBACK_FLAG;
+ regmap_write(regs, I2S_TX_RATE, 0);
+ regmap_update_bits(regs, I2S_DAO, stop_bits, stop_bits);
+ } else {
+ flag = I2S_CAPTURE_FLAG;
+ regmap_write(regs, I2S_RX_RATE, 0);
+ regmap_update_bits(regs, I2S_DAI, stop_bits, stop_bits);
+ }
+ i2s_info_p->streams_in_use &= ~flag;
+
+ if (i2s_info_p->streams_in_use == 0) {
+ clk_disable_unprepare(i2s_info_p->clk);
+ }
+
+ mutex_unlock(&i2s_info_p->lock);
+}
+
+static int lpc3xxx_i2s_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
+ int clk_id, unsigned int freq, int dir)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
+
+ /* Will use in HW params later */
+ i2s_info_p->freq = freq;
+
+ return 0;
+}
+
+static int lpc3xxx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
+ unsigned int fmt)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
+ struct device *dev = i2s_info_p->dev;
+
+ if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S) {
+ dev_warn(dev, "unsupported bus format %d\n", fmt);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int lpc3xxx_i2s_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
+ struct device *dev = i2s_info_p->dev;
+ struct regmap *regs = i2s_info_p->regs;
+ int xfersize;
+ u32 tmp, clkx, clky;
+
+ tmp = I2S_RESET | I2S_STOP;
+ switch (params_format(params)) {
+ case SNDRV_PCM_FORMAT_S8:
+ tmp |= I2S_WW8 | I2S_WS_HP(I2S_WW8_HP);
+ xfersize = 1;
+ break;
+
+ case SNDRV_PCM_FORMAT_S16_LE:
+ tmp |= I2S_WW16 | I2S_WS_HP(I2S_WW16_HP);
+ xfersize = 2;
+ break;
+
+ case SNDRV_PCM_FORMAT_S32_LE:
+ tmp |= I2S_WW32 | I2S_WS_HP(I2S_WW32_HP);
+ xfersize = 4;
+ break;
+
+ default:
+ dev_warn(dev, "Unsupported audio data format %d\n",
+ params_format(params));
+ return -EINVAL;
+ }
+
+ if (params_channels(params) == 1) {
+ tmp |= I2S_MONO;
+ }
+
+ __lpc3xxx_find_clkdiv(&clkx, &clky, i2s_info_p->freq, xfersize, i2s_info_p->clkrate);
+
+ dev_dbg(dev, "Stream : %s\n",
+ substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? "playback" : "capture");
+ dev_dbg(dev, "Desired clock rate : %d\n", i2s_info_p->freq);
+ dev_dbg(dev, "Base clock rate : %d\n", i2s_info_p->clkrate);
+ dev_dbg(dev, "Transfer size (bytes) : %d\n", xfersize);
+ dev_dbg(dev, "Clock divider (x) : %d\n", clkx);
+ dev_dbg(dev, "Clock divider (y) : %d\n", clky);
+ dev_dbg(dev, "Channels : %d\n", params_channels(params));
+ dev_dbg(dev, "Data format : %s\n", "I2S");
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ regmap_write(regs, I2S_DMA1, I2S_DMA1_TX_EN | I2S_DMA0_TX_DEPTH(4));
+ regmap_write(regs, I2S_TX_RATE, (clkx << 8) | clky);
+ regmap_write(regs, I2S_DAO, tmp);
+ } else {
+ regmap_write(regs, I2S_DMA0, I2S_DMA0_RX_EN | I2S_DMA1_RX_DEPTH(4));
+ regmap_write(regs, I2S_RX_RATE, (clkx << 8) | clky);
+ regmap_write(regs, I2S_DAI, tmp);
+ }
+
+ return 0;
+}
+
+static int lpc3xxx_i2s_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
+{
+ return 0;
+}
+
+static int lpc3xxx_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
+ struct snd_soc_dai *cpu_dai)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
+ struct regmap *regs = i2s_info_p->regs;
+ int ret = 0;
+
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ regmap_update_bits(regs, I2S_DAO, I2S_STOP, I2S_STOP);
+ } else {
+ regmap_update_bits(regs, I2S_DAI, I2S_STOP, I2S_STOP);
+ }
+ break;
+
+ case SNDRV_PCM_TRIGGER_START:
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ case SNDRV_PCM_TRIGGER_RESUME:
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ regmap_update_bits(regs, I2S_DAO, (I2S_RESET | I2S_STOP), 0);
+ } else {
+ regmap_update_bits(regs, I2S_DAI, (I2S_RESET | I2S_STOP), 0);
+ }
+ break;
+ default:
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+const struct snd_soc_dai_ops lpc3xxx_i2s_dai_ops = {
+ .startup = lpc3xxx_i2s_startup,
+ .shutdown = lpc3xxx_i2s_shutdown,
+ .prepare = lpc3xxx_i2s_prepare,
+ .trigger = lpc3xxx_i2s_trigger,
+ .hw_params = lpc3xxx_i2s_hw_params,
+ .set_sysclk = lpc3xxx_i2s_set_dai_sysclk,
+ .set_fmt = lpc3xxx_i2s_set_dai_fmt,
+};
+
+static int lpc3xxx_i2s_dai_probe(struct snd_soc_dai *dai)
+{
+ struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(dai);
+
+ snd_soc_dai_init_dma_data(dai, &i2s_info_p->playback_dma_config,
+ &i2s_info_p->capture_dma_config);
+ return 0;
+}
+
+struct snd_soc_dai_driver lpc3xxx_i2s_dai_driver = {
+ .probe = lpc3xxx_i2s_dai_probe,
+ .playback = {
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = LPC3XXX_I2S_RATES,
+ .formats = LPC3XXX_I2S_FORMATS,
+ },
+ .capture = {
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = LPC3XXX_I2S_RATES,
+ .formats = LPC3XXX_I2S_FORMATS,
+ },
+ .ops = &lpc3xxx_i2s_dai_ops,
+ .symmetric_rate = 1,
+ .symmetric_channels = 1,
+ .symmetric_sample_bits = 1,
+};
+
+static const struct snd_soc_component_driver lpc32xx_i2s_component = {
+ .name = "lpc32xx-i2s",
+};
+
+static const struct regmap_config lpc32xx_i2s_regconfig = {
+ .reg_bits = 32,
+ .reg_stride = 4,
+ .val_bits = 32,
+ .max_register = I2S_RX_RATE,
+};
+
+static int lpc32xx_i2s_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct lpc3xxx_i2s_info *i2s_info_p;
+ struct resource *res;
+ void __iomem *iomem;
+ int ret;
+
+ i2s_info_p = devm_kzalloc(dev, sizeof(*i2s_info_p), GFP_KERNEL);
+ if (!i2s_info_p)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, i2s_info_p);
+ i2s_info_p->dev = dev;
+
+ iomem = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(iomem)) {
+ dev_err(dev, "Can't map registers\n");
+ return PTR_ERR(iomem);
+ }
+
+ i2s_info_p->regs = devm_regmap_init_mmio(dev, iomem, &lpc32xx_i2s_regconfig);
+ if (IS_ERR(i2s_info_p->regs)) {
+ ret = PTR_ERR(i2s_info_p->regs);
+ dev_err(dev, "failed to init register map: %d\n", ret);
+ return ret;
+ }
+
+ i2s_info_p->clk = devm_clk_get(dev, "i2s_clk");
+ if (IS_ERR(i2s_info_p->clk)) {
+ dev_err(dev, "Can't get clock\n");
+ return PTR_ERR(i2s_info_p->clk);
+ }
+
+ i2s_info_p->clkrate = clk_get_rate(i2s_info_p->clk);
+ if (i2s_info_p->clkrate == 0) {
+ dev_err(dev, "Invalid returned clock rate\n");
+ goto err_clk_disable;
+ }
+
+ mutex_init(&i2s_info_p->lock);
+
+ ret = devm_snd_soc_register_component(dev, &lpc32xx_i2s_component,
+ &lpc3xxx_i2s_dai_driver, 1);
+ if (ret) {
+ dev_err(dev, "Can't register cpu_dai component\n");
+ goto err_clk_disable;
+ }
+
+ i2s_info_p->playback_dma_config.addr = (dma_addr_t)(res->start + I2S_TX_FIFO);
+ i2s_info_p->playback_dma_config.maxburst = 4;
+ i2s_info_p->playback_dma_config.filter_data = "i2s-tx";
+ i2s_info_p->capture_dma_config.addr = (dma_addr_t)(res->start + I2S_RX_FIFO);
+ i2s_info_p->capture_dma_config.maxburst = 4;
+ i2s_info_p->capture_dma_config.filter_data = "i2s-rx";
+
+ ret = lpc3xxx_pcm_register(pdev);
+ if (ret) {
+ dev_err(dev, "Can't register pcm component\n");
+ goto err_clk_disable;
+ }
+
+ return 0;
+
+err_clk_disable:
+ return ret;
+}
+
+static int lpc32xx_i2s_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static const struct of_device_id lpc32xx_i2s_match[] = {
+ { .compatible = "nxp,lpc3220-i2s" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, lpc32xx_i2s_match);
+
+static struct platform_driver lpc32xx_i2s_driver = {
+ .probe = lpc32xx_i2s_probe,
+ .remove = lpc32xx_i2s_remove,
+ .driver = {
+ .name = "lpc3xxx-i2s",
+ .of_match_table = of_match_ptr(lpc32xx_i2s_match),
+ },
+};
+
+module_platform_driver(lpc32xx_i2s_driver);
+
+MODULE_AUTHOR("Kevin Wells <kevin.wells(a)nxp.com>");
+MODULE_AUTHOR("Piotr Wojtaszczyk <piotr.wojtaszczyk(a)timesys.com>");
+MODULE_DESCRIPTION("ASoC LPC3XXX I2S interface");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/fsl/lpc3xxx-i2s.h b/sound/soc/fsl/lpc3xxx-i2s.h
new file mode 100644
index 000000000000..f88ab74cfe41
--- /dev/null
+++ b/sound/soc/fsl/lpc3xxx-i2s.h
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Author: Kevin Wells <kevin.wells(a)nxp.com>
+ *
+ * Copyright (C) 2008 NXP Semiconductors
+ * Copyright 2023 Timesys Corporation <piotr.wojtaszczyk(a)timesys.com>
+ */
+
+#ifndef __SOUND_SOC_LPC3XXX_I2S_H
+#define __SOUND_SOC_LPC3XXX_I2S_H
+
+#include <linux/types.h>
+#include <linux/regmap.h>
+
+struct lpc3xxx_i2s_info {
+ struct device *dev;
+ struct clk *clk;
+ struct mutex lock;
+ struct regmap *regs;
+ u32 streams_in_use;
+ u32 clkrate;
+ int freq;
+ struct snd_dmaengine_dai_dma_data playback_dma_config;
+ struct snd_dmaengine_dai_dma_data capture_dma_config;
+};
+
+int lpc3xxx_pcm_register(struct platform_device *pdev);
+
+#define _SBF(f, v) ((v) << (f))
+#define _BIT(n) _SBF(n, 1)
+
+/* I2S controller register offsets */
+#define I2S_DAO 0x00
+#define I2S_DAI 0x04
+#define I2S_TX_FIFO 0x08
+#define I2S_RX_FIFO 0x0C
+#define I2S_STAT 0x10
+#define I2S_DMA0 0x14
+#define I2S_DMA1 0x18
+#define I2S_IRQ 0x1C
+#define I2S_TX_RATE 0x20
+#define I2S_RX_RATE 0x24
+
+/* i2s_daO i2s_dai register definitions */
+#define I2S_WW8 _SBF(0, 0) /* Word width is 8bit*/
+#define I2S_WW16 _SBF(0, 1) /* Word width is 16bit*/
+#define I2S_WW32 _SBF(0, 3) /* Word width is 32bit*/
+#define I2S_MONO _BIT(2) /* Mono */
+#define I2S_STOP _BIT(3) /* Stop, diables the access to FIFO, mutes the channel */
+#define I2S_RESET _BIT(4) /* Reset the channel */
+#define I2S_WS_SEL _BIT(5) /* Channel Master(0) or slave(1) mode select*/
+#define I2S_WS_HP(s) _SBF(6, s) /* Word select half period - 1 */
+
+#define I2S_MUTE _BIT(15) /* Mute the channel, Transmit channel only */
+
+#define I2S_WW32_HP 0x1f /* Word select half period for 32bit word width */
+#define I2S_WW16_HP 0x0f /* Word select half period for 16bit word width */
+#define I2S_WW8_HP 0x7 /* Word select half period for 8bit word width */
+
+#define WSMASK_HP 0X7FC /* Mask for WS half period bits */
+
+/* i2s_tx_fifo register definitions */
+#define I2S_FIFO_TX_WRITE(d) (d)
+
+/* i2s_rx_fifo register definitions */
+#define I2S_FIFO_RX_WRITE(d) (d)
+
+/* i2s_stat register definitions */
+#define I2S_IRQ_STAT _BIT(0)
+#define I2S_DMA0_REQ _BIT(1)
+#define I2S_DMA1_REQ _BIT(2)
+
+#define I2S_RX_STATE_MASK 0x0000ff00
+#define I2S_TX_STATE_MASK 0x00ff0000
+
+/* i2s_dma0 Configuration register definitions */
+#define I2S_DMA0_RX_EN _BIT(0) /* Enable RX DMA1*/
+#define I2S_DMA0_TX_EN _BIT(1) /* Enable TX DMA1*/
+#define I2S_DMA0_RX_DEPTH(s) _SBF(8, s) /* Set the level for DMA1 RX Request */
+#define I2S_DMA0_TX_DEPTH(s) _SBF(16, s) /* Set the level for DMA1 TX Request */
+
+/* i2s_dma1 Configuration register definitions */
+#define I2S_DMA1_RX_EN _BIT(0) /* Enable RX DMA1*/
+#define I2S_DMA1_TX_EN _BIT(1) /* Enable TX DMA1*/
+#define I2S_DMA1_RX_DEPTH(s) _SBF(8, s) /* Set the level for DMA1 RX Request */
+#define I2S_DMA1_TX_DEPTH(s) _SBF(16, s) /* Set the level for DMA1 TX Request */
+
+/* i2s_irq register definitions */
+#define I2S_RX_IRQ_EN _BIT(0) /* Enable RX IRQ*/
+#define I2S_TX_IRQ_EN _BIT(1) /* Enable TX IRQ*/
+#define I2S_IRQ_RX_DEPTH(s) _SBF(8, s) /* valid values ar 0 to 7 */
+#define I2S_IRQ_TX_DEPTH(s) _SBF(16, s) /* valid values ar 0 to 7 */
+
+#endif
diff --git a/sound/soc/fsl/lpc3xxx-pcm.c b/sound/soc/fsl/lpc3xxx-pcm.c
new file mode 100644
index 000000000000..2dbc60d06452
--- /dev/null
+++ b/sound/soc/fsl/lpc3xxx-pcm.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Author: Kevin Wells <kevin.wells(a)nxp.com>
+ *
+ * Copyright (C) 2008 NXP Semiconductors
+ * Copyright 2023 Timesys Corporation <piotr.wojtaszczyk(a)timesys.com>
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/amba/pl08x.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/dmaengine_pcm.h>
+#include <sound/soc.h>
+
+#include "lpc3xxx-i2s.h"
+
+#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
+ SNDRV_PCM_FMTBIT_U8 | \
+ SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_U16_LE | \
+ SNDRV_PCM_FMTBIT_S24_LE | \
+ SNDRV_PCM_FMTBIT_U24_LE | \
+ SNDRV_PCM_FMTBIT_S32_LE | \
+ SNDRV_PCM_FMTBIT_U32_LE | \
+ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
+
+
+static const struct snd_pcm_hardware lpc3xxx_pcm_hardware = {
+ .info = (SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_MMAP_VALID |
+ SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_BLOCK_TRANSFER |
+ SNDRV_PCM_INFO_PAUSE |
+ SNDRV_PCM_INFO_RESUME),
+ .formats = STUB_FORMATS,
+ .period_bytes_min = 128,
+ .period_bytes_max = 2048,
+ .periods_min = 2,
+ .periods_max = 1024,
+ .buffer_bytes_max = 128 * 1024
+};
+
+static const struct snd_dmaengine_pcm_config lpc3xxx_dmaengine_pcm_config = {
+ .pcm_hardware = &lpc3xxx_pcm_hardware,
+ .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
+ .compat_filter_fn = pl08x_filter_id,
+ .prealloc_buffer_size = 128 * 1024,
+};
+
+const struct snd_soc_component_driver lpc3xxx_soc_platform_driver = {
+ .name = "lpc32xx-pcm",
+};
+
+int lpc3xxx_pcm_register(struct platform_device *pdev)
+{
+ int ret;
+
+ ret = devm_snd_dmaengine_pcm_register(&pdev->dev, &lpc3xxx_dmaengine_pcm_config,
+ SND_DMAENGINE_PCM_FLAG_NO_DT | SND_DMAENGINE_PCM_FLAG_COMPAT);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register dmaengine: %d\n", ret);
+ return ret;
+ }
+
+ return devm_snd_soc_register_component(&pdev->dev, &lpc3xxx_soc_platform_driver,
+ NULL, 0);
+}
+EXPORT_SYMBOL(lpc3xxx_pcm_register);
--
2.25.1
1
0
[PATCH v1 1/1] treewide: Align match_string() with sysfs_match_string()
by Andy Shevchenko 10 Jun '24
by Andy Shevchenko 10 Jun '24
10 Jun '24
Make two APIs look similar. Hence convert match_string() to be
a 2-argument macro. In order to avoid unneeded churn, convert
all users as well. There is no functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko(a)linux.intel.com>
---
Compile tested with `make allyesconfig` and `make allmodconfig`
on x86_64, arm, aarch64, powerpc64 (8 builds total).
I guess the best is to apply it to Linus' tree directly.
And now it seems a good timing as there are no new users
of this API either in v6.10-rcX, or in Linux Next.
But if you think differently, tell me.
arch/powerpc/xmon/xmon.c | 5 ++--
arch/x86/kernel/cpu/mtrr/if.c | 4 +--
crypto/asymmetric_keys/pkcs7_verify.c | 4 +--
drivers/acpi/scan.c | 4 +--
drivers/ata/pata_hpt366.c | 2 +-
drivers/ata/pata_hpt37x.c | 2 +-
drivers/base/property.c | 6 ++--
drivers/char/ipmi/ipmi_msghandler.c | 2 +-
drivers/char/ipmi/ipmi_si_hardcode.c | 2 +-
drivers/clk/bcm/clk-bcm2835.c | 4 +--
drivers/clk/rockchip/clk.c | 4 +--
drivers/clk/tegra/clk-tegra124-emc.c | 7 ++---
drivers/cpufreq/amd-pstate.c | 4 +--
drivers/cpufreq/intel_pstate.c | 2 +-
.../intel/qat/qat_common/adf_cfg_services.c | 5 ++--
.../gpu/drm/drm_panel_orientation_quirks.c | 2 +-
drivers/gpu/drm/i915/display/intel_pipe_crc.c | 2 +-
drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 4 +--
drivers/gpu/drm/nouveau/dispnv50/crc.c | 2 +-
drivers/hwmon/ltc4282.c | 14 ++++-----
drivers/hwmon/nct6775-platform.c | 6 ++--
drivers/hwtracing/intel_th/msu.c | 2 +-
drivers/i2c/busses/i2c-i801.c | 4 +--
drivers/leds/leds-sun50i-a100.c | 2 +-
drivers/mfd/omap-usb-host.c | 2 +-
drivers/mmc/host/sdhci-xenon-phy.c | 13 ++++-----
drivers/mtd/nand/raw/nand_macronix.c | 10 ++-----
.../net/ethernet/chelsio/cxgb4/cudbg_lib.c | 6 ++--
.../net/wireless/intel/iwlwifi/mvm/debugfs.c | 2 +-
drivers/pci/pcie/aer.c | 2 +-
drivers/phy/mediatek/phy-mtk-tphy.c | 8 ++---
drivers/phy/tegra/xusb.c | 4 +--
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 6 ++--
drivers/pinctrl/pinmux.c | 6 ++--
drivers/platform/x86/hp/hp-wmi.c | 29 +++++++------------
drivers/platform/x86/msi-ec.c | 4 +--
drivers/power/supply/ab8500_btemp.c | 2 +-
drivers/power/supply/ab8500_chargalg.c | 2 +-
drivers/power/supply/ab8500_charger.c | 2 +-
drivers/power/supply/ab8500_fg.c | 2 +-
drivers/staging/gdm724x/gdm_tty.c | 5 ++--
.../int340x_thermal/processor_thermal_rfim.c | 4 +--
.../processor_thermal_wt_req.c | 2 +-
drivers/usb/common/common.c | 8 ++---
drivers/usb/dwc3/dwc3-rtk.c | 2 +-
drivers/usb/typec/class.c | 14 ++++-----
drivers/usb/typec/tipd/core.c | 3 +-
drivers/video/fbdev/pxafb.c | 4 +--
fs/bcachefs/compress.c | 2 +-
fs/bcachefs/opts.c | 4 +--
fs/bcachefs/util.c | 4 +--
fs/ubifs/auth.c | 8 ++---
include/linux/string.h | 12 +++++++-
kernel/cgroup/rdma.c | 2 +-
kernel/sched/debug.c | 2 +-
kernel/trace/trace.c | 4 +--
kernel/trace/trace_osnoise.c | 4 +--
lib/dynamic_debug.c | 5 ++--
lib/string_helpers.c | 6 ++--
mm/mempolicy.c | 4 +--
mm/vmpressure.c | 4 +--
security/apparmor/lsm.c | 9 +++---
security/integrity/ima/ima_main.c | 2 +-
security/integrity/ima/ima_policy.c | 2 +-
sound/firewire/oxfw/oxfw.c | 2 +-
sound/pci/oxygen/oxygen_mixer.c | 2 +-
sound/soc/codecs/max98088.c | 2 +-
sound/soc/codecs/max98095.c | 2 +-
sound/soc/soc-dapm.c | 5 ++--
69 files changed, 150 insertions(+), 174 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index bd4813bad317..f479cc62674a 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -3478,8 +3478,7 @@ skipbl(void)
return c;
}
-#define N_PTREGS 44
-static const char *regnames[N_PTREGS] = {
+static const char *regnames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
@@ -3514,7 +3513,7 @@ scanhex(unsigned long *vp)
regname[i] = c;
}
regname[i] = 0;
- i = match_string(regnames, N_PTREGS, regname);
+ i = match_string(regnames, regname);
if (i < 0) {
printf("invalid register name '%%%s'\n", regname);
return 0;
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index a5c506f6da7f..9b749b848123 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -4,8 +4,8 @@
#include <linux/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/ctype.h>
-#include <linux/string.h>
#include <linux/slab.h>
+#include <linux/string_helpers.h>
#include <linux/init.h>
#define LINE_SIZE 80
@@ -139,7 +139,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
return -EINVAL;
ptr = skip_spaces(ptr + 5);
- i = match_string(mtrr_strings, MTRR_NUM_TYPES, ptr);
+ i = match_string(mtrr_strings, ptr);
if (i < 0)
return i;
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index f0d4ff3c20a8..1139d9d1c89a 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -141,8 +141,8 @@ int pkcs7_get_digest(struct pkcs7_message *pkcs7, const u8 **buf, u32 *len,
*buf = sinfo->sig->digest;
*len = sinfo->sig->digest_size;
- i = match_string(hash_algo_name, HASH_ALGO__LAST,
- sinfo->sig->hash_algo);
+ i = __match_string(hash_algo_name, HASH_ALGO__LAST,
+ sinfo->sig->hash_algo);
if (i >= 0)
*hash_algo = i;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 503773707e01..9cb350de30f0 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -798,7 +798,7 @@ static bool acpi_info_matches_ids(struct acpi_device_info *info,
if (!(info->valid & ACPI_VALID_HID))
return false;
- index = match_string(ids, -1, info->hardware_id.string);
+ index = __match_string(ids, -1, info->hardware_id.string);
if (index >= 0)
return true;
@@ -809,7 +809,7 @@ static bool acpi_info_matches_ids(struct acpi_device_info *info,
return false;
for (i = 0; i < cid_list->count; i++) {
- index = match_string(ids, -1, cid_list->ids[i].string);
+ index = __match_string(ids, -1, cid_list->ids[i].string);
if (index >= 0)
return true;
}
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index bdccd1ba1524..8134f9290791 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -178,7 +178,7 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
- i = match_string(list, -1, model_num);
+ i = __match_string(list, -1, model_num);
if (i >= 0) {
ata_dev_warn(dev, "%s is not supported for %s\n", modestr, list[i]);
return 1;
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index c0329cf01135..2d0b659bbd65 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -226,7 +226,7 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
- i = match_string(list, -1, model_num);
+ i = __match_string(list, -1, model_num);
if (i >= 0) {
ata_dev_warn(dev, "%s is not supported for %s\n",
modestr, list[i]);
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 837d77e3af2b..075c9dbd7aa5 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -15,7 +15,7 @@
#include <linux/property.h>
#include <linux/phy.h>
#include <linux/slab.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/types.h>
struct fwnode_handle *__dev_fwnode(struct device *dev)
@@ -489,7 +489,7 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode,
if (ret < 0)
goto out_free;
- ret = match_string(values, nval, string);
+ ret = __match_string(values, nval, string);
if (ret < 0)
ret = -ENODATA;
@@ -526,7 +526,7 @@ int fwnode_property_match_property_string(const struct fwnode_handle *fwnode,
if (ret)
return ret;
- ret = match_string(array, n, string);
+ ret = __match_string(array, n, string);
if (ret < 0)
ret = -ENOENT;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index e12b531f5c2f..c7526eb1e963 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -78,7 +78,7 @@ static int panic_op_write_handler(const char *val,
int e;
strscpy(valcp, val, sizeof(valcp));
- e = match_string(ipmi_panic_event_str, -1, strstrip(valcp));
+ e = __match_string(ipmi_panic_event_str, -1, strstrip(valcp));
if (e < 0)
return e;
diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c b/drivers/char/ipmi/ipmi_si_hardcode.c
index 0c92fa3eee88..4d3275374a53 100644
--- a/drivers/char/ipmi/ipmi_si_hardcode.c
+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
@@ -70,7 +70,7 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
if (!si_type_str || !*si_type_str) {
p.type = SI_KCS;
} else {
- t = match_string(si_to_str, -1, si_type_str);
+ t = __match_string(si_to_str, -1, si_type_str);
if (t < 0) {
pr_warn("Interface type specified for interface %d, was invalid: %s\n",
i, si_type_str);
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index fb04734afc80..9446422d5fa8 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1447,9 +1447,7 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
for (i = 0; i < clock_data->num_mux_parents; i++) {
parents[i] = clock_data->parents[i];
- ret = match_string(cprman_parent_names,
- ARRAY_SIZE(cprman_parent_names),
- parents[i]);
+ ret = match_string(cprman_parent_names, parents[i]);
if (ret >= 0)
parents[i] = cprman->real_parent_names[ret];
}
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 73d2cbdc716b..30414d081f46 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -266,8 +266,8 @@ static struct clk *rockchip_clk_register_frac_branch(
struct clk *mux_clk;
int ret;
- frac->mux_frac_idx = match_string(child->parent_names,
- child->num_parents, name);
+ frac->mux_frac_idx = __match_string(child->parent_names,
+ child->num_parents, name);
frac->mux_ops = &clk_mux_ops;
frac->clk_nb.notifier_call = rockchip_clk_frac_notifier_cb;
diff --git a/drivers/clk/tegra/clk-tegra124-emc.c b/drivers/clk/tegra/clk-tegra124-emc.c
index 2a6db0434281..a2709ed60ee7 100644
--- a/drivers/clk/tegra/clk-tegra124-emc.c
+++ b/drivers/clk/tegra/clk-tegra124-emc.c
@@ -20,7 +20,7 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/sort.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <soc/tegra/fuse.h>
@@ -413,13 +413,12 @@ static int load_one_timing_from_dt(struct tegra_clk_emc *tegra,
}
timing->parent_index = 0xff;
- i = match_string(emc_parent_clk_names, ARRAY_SIZE(emc_parent_clk_names),
- __clk_get_name(timing->parent));
+ i = match_string(emc_parent_clk_names, __clk_get_name(timing->parent));
if (i < 0) {
pr_err("timing %pOF: %s is not a valid parent\n",
node, __clk_get_name(timing->parent));
clk_put(timing->parent);
- return -EINVAL;
+ return i;
}
timing->parent_index = i;
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 1b7e82a0ad2e..b6f52f44625f 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1117,9 +1117,9 @@ static ssize_t store_energy_performance_preference(
if (ret != 1)
return -EINVAL;
- ret = match_string(energy_perf_strings, -1, str_preference);
+ ret = __match_string(energy_perf_strings, -1, str_preference);
if (ret < 0)
- return -EINVAL;
+ return ret;
mutex_lock(&amd_pstate_limits_lock);
ret = amd_pstate_set_energy_pref_index(cpudata, ret);
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 4b986c044741..1c2ee10415a2 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -832,7 +832,7 @@ static ssize_t store_energy_performance_preference(
if (ret != 1)
return -EINVAL;
- ret = match_string(energy_perf_strings, -1, str_preference);
+ ret = __match_string(energy_perf_strings, -1, str_preference);
if (ret < 0) {
if (!boot_cpu_has(X86_FEATURE_HWP_EPP))
return ret;
diff --git a/drivers/crypto/intel/qat/qat_common/adf_cfg_services.c b/drivers/crypto/intel/qat/qat_common/adf_cfg_services.c
index 268052294468..4b8c45e8b164 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_cfg_services.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_cfg_services.c
@@ -3,7 +3,7 @@
#include <linux/export.h>
#include <linux/pci.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include "adf_cfg.h"
#include "adf_cfg_services.h"
#include "adf_cfg_strings.h"
@@ -35,8 +35,7 @@ int adf_get_service_enabled(struct adf_accel_dev *accel_dev)
return ret;
}
- ret = match_string(adf_cfg_services, ARRAY_SIZE(adf_cfg_services),
- services);
+ ret = match_string(adf_cfg_services, services);
if (ret < 0)
dev_err(&GET_DEV(accel_dev),
"Invalid value of " ADF_SERVICES_ENABLED " param: %s\n",
diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index aa93129c3397..624743caac4c 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -481,7 +481,7 @@ int drm_get_panel_orientation_quirk(int width, int height)
if (!bios_date)
continue;
- i = match_string(data->bios_dates, -1, bios_date);
+ i = __match_string(data->bios_dates, -1, bios_date);
if (i >= 0)
return data->orientation;
}
diff --git a/drivers/gpu/drm/i915/display/intel_pipe_crc.c b/drivers/gpu/drm/i915/display/intel_pipe_crc.c
index 5a468ed6e26c..f9e7c66fd538 100644
--- a/drivers/gpu/drm/i915/display/intel_pipe_crc.c
+++ b/drivers/gpu/drm/i915/display/intel_pipe_crc.c
@@ -426,7 +426,7 @@ display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
return 0;
}
- i = match_string(pipe_crc_sources, ARRAY_SIZE(pipe_crc_sources), buf);
+ i = match_string(pipe_crc_sources, buf);
if (i < 0)
return i;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
index 670c9739e5e1..7fb9f5345654 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
@@ -645,8 +645,8 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder,
int i;
if (nouveau_tv_norm) {
- i = match_string(nv17_tv_norm_names, num_tv_norms,
- nouveau_tv_norm);
+ i = __match_string(nv17_tv_norm_names, num_tv_norms,
+ nouveau_tv_norm);
if (i < 0)
NV_WARN(drm, "Invalid TV norm setting \"%s\"\n",
nouveau_tv_norm);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 5936b6b3b15d..ea35d283b2d2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -38,7 +38,7 @@ static int nv50_crc_parse_source(const char *buf, enum nv50_crc_source *s)
return 0;
}
- i = match_string(nv50_crc_sources, ARRAY_SIZE(nv50_crc_sources), buf);
+ i = match_string(nv50_crc_sources, buf);
if (i < 0)
return i;
diff --git a/drivers/hwmon/ltc4282.c b/drivers/hwmon/ltc4282.c
index 4f608a3790fb..3546f5a7e7bd 100644
--- a/drivers/hwmon/ltc4282.c
+++ b/drivers/hwmon/ltc4282.c
@@ -21,7 +21,7 @@
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/property.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/units.h>
#include <linux/util_macros.h>
@@ -1282,8 +1282,7 @@ static int ltc4282_gpio_setup(struct ltc4282_state *st, struct device *dev)
ret = device_property_read_string(dev, "adi,gpio1-mode", &func);
if (!ret) {
- ret = match_string(ltc4282_gpio1_modes,
- ARRAY_SIZE(ltc4282_gpio1_modes), func);
+ ret = match_string(ltc4282_gpio1_modes, func);
if (ret < 0)
return dev_err_probe(dev, ret,
"Invalid func(%s) for gpio1\n",
@@ -1298,8 +1297,7 @@ static int ltc4282_gpio_setup(struct ltc4282_state *st, struct device *dev)
ret = device_property_read_string(dev, "adi,gpio2-mode", &func);
if (!ret) {
- ret = match_string(ltc4282_gpio2_modes,
- ARRAY_SIZE(ltc4282_gpio2_modes), func);
+ ret = match_string(ltc4282_gpio2_modes, func);
if (ret < 0)
return dev_err_probe(dev, ret,
"Invalid func(%s) for gpio2\n",
@@ -1463,8 +1461,7 @@ static int ltc4282_setup(struct ltc4282_state *st, struct device *dev)
ret = device_property_read_string(dev, "adi,overvoltage-dividers",
÷r);
if (!ret) {
- int div = match_string(ltc4282_dividers,
- ARRAY_SIZE(ltc4282_dividers), divider);
+ int div = match_string(ltc4282_dividers, divider);
if (div < 0)
return dev_err_probe(dev, -EINVAL,
"Invalid val(%s) for adi,overvoltage-divider\n",
@@ -1478,8 +1475,7 @@ static int ltc4282_setup(struct ltc4282_state *st, struct device *dev)
ret = device_property_read_string(dev, "adi,undervoltage-dividers",
÷r);
if (!ret) {
- int div = match_string(ltc4282_dividers,
- ARRAY_SIZE(ltc4282_dividers), divider);
+ int div = match_string(ltc4282_dividers, divider);
if (div < 0)
return dev_err_probe(dev, -EINVAL,
"Invalid val(%s) for adi,undervoltage-divider\n",
diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c
index 9aa4dcf4a6f3..eb7eef9d2a76 100644
--- a/drivers/hwmon/nct6775-platform.c
+++ b/drivers/hwmon/nct6775-platform.c
@@ -1514,13 +1514,11 @@ static int __init sensors_nct6775_platform_init(void)
if (board_name && board_vendor &&
!strcmp(board_vendor, "ASUSTeK COMPUTER INC.")) {
- err = match_string(asus_wmi_boards, ARRAY_SIZE(asus_wmi_boards),
- board_name);
+ err = match_string(asus_wmi_boards, board_name);
if (err >= 0)
access = nct6775_determine_access(ASUSWMI_DEVICE_UID);
- err = match_string(asus_msi_boards, ARRAY_SIZE(asus_msi_boards),
- board_name);
+ err = match_string(asus_msi_boards, board_name);
if (err >= 0)
access = nct6775_determine_access(ASUSMSI_DEVICE_UID);
}
diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index be63d5b8f193..b083f1360111 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1901,7 +1901,7 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,
if (!mode)
return -ENOMEM;
- i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode);
+ i = match_string(msc_mode, mode);
if (i >= 0) {
kfree(mode);
goto found;
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index d2d2a6dbe29f..0eccb636b2fe 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -111,7 +111,7 @@
#include <linux/io.h>
#include <linux/dmi.h>
#include <linux/slab.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/completion.h>
#include <linux/err.h>
#include <linux/platform_device.h>
@@ -1186,7 +1186,7 @@ static acpi_status check_acpi_smo88xx_device(acpi_handle obj_handle,
if (!hid)
goto smo88xx_not_found;
- i = match_string(acpi_smo8800_ids, ARRAY_SIZE(acpi_smo8800_ids), hid);
+ i = match_string(acpi_smo8800_ids, hid);
if (i < 0)
goto smo88xx_not_found;
diff --git a/drivers/leds/leds-sun50i-a100.c b/drivers/leds/leds-sun50i-a100.c
index 119eff9471f0..4220f1f8a503 100644
--- a/drivers/leds/leds-sun50i-a100.c
+++ b/drivers/leds/leds-sun50i-a100.c
@@ -256,7 +256,7 @@ static int sun50i_a100_ledc_parse_format(struct device *dev,
device_property_read_string(dev, "allwinner,pixel-format", &format);
- i = match_string(sun50i_a100_ledc_formats, ARRAY_SIZE(sun50i_a100_ledc_formats), format);
+ i = match_string(sun50i_a100_ledc_formats, format);
if (i < 0)
return dev_err_probe(dev, i, "Bad pixel format '%s'\n", format);
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 949feb03d4f8..06c208d8a992 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -498,7 +498,7 @@ static int usbhs_omap_get_dt_pdata(struct device *dev,
continue;
/* get 'enum usbhs_omap_port_mode' from port mode string */
- ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode);
+ ret = match_string(port_modes, mode);
if (ret < 0) {
dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n",
i, mode);
diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
index cc9d28b75eb9..1865e26ae736 100644
--- a/drivers/mmc/host/sdhci-xenon-phy.c
+++ b/drivers/mmc/host/sdhci-xenon-phy.c
@@ -135,15 +135,14 @@ struct xenon_emmc_phy_regs {
u32 logic_timing_val;
};
-static const char * const phy_types[] = {
- "emmc 5.0 phy",
- "emmc 5.1 phy"
-};
-
enum xenon_phy_type_enum {
EMMC_5_0_PHY,
EMMC_5_1_PHY,
- NR_PHY_TYPES
+};
+
+static const char * const phy_types[] = {
+ [EMMC_5_0_PHY] = "emmc 5.0 phy",
+ [EMMC_5_1_PHY] = "emmc 5.1 phy",
};
enum soc_pad_ctrl_type {
@@ -852,7 +851,7 @@ static int xenon_add_phy(struct device *dev, struct sdhci_host *host,
struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
int ret;
- priv->phy_type = match_string(phy_types, NR_PHY_TYPES, phy_name);
+ priv->phy_type = match_string(phy_types, phy_name);
if (priv->phy_type < 0) {
dev_err(mmc_dev(host->mmc),
"Unable to determine PHY name %s. Use default eMMC 5.1 PHY\n",
diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
index e229de32ff50..8b3fb2c72bd6 100644
--- a/drivers/mtd/nand/raw/nand_macronix.c
+++ b/drivers/mtd/nand/raw/nand_macronix.c
@@ -178,8 +178,7 @@ static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
if (!chip->parameters.supports_set_get_features)
return;
- i = match_string(broken_get_timings, ARRAY_SIZE(broken_get_timings),
- chip->parameters.model);
+ i = match_string(broken_get_timings, chip->parameters.model);
if (i < 0)
return;
@@ -317,8 +316,7 @@ static void macronix_nand_deep_power_down_support(struct nand_chip *chip)
"MX30UF4G28AD",
};
- i = match_string(deep_power_down_dev, ARRAY_SIZE(deep_power_down_dev),
- chip->parameters.model);
+ i = match_string(deep_power_down_dev, chip->parameters.model);
if (i < 0)
return;
@@ -461,9 +459,7 @@ static void macronix_nand_setup_otp(struct nand_chip *chip)
};
struct mtd_info *mtd;
- if (match_string(supported_otp_models,
- ARRAY_SIZE(supported_otp_models),
- chip->parameters.model) < 0)
+ if (match_string(supported_otp_models, chip->parameters.model) < 0)
return;
if (!chip->parameters.supports_set_get_features)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
index 557c591a6ce3..cff23dc56641 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
@@ -4,7 +4,7 @@
*/
#include <linux/sort.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include "t4_regs.h"
#include "cxgb4.h"
@@ -1191,9 +1191,9 @@ static int cudbg_get_mem_region(struct adapter *padap,
if (rc)
return rc;
- i = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name);
+ i = match_string(cudbg_region, region_name);
if (i < 0)
- return -EINVAL;
+ return i;
idx = i;
for (i = 0; i < meminfo->mem_c; i++) {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 79f4ac8cbc72..58388ca9ecfa 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -724,7 +724,7 @@ iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
};
int ret, bt_force_ant_mode;
- ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf);
+ ret = match_string(modes_str, buf);
if (ret < 0)
return ret;
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index ac6293c24976..2d317c7e1cea 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -210,7 +210,7 @@ void pcie_ecrc_get_policy(char *str)
{
int i;
- i = match_string(ecrc_policy_str, ARRAY_SIZE(ecrc_policy_str), str);
+ i = match_string(ecrc_policy_str, str);
if (i < 0)
return;
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 25b86bbb9cec..762674acb7fc 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -389,7 +389,7 @@ static int u2_phy_params_show(struct seq_file *sf, void *unused)
u32 val = 0;
int ret;
- ret = match_string(u2_phy_files, ARRAY_SIZE(u2_phy_files), fname);
+ ret = match_string(u2_phy_files, fname);
if (ret < 0)
return ret;
@@ -464,7 +464,7 @@ static ssize_t u2_phy_params_write(struct file *file, const char __user *ubuf,
if (rc)
return rc;
- ret = match_string(u2_phy_files, ARRAY_SIZE(u2_phy_files), fname);
+ ret = match_string(u2_phy_files, fname);
if (ret < 0)
return (ssize_t)ret;
@@ -530,7 +530,7 @@ static int u3_phy_params_show(struct seq_file *sf, void *unused)
u32 tmp;
int ret;
- ret = match_string(u3_phy_files, ARRAY_SIZE(u3_phy_files), fname);
+ ret = match_string(u3_phy_files, fname);
if (ret < 0)
return ret;
@@ -590,7 +590,7 @@ static ssize_t u3_phy_params_write(struct file *file, const char __user *ubuf,
if (rc)
return rc;
- ret = match_string(u3_phy_files, ARRAY_SIZE(u3_phy_files), fname);
+ ret = match_string(u3_phy_files, fname);
if (ret < 0)
return (ssize_t)ret;
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index cfdb54b6070a..5fb8656aa31d 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -123,7 +123,7 @@ int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
if (err < 0)
return err;
- err = match_string(lane->soc->funcs, lane->soc->num_funcs, function);
+ err = __match_string(lane->soc->funcs, lane->soc->num_funcs, function);
if (err < 0) {
dev_err(dev, "invalid function \"%s\" for lane \"%pOFn\"\n",
function, np);
@@ -748,7 +748,7 @@ static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
usb2->internal = of_property_read_bool(np, "nvidia,internal");
if (!of_property_read_string(np, "mode", &mode)) {
- int err = match_string(modes, ARRAY_SIZE(modes), mode);
+ int err = match_string(modes, mode);
if (err < 0) {
dev_err(&port->dev, "invalid value %s for \"mode\"\n",
mode);
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 4c4ada06423d..55b5464595b5 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -352,7 +352,7 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev,
dev_dbg(dev, "enable function %s group %s\n", name, grp->name);
- func = match_string(grp->funcs, NB_FUNCS, name);
+ func = match_string(grp->funcs, name);
if (func < 0)
return -ENOTSUPP;
@@ -885,7 +885,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
for (j = 0; j < grp->extra_npins; j++)
grp->pins[i+j] = grp->extra_pin + j;
- for (f = 0; (f < NB_FUNCS) && grp->funcs[f]; f++) {
+ for (f = 0; (f < ARRAY_SIZE(grp->funcs)) && grp->funcs[f]; f++) {
int ret;
/* check for unique functions and count groups */
ret = armada_37xx_add_function(info->funcs, &funcsize,
@@ -937,7 +937,7 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
struct armada_37xx_pin_group *gp = &info->groups[g];
int f;
- f = match_string(gp->funcs, NB_FUNCS, name);
+ f = match_string(gp->funcs, name);
if (f < 0)
continue;
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index addba55334d9..af2334b16b94 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -23,7 +23,7 @@
#include <linux/radix-tree.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinctrl.h>
@@ -376,7 +376,7 @@ int pinmux_map_to_setting(const struct pinctrl_map *map,
}
if (map->data.mux.group) {
group = map->data.mux.group;
- ret = match_string(groups, num_groups, group);
+ ret = __match_string(groups, num_groups, group);
if (ret < 0) {
dev_err(pctldev->dev,
"invalid group \"%s\" for function \"%s\"\n",
@@ -730,7 +730,7 @@ static ssize_t pinmux_select_write(struct file *file, const char __user *user_bu
goto exit_free_buf;
}
- ret = match_string(groups, num_groups, gname);
+ ret = __match_string(groups, num_groups, gname);
if (ret < 0) {
dev_err(pctldev->dev, "invalid group %s", gname);
goto exit_free_buf;
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 5fa553023842..ad7a9063c5d2 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -25,7 +25,7 @@
#include <linux/hwmon.h>
#include <linux/acpi.h>
#include <linux/rfkill.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/dmi.h>
MODULE_AUTHOR("Matthew Garrett <mjg59(a)srcf.ucam.org>");
@@ -443,18 +443,15 @@ static int hp_wmi_get_tablet_mode(void)
{
char system_device_mode[4] = { 0 };
const char *chassis_type;
- bool tablet_found;
int ret;
chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
if (!chassis_type)
return -ENODEV;
- tablet_found = match_string(tablet_chassis_types,
- ARRAY_SIZE(tablet_chassis_types),
- chassis_type) >= 0;
- if (!tablet_found)
- return -ENODEV;
+ ret = match_string(tablet_chassis_types, chassis_type);
+ if (ret < 0)
+ return ret;
ret = hp_wmi_perform_query(HPWMI_SYSTEM_DEVICE_MODE, HPWMI_READ,
system_device_mode, zero_if_sup(system_device_mode),
@@ -490,9 +487,7 @@ static bool is_omen_thermal_profile(void)
if (!board_name)
return false;
- return match_string(omen_thermal_profile_boards,
- ARRAY_SIZE(omen_thermal_profile_boards),
- board_name) >= 0;
+ return match_string(omen_thermal_profile_boards, board_name) >= 0;
}
static int omen_get_thermal_policy_version(void)
@@ -503,9 +498,9 @@ static int omen_get_thermal_policy_version(void)
const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
if (board_name) {
- int matches = match_string(omen_thermal_profile_force_v0_boards,
- ARRAY_SIZE(omen_thermal_profile_force_v0_boards),
- board_name);
+ int matches;
+
+ matches = match_string(omen_thermal_profile_force_v0_boards, board_name);
if (matches >= 0)
return 0;
}
@@ -1230,9 +1225,7 @@ static bool has_omen_thermal_profile_ec_timer(void)
if (!board_name)
return false;
- return match_string(omen_timed_thermal_profile_boards,
- ARRAY_SIZE(omen_timed_thermal_profile_boards),
- board_name) >= 0;
+ return match_string(omen_timed_thermal_profile_boards, board_name) >= 0;
}
inline int omen_thermal_profile_ec_flags_set(enum hp_thermal_profile_omen_flags flags)
@@ -1376,9 +1369,7 @@ static bool is_victus_thermal_profile(void)
if (!board_name)
return false;
- return match_string(victus_thermal_profile_boards,
- ARRAY_SIZE(victus_thermal_profile_boards),
- board_name) >= 0;
+ return match_string(victus_thermal_profile_boards, board_name) >= 0;
}
static int platform_profile_victus_get(struct platform_profile_handler *pprof,
diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c
index f19504dbf164..a1b2dbb1a10f 100644
--- a/drivers/platform/x86/msi-ec.c
+++ b/drivers/platform/x86/msi-ec.c
@@ -25,7 +25,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/seq_file.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#define SM_ECO_NAME "eco"
#define SM_COMFORT_NAME "comfort"
@@ -1316,7 +1316,7 @@ static int __init load_configuration(void)
/* load the suitable configuration, if exists */
for (int i = 0; CONFIGS[i]; i++) {
- if (match_string(CONFIGS[i]->allowed_fw, -1, fw_version) != -EINVAL) {
+ if (__match_string(CONFIGS[i]->allowed_fw, -1, fw_version) >= 0) {
conf = *CONFIGS[i];
conf.allowed_fw = NULL;
return 0;
diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c
index 56f136b2d071..824c71965150 100644
--- a/drivers/power/supply/ab8500_btemp.c
+++ b/drivers/power/supply/ab8500_btemp.c
@@ -556,7 +556,7 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
* For all psy where the name of your driver
* appears in any supplied_to
*/
- j = match_string(supplicants, ext->num_supplicants, psy->desc->name);
+ j = __match_string(supplicants, ext->num_supplicants, psy->desc->name);
if (j < 0)
return 0;
diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c
index 55ab7a28056e..230a4efee210 100644
--- a/drivers/power/supply/ab8500_chargalg.c
+++ b/drivers/power/supply/ab8500_chargalg.c
@@ -857,7 +857,7 @@ static int ab8500_chargalg_get_ext_psy_data(struct device *dev, void *data)
psy = (struct power_supply *)data;
di = power_supply_get_drvdata(psy);
/* For all psy where the driver name appears in any supplied_to */
- j = match_string(supplicants, ext->num_supplicants, psy->desc->name);
+ j = __match_string(supplicants, ext->num_supplicants, psy->desc->name);
if (j < 0)
return 0;
diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c
index 9b34d1a60f66..5eae14ca92fe 100644
--- a/drivers/power/supply/ab8500_charger.c
+++ b/drivers/power/supply/ab8500_charger.c
@@ -1902,7 +1902,7 @@ static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data)
* in practice what we will find will always be "ab8500_fg" as
* the fuel gauge is responsible of keeping track of VBAT.
*/
- j = match_string(supplicants, ext->num_supplicants, psy->desc->name);
+ j = __match_string(supplicants, ext->num_supplicants, psy->desc->name);
if (j < 0)
return 0;
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index 2ccaf6116c09..c3bc2833fc7e 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -2197,7 +2197,7 @@ static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data)
* For all psy where the name of your driver
* appears in any supplied_to
*/
- j = match_string(supplicants, ext->num_supplicants, psy->desc->name);
+ j = __match_string(supplicants, ext->num_supplicants, psy->desc->name);
if (j < 0)
return 0;
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 15c246d3b1a3..e87987a93860 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -53,10 +53,9 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
struct gdm *gdm = NULL;
int ret;
- ret = match_string(DRIVER_STRING, TTY_MAX_COUNT,
- tty->driver->driver_name);
+ ret = match_string(DRIVER_STRING, tty->driver->driver_name);
if (ret < 0)
- return -ENODEV;
+ return ret;
mutex_lock(&gdm_table_lock);
gdm = gdm_table[ret][tty->index];
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
index e56db75a94fb..dbd176b0fb1f 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
@@ -111,7 +111,7 @@ static ssize_t suffix##_show(struct device *dev,\
match_strs = (const char **)fivr_strings;\
mmio_regs = tgl_fivr_mmio_regs;\
} \
- ret = match_string(match_strs, -1, attr->attr.name);\
+ ret = __match_string(match_strs, -1, attr->attr.name);\
if (ret < 0)\
return ret;\
reg_val = readl((void __iomem *) (proc_priv->mmio_base + mmio_regs[ret].offset));\
@@ -145,7 +145,7 @@ static ssize_t suffix##_store(struct device *dev,\
mmio_regs = tgl_fivr_mmio_regs;\
} \
\
- ret = match_string(match_strs, -1, attr->attr.name);\
+ ret = __match_string(match_strs, -1, attr->attr.name);\
if (ret < 0)\
return ret;\
if (mmio_regs[ret].read_only)\
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c
index f298e7442662..57f456befb34 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c
@@ -50,7 +50,7 @@ static ssize_t workload_type_store(struct device *dev,
if (ret != 1)
return -EINVAL;
- ret = match_string(workload_types, -1, str_preference);
+ ret = __match_string(workload_types, -1, str_preference);
if (ret < 0)
return ret;
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index b84efae26e15..657be0162dd9 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -114,11 +114,11 @@ enum usb_device_speed usb_get_maximum_speed(struct device *dev)
if (ret < 0)
return USB_SPEED_UNKNOWN;
- ret = match_string(ssp_rate, ARRAY_SIZE(ssp_rate), maximum_speed);
+ ret = match_string(ssp_rate, maximum_speed);
if (ret > 0)
return USB_SPEED_SUPER_PLUS;
- ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed);
+ ret = match_string(speed_names, maximum_speed);
return (ret < 0) ? USB_SPEED_UNKNOWN : ret;
}
EXPORT_SYMBOL_GPL(usb_get_maximum_speed);
@@ -141,7 +141,7 @@ enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev)
if (ret < 0)
return USB_SSP_GEN_UNKNOWN;
- ret = match_string(ssp_rate, ARRAY_SIZE(ssp_rate), maximum_speed);
+ ret = match_string(ssp_rate, maximum_speed);
return (ret < 0) ? USB_SSP_GEN_UNKNOWN : ret;
}
EXPORT_SYMBOL_GPL(usb_get_maximum_ssp_rate);
@@ -184,7 +184,7 @@ static enum usb_dr_mode usb_get_dr_mode_from_string(const char *str)
{
int ret;
- ret = match_string(usb_dr_modes, ARRAY_SIZE(usb_dr_modes), str);
+ ret = match_string(usb_dr_modes, str);
return (ret < 0) ? USB_DR_MODE_UNKNOWN : ret;
}
diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c
index 3cd6b184551c..90cee91f4ff9 100644
--- a/drivers/usb/dwc3/dwc3-rtk.c
+++ b/drivers/usb/dwc3/dwc3-rtk.c
@@ -185,7 +185,7 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np)
if (ret < 0)
goto out;
- ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed);
+ ret = match_string(speed_names, maximum_speed);
out:
of_node_put(dwc3_np);
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 9610e647a8d4..7bc4695f8d0b 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -1986,8 +1986,7 @@ EXPORT_SYMBOL_GPL(typec_set_pwr_opmode);
*/
int typec_find_pwr_opmode(const char *name)
{
- return match_string(typec_pwr_opmodes,
- ARRAY_SIZE(typec_pwr_opmodes), name);
+ return match_string(typec_pwr_opmodes, name);
}
EXPORT_SYMBOL_GPL(typec_find_pwr_opmode);
@@ -2001,8 +2000,7 @@ EXPORT_SYMBOL_GPL(typec_find_pwr_opmode);
*/
int typec_find_orientation(const char *name)
{
- return match_string(typec_orientations, ARRAY_SIZE(typec_orientations),
- name);
+ return match_string(typec_orientations, name);
}
EXPORT_SYMBOL_GPL(typec_find_orientation);
@@ -2016,8 +2014,7 @@ EXPORT_SYMBOL_GPL(typec_find_orientation);
*/
int typec_find_port_power_role(const char *name)
{
- return match_string(typec_port_power_roles,
- ARRAY_SIZE(typec_port_power_roles), name);
+ return match_string(typec_port_power_roles, name);
}
EXPORT_SYMBOL_GPL(typec_find_port_power_role);
@@ -2031,7 +2028,7 @@ EXPORT_SYMBOL_GPL(typec_find_port_power_role);
*/
int typec_find_power_role(const char *name)
{
- return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
+ return match_string(typec_roles, name);
}
EXPORT_SYMBOL_GPL(typec_find_power_role);
@@ -2045,8 +2042,7 @@ EXPORT_SYMBOL_GPL(typec_find_power_role);
*/
int typec_find_port_data_role(const char *name)
{
- return match_string(typec_port_data_roles,
- ARRAY_SIZE(typec_port_data_roles), name);
+ return match_string(typec_port_data_roles, name);
}
EXPORT_SYMBOL_GPL(typec_find_port_data_role);
diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index ad76dbd20e65..2ce2d355a039 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -722,8 +722,7 @@ static int tps6598x_check_mode(struct tps6598x *tps)
if (ret)
return ret;
- ret = match_string(modes, ARRAY_SIZE(modes), mode);
-
+ ret = match_string(modes, mode);
switch (ret) {
case TPS_MODE_APP:
case TPS_MODE_PTCH:
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index 2ef56fa28aff..f1b562b94744 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -37,9 +37,9 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/errno.h>
-#include <linux/string.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
+#include <linux/string_helpers.h>
#include <linux/mm.h>
#include <linux/fb.h>
#include <linux/delay.h>
@@ -2107,7 +2107,7 @@ static int of_get_pxafb_display(struct device *dev, struct device_node *disp,
if (ret)
s = "color-tft";
- i = match_string(lcd_types, -1, s);
+ i = __match_string(lcd_types, -1, s);
if (i < 0) {
dev_err(dev, "lcd-type %s is unknown\n", s);
return i;
diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
index 1410365a8891..a62c5dd5b470 100644
--- a/fs/bcachefs/compress.c
+++ b/fs/bcachefs/compress.c
@@ -667,7 +667,7 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
type_str = strsep(&p, ":");
level_str = p;
- ret = match_string(bch2_compression_opts, -1, type_str);
+ ret = __match_string(bch2_compression_opts, -1, type_str);
if (ret < 0 && err)
prt_str(err, "invalid compression type");
if (ret < 0)
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index bb068fd72465..cbe4e820419f 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -122,7 +122,7 @@ static int bch2_opt_fix_errors_parse(struct bch_fs *c, const char *val, u64 *res
if (!val) {
*res = FSCK_FIX_yes;
} else {
- int ret = match_string(bch2_fsck_fix_opts, -1, val);
+ int ret = __match_string(bch2_fsck_fix_opts, -1, val);
if (ret < 0 && err)
prt_str(err, "fix_errors: invalid selection");
@@ -366,7 +366,7 @@ int bch2_opt_parse(struct bch_fs *c,
return -EINVAL;
}
- ret = match_string(opt->choices, -1, val);
+ ret = __match_string(opt->choices, -1, val);
if (ret < 0) {
if (err)
prt_printf(err, "%s: invalid selection",
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c
index de331dec2a99..8cef641a38fb 100644
--- a/fs/bcachefs/util.c
+++ b/fs/bcachefs/util.c
@@ -19,7 +19,7 @@
#include <linux/preempt.h>
#include <linux/random.h>
#include <linux/seq_file.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/types.h>
#include <linux/sched/clock.h>
@@ -215,7 +215,7 @@ u64 bch2_read_flag_list(char *opt, const char * const list[])
s = strim(d);
while ((p = strsep(&s, ","))) {
- int flag = match_string(list, -1, p);
+ int flag = __match_string(list, -1, p);
if (flag < 0) {
ret = -1;
diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c
index a4a0158f712d..fc0da18bfa65 100644
--- a/fs/ubifs/auth.c
+++ b/fs/ubifs/auth.c
@@ -264,13 +264,13 @@ int ubifs_init_authentication(struct ubifs_info *c)
return -EINVAL;
}
- c->auth_hash_algo = match_string(hash_algo_name, HASH_ALGO__LAST,
- c->auth_hash_name);
- if ((int)c->auth_hash_algo < 0) {
+ err = __match_string(hash_algo_name, HASH_ALGO__LAST, c->auth_hash_name);
+ if (err < 0) {
ubifs_err(c, "Unknown hash algo %s specified",
c->auth_hash_name);
- return -EINVAL;
+ return err;
}
+ c->auth_hash_algo = err;
snprintf(hmac_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)",
c->auth_hash_name);
diff --git a/include/linux/string.h b/include/linux/string.h
index 60168aa2af07..92fc7631f6a4 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -303,8 +303,18 @@ extern unsigned long long memparse(const char *ptr, char **retptr);
extern bool parse_option_str(const char *str, const char *option);
extern char *next_arg(char *args, char **param, char **val);
+int __match_string(const char * const *array, size_t n, const char *string);
+
+/**
+ * match_string - matches given string in an array
+ * @_a: array of strings
+ * @_s: string to match with
+ *
+ * Helper for __match_string(). Calculates the size of @a automatically.
+ */
+#define match_string(_a, _s) __match_string(_a, ARRAY_SIZE(_a), _s)
+
extern bool sysfs_streq(const char *s1, const char *s2);
-int match_string(const char * const *array, size_t n, const char *string);
int __sysfs_match_string(const char * const *array, size_t n, const char *s);
/**
diff --git a/kernel/cgroup/rdma.c b/kernel/cgroup/rdma.c
index ef5878fb2005..10105cfc5981 100644
--- a/kernel/cgroup/rdma.c
+++ b/kernel/cgroup/rdma.c
@@ -366,7 +366,7 @@ static int parse_resource(char *c, int *intval)
if (!name || !value)
return -EINVAL;
- i = match_string(rdmacg_resource_names, RDMACG_RESOURCE_MAX, name);
+ i = match_string(rdmacg_resource_names, name);
if (i < 0)
return i;
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index c1eb9a1afd13..b6238341e3c0 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -105,7 +105,7 @@ static int sched_feat_set(char *cmp)
cmp += 3;
}
- i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
+ i = __match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
if (i < 0)
return i;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 578a49ff5c32..13c0a1fa30cd 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -32,7 +32,6 @@
#include <linux/percpu.h>
#include <linux/splice.h>
#include <linux/kdebug.h>
-#include <linux/string.h>
#include <linux/mount.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
@@ -45,6 +44,7 @@
#include <linux/trace.h>
#include <linux/sched/clock.h>
#include <linux/sched/rt.h>
+#include <linux/string_helpers.h>
#include <linux/fsnotify.h>
#include <linux/irq_work.h>
#include <linux/workqueue.h>
@@ -5309,7 +5309,7 @@ int trace_set_options(struct trace_array *tr, char *option)
mutex_lock(&event_mutex);
mutex_lock(&trace_types_lock);
- ret = match_string(trace_options, -1, cmp);
+ ret = __match_string(trace_options, -1, cmp);
/* If no option could be set, test the specific tracer options */
if (ret < 0)
ret = set_tracer_option(tr, cmp, neg);
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index a8e28f9b9271..7bed499effd3 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2230,9 +2230,9 @@ static ssize_t osnoise_options_write(struct file *filp, const char __user *ubuf,
enable = false;
}
- option = match_string(osnoise_options_str, OSN_MAX, option_str);
+ option = match_string(osnoise_options_str, option_str);
if (option < 0)
- return -EINVAL;
+ return option;
/*
* trace_types_lock is taken to avoid concurrency on start/stop.
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index f2c5e7910bb1..cd4fbcea38ba 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -24,7 +24,6 @@
#include <linux/list.h>
#include <linux/sysctl.h>
#include <linux/ctype.h>
-#include <linux/string.h>
#include <linux/parser.h>
#include <linux/string_helpers.h>
#include <linux/uaccess.h>
@@ -154,7 +153,7 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons
int idx;
list_for_each_entry(map, &dt->maps, link) {
- idx = match_string(map->class_names, map->length, class_string);
+ idx = __match_string(map->class_names, map->length, class_string);
if (idx >= 0) {
*class_id = idx + map->base;
return map;
@@ -665,7 +664,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
if (*cl_str == '+')
cl_str++;
}
- cls_id = match_string(map->class_names, map->length, cl_str);
+ cls_id = __match_string(map->class_names, map->length, cl_str);
if (cls_id < 0) {
pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp));
continue;
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 69ba49b853c7..d3d0d2154146 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -898,7 +898,7 @@ bool sysfs_streq(const char *s1, const char *s2)
EXPORT_SYMBOL(sysfs_streq);
/**
- * match_string - matches given string in an array
+ * __match_string - matches given string in an array
* @array: array of strings
* @n: number of strings in the array or -1 for NULL terminated arrays
* @string: string to match with
@@ -914,7 +914,7 @@ EXPORT_SYMBOL(sysfs_streq);
* Return:
* index of a @string in the @array if matches, or %-EINVAL otherwise.
*/
-int match_string(const char * const *array, size_t n, const char *string)
+int __match_string(const char * const *array, size_t n, const char *string)
{
int index;
const char *item;
@@ -929,7 +929,7 @@ int match_string(const char * const *array, size_t n, const char *string)
return -EINVAL;
}
-EXPORT_SYMBOL(match_string);
+EXPORT_SYMBOL(__match_string);
/**
* __sysfs_match_string - matches given string in an array
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index aec756ae5637..89c132170431 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -89,7 +89,6 @@
#include <linux/nodemask.h>
#include <linux/cpuset.h>
#include <linux/slab.h>
-#include <linux/string.h>
#include <linux/export.h>
#include <linux/nsproxy.h>
#include <linux/interrupt.h>
@@ -103,6 +102,7 @@
#include <linux/ksm.h>
#include <linux/rmap.h>
#include <linux/security.h>
+#include <linux/string_helpers.h>
#include <linux/syscalls.h>
#include <linux/ctype.h>
#include <linux/mm_inline.h>
@@ -3183,7 +3183,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol)
} else
nodes_clear(nodes);
- mode = match_string(policy_modes, MPOL_MAX, str);
+ mode = match_string(policy_modes, str);
if (mode < 0)
goto out;
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index bd5183dfd879..eaaa133ce12b 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -388,7 +388,7 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
/* Find required level */
token = strsep(&spec, ",");
- ret = match_string(vmpressure_str_levels, VMPRESSURE_NUM_LEVELS, token);
+ ret = match_string(vmpressure_str_levels, token);
if (ret < 0)
goto out;
level = ret;
@@ -396,7 +396,7 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
/* Find optional mode */
token = strsep(&spec, ",");
if (token) {
- ret = match_string(vmpressure_str_modes, VMPRESSURE_NUM_MODES, token);
+ ret = match_string(vmpressure_str_modes, token);
if (ret < 0)
goto out;
mode = ret;
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 6239777090c4..e3fc94b4c7e5 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -1820,9 +1820,9 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
if (apparmor_initialized && !aa_current_policy_admin_capable(NULL))
return -EPERM;
- i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
+ i = __match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
if (i < 0)
- return -EINVAL;
+ return i;
aa_g_audit = i;
return 0;
@@ -1849,10 +1849,9 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
if (apparmor_initialized && !aa_current_policy_admin_capable(NULL))
return -EPERM;
- i = match_string(aa_profile_mode_names, APPARMOR_MODE_NAMES_MAX_INDEX,
- val);
+ i = __match_string(aa_profile_mode_names, APPARMOR_MODE_NAMES_MAX_INDEX, val);
if (i < 0)
- return -EINVAL;
+ return i;
aa_g_profile_mode = i;
return 0;
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index f04f43af651c..49d6e9cc3387 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -64,7 +64,7 @@ static int __init hash_setup(char *str)
goto out;
}
- i = match_string(hash_algo_name, HASH_ALGO__LAST, str);
+ i = __match_string(hash_algo_name, HASH_ALGO__LAST, str);
if (i < 0) {
pr_err("invalid hash algorithm \"%s\"", str);
return 1;
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index c0556907c2e6..fa67c5794071 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -1380,7 +1380,7 @@ static unsigned int ima_parse_appraise_algos(char *arg)
char *token;
while ((token = strsep(&arg, ",")) != NULL) {
- idx = match_string(hash_algo_name, HASH_ALGO__LAST, token);
+ idx = __match_string(hash_algo_name, HASH_ALGO__LAST, token);
if (idx < 0) {
pr_err("unknown hash algorithm \"%s\"",
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 98ae0e8cba87..5b38069daa0a 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -59,7 +59,7 @@ static bool detect_loud_models(struct fw_unit *unit)
if (err < 0)
return false;
- return match_string(models, ARRAY_SIZE(models), model) >= 0;
+ return match_string(models, model) >= 0;
}
static int name_card(struct snd_oxfw *oxfw, const struct ieee1394_device_id *entry)
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index eb3aca16359c..73e15d5d6be9 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -1074,7 +1074,7 @@ static int add_controls(struct oxygen *chip,
err = snd_ctl_add(chip->card, ctl);
if (err < 0)
return err;
- j = match_string(known_ctl_names, CONTROL_COUNT, ctl->id.name);
+ j = match_string(known_ctl_names, ctl->id.name);
if (j >= 0) {
chip->controls[j] = ctl;
ctl->private_free = oxygen_any_ctl_free;
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index 8b56ee550c09..4736a4ba0e1f 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -1414,7 +1414,7 @@ static int max98088_get_channel(struct snd_soc_component *component, const char
{
int ret;
- ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
+ ret = match_string(eq_mode_name, name);
if (ret < 0)
dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
return ret;
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 7e525d49328d..430bce3333a9 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -1627,7 +1627,7 @@ static int max98095_get_bq_channel(struct snd_soc_component *component,
{
int ret;
- ret = match_string(bq_mode_name, ARRAY_SIZE(bq_mode_name), name);
+ ret = match_string(bq_mode_name, name);
if (ret < 0)
dev_err(component->dev, "Bad biquad channel name '%s'\n", name);
return ret;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 16dad4a45443..7064f4cae549 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -769,14 +769,13 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
item = 0;
}
- i = match_string(e->texts, e->items, control_name);
+ i = __match_string(e->texts, e->items, control_name);
if (i < 0)
- return -ENODEV;
+ return i;
path->name = e->texts[i];
path->connect = (i == item);
return 0;
-
}
/* set up initial codec paths */
--
2.43.0.rc1.1336.g36b5255a03ac
18
17
Onboard Speaker does not work and Internal Mic (DMIC) isn't detected on Dell Latitude 7350 Detachable
by GitHub issues - edited 10 Jun '24
by GitHub issues - edited 10 Jun '24
10 Jun '24
alsa-project/alsa-ucm-conf issue #424 was edited from DeepHarsora-Dell:
Installed Fedora Rawhide on Dell Latitude 7350 Detachable resulting in no-audio output from onboard speaker and in-built mic (DMIC) can't be detected. (SKU - 0x0C64)
Updated the SUT with the following
1. Topology built rightly.
2. Noticed proper SOF Machine driver in upstream as on v.6.10-rc1, able to load the topology.
3. Updated the UCM2 config files as per [[ALSA_UCM_README]](https://github.com/alsa-project/alsa-ucm-conf/blob/master…
Below is the error found while alsaucm reload
[linuxengg@fedora ~]$ sudo alsaucm reload
ALSA lib ucm_subs.c:807:(uc_mgr_get_substituted_value) variable '${var:__RegEx}' is not defined in this context!
ALSA lib parser.c:2024:(parse_verb_file) error: /sof-soundwire/HiFi.conf failed to parse device ALSA lib main.c:1554:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -22
alsaucm: error failed to open sound card hw:0: Invalid argument
Issue URL : https://github.com/alsa-project/alsa-ucm-conf/issues/424
Repository URL: https://github.com/alsa-project/alsa-ucm-conf
1
0
alsa-project/alsa-lib issue #400 was opened from sylware:
To have the less "technical distance" with modern audio hardware (for instance usb audio 2), is it better to have interleaved audio frames each with a pitch, or brutally planar with a pitch per plane?
Issue URL : https://github.com/alsa-project/alsa-lib/issues/400
Repository URL: https://github.com/alsa-project/alsa-lib
1
0