public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <bbrezillon@kernel.org>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Tudor Ambarus <Tudor.Ambarus@microchip.com>,
	Richard Weinberger <richard@nod.at>,
	Marek Vasut <marek.vasut@gmail.com>,
	linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v3 2/2] mtd: rework partitions handling
Date: Thu, 17 Jan 2019 21:29:16 +0100	[thread overview]
Message-ID: <20190117212916.70ad1269@bbrezillon> (raw)
In-Reply-To: <20190117152929.28256-2-miquel.raynal@bootlin.com>

On Thu, 17 Jan 2019 16:29:29 +0100
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> @@ -600,6 +601,7 @@ static int mtdchar_blkpg_ioctl(struct mtd_info *mtd,
>  static int mtdchar_write_ioctl(struct mtd_info *mtd,
>  		struct mtd_write_req __user *argp)
>  {
> +	struct mtd_info *master = mtd_get_master(mtd);
>  	struct mtd_write_req req;
>  	struct mtd_oob_ops ops;
>  	const void __user *usr_data, *usr_oob;
> @@ -611,9 +613,8 @@ static int mtdchar_write_ioctl(struct mtd_info *mtd,
>  	usr_data = (const void __user *)(uintptr_t)req.usr_data;
>  	usr_oob = (const void __user *)(uintptr_t)req.usr_oob;
>  
> -	if (!mtd->_write_oob)
> +	if (!master->_write_oob)
>  		return -EOPNOTSUPP;
> -

Keep this blank line.

>  	ops.mode = req.mode;
>  	ops.len = (size_t)req.len;
>  	ops.ooblen = (size_t)req.ooblen;

> @@ -936,20 +942,26 @@ EXPORT_SYMBOL_GPL(get_mtd_device);
>  
>  int __get_mtd_device(struct mtd_info *mtd)
>  {
> +	struct mtd_info *master = mtd_get_master(mtd);
>  	int err;
>  
> -	if (!try_module_get(mtd->owner))
> +	if (!try_module_get(master->owner))
>  		return -ENODEV;
>  
> -	if (mtd->_get_device) {
> -		err = mtd->_get_device(mtd);
> +	if (master->_get_device) {
> +		err = master->_get_device(mtd);

					 ^ master

I think I mentioned that one in my previous review ;-).

>  
>  		if (err) {
> -			module_put(mtd->owner);
> +			module_put(master->owner);
>  			return err;
>  		}
>  	}
> -	mtd->usecount++;
> +
> +	while (mtd->parent) {
> +		mtd->usecount++;
> +		mtd = mtd->parent;
> +	}
> +
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(__get_mtd_device);

...

>  int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
>  {
> -	if (!mtd->_block_markbad)
> +	struct mtd_info *master = mtd_get_master(mtd);
> +	int ret;
> +
> +	if (!master->_block_markbad)
>  		return -EOPNOTSUPP;
>  	if (ofs < 0 || ofs >= mtd->size)
>  		return -EINVAL;
>  	if (!(mtd->flags & MTD_WRITEABLE))
>  		return -EROFS;
> -	return mtd->_block_markbad(mtd, ofs);
> +
> +	ret = master->_block_markbad(master, mtd_get_master_offset(mtd, ofs));
> +	if (ret)
> +		return ret;
> +
> +	while (mtd->parent) {
> +		mtd->ecc_stats.badblocks++;
> +		mtd = mtd->parent;
> +	}

Not exactly related to this patch, but if we mark a block bad on the
master device this information is not propagated to parts exposing this
block.

> +
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(mtd_block_markbad);

...

>  
>  /*
>   * This function unregisters and destroy all slave MTD objects which are
> - * attached to the given MTD object.
> + * attached to the given MTD object, recursively.
>   */
> +int del_mtd_partitions_locked(struct mtd_info *mtd)

Should be static as the only users are in mtdpart.c.

> +{
> +	struct mtd_info *child, *next;
> +	int ret, err = 0;
> +
> +	list_for_each_entry_safe(child, next, &mtd->partitions,
> +				 props.part.node) {
> +		if (mtd_has_partitions(child))
> +			del_mtd_partitions_locked(child);
> +
> +		pr_info("Deleting %s MTD partition\n", child->name);
> +		ret = del_mtd_device(child);
> +		if (ret < 0) {
> +			pr_err("Error when deleting partition \"%s\" (%d)\n",
> +			       child->name, ret);
> +			err = ret;
> +			continue;
> +		}
> +
> +		list_del(&child->props.part.node);
> +		free_partition(child);
> +	}
> +
> +	return err;
> +}

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

       reply	other threads:[~2019-01-17 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190117152929.28256-1-miquel.raynal@bootlin.com>
     [not found] ` <20190117152929.28256-2-miquel.raynal@bootlin.com>
2019-01-17 20:29   ` Boris Brezillon [this message]
2019-01-22 11:12     ` [PATCH v3 2/2] mtd: rework partitions handling Miquel Raynal
2019-01-21 10:03 ` [PATCH v3 1/2] mtd: partitions: clarify __mtd_del_partition() name Boris Brezillon
2019-01-22 11:01   ` Miquel Raynal

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=20190117212916.70ad1269@bbrezillon \
    --to=bbrezillon@kernel.org \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    /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