[PATCH 3/5] partitons: add framework

Sascha Hauer s.hauer at pengutronix.de
Thu Feb 14 15:37:03 EST 2013


On Thu, Feb 14, 2013 at 04:52:25PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> so we can support multiple format
> 
> use filetpye to detect the parser to use
> 
> Cc: Rob Herring <rob.herring at calxeda.com>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  common/Kconfig             |   14 +----
>  common/Makefile            |    2 +-
>  common/partitions.c        |  132 +++++++++++++++-----------------------------
>  common/partitions/Makefile |    1 +
>  common/partitions/dos.c    |   87 +++++++++++++++++++++++++++++
>  common/partitions/parser.h |   35 ++++++++++++

common/partitions/Kconfig is missing in this patch.

> +int partition_parser_register(struct partition_parser *p)
> +{
> +	if (!p || !p->parse)
> +		return -EINVAL;

Please drop these stupid checks. Everyone calling this with a NULL
pointer really deserves a stack dump.

> +
> +#ifndef __PARTITIONS_PARSER_H__
> +#define __PARTITIONS_PARSER_H__
> +
> +#include <block.h>
> +#include <filetype.h>
> +#include <linux/list.h>
> +
> +#define MAX_PARTITION		8
> +
> +struct partition {
> +	uint64_t first_sec;
> +	uint64_t size;
> +};
> +
> +struct partition_desc {
> +	int used_entries;
> +	struct partition parts[MAX_PARTITION];
> +};
> +
> +struct partition_parser {
> +	void (*parse)(uint8_t *buf, struct block_device *blk, struct partition_desc *pd);

use void * for passing buffers please.

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