Re: [PATCH V2 2/2] mfd: syscon: Find syscon by names with arguments support

From: Arnd Bergmann
Date: Thu Nov 21 2019 - 10:04:31 EST


On Wed, Nov 20, 2019 at 4:44 PM Orson Zhai <orson.zhai@xxxxxxxxxx> wrote:
>
> There are a lot of global registers used across multiple similar SoCs
> from Unisoc. It is not easy to manage all of them very well by current
> syscon helper functions.
>
> Add helper functions to get regmap and arguments by syscon-names all
> together.
>
> This patch does not affect original syscon code and usage. It may help
> other SoC vendors if they have the same trouble as well.
>
> Signed-off-by: Orson Zhai <orson.zhai@xxxxxxxxxx>
> ---
> drivers/mfd/syscon.c | 75 ++++++++++++++++++++++++++++++++++++++
> include/linux/mfd/syscon.h | 26 +++++++++++++
> 2 files changed, 101 insertions(+)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 660723276481..e818decc7bf2 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -225,6 +225,81 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
> }
> EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle);
>
> +struct regmap *syscon_regmap_lookup_by_name(struct device_node *np,
> + const char *list_name,
> + const char *cell_name)
> +{

According to the binding change I suggested, this would not take a 'cell_name'
argument, but instead a an arg_count.

> +
> +int syscon_get_args_by_name(struct device_node *np,
> + const char *list_name,
> + const char *cell_name,
> + int arg_count,
> + unsigned int *out_args)
> +{

and I think this could be combined with it, like

struct regmap *syscon_regmap_lookup_by_name(struct device_node *np,
const char *name, int
arg_count, __u32 *out_args)

Arnd