[PATCH 3/7] mfd: syscon: Decouple syscon interface from platform devices

Sascha Hauer s.hauer at pengutronix.de
Thu Jul 14 22:59:52 PDT 2016


On Wed, Jul 13, 2016 at 11:11:01PM -0700, Andrey Smirnov wrote:
> Follow Linux Kernel change introduced in
> bdb0066df96e74a4002125467ebe459feff1ebef and avoid device/driver model
> for DT-based platforms. See the original kernel commit for the rationale.
> 
> Also make syscon_base_lookup_by_pdevname() behave the same way as its
> kernel counterpart in the case whern "property" argument is NULL.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
> ---
>  drivers/mfd/syscon.c | 79 ++++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 61 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index ac46122..5fd22dd 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -17,15 +17,68 @@
>  #include <driver.h>
>  #include <malloc.h>
>  #include <xfuncs.h>
> -
> +#include <of_address.h>
>  #include <linux/err.h>
>  
>  #include <mfd/syscon.h>
>  
> +static LIST_HEAD(syscon_list);
> +
>  struct syscon {
> +	struct device_node *np;
>  	void __iomem *base;
> +	struct list_head list;
>  };
>  
> +static struct syscon *of_syscon_register(struct device_node *np)
> +{
> +	int ret;
> +	struct syscon *syscon;
> +	struct resource res;
> +
> +	if (!of_device_is_compatible(np, "syscon"))
> +		return ERR_PTR(-EINVAL);
> +
> +	syscon = xzalloc(sizeof(*syscon));
> +
> +	if (of_address_to_resource(np, 0, &res)) {
> +		ret = -ENOMEM;
> +		goto err_map;
> +	}
> +
> +	syscon->base = IOMEM(res.start);
> +	syscon->np   = np;
> +
> +	list_add_tail(&syscon->list, &syscon_list);
> +
> +	return syscon;
> +
> +err_map:
> +	kfree(syscon);
> +	return ERR_PTR(ret);
> +}
> +
> +void __iomem *syscon_node_to_base(struct device_node *np)

This should either be static or the prototype added to include/

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list