mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Daniel Schultz <d.schultz@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/5] common: state: Make find_var public
Date: Wed, 1 Nov 2017 08:53:49 +0100	[thread overview]
Message-ID: <20171101075349.3hmtgjqxlzksf5q3@pengutronix.de> (raw)
In-Reply-To: <1509115052-4331-4-git-send-email-d.schultz@phytec.de>

On Fri, Oct 27, 2017 at 04:37:31PM +0200, Daniel Schultz wrote:
> Make find_var public to grant access to state variables.
> 
> Make also the MAC node public to receive the stored address.
> 
> Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
> ---
>  common/state/state.h | 27 +--------------------------
>  include/state.h      | 26 ++++++++++++++++++++++++++
>  2 files changed, 27 insertions(+), 26 deletions(-)
> 
> diff --git a/common/state/state.h b/common/state/state.h
> index 81aaec2..0fca848 100644
> --- a/common/state/state.h
> +++ b/common/state/state.h
> @@ -1,6 +1,7 @@
>  #include <linux/types.h>
>  #include <linux/list.h>
>  #include <driver.h>
> +#include <state.h>
>  
>  struct state;
>  struct mtd_info_user;
> @@ -128,16 +129,6 @@ struct variable_type {
>  					  struct device_node *);
>  };
>  
> -/* instance of a single variable */
> -struct state_variable {
> -	struct state *state;
> -	struct list_head list;
> -	const char *name;
> -	unsigned int start;
> -	unsigned int size;
> -	void *raw;
> -};
> -
>  /*
>   *  uint32
>   */
> @@ -161,16 +152,6 @@ struct state_enum32 {
>  };
>  
>  /*
> - *  MAC address
> - */
> -struct state_mac {
> -	struct state_variable var;
> -	struct param_d *param;
> -	uint8_t value[6];
> -	uint8_t value_default[6];
> -};
> -
> -/*
>   *  string
>   */
>  struct state_string {
> @@ -204,7 +185,6 @@ int state_backend_bucket_circular_create(struct device_d *dev, const char *path,
>  int state_backend_bucket_cached_create(struct device_d *dev,
>  				       struct state_backend_storage_bucket *raw,
>  				       struct state_backend_storage_bucket **out);
> -struct state_variable *state_find_var(struct state *state, const char *name);
>  struct digest *state_backend_format_raw_get_digest(struct state_backend_format
>  						   *format);
>  void state_backend_set_readonly(struct state *state);
> @@ -229,11 +209,6 @@ static inline struct state_enum32 *to_state_enum32(struct state_variable *s)
>  	return container_of(s, struct state_enum32, var);
>  }
>  
> -static inline struct state_mac *to_state_mac(struct state_variable *s)
> -{
> -	return container_of(s, struct state_mac, var);
> -}
> -
>  static inline struct state_string *to_state_string(struct state_variable *s)
>  {
>  	return container_of(s, struct state_string, var);
> diff --git a/include/state.h b/include/state.h
> index 63164f9..ae67d95 100644
> --- a/include/state.h
> +++ b/include/state.h
> @@ -5,6 +5,30 @@
>  
>  struct state;
>  
> +/* instance of a single variable */
> +struct state_variable {
> +	struct state *state;
> +	struct list_head list;
> +	const char *name;
> +	unsigned int start;
> +	unsigned int size;
> +	void *raw;
> +};
> +
> +/*
> + *  MAC address
> + */
> +struct state_mac {
> +	struct state_variable var;
> +	struct param_d *param;
> +	uint8_t value[6];
> +	uint8_t value_default[6];
> +};
> +static inline struct state_mac *to_state_mac(struct state_variable *s)
> +{
> +	return container_of(s, struct state_mac, var);
> +}
> +
>  int state_backend_dtb_file(struct state *state, const char *of_path,
>  		const char *path);
>  int state_backend_raw_file(struct state *state, const char *of_path,
> @@ -23,4 +47,6 @@ int state_load(struct state *state);
>  int state_save(struct state *state);
>  void state_info(void);
>  
> +struct state_variable *state_find_var(struct state *state, const char *name);
> +

I don't like exporting this state internal stuff very much. I rather
suggest a

	int state_read_mac(struct state *state, const char *name, u8 *buf);

to read the mac.

This function should also provide the type safety to check whether the state
variable actually is of type MAC address. To make that possible we may
have to store a pointer to the variable_type in struct state_variable.

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:[~2017-11-01  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27 14:37 [PATCH 1/5] ARM: boards: phytec-som-am335x: Add unified MLO Daniel Schultz
2017-10-27 14:37 ` [PATCH 2/5] ARM: dts: AM335x: Add state framework Daniel Schultz
2017-10-27 14:37 ` [PATCH 3/5] ARM: configs: am335x_defconfig: Add state config Daniel Schultz
2017-10-27 14:37 ` [PATCH 4/5] common: state: Make find_var public Daniel Schultz
2017-11-01  7:53   ` Sascha Hauer [this message]
2017-10-27 14:37 ` [PATCH 5/5] ARM: phytec-som-am335x: Set MAC addresses from state Daniel Schultz

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=20171101075349.3hmtgjqxlzksf5q3@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=d.schultz@phytec.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