[PATCH v2 00/11] of: Add wrappers to match root node with OF device ID tables

Krzysztof Kozlowski posted 11 patches 1 month, 1 week ago
drivers/cpufreq/cpufreq-dt-platdev.c               | 15 ++-----
drivers/cpufreq/mediatek-cpufreq.c                 | 12 +-----
drivers/cpufreq/sun50i-cpufreq-nvmem.c             | 11 +----
drivers/cpuidle/cpuidle-big_little.c               | 11 +----
drivers/firmware/qcom/qcom_scm.c                   | 17 +-------
drivers/irqchip/irq-atmel-aic-common.c             | 15 ++-----
drivers/of/base.c                                  | 47 ++++++++++++++++++++++
.../platform/surface/surface_aggregator_registry.c | 13 +-----
drivers/powercap/dtpm.c                            | 16 +-------
drivers/soc/qcom/ubwc_config.c                     | 14 ++-----
drivers/soc/tegra/common.c                         | 12 +-----
include/linux/of.h                                 | 13 ++++++
12 files changed, 79 insertions(+), 117 deletions(-)
[PATCH v2 00/11] of: Add wrappers to match root node with OF device ID tables
Posted by Krzysztof Kozlowski 1 month, 1 week ago
Changes in v2:
- Drop cpufreq/ti change: not correct.
- Drop soc/qcom/qcom_pd_mapper.c - objections from Dmitry and I think
  better to drop the patch in such case.
- I did not implement feedback for first patch to make the
  of_machine_compatible_match() matching machines in arbitrary nodes,
  because there is no such use case possible and no arguments were provided.
  I also did not use cleanup.h in first patch because existing code
  of_device_get_match_data() does not use it and I prefer uniformity.

- Add Ack/Rb tags.
- Link to v1: https://patch.msgid.link/20251106-b4-of-match-matchine-data-v1-0-d780ea1780c2@linaro.org

Dependency/merging
==================
All patches depend on the first patch, thus everything could go via
Rob's tree with people's acks.

Description
===========
Several drivers duplicate same code for getting reference to the root
node, matching it against 'struct of_device_id' table and getting out
the match data from the table entry.

There is a of_machine_compatible_match() wrapper but it takes array of
strings, which is not suitable for many drivers since they want the
driver data associated with each compatible.

Add two wrappers, similar to existing of_device_get_match_data():
1. of_machine_device_match() doing only matching against 'struct
   of_device_id' and returning bool.
2. of_machine_get_match_data() doing the matching and returning
   associated driver data for found compatible.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (11):
      of: Add wrappers to match root node with OF device ID tables
      cpufreq: dt-platdev: Simplify with of_machine_get_match_data()
      cpufreq: mediatek: Simplify with of_machine_get_match_data()
      cpufreq: sun50i: Simplify with of_machine_device_match()
      cpuidle: big_little: Simplify with of_machine_device_match()
      firmware: qcom: scm: Simplify with of_machine_device_match()
      irqchip/atmel-aic: Simplify with of_machine_get_match_data()
      platform: surface: Simplify with of_machine_get_match_data()
      powercap: dtpm: Simplify with of_machine_get_match_data()
      soc: qcom: ubwc: Simplify with of_machine_get_match_data()
      soc: tegra: Simplify with of_machine_device_match()

 drivers/cpufreq/cpufreq-dt-platdev.c               | 15 ++-----
 drivers/cpufreq/mediatek-cpufreq.c                 | 12 +-----
 drivers/cpufreq/sun50i-cpufreq-nvmem.c             | 11 +----
 drivers/cpuidle/cpuidle-big_little.c               | 11 +----
 drivers/firmware/qcom/qcom_scm.c                   | 17 +-------
 drivers/irqchip/irq-atmel-aic-common.c             | 15 ++-----
 drivers/of/base.c                                  | 47 ++++++++++++++++++++++
 .../platform/surface/surface_aggregator_registry.c | 13 +-----
 drivers/powercap/dtpm.c                            | 16 +-------
 drivers/soc/qcom/ubwc_config.c                     | 14 ++-----
 drivers/soc/tegra/common.c                         | 12 +-----
 include/linux/of.h                                 | 13 ++++++
 12 files changed, 79 insertions(+), 117 deletions(-)
