[PATCH v4 3/3] mtd: part: Remove partition overlap checks
Brian Norris
computersforpeace at gmail.com
Tue Mar 31 11:45:21 PDT 2015
On Mon, Mar 30, 2015 at 02:01:38PM -0700, Dan Ehrenberg wrote:
> This patch makes MTD dynamic partitioning more flexible by removing
> overlap checks for dynamic partitions. I don't see any particular
> reason why overlapping dynamic partitions should be prohibited while
> static partitions are allowed to overlap freely.
>
> The checks previously had an off-by-one error, where 'end' should be
> one less than what it is currently set at, and adding partitions out of
> increasing order will fail. Disabling the checks resolves this issue.
>
> Signed-off-by: Dan Ehrenberg <dehrenberg at chromium.org>
> ---
> drivers/mtd/mtdpart.c | 17 +----------------
> 1 file changed, 1 insertion(+), 16 deletions(-)
>
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index be80340..c444842 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -582,7 +582,7 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
> long long offset, long long length)
> {
> struct mtd_partition part;
> - struct mtd_part *p, *new;
> + struct mtd_part *new;
> uint64_t start, end;
drivers/mtd/mtdpart.c: In function ‘mtd_add_partition’:
drivers/mtd/mtdpart.c:586:18: warning: variable ‘end’ set but not used [-Wunused-but-set-variable]
uint64_t start, end;
^
drivers/mtd/mtdpart.c:586:11: warning: variable ‘start’ set but not used [-Wunused-but-set-variable]
uint64_t start, end;
^
> int ret = 0;
>
> @@ -611,17 +611,6 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
> end = offset + length;
>
> mutex_lock(&mtd_partitions_mutex);
> - list_for_each_entry(p, &mtd_partitions, list)
> - if (p->master == master) {
> - if ((start >= p->offset) &&
> - (start < (p->offset + p->mtd.size)))
> - goto err_inv;
> -
> - if ((end >= p->offset) &&
> - (end < (p->offset + p->mtd.size)))
> - goto err_inv;
> - }
> -
> list_add(&new->list, &mtd_partitions);
> mutex_unlock(&mtd_partitions_mutex);
>
> @@ -630,10 +619,6 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
> mtd_add_partition_attrs(new);
>
> return ret;
> -err_inv:
> - mutex_unlock(&mtd_partitions_mutex);
> - free_partition(new);
> - return -EINVAL;
> }
> EXPORT_SYMBOL_GPL(mtd_add_partition);
>
Brian
More information about the linux-mtd
mailing list