mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/7] state: backend: support phandle and of_path references
Date: Fri, 15 May 2015 07:05:49 +0200	[thread overview]
Message-ID: <20150515050549.GF6325@pengutronix.de> (raw)
In-Reply-To: <1431511952-32124-5-git-send-email-mkl@pengutronix.de>

On Wed, May 13, 2015 at 12:12:30PM +0200, Marc Kleine-Budde wrote:
> This patch improves the backend property, it can be either a phandle or a
> of_path. During probe() of the state driver the backend property is
> dereferenced and the resulting of_path is saved in the state context. In a
> later patch it will be used to generate a phandle reference to the backend
> during DT fixup.
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  common/state.c       |  9 ++++---
>  drivers/misc/state.c | 70 ++++++++++++++++++++++++++++++++++++++++++----------
>  include/state.h      |  7 +++---
>  3 files changed, 67 insertions(+), 19 deletions(-)
> 
> diff --git a/common/state.c b/common/state.c
> index 744a6f8250c4..d6060bb7dff4 100644
> --- a/common/state.c
> +++ b/common/state.c
> @@ -54,6 +54,7 @@ struct state_backend {
>  	int (*load)(struct state_backend *backend, struct state *state);
>  	int (*save)(struct state_backend *backend, struct state *state);
>  	const char *name;
> +	const char *of_path;
>  	const char *path;
>  };
>  
> @@ -903,7 +904,7 @@ out:
>   * @state	The state instance to work on
>   * @path	The path where the state will be stored to
>   */
> -int state_backend_dtb_file(struct state *state, const char *path)
> +int state_backend_dtb_file(struct state *state, const char *of_path, const char *path)
>  {
>  	struct state_backend_dtb *backend_dtb;
>  	struct state_backend *backend;
> @@ -918,6 +919,7 @@ int state_backend_dtb_file(struct state *state, const char *path)
>  
>  	backend->load = state_backend_dtb_load;
>  	backend->save = state_backend_dtb_save;
> +	backend->of_path = xstrdup(of_path);
>  	backend->path = xstrdup(path);
>  	backend->name = "dtb";
>  
> @@ -1133,8 +1135,8 @@ out_free:
>   * device @size may be 0. The two copies are spread to different
>   * eraseblocks if approriate for this device.
>   */
> -int state_backend_raw_file(struct state *state, const char *path, off_t offset,
> -		size_t size)
> +int state_backend_raw_file(struct state *state, const char *of_path,
> +		const char *path, off_t offset, size_t size)
>  {
>  	struct state_backend_raw *backend_raw;
>  	struct state_backend *backend;
> @@ -1159,6 +1161,7 @@ int state_backend_raw_file(struct state *state, const char *path, off_t offset,
>  
>  	backend->load = state_backend_raw_load;
>  	backend->save = state_backend_raw_save;
> +	backend->of_path = xstrdup(of_path);
>  	backend->path = xstrdup(path);
>  	backend->name = "raw";
>  
> diff --git a/drivers/misc/state.c b/drivers/misc/state.c
> index 3b07bb93d725..9e8a40255348 100644
> --- a/drivers/misc/state.c
> +++ b/drivers/misc/state.c
> @@ -24,10 +24,12 @@
>  static int state_probe(struct device_d *dev)
>  {
>  	struct device_node *np = dev->device_node;
> +	struct device_node *partition_node;
>  	struct state *state;
>  	const char *alias;
>  	const char *backend_type = NULL;
>  	int ret;
> +	const char *of_path;
>  	char *path;
>  
>  	if (!np)
> @@ -41,28 +43,70 @@ static int state_probe(struct device_d *dev)
>  	if (IS_ERR(state))
>  		return PTR_ERR(state);
>  
> -	ret = of_find_path(np, "backend", &path, 0);
> -	if (ret)
> -		return ret;
> +	of_path = of_get_property(np, "backend", NULL);
> +	if (!of_path) {
> +		ret = -ENODEV;
> +		goto out_release;
> +	}
> +
> +	/* guess if of_path is a path, not a phandle */
> +	if (of_path[0] == '/') {

Since this also matches to the 47th phandle in the device tree I made
this:

	if (of_path[0] == '/' && len > 1)

And applied up to 6/7

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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-05-15  5:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 10:12 [PATCH 1/7] state: print name of property of size mismatch is detected Marc Kleine-Budde
2015-05-13 10:12 ` [PATCH 2/7] state: print proper error message, if reg property is not found Marc Kleine-Budde
2015-05-13 10:12 ` [PATCH 3/7] state: make state_release() non static Marc Kleine-Budde
2015-05-13 10:12 ` [PATCH 4/7] state: add functionality to export state description Marc Kleine-Budde
2015-05-13 10:12 ` [PATCH 5/7] state: backend: support phandle and of_path references Marc Kleine-Budde
2015-05-15  5:05   ` Sascha Hauer [this message]
2015-05-15  6:12     ` Marc Kleine-Budde
2015-05-13 10:12 ` [PATCH 6/7] state: add fixup to copy state from barebox to kernel device tree Marc Kleine-Budde
2015-05-15  9:28   ` Uwe Kleine-König
2015-05-16 10:15   ` [PATCH] fixup! " Uwe Kleine-König
2015-05-18  6:07     ` Sascha Hauer
2015-05-13 10:12 ` [PATCH 7/7] state: return -EPROBE_DEFER if the backend isn't available Marc Kleine-Budde
2015-05-13 12:06   ` Uwe Kleine-König

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=20150515050549.GF6325@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=mkl@pengutronix.de \
    /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