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 v2] mtd: rework partitions handling
Date: Mon, 21 Jan 2019 09:51:20 +0100 [thread overview]
Message-ID: <20190121095120.5d7850cb@bbrezillon> (raw)
In-Reply-To: <20190116162144.4458-1-miquel.raynal@bootlin.com>
On Wed, 16 Jan 2019 17:21:44 +0100
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> @@ -457,13 +525,31 @@ int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
>
> static inline int mtd_suspend(struct mtd_info *mtd)
> {
> - return mtd->_suspend ? mtd->_suspend(mtd) : 0;
> + struct mtd_info *master = mtd_get_master(mtd);
> + int ret;
> +
> + if (master->suspended)
> + return 0;
> +
> + ret = master->_suspend ? master->_suspend(master) : 0;
> + if (ret)
> + return ret;
> +
> + master->suspended = 1;
It's not entirely clear to me whether dev->suspend() hooks can be
called simultaneously on several CPUs or not, if that's the case, we
should use an atomic_t for the ->suspended field and use the
atomic_add_unless() function when manipulating it.
if (!atomic_add_unless(&master->suspended, 1, 1))
return 0;
ret = master->_suspend ? master->_suspend(master) : 0;
if (ret) {
atomic_dec(&master->suspended);
return ret;
}
> + return 0;
> }
>
> static inline void mtd_resume(struct mtd_info *mtd)
> {
> - if (mtd->_resume)
> - mtd->_resume(mtd);
> + struct mtd_info *master = mtd_get_master(mtd);
> +
> + if (!master->suspended)
> + return;
> +
> + if (master->_resume)
> + master->_resume(master);
> +
> + master->suspended = 0;
Same here:
if (!atomic_add_unless(&master->suspended, -1, 0))
return;
if (master->_resume)
master->_resume(master);
> }
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2019-01-21 8:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 16:21 [PATCH v2] mtd: rework partitions handling Miquel Raynal
2019-01-16 17:23 ` Boris Brezillon
2019-01-21 8:51 ` Boris Brezillon [this message]
2019-01-22 11:37 ` 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=20190121095120.5d7850cb@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