From: Bruno Pena <brunompena@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Bruno Pena <brunompena@gmail.com>
Subject: [PATCH] mtd: core: allow mask_flags to be set for mtd_add_partition
Date: Tue, 26 Nov 2019 22:25:11 +0100 [thread overview]
Message-ID: <20191126212511.1218-1-brunompena@gmail.com> (raw)
This patchs makes it possible to mask certain flags for new partitions (e.g. to make them read-only).
The change consists in the addition of a new argument "mask_flags" to "mtd_add_partition" that is passed on to the "allocate_partition".
Signed-off-by: Bruno Pena <brunompena@gmail.com>
---
drivers/mtd/mtdchar.c | 5 ++++-
drivers/mtd/mtdpart.c | 3 ++-
include/linux/mtd/partitions.h | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 0238952..0c0a6f2 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -583,7 +583,10 @@ static int mtdchar_blkpg_ioctl(struct mtd_info *mtd,
/* Sanitize user input */
p.devname[BLKPG_DEVNAMELTH - 1] = '\0';
- return mtd_add_partition(mtd, p.devname, p.start, p.length);
+ /* No mtd flag masking required */
+ uint32_t mask_flags = 0;
+
+ return mtd_add_partition(mtd, p.devname, p.start, p.length, mask_flags);
case BLKPG_DEL_PARTITION:
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index b6af41b..66675a4 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -588,7 +588,7 @@ static int mtd_add_partition_attrs(struct mtd_part *new)
}
int mtd_add_partition(struct mtd_info *parent, const char *name,
- long long offset, long long length)
+ long long offset, long long length, uint32_t mask_flags)
{
struct mtd_partition part;
struct mtd_part *new;
@@ -609,6 +609,7 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,
part.name = name;
part.size = length;
part.offset = offset;
+ part.mask_flags = mask_flags;
new = allocate_partition(parent, &part, -1, offset);
if (IS_ERR(new))
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 11cb0c5..1a0deeb 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -107,7 +107,7 @@ extern void deregister_mtd_parser(struct mtd_part_parser *parser);
int mtd_is_partition(const struct mtd_info *mtd);
int mtd_add_partition(struct mtd_info *master, const char *name,
- long long offset, long long length);
+ long long offset, long long length, uint32_t mask_flags);
int mtd_del_partition(struct mtd_info *master, int partno);
uint64_t mtd_get_device_size(const struct mtd_info *mtd);
--
2.7.4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2019-11-26 21:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 21:25 Bruno Pena [this message]
2020-02-05 8:31 ` [PATCH] mtd: core: allow mask_flags to be set for mtd_add_partition Rafał Miłecki
2020-02-05 17:34 ` Bruno Pena
2020-02-06 13:46 ` Rafał Miłecki
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=20191126212511.1218-1-brunompena@gmail.com \
--to=brunompena@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).