---
base-commit: a4ebba34e722123f1c09ce3282e26f052fc8b27f
change-id: 20251106-b4-of-match-matchine-data-4a64bf046814

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Re: [PATCH v2 00/11] of: Add wrappers to match root node with OF device ID tables
Posted by AngeloGioacchino Del Regno 1 month, 1 week ago
Il 12/11/25 11:28, Krzysztof Kozlowski ha scritto:
> Changes in v2:

Note:

Looks ok based on code and based on testing on the following platforms:
  - tegra: Jetson Xavier NX Development Kit
  - qcom: sdm630 Sony Xperia XA2 (Nile), sc7180 Trogdor Lazor Chromebook
  - mediatek: MT6795 Xperia M5 (midstream kernel), MT8173 Elm Chromebook
              MT8365 Genio 350 (mt8365-evk)

Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

Cheers,
Angelo

> - Drop cpufreq/ti change: not correct.
> - Drop soc/qcom/qcom_pd_mapper.c - objections from Dmitry and I think
>    better to drop the patch in such case.
> - I did not implement feedback for first patch to make the
>    of_machine_compatible_match() matching machines in arbitrary nodes,
>    because there is no such use case possible and no arguments were provided.
>    I also did not use cleanup.h in first patch because existing code
>    of_device_get_match_data() does not use it and I prefer uniformity.
> 
> - Add Ack/Rb tags.
> - Link to v1: https://patch.msgid.link/20251106-b4-of-match-matchine-data-v1-0-d780ea1780c2@linaro.org
> 
> Dependency/merging
> ==================
> All patches depend on the first patch, thus everything could go via
> Rob's tree with people's acks.
> 
> Description
> ===========
> Several drivers duplicate same code for getting reference to the root
> node, matching it against 'struct of_device_id' table and getting out
> the match data from the table entry.
> 
> There is a of_machine_compatible_match() wrapper but it takes array of
> strings, which is not suitable for many drivers since they want the
> driver data associated with each compatible.
> 
> Add two wrappers, similar to existing of_device_get_match_data():
> 1. of_machine_device_match() doing only matching against 'struct
>     of_device_id' and returning bool.
> 2. of_machine_get_match_data() doing the matching and returning
>     associated driver data for found compatible.
> 
> Best regards,
> Krzysztof
> 
> ---
> Krzysztof Kozlowski (11):
>        of: Add wrappers to match root node with OF device ID tables
>        cpufreq: dt-platdev: Simplify with of_machine_get_match_data()
>        cpufreq: mediatek: Simplify with of_machine_get_match_data()
>        cpufreq: sun50i: Simplify with of_machine_device_match()
>        cpuidle: big_little: Simplify with of_machine_device_match()
>        firmware: qcom: scm: Simplify with of_machine_device_match()
>        irqchip/atmel-aic: Simplify with of_machine_get_match_data()
>        platform: surface: Simplify with of_machine_get_match_data()
>        powercap: dtpm: Simplify with of_machine_get_match_data()
>        soc: qcom: ubwc: Simplify with of_machine_get_match_data()
>        soc: tegra: Simplify with of_machine_device_match()
> 
>   drivers/cpufreq/cpufreq-dt-platdev.c               | 15 ++-----
>   drivers/cpufreq/mediatek-cpufreq.c                 | 12 +-----
>   drivers/cpufreq/sun50i-cpufreq-nvmem.c             | 11 +----
>   drivers/cpuidle/cpuidle-big_little.c               | 11 +----
>   drivers/firmware/qcom/qcom_scm.c                   | 17 +-------
>   drivers/irqchip/irq-atmel-aic-common.c             | 15 ++-----
>   drivers/of/base.c                                  | 47 ++++++++++++++++++++++
>   .../platform/surface/surface_aggregator_registry.c | 13 +-----
>   drivers/powercap/dtpm.c                            | 16 +-------
>   drivers/soc/qcom/ubwc_config.c                     | 14 ++-----
>   drivers/soc/tegra/common.c                         | 12 +-----
>   include/linux/of.h                                 | 13 ++++++
>   12 files changed, 79 insertions(+), 117 deletions(-)
> ---
> base-commit: a4ebba34e722123f1c09ce3282e26f052fc8b27f
> change-id: 20251106-b4-of-match-matchine-data-4a64bf046814
> 
> Best regards,
Re: [PATCH v2 00/11] of: Add wrappers to match root node with OF device ID tables
Posted by Thierry Reding 1 month ago
On Wed, Nov 12, 2025 at 12:52:48PM +0100, AngeloGioacchino Del Regno wrote:
> Il 12/11/25 11:28, Krzysztof Kozlowski ha scritto:
> > Changes in v2:
> 
> Note:
> 
> Looks ok based on code and based on testing on the following platforms:
>  - tegra: Jetson Xavier NX Development Kit

