lkml.org 
[lkml]   [2016]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 05/51] mtd: add mtd_ooblayout_xxx() helper functions
On Thu,  4 Feb 2016 11:06:28 +0100
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> In order to make the ecclayout definition completely dynamic we need to
> rework the way the OOB layout are defined and iterated.
>
> Create a few mtd_ooblayout_xxx() helpers to ease OOB bytes manipulation
> and hide ecclayout internals to their users.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/mtd/mtdcore.c | 401 ++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/mtd/mtd.h | 33 ++++
> 2 files changed, 434 insertions(+)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 3096251..14e46ca 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c

[...]

> +
> +/**
> + * mtd_ooblayout_count_bytes - count the number of bytes in a OOB category
> + * @mtd: mtd info structure
> + * @iter: category iterator
> + *
> + * Count the number of bytes in a given category.
> + *
> + * Returns a positive value on success, a negative error code otherwise.
> + */
> +static int mtd_ooblayout_count_bytes(struct mtd_info *mtd,
> + int (*iter)(struct mtd_info *,
> + int section,
> + struct mtd_oob_region *oobregion))
> +{
> + struct mtd_oob_region oobregion = { };
> + int section = 0, ret, nbytes = 0;
> +
> + while (1) {
> + ret = iter(mtd, section, &oobregion);

^ section++

Oops, will fix that in next version.

> + if (ret) {
> + if (ret == -ERANGE)
> + ret = nbytes;
> + break;
> + }
> +
> + nbytes += oobregion.length;
> + }
> +
> + return ret;
> +}


--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

\
 
 \ /
  Last update: 2016-02-05 09:01    [W:0.169 / U:1.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site