From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 01/11] mtd: Add a function to report when the MTD dev list has been updated
Date: Sun, 9 Dec 2018 00:40:35 +0100 [thread overview]
Message-ID: <20181209004035.1c9330ae@jawa> (raw)
In-Reply-To: <20181202095432.23713-2-boris.brezillon@bootlin.com>
Hi Boris,
> We need to parse mtdparts/mtids again everytime a device has been
> added/removed from the MTD list, but there's currently no way to know
> when such an update has been done.
>
> Add an ->updated field to the idr struct that we set to true every
> time a device is added/removed and expose a function returning the
> value of this field and resetting it to false.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> Tested-by: Heiko Schocher <hs@denx.de>
This series fixed a but on Vybrid, when I run several times "mtdpart
default" after calling sf probe for two SPI-NOR memories.
When I called "mtdpart default" for the second time, the mtd partitions
were gone despite being visible with "mtdparts" command.
Hence,
Tested-by: Lukasz Majewski <lukma@denx.de>
> ---
> Changes in v4:
> - Add T-b tag
>
> Changes in v2:
> - None
>
> Changes in v2:
> - None
> ---
> drivers/mtd/mtdcore.c | 16 +++++++++++++++-
> include/linux/mtd/mtd.h | 1 +
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index fb6c779abbfe..7a15ded8c883 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -87,14 +87,17 @@ struct idr_layer {
>
> struct idr {
> struct idr_layer id[MAX_IDR_ID];
> + bool updated;
> };
>
> #define DEFINE_IDR(name) struct idr name;
>
> void idr_remove(struct idr *idp, int id)
> {
> - if (idp->id[id].used)
> + if (idp->id[id].used) {
> idp->id[id].used = 0;
> + idp->updated = true;
> + }
>
> return;
> }
> @@ -134,6 +137,7 @@ int idr_alloc(struct idr *idp, void *ptr, int
> start, int end, gfp_t gfp_mask) if (idl->used == 0) {
> idl->used = 1;
> idl->ptr = ptr;
> + idp->updated = true;
> return i;
> }
> i++;
> @@ -155,6 +159,16 @@ struct mtd_info *__mtd_next_device(int i)
> }
> EXPORT_SYMBOL_GPL(__mtd_next_device);
>
> +bool mtd_dev_list_updated(void)
> +{
> + if (mtd_idr.updated) {
> + mtd_idr.updated = false;
> + return true;
> + }
> +
> + return false;
> +}
> +
> #ifndef __UBOOT__
> static LIST_HEAD(mtd_notifiers);
>
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 68e591532492..d20ebd820289 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -581,6 +581,7 @@ int mtd_arg_off_size(int argc, char *const
> argv[], int *idx, loff_t *off, void mtd_get_len_incl_bad(struct
> mtd_info *mtd, uint64_t offset, const uint64_t length, uint64_t
> *len_incl_bad, int *truncated);
> +bool mtd_dev_list_updated(void);
>
> /* drivers/mtd/mtd_uboot.c */
> int mtd_search_alternate_name(const char *mtdname, char *altname,
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181209/d057ac92/attachment.sig>
next prev parent reply other threads:[~2018-12-08 23:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-02 9:54 [U-Boot] [PATCH v4 00/11] mtd/sf: Various fixes Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 01/11] mtd: Add a function to report when the MTD dev list has been updated Boris Brezillon
2018-12-08 23:40 ` Lukasz Majewski [this message]
2018-12-02 9:54 ` [U-Boot] [PATCH v4 02/11] mtd: Parse mtdparts/mtdids again when the MTD " Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 03/11] mtd: Delete partitions attached to the device when a device is deleted Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 04/11] mtd: sf: Make sure we don't register the same device twice Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 05/11] mtd: Use get_mtdids() instead of env_get("mtdids") in mtd_search_alternate_name() Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 06/11] mtd: Be more strict on the "mtdparts=" prefix check Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 07/11] mtd: Make sure the name passed in mtdparts fits in mtd_name[] Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 08/11] mtd: Make sure we don't parse MTD partitions belonging to another dev Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 09/11] mtd: Don't stop MTD partition creation when it fails on one device Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 10/11] mtd: sf: Unregister the MTD device prior to removing the spi_flash obj Boris Brezillon
2018-12-02 9:54 ` [U-Boot] [PATCH v4 11/11] mtd: sf: Make sf_mtd.c more robust Boris Brezillon
2018-12-05 11:02 ` [U-Boot] [PATCH v4 00/11] mtd/sf: Various fixes Boris Brezillon
2018-12-05 19:18 ` Jagan Teki
2018-12-09 6:42 ` Boris Brezillon
2018-12-09 13:36 ` Tom Rini
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=20181209004035.1c9330ae@jawa \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/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