Thanks for testing, but Xavier NX doesn't run any of the code changed by
this patch. soc_is_tegra() is a legacy function that we need for DT
backwards-compatibility and should only run on 32-bit ARM devices.

Technically there's one case in drivers/soc/tegra/flowctrl.c that runs
this on Tegra210, but it should probably undergo the same treatment as
the PMC and FUSE drivers. The code that needs this is only used for CPU
power management on 32-bit ARM devices.

Thierry
Re: [PATCH v2 00/11] of: Add wrappers to match root node with OF device ID tables
Posted by Rob Herring 3 weeks, 1 day ago
On Wed, Nov 12, 2025 at 11:28:45AM +0100, Krzysztof Kozlowski wrote:
> Changes in v2:
> - Drop cpufreq/ti change: not correct.
> - Drop soc/qcom/qcom_pd_mapper.c - objections from Dmitry and I think
>   better to drop the patch in such case.
> - I did not implement feedback for first patch to make the
>   of_machine_compatible_match() matching machines in arbitrary nodes,
>   because there is no such use case possible and no arguments were provided.
>   I also did not use cleanup.h in first patch because existing code
>   of_device_get_match_data() does not use it and I prefer uniformity.
> 
> - Add Ack/Rb tags.
> - Link to v1: https://patch.msgid.link/20251106-b4-of-match-matchine-data-v1-0-d780ea1780c2@linaro.org
> 
> Dependency/merging
> ==================
> All patches depend on the first patch, thus everything could go via
> Rob's tree with people's acks.
> 
> Description
> ===========
> Several drivers duplicate same code for getting reference to the root
> node, matching it against 'struct of_device_id' table and getting out
> the match data from the table entry.
> 
> There is a of_machine_compatible_match() wrapper but it takes array of
> strings, which is not suitable for many drivers since they want the
> driver data associated with each compatible.
> 
> Add two wrappers, similar to existing of_device_get_match_data():
> 1. of_machine_device_match() doing only matching against 'struct
>    of_device_id' and returning bool.
> 2. of_machine_get_match_data() doing the matching and returning
>    associated driver data for found compatible.
> 
> Best regards,
> Krzysztof
> 
> ---
> Krzysztof Kozlowski (11):
>       of: Add wrappers to match root node with OF device ID tables
>       cpufreq: dt-platdev: Simplify with of_machine_get_match_data()
>       cpufreq: mediatek: Simplify with of_machine_get_match_data()
>       cpufreq: sun50i: Simplify with of_machine_device_match()
>       cpuidle: big_little: Simplify with of_machine_device_match()
>       firmware: qcom: scm: Simplify with of_machine_device_match()
>       irqchip/atmel-aic: Simplify with of_machine_get_match_data()
>       platform: surface: Simplify with of_machine_get_match_data()
>       powercap: dtpm: Simplify with of_machine_get_match_data()
>       soc: qcom: ubwc: Simplify with of_machine_get_match_data()
>       soc: tegra: Simplify with of_machine_device_match()
> 
>  drivers/cpufreq/cpufreq-dt-platdev.c               | 15 ++-----
>  drivers/cpufreq/mediatek-cpufreq.c                 | 12 +-----
>  drivers/cpufreq/sun50i-cpufreq-nvmem.c             | 11 +----
>  drivers/cpuidle/cpuidle-big_little.c               | 11 +----
>  drivers/firmware/qcom/qcom_scm.c                   | 17 +-------
>  drivers/irqchip/irq-atmel-aic-common.c             | 15 ++-----
>  drivers/of/base.c                                  | 47 ++++++++++++++++++++++
>  .../platform/surface/surface_aggregator_registry.c | 13 +-----
>  drivers/powercap/dtpm.c                            | 16 +-------
>  drivers/soc/qcom/ubwc_config.c                     | 14 ++-----
>  drivers/soc/tegra/common.c                         | 12 +-----
>  include/linux/of.h                                 | 13 ++++++
>  12 files changed, 79 insertions(+), 117 deletions(-)

Applied, thanks.

Rob