Linux clock framework development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Ulf Hansson" <ulfh@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
	"Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>,
	"Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Vinod Koul" <vkoul@kernel.org>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	"Kuninori Morimoto" <kuninori.morimoto.gx@renesas.com>,
	"Paul Elder" <paul.elder+renesas@ideasonboard.com>,
	"Clément Le Goffic" <clegoffic@baylibre.com>,
	"Sudeep Holla" <sudeep.holla@kernel.org>,
	"Cristian Marussi" <cristian.marussi@arm.com>,
	arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v5 12/15] pmdomain: renesas: r8a78000: Replace sentinel by explicit ID map size
Date: Mon, 23 Nov 2026 13:39:15 +0200	[thread overview]
Message-ID: <20261123113915.GI3010398@killaraus.ideasonboard.com> (raw)
In-Reply-To: <ee60a54c457af21277a13e8e1db36ce83209b3f5.1795029012.git.geert+renesas@glider.be>

On Wed, Nov 18, 2026 at 08:45:00PM +0100, Geert Uytterhoeven wrote:
> The use of a sentinel in the module ID mapping array will become
> cumbersome when the need arises to find out the actual number of
> elements in the array.  Rework the mapping data structure to fix this,
> also improving naming.  Let mod_id_map_find() return an index, to be
> used for indexing additional mapping target arrays later.
> Add a MOD_ID_MAP() initialization macro for brevity.
> 
> While at it, drop the check for "!map" in mod_id_map_find(), as that
> pointer can never be NULL.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v5:
>   - New.
> ---
>  drivers/pmdomain/renesas/r8a78000-mdlc.c | 49 +++++++++++++-----------
>  1 file changed, 27 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/pmdomain/renesas/r8a78000-mdlc.c b/drivers/pmdomain/renesas/r8a78000-mdlc.c
> index 1ace1fb10870f646..6477abe64511e880 100644
> --- a/drivers/pmdomain/renesas/r8a78000-mdlc.c
> +++ b/drivers/pmdomain/renesas/r8a78000-mdlc.c
> @@ -16,13 +16,23 @@
>  
>  #include <dt-bindings/power/renesas,r8a78000-mdlc.h>
>  
> -struct mod_map {
> -	int hw_id;		/* Hardware module ID or -1 sentinel */
> +struct mod_id_map_entry {
> +	u32 hw_id;		/* Hardware module ID */
>  };
>  
> +struct mod_id_map {
> +	const struct mod_id_map_entry *entries;
> +	unsigned int size;
> +};
> +
> +#define MOD_ID_MAP(_entries) .mod_map = &(struct mod_id_map) {		\
> +	.entries = _entries,						\
> +	.size = ARRAY_SIZE(_entries),					\
> +}
> +
>  struct mdlc_info {
>  	u32 base;
> -	const struct mod_map *mod_map;
> +	const struct mod_id_map *mod_map;
>  };
>  
>  /**
> @@ -41,7 +51,7 @@ struct r8a78000_mdlc_priv {
>  	struct reset_controller_dev rcdev;
>  	struct device *dev;
>  	struct device_node *np;
> -	const struct mod_map *mod_map;
> +	const struct mod_id_map *mod_map;
>  };
>  
>  static struct generic_pm_domain *r8a78000_genpd_always_on;
> @@ -77,17 +87,14 @@ static struct generic_pm_domain *r8a78000_genpd_xlate(
>  #define rcdev_to_priv(_rcdev)	\
>  	container_of(_rcdev, struct r8a78000_mdlc_priv, rcdev)
>  
> -static const struct mod_map *mod_map_find(const struct mod_map *map, u32 id)
> +static int mod_id_map_find(const struct mod_id_map *map, u32 hw_id)

Same comment as in the clock driver about prefixes and namespace
clashes.

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

>  {
> -	if (!map)
> -		return NULL;
> -
> -	for (; map->hw_id >= 0; map++) {
> -		if (map->hw_id == id)
> -			return map;
> +	for (unsigned int i = 0; i < map->size; i++) {
> +		if (map->entries[i].hw_id == hw_id)
> +			return i;
>  	}
>  
> -	return NULL;
> +	return -1;
>  }
>  
>  static int r8a78000_mdlc_reset_xlate(struct reset_controller_dev *rcdev,
> @@ -95,7 +102,7 @@ static int r8a78000_mdlc_reset_xlate(struct reset_controller_dev *rcdev,
>  {
>  	struct r8a78000_mdlc_priv *priv = rcdev_to_priv(rcdev);
>  	struct device *dev = priv->dev;
> -	const struct mod_map *map;
> +	int idx;
>  	u32 id;
>  
>  	if (spec->args_count != 1)
> @@ -103,8 +110,8 @@ static int r8a78000_mdlc_reset_xlate(struct reset_controller_dev *rcdev,
>  
>  	id = spec->args[0];
>  
> -	map = mod_map_find(priv->mod_map, id);
> -	if (!map) {
> +	idx = mod_id_map_find(priv->mod_map, id);
> +	if (idx < 0) {
>  		dev_err(dev, "Unknown reset 0x%x\n", id);
>  		return -ENOENT;
>  	}
> @@ -141,9 +148,8 @@ static int r8a78000_mdlc_attach_dev(struct generic_pm_domain *domain,
>  	struct device_node *np = dev->of_node;
>  	struct r8a78000_mdlc_priv *priv;
>  	struct of_phandle_args pd_spec;
> -	const struct mod_map *map;
>  	unsigned int id;
> -	int ret;
> +	int ret, idx;
>  
>  	ret = of_parse_phandle_with_args(np, "power-domains",
>  					 "#power-domain-cells", 0, &pd_spec);
> @@ -166,8 +172,8 @@ static int r8a78000_mdlc_attach_dev(struct generic_pm_domain *domain,
>  	id = pd_spec.args[1];
>  	of_node_put(pd_spec.np);
>  
> -	map = mod_map_find(priv->mod_map, id);
> -	if (!map) {
> +	idx = mod_id_map_find(priv->mod_map, id);
> +	if (idx < 0) {
>  		dev_err(dev, "Unknown module 0x%x\n", id);
>  		return -ENOENT;
>  	}
> @@ -292,15 +298,14 @@ static int r8a78000_mdlc_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static const struct mod_map r8a78000_mdlc_perw_mod_default[] = {
> +static const struct mod_id_map_entry r8a78000_mdlc_perw_mod_default[] = {
>  	{ 0x54 },	/* HSCIF0 */
> -	{ -1 }
>  };
>  
>  static const struct mdlc_info r8a78000_mdlc_default[] = {
>  	{
>  		.base = 0xc05d0000,
> -		.mod_map = r8a78000_mdlc_perw_mod_default,
> +		MOD_ID_MAP(r8a78000_mdlc_perw_mod_default),
>  	},
>  	{ /* sentinel */ }
>  };

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2026-11-23 11:39 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 19:44 [PATCH v5 00/15] R-Car X5H Ironhide CPG/MDLC SCMI remapping support Geert Uytterhoeven
2026-11-18 19:44 ` [PATCH v5 01/15] clk: renesas: r8a78000: Merge debug prints in r8a78000_clk_get() Geert Uytterhoeven
2026-11-20  2:57   ` Marek Vasut
2026-11-20  7:56     ` Geert Uytterhoeven
2026-11-23 10:57       ` Laurent Pinchart
2026-11-18 19:44 ` [PATCH v5 02/15] clk: renesas: r8a78000: Replace sentinel by explicit ID map size Geert Uytterhoeven
2026-11-20  3:02   ` Marek Vasut
2026-11-23 11:01   ` Laurent Pinchart
2026-11-18 19:44 ` [PATCH v5 03/15] clk: renesas: r8a78000: Shrink IDs to 16 bits Geert Uytterhoeven
2026-11-20  3:04   ` Marek Vasut
2026-11-23 11:12   ` Laurent Pinchart
2026-11-18 19:44 ` [PATCH v5 04/15] clk: renesas: r8a78000: Add clk_hw to clk_map Geert Uytterhoeven
2026-11-20  3:25   ` Marek Vasut
2026-11-23 11:24   ` Laurent Pinchart
2026-11-18 19:44 ` [PATCH v5 05/15] clk: renesas: r8a78000: Add SCMI remapping support Geert Uytterhoeven
2026-11-20  3:45   ` Marek Vasut
2026-11-23 11:36   ` Laurent Pinchart
2026-11-18 19:44 ` [PATCH v5 06/15] reset: Extract __reset_control_get_from_provider() Geert Uytterhoeven
2026-11-18 19:44 ` [PATCH v5 07/15] reset: Add reset_control_get_from_provider_exclusive() Geert Uytterhoeven
2026-11-18 19:44 ` [PATCH v5 08/15] pmdomain: Make genpd_get_from_provider() always return on first match Geert Uytterhoeven
2026-11-18 19:44 ` [PATCH v5 09/15] pmdomain: Make genpd_get_from_provider() return -EPROBE_DEFER Geert Uytterhoeven
2026-11-18 19:44 ` [PATCH v5 10/15] pmdomain: Make genpd_get_from_provider() public Geert Uytterhoeven
2026-11-18 19:44 ` [PATCH v5 11/15] pmdomain: renesas: r8a78000: Drop MDLC name comment Geert Uytterhoeven
2026-11-20  3:35   ` Marek Vasut
2026-11-23 11:37   ` Laurent Pinchart
2026-11-18 19:45 ` [PATCH v5 12/15] pmdomain: renesas: r8a78000: Replace sentinel by explicit ID map size Geert Uytterhoeven
2026-11-20  3:36   ` Marek Vasut
2026-11-23 11:39   ` Laurent Pinchart [this message]
2026-11-18 19:45 ` [PATCH v5 13/15] pmdomain: renesas: r8a78000: Shrink IDs to 16 bits Geert Uytterhoeven
2026-11-20  3:37   ` Marek Vasut
2026-11-23 11:39   ` Laurent Pinchart
2026-11-18 19:45 ` [PATCH v5 14/15] pmdomain: renesas: r8a78000: Add SCMI remapping support Geert Uytterhoeven
2026-11-18 20:22   ` sashiko-bot
2026-11-19  7:48     ` Geert Uytterhoeven
2026-11-18 19:45 ` [PATCH v5 15/15] arm64: dts: renesas: ironhide: Enable SCMI devpd, sys, clock, and reset Geert Uytterhoeven
2026-11-19 14:47 ` [PATCH v5 00/15] R-Car X5H Ironhide CPG/MDLC SCMI remapping support Clément Le Goffic
2026-11-19 23:47   ` Laurent Pinchart
2026-11-20 10:29     ` Clément Le Goffic
2026-11-20 11:10       ` Wolfram Sang
2026-11-20 14:33         ` Clément Le Goffic
2026-11-23 10:36           ` Laurent Pinchart
2026-11-23 10:31       ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123113915.GI3010398@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=bmasney+clk@redhat.com \
    --cc=clegoffic@baylibre.com \
    --cc=conor+dt@kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=jbrunet+clk@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=p.zabel@pengutronix.de \
    --cc=paul.elder+renesas@ideasonboard.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sudeep.holla@kernel.org \
    --cc=ulfh@kernel.org \
    --cc=vkoul@kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox